Passing constants and addresses to assembler
scotta
Posts: 168
I was wondering if anyone has figured out a way to pass constants
and references (addresses) from Spin to assembler without the
use of the PAR variable ?
Scott
and references (addresses) from Spin to assembler without the
use of the PAR variable ?
Scott
Comments
- You can use constants "as is". They are fully integrated into the Propeller Tool concept.
- You can set or preset any address you want in a DAT cell loaded up with the COG code. See the examples in my Tutorial.
I think its easier than using PAR, and uses the same code
space and execution time (as PAR).
Note how the LCDx_BAUD variable is being changed
from spin (in Main method), on a separate cog. The
assembler LCD object dereferences this on the fly.
I have used this technique for simple assembler interfaces
with 1 variable to 40 incoming references and
(about) 10 pre-set constants.
I think "Start" = "SetUp" ?
Edit: An additional advantage is that you can sometimes trade expensive COG space against cheap HUB space:
will save you 3 COG instructions..
Post Edited (deSilva) : 9/26/2007 10:49:05 PM GMT
much easier to read than:
mov t1,par
rdlong a,t1
add t1,#4
rdlong b,t1
...
But the PAR method is much more systematic and can have advantages in case of MANY parameters.
Also, when you want to load many COGs with the same code a PAR parametrisation avoids the waiting for the end of loading of each of those COGs....
The main pitfall is, that when using VAR variables as target, the mixing of LONGs, WORDs, and BYTEs can lead to much confusion
I should Read the Funny Manual
Thanks !