Equip your Genius
Welcome to the Parallax Discussion Forums, sign-up to participate.
Learn with BlocklyProp
pasm arrays from spin to pasm and back
2018-10-21 - 21:48:17
edited 2018-10-21 - 21:49:02
I have been looking for beginning code for arrays in pasm and have been finding broken links.
Does any one have some simple beginning code for passing arrays from spin to pasm?
2018-10-21 - 21:57:54
arrays are essentially just a lot of variables in a row. Just pass the address of the beginning using PAR or something and then add the the index you want to access to it. Make sure to shift the index left by 1 bit for a word array and 2 bits for a long array.
2018-10-21 - 22:11:42
I will try that
2018-10-23 - 20:10:13
You need to know the base address in the hub, plus the variable size. PASM sees the hub as a big array of bytes, so if your array is words or long, you'll have to increment/decrement your array pointer by two or four accordingly. Also, use the appropriate hubop for your variable size.
-- please do not call me Jonny.
2018-10-27 - 20:12:50
Figured it out thanks to all
2018-10-27 - 20:52:44
It's a little trickier if you want the array to be on COG memory. Then you have to use self-modifying code.
2018-10-28 - 21:37:28
Example of self modifying code??
2018-10-28 - 22:46:26
Here's one that uses tables to convert binary to BCD:
Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.