If I define a PASM variable with RES is it safe to assume that on launching the cog that variable will be zero, or could it be some random number based on stray bits in the cog ram?
Assuming you follow the rules and put your RES variables last, they will be initialized to whatever is in hub RAM after the last BYTE, WORD, or LONG in your DAT section. In other words, RES variables take up no space of their own in hub RAM but overlap with whatever follows the defined stuff. When the cog loads, that overlapping data gets loaded with it, up to the 496-long limit.
If you have to move a value to the a variable which is defined by RES there is no difference in memory usage. Then you could also use long to define it, because the mov itself also needs 32 bits. So, I prefer the definition via LONG because you can initialize it with any value. If you initialize a RES with a mov, then you can only assign values in a range from $000 to $1FF.
MagIO2 said...
If you have to move a value to the a variable which is defined by RES there is no difference in memory usage.
That depends on how many times you have to do it. If but once at the beginning, you're right. But if it's a loop counter, for example, that has to be reinitialized each time at the beginning of the loop, a RES will save hub space.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: http://forums.parallax.com/showthread.php?p=800114
NTSC color bars (template): http://forums.parallax.com/showthread.php?p=803904
-Phil
-Phil