SLAU132V October 2004 – February 2020
When the compiler allocates space for a structure, it allocates as many words as are needed to hold all of the structure's members and to comply with alignment constraints for each member.
When a structure contains a 32-bit (long) member, the long is aligned to a 1-word (16-bit) boundary. This may require padding before, inside, or at the end of the structure to ensure that the long is aligned accordingly and that the sizeof value for the structure is an even value.
All non-field types are aligned on word or byte boundaries. Fields are allocated as many bits as requested. Adjacent fields are packed into adjacent bits of a word, but they do not overlap words. If a field would overlap into the next word, the entire field is placed into the next word.
Fields are packed as they are encountered; the least significant bits of the structure word are filled first. Example 1 shows the C code definition of var while Figure 6-1 shows the memory layout of var.