pTAL Reference Manual (H06.03+)
Structures
HP pTAL Reference Manual—523746-005
9-15
Structure Alignment
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 9-3
on page 9-9. 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 9-4. 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;
Example 9-5. 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;
INT(32) c; ! c is field with widest
END; ! alignment: 4
STRUCT s3 FIELDALIGN(SHARED8); ! Base alignment of structure is
BEGIN ! 8 because of FIXED c
STRING a;
STRING b;
FILLER 6;
FIXED c; ! c is field with widest
END; ! alignment: 8










