-Onbf: Disable Optimize Bitfields

Group

OPTIMIZATIONS

Scope

Function

Syntax
  -Onbf
  
  
Arguments

None

Default

None

Defines

None

Pragmas

None

Description

This option prevents the Compiler from combining sequences of bitfield assignments containing constants. This simplifies debugging and makes the code more readable.

Example
Listing: Example Bitfield Definition


struct {
  b0:1;

  b1:1;

  b2:1;

} bf;

void main(void) {

  bf.b0 = 0;

  bf.b1 = 0;

  bf.b2 = 0;

}

Without -Onbf (pseudo intermediate code):

  BITCLR  bf, #7  // all 3 bits (the mask is 7)

  
                  // are cleared

  

With -Onbf (pseudo intermediate code):

  BITCLR  bf, #1  // clear bit 1 (mask 1)

  
  BITCLR  bf, #2  // clear bit 2 (mask 2)

  
  BITCLR  bf, #4  // clear bit 3 (mask 4)

  
Example
  -Onbf