SPRU513Z August 2001 – October 2023 SM320F28335-EP
Declare Structure Type
[stag] .struct [expr]
[mem0]
element [expr0]
[mem1] element [expr1]
. . .
[memn] .tag
stag [exprn]
. . .
[memN] element [exprN]
[size] .endstruct
label .tag stag
The .struct directive assigns symbolic offsets to the elements of a data structure definition. This allows you to group similar data elements together and let the assembler calculate the element offset. This is similar to a C structure or a Pascal record. The .struct directive does not allocate memory; it merely creates a symbolic template that can be used repeatedly.
The .endstruct directive terminates the structure definition.
The .tag directive gives structure characteristics to a label, simplifying the symbolic representation and providing the ability to define structures that contain other structures. The .tag directive does not allocate memory. The structure tag (stag) of a .tag directive must have been previously defined.
Parameters used with the .struct, .endstruct, and .tag directives are:
The following examples show various uses of the .struct, .tag, and .endstruct directives.
REAL_REC .struct ; stag
NOM .int ; member1 = 0
DEN .int ; member2 = 1
REAL_LEN .endstruct ; real_len = 4
ADD ACC, @(REAL + REAL_REC.DEN) ;access structure element
REAL .usect ".ebss", REAL_LEN ; allocate mem rec
CPLX_REC .struct
REALI .tag REAL_REC ; stag
IMAGI .tag REAL_REC ; member1 = 0
CPLX_LEN .endstruct ; rec_len = 4
COMPLEX .tag CPLX_REC ; assign structure attrib
ADD ACC, COMPLEX.REALI ; access structure
ADD ACC, COMPLEX.IMAGI
COMPLEX .usect ".ebss", CPLX_LEN ; allocate space
.struct ; no stag puts mems into
X .int ; global symbol table
Y .int ;create 3 dim templates
Z .int
.endstruct
BIT_REC .struct ; stag
STREAM .string 64
BIT7 .field 7 ; bits1 = 64
BIT9 .field 9 ; bits2 = 64
BIT10 .field 10 ; bits3 = 65
X_INT .int ; x_int = 67
BIT_LEN .endstruct ; length = 68
BITS .tag BIT_REC
ADD AC, @BITS.BIT7 ; move into acc
AND ACC, #007Fh ; mask off garbage bits
BITS .usect ".ebss", BIT_REC