This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

bug of define a bit in bdata

C:
bdata unsigned BUFR16=0;
sbit BIT8=BUFR16^8;

the assemble language which is compiled by Keil uVision3:
C:0x1172 9210 MOV BIT8(0x22.0),C
......
;BUFR16<<=1;
C:0x117D E522 MOV A,0x22
C:0x117F 25E0 ADD A,ACC(0xE0)
C:0x1181 F522 MOV 0x22,A
C:0x1183 E521 MOV A,BUFR16(0x21)
C:0x1185 33 RLC A
C:0x1186 F521 MOV BUFR16(0x21),A
......

Parents
  • At a guess, the question has something to do with the bit ordering within a U16 declared in bdata.

    See the note at the end of the Bit-Addressable Objects section in Chapter 3 of the compiler manual.


    The sbit data type uses the specified variable as a base address and adds the bit position to obtain a physical bit address. Physical bit addresses are not equivalent to logical bit positions for certain data types. Physical bit position 0 refers to bit position 0 of the first byte. Physical bit position 8 refers to bit position 0 of the second byte. Because int variables are stored high-byte first, bit 0 of the integer is located in bit position 0 of the second byte. This is physical bit position 8 when accessed using an sbit data type.

Reply
  • At a guess, the question has something to do with the bit ordering within a U16 declared in bdata.

    See the note at the end of the Bit-Addressable Objects section in Chapter 3 of the compiler manual.


    The sbit data type uses the specified variable as a base address and adds the bit position to obtain a physical bit address. Physical bit addresses are not equivalent to logical bit positions for certain data types. Physical bit position 0 refers to bit position 0 of the first byte. Physical bit position 8 refers to bit position 0 of the second byte. Because int variables are stored high-byte first, bit 0 of the integer is located in bit position 0 of the second byte. This is physical bit position 8 when accessed using an sbit data type.

Children
No data