memory storage order/arrangement
Bobb Fwed
Posts: 1,119
I have some longs and words declared in a var block:
now I would think that var5 being a eight-length word is the same thing as a four-length long, but when I try to access the expected addresses in PASM (referenced from var1's location as based in PAR), it doesn't seem to line up.... I haven't messed with exactly how it isn't lining up, but maybe someone can tell me before I spend time rediscovering the wheel. Does the compiler (or other) rearrange word and long (and byte for that matter) declarations or something weird like that?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
long var1 long var2 long var3[noparse][[/noparse] 4 ] word var4[noparse][[/noparse] 8 ] word var5[noparse][[/noparse] 8 ]
now I would think that var5 being a eight-length word is the same thing as a four-length long, but when I try to access the expected addresses in PASM (referenced from var1's location as based in PAR), it doesn't seem to line up.... I haven't messed with exactly how it isn't lining up, but maybe someone can tell me before I spend time rediscovering the wheel. Does the compiler (or other) rearrange word and long (and byte for that matter) declarations or something weird like that?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
Comments
1. Why not create a long array with 14 longs (long allvars[noparse]/noparse]14])? You can access var1, var2 and var3[noparse][[/noparse very easyly using dedicaded index ... maybe define this in the constant block as VAR1, VAR2 and VAR3. Then you can write allvars[noparse][[/noparse]VAR1] .. allvars[noparse][[/noparse]VAR3 +2] ... for example ..
The words can be accessed by word[noparse][[/noparse]@allvars+VAR4]
2. You can create the vars in the dat section instead. There the data is not reordered. But you have to take care of the alignment by yourself. Doing something wrong here can lead to hard to find bugs.
Any idea why I am having problems switching between long[noparse][[/noparse] 4 ] and word[noparse][[/noparse] 8 ] at the end of my var list?
What about, when one object declares longs/words/bytes...are those mixed in with other objects' variables? Could that be causing my above problem?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!