Arrays, Aliases, and Modifiers, Oh My!
CliffS
Posts: 12
This has to be easy, but I'm baffled.
I'd like to set up an 8-word array which will be aliased into a 128 bit array, and also be aliased into (6 different words and 4 different bytes)
Here's my pseudocode:
Galaxy VAR Word(8) ' ok, here's my 8 word array. There are 8 Galaxies: Galaxy(0), Galaxy(1) ... Galaxy(7)
Planet VAR Galaxy.BIT0 ' now I have 128 planets. So Planet(19) is the 4th bit in Galaxy(3) no problem so far...
' the following lines don't fly. What's wrong with 'em???
RedStar VAR Galaxy(0) ' make Red Star to be a 16 bit fullword that is the same as Galaxy(0)
OrangeStar VAR Galaxy(1) 'make Orange Star to be a 16 bit fullword that is the same as Galaxy(1)
YellowStar VAR Galaxy(3) ' make Blue Star to be a 16 bit fullword that is the same as Galaxy(3)
WhiteDwarf VAR Galaxy(7) ' make WhiteDwarf to be a 8 bit byte that maps into HIGHBYTE of Galaxy(7) [noparse][[/noparse]How do I tell the complier that WhiteDwarf is a byte???]
BrownDwarf VAR Galaxy(7) ' make BrownDwarf to be an 8 bit byte that maps into LOWBYTE of Galaxy(7)
' and, of course, OrangeStar would be the same as planet(8), Planet(9), Planet(10) ... Planet(15)
' WhiteDwarf would be the same as planet(28) to Planet(35)
How to do it?
Cheers to all,
-Cliff
I'd like to set up an 8-word array which will be aliased into a 128 bit array, and also be aliased into (6 different words and 4 different bytes)
Here's my pseudocode:
Galaxy VAR Word(8) ' ok, here's my 8 word array. There are 8 Galaxies: Galaxy(0), Galaxy(1) ... Galaxy(7)
Planet VAR Galaxy.BIT0 ' now I have 128 planets. So Planet(19) is the 4th bit in Galaxy(3) no problem so far...
' the following lines don't fly. What's wrong with 'em???
RedStar VAR Galaxy(0) ' make Red Star to be a 16 bit fullword that is the same as Galaxy(0)
OrangeStar VAR Galaxy(1) 'make Orange Star to be a 16 bit fullword that is the same as Galaxy(1)
YellowStar VAR Galaxy(3) ' make Blue Star to be a 16 bit fullword that is the same as Galaxy(3)
WhiteDwarf VAR Galaxy(7) ' make WhiteDwarf to be a 8 bit byte that maps into HIGHBYTE of Galaxy(7) [noparse][[/noparse]How do I tell the complier that WhiteDwarf is a byte???]
BrownDwarf VAR Galaxy(7) ' make BrownDwarf to be an 8 bit byte that maps into LOWBYTE of Galaxy(7)
' and, of course, OrangeStar would be the same as planet(8), Planet(9), Planet(10) ... Planet(15)
' WhiteDwarf would be the same as planet(28) to Planet(35)
How to do it?
Cheers to all,
-Cliff
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
So unless you tell the compiler otherwise, it assigns memory in the order implied by the program's source code.
Hmmmm...
Cheers,
-Cliff
I think it assigns memory locations in order of size. Words first, then Bytes, Nibbles and finally Bits.
Rich H
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Simple Servo Tester, a kit from Gadget Gangster.