pTAL Reference Manual (H06.03+)
Structures
HP pTAL Reference Manual—523746-005
9-22
SHARED8 Parameter
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.
Example 9-13. 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;
Table 9-5. Variable Alignment (page 1 of 2)
Data Type Alignment Notes
STRING 1
INT 2
* In pTAL, the alignment of all address types is 4, except SGBADDR and SGWADDR addresses for which the
alignment is 2. In TAL, the alignment of all address types is 2.
** The alignment of an array is the alignment of its element type.










