VAR Aliases...
DToolan
Posts: 11
If I create a word var (or any other kind of var)... can I somehow create a byte array that resides on top of that var so I can access each byte without having to mask and shift?
Example:
Word MyWordVar
Byte MyByteArray[2] @MyWordVar '<- MyByteArray actually lives on top of the memory locations of MyWordVar
MyWordVar := $AA55
'MyByteArray[0] should equal $55 and MyByteArray[1] should equal $AA without having to mask and shift MyWordVar into seperate bytes
Example:
Word MyWordVar
Byte MyByteArray[2] @MyWordVar '<- MyByteArray actually lives on top of the memory locations of MyWordVar
MyWordVar := $AA55
'MyByteArray[0] should equal $55 and MyByteArray[1] should equal $AA without having to mask and shift MyWordVar into seperate bytes
Comments
I doubt it's what you're looking for but you don't have to shift the bits.
In this example MyByteArray[1] will hold the least significant byte (I'm pretty sure).
Also (as I'm sure you know) MyByteArray wont change automatically when you change MyWordVar. Which, if I understand you correctly, is your main objective (which my example fails to do).
Maybe some else has a better idea?
Duane
http://forums.parallax.com/showthread.php?112970-Word-Sized-constant-in-Byte-array&p=808493&viewfull=1#post808493
Main Reference Thread:
http://forums.parallax.com/showthread.php?112970-Word-Sized-constant-in-Byte-array
Pertinent information: