pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Example 63 FIELDALIGN(SHARED2) and REFALIGNED(2) Directives
?FIELDALIGN(SHARED2)
?REFALIGNED(2)
INT(32).ptr; ! Global pointer
PROC p;
BEGIN
@ptr := @str.F32; ! str.F32 might or might not be aligned
! at a 32-bit address. REFALIGNED
... := ptr + 3D; ! directive ensures that pTAL
! generates conservative code for
END; ! references to ptr.
Example 64 Byte Offsets (Decimal) of Fields of a SHARED2 Structure
STRUCT s1 FIELDALIGN(SHARED2);
BEGIN
INT i; ! i begins at byte offset: 0
INT(32) j; ! j begins at byte offset: 2
STRING s1; ! s1 begins at byte offset: 6
UNSIGNED(3) u1; ! u1 begins at byte offset: 8
UNSIGNED(2) u2; ! u2 begins at byte offset: 8 + 3 bits
STRING s2; ! s2 begins at byte offset: 10
FIXED f; ! f begins at byte offset: 12
INT k; ! k begins at byte offset: 20
END;
SHARED8 Parameter
Since the SHARED8 parameter is included with both the FIELDALIGN clause and the FIELDALIGN
compiler directive, the following information relates to both usages:
• The structure must begin at an address that is an integral multiple of the width of the widest
field in the structure. Thus:
◦ A 1-byte field (STRING) can begin at any byte address.
◦ The byte offset of a 2-byte field [INT or UNSIGNED(1-16)] must be an even number,
except that contiguous UNSIGNED fields can be packed.
◦ The byte offset of a 4-byte field [INT(32), REAL, UNSIGNED(17-31)] must be an integral
multiple of four, except that contiguous UNSIGNED fields can be packed.
◦ The byte offset of an 8-byte field [FIXED or REAL(64] must be an integral multiple of eight.
◦ The byte offset of a substructure field must be an integral multiple of the widest field in
the substructure.
◦ The byte offset of an array must be an integral multiple of an element of the array—that
is, one of the previous items in this list.
• In a SHARED8 structure or substructure, you must explicitly declare filler items as needed to
ensure that fields are aligned according to the preceding rules.
Table 45 Variable Alignment
NotesAlignmentData Type
1STRING
2INT
Multiple UNSIGNED fields can be packed in a word
or doubleword.
2UNSIGNED(1-16)
.SG pointers are 16 bits in both pTAL and TAL.*2.SG pointers
SHARED8 Parameter 129