Is there a formal description for setting up/handling variables between Spin an
Harley
Posts: 997
I tried a search for this subject, but what came up wasn't too helpful. Maybe didn't use the proper words.
And I don't want to reverse engineer some program to hopefully derive how to do this correctly.
I have two Props, and on one I have had something which seems to work. But attempting to do so on other Prop, I cannot figure out how to do so again. All I need is to pass several variables (1/2 dozen) from Spin to Asm, and do so also from Asm to Spin. Seems it should be easy, but have spent too many hours/iterations and yet it doesn't work.
Only have to do so with two cogs. But one cog also needs to affect (change) a variable between cogs. Need something explained simply to get my head around this detail.
Thanks for any/all help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
And I don't want to reverse engineer some program to hopefully derive how to do this correctly.
I have two Props, and on one I have had something which seems to work. But attempting to do so on other Prop, I cannot figure out how to do so again. All I need is to pass several variables (1/2 dozen) from Spin to Asm, and do so also from Asm to Spin. Seems it should be easy, but have spent too many hours/iterations and yet it doesn't work.
Only have to do so with two cogs. But one cog also needs to affect (change) a variable between cogs. Need something explained simply to get my head around this detail.
Thanks for any/all help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
Comments
Do make sure you've looked at the assembly tips and traps and DeSilva's tutorial on Propeller assembly coding in the "sticky" threads at the top of the forum subject list.
The easiest way to reference some Spin variables from assembly is to group them together and make them all longs, then pass the address of the first one as the 2nd parameter to COGNEW when you start the assembly routine like:
COGNEW(@entryPoint,@firstVar)
In the assembly routine, you access the first long with: RDLONG anywhere,PAR or WRLONG anywhere,PAR.
For the other variables, you'll need to move PAR to another location and increment it as in:
MOV temp,PAR
ADD temp,#4
RDLONG anywhere,temp
and do similar things to access the other variables.
Obviously, if you want to access WORDs or BYTEs, you'd use RDWORD or RDBYTE and increment the address appropriately.
Remember, the Spin compiler sorts the variables in size order (LONGs first, then WORDs, then BYTEs). They're not placed
in the order of declaration unless they're in a DAT section.
Post Edited (Mike Green) : 4/18/2008 11:07:39 PM GMT
Mike, thanks for that clear explanation. I think I've done what you describe; maybe there is something else I'm doing wrong. Got to take time to review just what is going on presently.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
Again thank you for the guidance. I found that I had a '@' symbol in an inappropriate location; compiled OK, and therefore was not doing what was intended.
I do have a hard copy of Phil's Tips and Traps and DeSilva's tutorial; very helpful, though possibly not up to date. But doesn't help when a stupid typo is in place.
Things working better now. Lots more debugging yet though.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko