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

How do I get the bit address in Keil C

Hi,

I want to know the address of a bit variable.
For example:

bit gBit;
func()
{
  printf("%d", &gBit);
}
How do I know where the variable gBit is allocated by the linker in run time?

Parents
  • As long as I can get this address, I can assign value to the bit of that address.

    No, you can't. More to the point, the 8051 can't do that. As a previous reply already pointed out to you: the '51 doesn't have the concept of a pointer to a bit variable. Or, to put in terms of assembly code: there is no indirect addressing mode for single bits, only direct addressing.

    A bit variable simply can't be used the way you want it to. Use a byte instead.

Reply
  • As long as I can get this address, I can assign value to the bit of that address.

    No, you can't. More to the point, the 8051 can't do that. As a previous reply already pointed out to you: the '51 doesn't have the concept of a pointer to a bit variable. Or, to put in terms of assembly code: there is no indirect addressing mode for single bits, only direct addressing.

    A bit variable simply can't be used the way you want it to. Use a byte instead.

Children