pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

Do not assume that fields of an AUTO structure are contiguous in memory. The compilers insert
filler where required for optimal alignment.
Pointer fields and nonpointer fields in structures declared with AUTO field alignment can be any
address type or data type, respectively.
TAL, pTAL, and C lay out AUTO structures differently.
Differences Between PLATFORM and AUTO
PLATFORM structures and substructures can contain UNSIGNED and STRING items within a 2-byte
word. In AUTO structures and substructures, STRING items and UNSIGNED items are not allocated
within a 2-byte word.
PLATFORM structures and substructures can contain an odd number of bytes. AUTO (and SHARED8)
structures must contain an even number of bytes. pTAL adds an extra byte at the end of AUTO
structures if, without the byte, the structure would contain an odd number of bytes.
The length of PLATFORM structures or substructures that contains an UNSIGNED item must be an
integral multiple of four bytes. pTAL adds extra bytes, as needed, to the end of such structures and
substructures.
Field and Base Alignment
The field alignment of a structure specifies the offsets at which fields of the structure must begin
relative to the base of the structure. A scalar field is well-aligned when its byte offset is an integral
multiple of its width. A substructure is well-aligned when the offset of its base, relative to its
encompassing structure, is an integral multiple of its widest field.
Use the FIELDALIGN clause to specify how you want pTAL to align the fields in the structure. For
more information, see FIELDALIGN Clause (page 127).
Topics:
Base Alignment (page 119)
Structure Alignment Examples (page 120)
Base Alignment
The base alignment of a structure is the alignment of the widest field in the structure. The base
alignment determines where the structure can be located in memory and be well-aligned. A structure
is well-aligned when the memory address at which it is located is an integral multiple of its base
alignment.
Table 43 Base Alignment and Field Alignment Relationships
FIELDALIGN(SHARED8)FIELDALIGN(SHARED2)Width of Widest Field in Structure
1 or 2*1 or 2*1
222
424
828
*Definition (inline) substructures have a base alignment of one. All other structures—definition structures, referral
structures, and referral substructures—have a base alignment of two.
A structure is well-aligned if the address of the base of the structure in memory is a multiple of its
base alignment; otherwise, the structure is misaligned. If a structure is misaligned, some or all of
its fields will also be misaligned.
Field and Base Alignment 119