pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
An array of structures or substructures is the same as an array of a pTAL data type. The width of
the widest field of an element of such an array, combined with the FIELDALIGN parameter you
specify, determines the required alignment of the structure or substructure and of its fields.
Example 53 SHARED2: 2-Byte Alignment
STRUCT s1[0:9] FIELDALIGN(SHARED2); ! s1 is SHARED2
BEGIN ! Alignment is 2
INT i;
FILLER 2;
INT(32) j;
END;
Example 54 SHARED8: 4-Byte Alignment
STRUCT s2[0:9] FIELDALIGN(SHARED8); ! s2 is SHARED8
BEGIN ! Alignment is 4
INT i;
FILLER 2;
INT(32) j;
END;
Example 55 8-Byte Alignment and 4-Byte Alignment
STRUCT s3[0:9] FIELDALIGN(SHARED8); ! s3 is SHARED8
BEGIN ! Alignment is 8
STRUCT s4[0:4]; ! s4 is SHARED8
BEGIN ! Alignment is 4
INT i;
FILLER 2;
INT(32) j;
END;
REAL(64) k;
END;
Structure Alignment
A structure’s alignment is the alignment of the widest field declared in the structure and is always
less than or equal to the alignment specified in a FIELDALIGN clause or FIELDALIGN compiler
directive. For alignment values of structure fields, see Table 43 (page 119). The alignment of a field
that is a substructure is the alignment of the widest field contained in the substructure.
If the alignment of the widest field in a SHARED8 structure is 2, the structure must begin at a 2-byte
address, and the structure’s base alignment is 2. If the alignment of the widest field in the structure
is four bytes, for example an INT(32), the structure must begin at a 4-byte address. If the alignment
of the widest field in the structure is eight bytes, for example an FIXED field, the structure must begin
at an 8-byte address.
Example 56 SHARED8 Structures With Different Base Alignments
STRUCT s1 FIELDALIGN(SHARED8); ! Base alignment of structure is
BEGIN ! 2 because of INT c
STRING a;
STRING b;
INT c; ! c is field with widest
END; ! alignment: 2
STRUCT s2 FIELDALIGN(SHARED8); ! Base alignment of structure is
BEGIN ! 4 because of INT(32) c
STRING a;
STRING b;
FILLER 2;
Structure Alignment 123