Variables are declared with XREF. In addition, for structures, every field is defined with an EQU directive. For bitfields, the bit offset and bit size are also defined.
Variables in the __SHORT_SEG segment are defined with XREF.B to inform the assembler about the direct access. Fields in structures in __SHORT_SEG segments, are defined with a EQU.B directive.
#pragma CREATE_ASM_LISTING ON struct A { char a; int i:2; }; struct A VarA; #pragma DATA_SEG __SHORT_SEG ShortSeg int VarInt;
Creates:
XREF VarA VarA_a EQU VarA + $0 VarA_i EQU VarA + $1 VarA_i_BIT_WIDTH EQU $2 VarA_i_BIT_OFFSET EQU $0 XREF.B VarInt
The variable size is not explicitly written. To generate the variable size, use a typedef with the variable type.
The offsets, bit widths, and bit offsets given here are examples. Different compilers may generate different values. In C, the structure alignment and the bitfield allocation is determined by the compiler which specifies the correct values.