Table of Contents        Previous topic       Next topic       

C COMPILER->8051 Specific Features->Bit Addressable Objects

Objects can be located in the 8051 bit addressable memory space using the _bdata keyword.  For instance:

int _bdata nMask;

declares an int that will be located in bit addressable memory.

The sole reason for wanting to locate an object in bit addressable memory is so that the individual bits of the object can be separately accessed.  This is done by declaring a bit object using the _sfrbit keyword (even though in this case the bit is not located in sfr data space) in conjunction with the '^' operator.  For instance:

int _bdata nMask;
_sfrbit bit3 = nMask^3;

The variable bit3 can then be used to access bit 3 of variable nMask.

Any global object can be located in bit addressable memory space  int's, floats, doubles, structures, arrays, etc. as long as there is sufficient space.  Local objects and function arguments cannot be located in bit addressable memory space.