TAL Programmer's Guide
Declaring Substructures
Using Structures
096254 Tandem Computers Incorporated 8–15
Declaring Referral
Substructures
A referral substructure uses the layout of a previously declared structure. To declare a
referral substructure, specify:
The keyword STRUCT
The substructure identifier (with no indirection symbol)
A referral that provides a layout—enclose in parentheses the identifier of an
existing structure (except the encompassing structure) or structure pointer
Optional substructure bounds—the default bounds are [0:0] (one occurrence)
In the following example, referral substructure REF_SUB uses the body of structure
STRUCT_TWO from the preceding example:
STRUCT .EXT struct_three;
BEGIN
INT a;
STRUCT ref_sub (struct_two) [0:2]; !Declare REF_SUB
END;
Allocating Referral Substructures
The compiler allocates storage for a referral substructure when it allocates storage for
the encompassing structure. The compiler allocates the storage based on:
The addressing mode and number of occurrences specified in the new declaration
The layout of the previous declaration
A referral substructure always begins on a word boundary. If the substructure
contains an odd number of bytes, the compiler appends a pad byte to each occurrence
of the substructure.
The following example shows how the compiler aligns referral substructure ABC on a
word boundary, allocating a pad byte in each unused byte:
STRUCT template (*);
BEGIN
STRING a[0:2];
INT b;
STRING c;
END;
STRUCT .indirect_structure;
BEGIN
INT header[0:1];
STRING abyte;
STRUCT abc (template) [0:1];
!Referral substructure
END;
391
ABYTE / / /
HEADER[0]
HEADER[1]
A[0] A[1]
A[2]
B
C / / /
/ / /
A[0] A[1]
A[2]
B
C / / /
/ / /
ABC[0]
ABC[1]