Lookup tables in VAR blocks?
Jack Buffington
Posts: 115
I tacked this onto a previous topic but that topic was a little old and didn't get any replies...
Does anyone know how to initialize an array in a VAR block with pre-defined values. I need to pass the address of the lookup table to an assembly program. The lookup table will be followed by other variables that the assembly will need to reference. I can create a lookup table in a DAT block and then reference it from SPIN like this but that won't work for me directly.
I could do something like this but it sucks up another chunk of HUB RAM the same size as the lookup table. I'm tight on HUB RAM so I would prefer to not do that.
Is there some way to just initialize an array from within the VAR block. I'm not seeing anything in the propeller manual.
Does anyone know how to initialize an array in a VAR block with pre-defined values. I need to pass the address of the lookup table to an assembly program. The lookup table will be followed by other variables that the assembly will need to reference. I can create a lookup table in a DAT block and then reference it from SPIN like this but that won't work for me directly.
DAT lookupTable long 1,2,3,4,5,6,7,8,9,10 PUB start dira := $FFFFFFFF repeat outa := lookupTable
I could do something like this but it sucks up another chunk of HUB RAM the same size as the lookup table. I'm tight on HUB RAM so I would prefer to not do that.
DAT lookupTable long 1,2,3,4,5,6,7,8,9,10 VAR long theTable[noparse][[/noparse]10] long count PUB start repeat count from 0 to 9 theTable[noparse][[/noparse]count] := lookupTable[noparse][[/noparse]count] cognew(@PmyAssemblyStart,@theTable[noparse][[/noparse]0])
Is there some way to just initialize an array from within the VAR block. I'm not seeing anything in the propeller manual.
Comments
-Phil
One gotcha that I found was that the compiler seems to join multiple DAT sections into one address space so if I declare my variables in one file, I have to put my program in another file, which is what I normally do but for the sake of testing things out, I didn't.
For those of you searching for this same thing, here is the code that I wrote and tested:
In one file:
In the other file:
Post Edited (Jack Buffington) : 4/2/2010 9:36:37 PM GMT
I didn't see any e-mail notice from the forum so I posted again. In looking back now, I see that it was there after all. Sorry for the repost and thanks for your reply on the other thread.
-Phil