CODE GENERATION
Function
-BfaB(MS|LS)
MS: Most significant bit in byte first (left to right)
LS: Least significant bit in byte first (right to left)
HC08: -BfaBLS
__BITFIELD_MSWORD_FIRST__
__BITFIELD_LSWORD_FIRST__
__BITFIELD_MSBYTE_FIRST__
__BITFIELD_LSBYTE_FIRST__
__BITFIELD_MSBIT_FIRST__
__BITFIELD_LSBIT_FIRST__
None
Normally, bit allocation in byte bitfields proceeds from the least significant bit to the most significant bit. This produces less code overhead in the case of partially-allocated byte bitfields.
The following listing uses the default condition and uses the three least significant bits.
struct {unsigned char b: 3; } B; // the default is using the 3 least significant bits
This allows a mask operation without any shift to access the bitfield.
To change this allocation order, use the -BfaBMS or -BfaBLS options shown in the following listing.
struct { char b1:1; char b2:1; char b3:1; char b4:1; char b5:1; } myBitfield; 7 0 -------------------- |b1|b2|b3|b4|b5|####| (-BfaBMS) -------------------- 7 0 -------------------- |####|b5|b4|b3|b2|b1| (-BfaBLS) --------------------