How are structure bit fields dealt with?
As efficiently as possible. Bit fields are packed within 32-bit boundaries. Packed bit fields can have a dramatic impact on the amount of code generated.
Bit Fields
This example declares two structs, one with less than 32 bits of bit fields, and one with more.
struct {
0000 01 00 unsigned int shortElement : 1; /* 1 bit in size */
0000 11 01 unsigned int longestElement : 17; /* 17 bits */
0002 06 02 unsigned int longElement : 6; /* 7 bits in size */
0000 0004 } myBitField;
struct {
0000 0F 00 unsigned int fifteenbits : 15;
0001 04 07 int fourbits : 4;
0004 11 00 unsigned int seventeenbits: 17;
0004 0008 } myLongerBitField;
0200 9FEFFB00 ram p23_0 = 0001. myBitField.shortElement = 1;
0204 0800DBA2 alu p7_0 = p7_0 |
#0x000001,ccs.
0208 9FFFFB00 ram 0001 = p23_0.
020C CFEFF000 ram p31_0 = 0000. myBitField.longElement = 0x55;
0210 1FF03FE4 alu p = #0x03FFFF.
0214 3B180FF2 alu a = p & p ,ccs.
0218 19597382 alu p = a | #0x540000,
ccs.
021C CFFFF000 ram 0000 = p31_0.
0220 9FEFFB01 ram p23_0 = 0005. myLongerBitField.fourbits = -2;
0224 09F87FF2 alu p = p & #0xFF7FFF,
ccs.
0228 1BE87392 alu p = p & #0xF8FFFF,
ccs.
022C 000FF418 alu diob = #0xFF0000.
0230 3B787FF0 alu p = p | diob ,ccs.

New: