Hi,
I've looked at this and although I'm not that good at assembly here how I believe it works.
When you create a BIT variable the compiler allocates a BYTE of RAM and calls it PB1, your bit variable is then defined as the first bit in that byte. When you create a second BIT variable it gets defined as the second bit in the previously allocated BYTE (ie still only a single byte). When you create the 9th BIT variable a new BYTE is allocated (PB2) and so on. So, one BIT variable takes 1 BYTE but 8 bit variables still only takes ONE byte.
Basically, this is what it looks like in the assembly listing:
Code:
00081 PB01 EQU RAM_START + 019h
00083 PB02 EQU RAM_START + 01Ah
00092 #define _myBit1 PB01, 000h
00093 #define _myBit2 PB01, 001h
00094 #define _myBit3 PB01, 002h
00095 #define _myBit4 PB01, 003h
00096 #define _myBit5 PB01, 004h
00097 #define _myBit6 PB01, 005h
00098 #define _myBit7 PB01, 006h
00099 #define _myBit8 PB01, 007h
00100 #define _myBit9 PB02, 000h
As you can see, for 9 BIT variables only TWO bytes of RAM is allocated - thankfully and as expected.
/Henrik.
Bookmarks