Using the STRUC, UNION, and FIELD directives, you can define data items that are grouped together. Such a group is called a structure and can be thought of in the same way as a structure or union in C. Structured types are bracketed between STRUC and ENDSTRUC, and should contain only FIELD directives; similarly, unions are bracketed between UNION and ENDUNION, and should only contain FIELD directives.
We could declare a structure type called Amount that has two members, Dollars and Cents, like this:
Amount STRUC Dollars FIELD LONG Centse FIELD BYTE ENDSTRUC
The field Dollars is declared to be of type LONG and Cents is of type BYTE (so we can count lots of Dollars, and a small amount of loose change).
In structures, fields are allocated one after another, increasing the size of the structure for each field added. For a union, all fields are overlaid, and the size of the union is the size of the largest field within the union.
For a 32-bit, big-endian machine, we could overlay four bytes over a 32-bit word like this:
Word UNION asWord FIELD WORD asBytes FIELD BYTE[4] ENDUNION
The most useful thing about user-defined structures is that they act like any built-in data type, so you can allocate space for variables of the structure type:
Balance DV Amount
Here we've declared enough storage for the variable Balance to hold an Amount, and the assembler (and debugger) knows that Balance is of type Amount.