-BfaB: Bitfield Byte Allocation

Group

CODE GENERATION

Scope

Function

Syntax
-BfaB(MS|LS) 
Arguments

MS: Most significant bit in byte first (left to right)

LS: Least significant bit in byte first (right to left)

Default
HC08: -BfaBLS 
Defines

__BITFIELD_MSWORD_FIRST__

__BITFIELD_LSWORD_FIRST__

__BITFIELD_MSBYTE_FIRST__

__BITFIELD_LSBYTE_FIRST__

__BITFIELD_MSBIT_FIRST__

__BITFIELD_LSBIT_FIRST__

Pragmas

None

Description

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.

Example

The following listing uses the default condition and uses the three least significant bits.

Listing: Changing the Allocation Order Example


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.

Listing: Changing the Allocation Order Example


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)

  --------------------
See also

Bitfield Allocation