Bit Types

C51 provides you with a bit data type which may be used for variable declarations, argument lists, and function return values. A bit variable is declared just as other C data types are declared. For example:
static bit done_flag = 0;	/* bit variable */

bit testfunc ( /* bit function */
bit flag1, /* bit arguments */
bit flag2)
{
.
.
.
return (0); /* bit return value */
}

All bit variables are stored in a bit segment located in the internal memory area of the 8051. Because this area is only 16 bytes long, a maximum of 128 bit variables may be declared within any one scope.

Memory types may be included in the declaration of a bit variable. However, because bit variables are stored in the internal data area of the 8051, the data and idata memory types only may be included in the declaration. Any other memory types are invalid.

The following restrictions apply to bit variables and bit declarations:

    Functions which use disabled interrupts (#pragma disable) and functions that are declared using an explicit register bank (using n) cannot return a bit value. The C51 compiler generates an error message for functions of this type that attempt to return a bit type.

    A bit cannot be declared as a pointer. For example:

    bit *ptr

    An array of type bit is invalid. For example:

    bit ware [5]