pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11-21
Using Field Alignment
The total number of bytes in a SHARED8 structure must be an integral multiple of the
widest field in the structure. If needed, you must explicitly declare filler at the end of a
SHARED8 structure to ensure this condition. In Example 11-4 on page 11-21, filler is
required at the end of each structure.
UNSIGNED(1-16) fields cannot cross an even-byte address (see Example 11-5 on
page 11-21).
In a SHARED8 structure, UNSIGNED(17-31) fields cannot cross a four-byte address
(see Example 11-6 on page 11-22).
Example 11-4. Structure Length
STRUCT s1 FIELDALIGN(SHARED8);
BEGIN
FIXED i; ! Structure's widest field is 8 bytes
INT(32) j; ! j is 4 bytes
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;
Example 11-5. Alignment of UNSIGNED(1-16) Fields
Incorrect:
STRUCT s FIELDALIGN(SHARED8);
BEGIN
UNSIGNED(10) u1;
UNSIGNED(16) u2; ! This field is invalid because
END; ! it crosses an even-byte address
Correct:
STRUCT s FIELDALIGN(SHARED8);
BEGIN
UNSIGNED(10) u1;
BIT_FILLER 6; ! Six bits forces u2 to begin at the
! next even-byte address
UNSIGNED(16) u2; ! u2 begins at an even-byte address
END;