Trouble with the bdata Memory Type
Some users have reported difficulties in using the bdata memory type. Using
bdata is similar to using the sfr modifier. The most common error is
encountered when referencing a bdata variable defined in another module. For
example:
extern bdata char xyz_flag;
sbit xyz_bit1 = xyz_flag^1;
In order to generate the appropriate instructions, the compiler must have the
absolute value of the reference to be generated. In the above example, this
cannot be done, as this address of xyz_flag cannot be known until after the
linking phase has been completed. Follow the rules below to avoid this problem.
1. A bdata variable (defined and used in the same way as an sfr) must be
defined in global space; not within the scope of a procedure.
2. A bdata bit variable (defined and used in the same way as an sbit) must also
be defined in global space, and cannot be located within the scope of a
procedure.
3. The definition of the bdata variable and the creation of its sbit access
component name must be accomplished where the compiler has a “view” of
both the variable and the component.
For example, declare the bdata variable and the bit component in the same
source module:
bdata char xyz_flag;
sbit xyz_bit1 = xyz_flag^1;
Then, declare the bit component external:
extern bit xyz_bit1;
As with any other declared and named C variable that reserves space, simply
define your bdata variable and its component sbits in a module. Then, use the
extern bit specifier to reference it as the need arises.