11.3 Controlling the Output of Bit Manipulation Instructions [V1.05.00 or later]

To output bit manipulation instructions without using intrinsic functions, satisfy all conditions shown below.

(a)

A constant value is assigned.

(b)

The value is assigned to a single-bit bit field of a 1-byte type.

(c)

The bit field where the value is assigned is qualified with volatile.

 

To stop the output of bit manipulation instructions, satisfy condition (c) above and either assign a value that is not a constant in condition (a) or use a type that is not a 1-byte type in condition (b).

When none of the above conditions is satisfied, the compiler automatically determines whether to output bit manipulation instructions according to the specified optimization level and the contents of the source program.

Note

1-byte types are char, unsigned char, signed char, and _Bool.

 

Example

volatile struct {
  unsigned char bit0:1;
  unsigned int bit1:1;
} data;
 
void func(void) {
  data.bit0 = 1;  /* A bit manipulation instruction is output. */
  data.bit1 = 1;  /* No bit manipulation instruction is output. */
}