SPRUI03E June 2015 – January 2023
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.
1 real_rec .struct ; stag
2 00000000 nom .int ; member1 = 0
3 00000004 den .int ; member2 = 1
4 00000008 real_len .endstruct ; real_len = 2
5
6 00000000 0080016C- LDW *+B14(real+real_rec.den), A1
7 ; access structure
8
9 00000000 .bss real, real_len ; allocate mem rec
10
11 cplx_rec .struct ; stag
12 00000000 reali .tag real_rec ; member1 = 0
13 00000008 imagi .tag real_rec ; member2 = 2
14 00000010 cplx_len .endstruct ; cplx_len = 4
15
16 complex .tag cplx_rec ; assign structure
17 ; attribute
18 00000008 .bss complex, cplx_len ; allocate mem rec
19
20 00000004 0100046C- LDW *+B14(complex.imagi.nom), A2
21 ; access structure
22 00000008 0100036C- LDW *+B14(complex.reali.den), A2
23 ; access structure
24 0000000c 018C4A78 CMPEQ A2, A3, A3
1 .struct ; no stag puts
2 ; mems into global
3 ; symbol table
4
5 00000000 X .byte ; create 3 dim
6 00000001 Y .byte ; templates
7 00000002 Z .byte
8 00000003 .endstruct
1 bit_rec .struct ; stag
2 00000000 stream .string 64
3 00000040 bit7 .field 7 ; bit7 = 64
4 00000040 bit1 .field 9 ; bit9 = 64
5 00000042 bit5 .field 10 ; bit5 = 64
6 00000044 x_int .byte ; x_int = 68
7 00000045 bit_len .endstruct ; length = 72
8
9 bits .tag bit_rec
10 00000000 .bss bits, bit_len
11
12 00000000 0100106C- LDW *+B14(bits.bit7), A2
13 ; load field
14 00000004 0109E7A0 AND 0Fh, A2, A2 ; mask off garbage