Initialization state of COG RAM?
epmoyer
Posts: 314
Is the initialization state of COG RAM guaranteed, and if so, what is the initialization value (zero perhaps ?).
I'm trying to determine whether, when writing Propeller Assembly, I can count on the initial state of "uninitialized" data words (i.e. like r1 in the example below) to be some known value (i.e. does the spin interpreter wipe all of Cog RAM to some known value before loading and starting ASM code in a new cog, or is the memory left in whatever state it was in before the load/start was performed?)
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The World's First Open Source Guitar Pedal:··http://www.OpenStomp.com
I'm trying to determine whether, when writing Propeller Assembly, I can count on the initial state of "uninitialized" data words (i.e. like r1 in the example below) to be some known value (i.e. does the spin interpreter wipe all of Cog RAM to some known value before loading and starting ASM code in a new cog, or is the memory left in whatever state it was in before the load/start was performed?)
r1 res 1 ' General purpose register
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The World's First Open Source Guitar Pedal:··http://www.OpenStomp.com
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Need to make your prop design easier or secure? Get a PropMod $50CAN has crystal, eeprom, and programing header in a 40 pin dip 0.7" pitch module.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Need to make your prop design easier or secure? Get a PropMod $50CAN has crystal, eeprom, and programing header in a 40 pin dip 0.7" pitch module.
-Phil
It makes sense that it works that way, since the COG load call doesn't specify a code length.
Given that it always copies 496 longs, that says you can't expect a known initialization of uninitialized COG ram data. Of course, you can always declare it as pre-initialized data in ASM at the cost of a Longword of storage (i.e. the ASM code footprint gets 1 longword bigger), but generally it costs you a longword to pre-initialize the data programatically anyway, so in the general case it's a toss up and in specific cases one or or the other may be more efficient depending on whether there are multiple sequential words to initialize, and whether initialization needs to be performed more than once.
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The World's First Open Source Guitar Pedal:··http://www.OpenStomp.com
So: Yes all cog memory is set to a known value, no random data is in a cog.
But: The cog-ram data behind your Assembly code depends on the following DAT, PUB or PRI sections that the compiler links into that HubRAM. To know the values, you have to look at the HexDump which you get with F8. It's not so easy to find the correct addresses, and the data can change, if you change your Spin code.
The RES directive just increments the cogram pointer of the assembler, but writes no data in HubRAM and does not increment the hubram pointer. So the labels get the right cog address, but no hub ram is occupied. The main purpose of the RES is to spare HubRAM.
Andy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i@arrl.net
Post Edited (Carl Hayes) : 3/2/2009 2:55:35 AM GMT