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

Example 69 Structures That Need Filler
STRUCT s1 FIELDALIGN(SHARED8);
BEGIN
FIXED i; ! Structure's widest field is 8 bytes
INT(32) j; ! j is 4 bytes FILLER 4
FILLER 4; ! Pad with 4 bytes
END;
STRUCT s2 FIELDALIGN(SHARED8);
BEGIN
INT(32) i; ! Structure's widest field is 4 bytes
INT j; ! j is 2 bytes
FILLER 2; ! Pad with 2 bytes
END;
UNSIGNED(1-16) fields cannot cross an even-byte address.
Example 70 Structure Field Crossing an Even-Byte Address (Error)
STRUCT s FIELDALIGN(SHARED8);
BEGIN
UNSIGNED(10) u1;
UNSIGNED(16) u2; ! Invalid field -- crosses even-byte address
END;
In Example 71 (page 133), u1 starts at the beginning of the structure. u2, therefore, would begin
at a 10-bit offset from the beginning of s. Because u2 is 16 bits, the last ten bits of u2 would be
allocated in a second word, which would cause u2 to cross an even-byte address; therefore, you
must explicitly declare filler to force u2 to begin at the next even-byte offset from the beginning of
s.
Example 71 Structure That Needs Filler
STRUCT s FIELDALIGN(SHARED8);
BEGIN
UNSIGNED(10) u1;
BIT_FILLER 6; ! Forces u2 to begin at next even-byte address
UNSIGNED(16) u2;
END;
Alignment of UNSIGNED(17-31) Fields
In a SHARED8 structure, UNSIGNED(17-31) fields cannot cross a 4-byte address. Because an
UNSIGNED(17-31) field is longer than 16 bits, its base alignment is 4 bytes.
In Example 72 (page 133), i starts at the beginning of the structure. u, therefore, begins at an
even-byte offset from the beginning of s. Because u is 28 bits, the last 12 bits of u would be
allocated in the next word, which would cause u to cross a 4-byte address.
Example 72 SHARED8 Structure With Misaligned UNSIGNED Fields
STRUCT s FIELDALIGN(SHARED8);
BEGIN
INT i;
UNSIGNED(28) u; ! Invalid field
END;
You must explicitly declare filler to force u to begin at the next 4-byte offset from the beginning of
s.
SHARED8 Parameter 133