TAL Programmer's Guide
Declaring Substructures
Using Structures
8–14 096254 Tandem Computers Incorporated
Allocating Definition Substructures
The compiler allocates storage for each substructure when it allocates storage for the
encompassing structure. The compiler aligns a definition substructure on a byte or
word boundary.
Byte Alignment. A definition substructure is byte aligned if the first item it contains
begins on a byte boundary.
In the following example, definition substructure SUB follows a STRING item (X); the
first item in SUB is also a STRING item (AA). Thus, each occurrence of SUB begins on
a byte boundary. After the last occurrence of SUB, the compiler allocates a pad byte,
because the next variable, Y, is an INT variable and must begin on a word boundary:
STRUCT struct_one;
BEGIN
STRING x;
STRUCT sub[0:2]; !Byte-aligned SUB
BEGIN
STRING aa;
INT b;
STRING c;
END; !End SUB
INT y;
END;
389
X
B
C
B
C
B
C
Y
AA
AA
/ / /
AA
Word Alignment. A definition substructure is word aligned if the first item it contains is
word aligned, including arrays that have bounds of [n:n-1]. If a word-aligned
substructure has more than one occurrence and contains an odd number of bytes, the
compiler allocates a pad byte after each occurrence.
In the following example, definition substructure SUB starts with INT item A_A. The
compiler starts each occurrence of SUB on a word boundary, allocating a pad byte in
each unused byte:
STRUCT struct_two;
BEGIN
STRING x;
STRUCT sub [0:1]; !Word-aligned SUB
BEGIN
INT a_a;
INT b;
STRING c;
END; !End SUB
END;
390
X
A_A
B
C
/ / /
A_A
B
C
/ / /
/ / /
SUB[0]
SUB[1]