SPRUI03E June 2015 – January 2023
These directives set up specialized types for later use with the .tag directive, allowing you to use symbolic names to refer to portions of a complex object. The types created are analogous to the struct and union types of the C language.
The .struct, .union, .cstruct, and .cunion directives group related data into an aggregate structure which is more easily accessed. These directives do not allocate space for any object. Objects must be separately allocated, and the .tag directive must be used to assign the type to the object.
COORDT .struct ; structure tag definition
X .byte ;
Y .byte
T_LEN .endstruct
COORD .tag COORDT ; declare COORD (coordinate)
.bss COORD, T_LEN ; actual memory allocation
LDB *+B14(COORD.Y), A2 ; move member Y of structure
; COORD into register A2
The .cstruct and .cunion directives guarantee that the data structure will have the same alignment and padding as if the structure were defined in analogous C code. This allows structures to be shared between C and assembly code. See Chapter 12. For .struct and .union, element offset calculation is left up to the assembler, so the layout may be different than .cstruct and .cunion.