pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Figure 5 Well-Aligned and Misaligned SHARED8 Structures With Base Alignment of 8
Figure 6 (page 121) shows a structure that is declared FIELDALIGN(SHARED8). The widest fields
in s2, i32a and i32b, are each four bytes; therefore, although the field alignment of s2 is
SHARED8, the base alignment of s2 is four, not eight. s2 is well-aligned in memory if the base of
the structure begins at any address that is a multiple of four.
Figure 6 Alignment of a SHARED8 Structure With Base Alignment of 4
STRUCT s2 FIELDALIGN(SHARED8); ! Base alignment is 4
BEGIN
STRING s1 ! Begins at offset 0
FILLER 3; ! 3 bytes of filler required
INT(32) i32a; ! Begins at offest 4
STRING s2 ! Begins at offset 8
STRING s3 ! Begins at offset 9
FILLER 2; ! 2 bytes of filler required
INT(32) i32b; ! Begins at offest 12
INT k; ! Begins at offest 16
FILLER 2; ! Must pad to multiple of base alignment
END; ! Total length of s2: 20 bytes
Figure 7 (page 122) shows which fields are misaligned if s2 is allocated at an address other than
a 4-byte address.
Field and Base Alignment 121