pTAL Reference Manual (H06.03+)
Structures
HP pTAL Reference Manual—523746-005
9-13
Array Alignment in Structures
Figure 9-4 on page 9-13 shows which fields are misaligned if s2 is allocated at an
address other than a 4-byte address.
Array Alignment in Structures
When you declare an array in a structure, the alignment of the beginning of the array is
the alignment of the base type of the array. Thus, for example, the field alignment of an
array of INTs is the same as the field alignment of a single INT, which is 2. Declaring an
array in a structure is the same as explicitly declaring individual fields, each with the
same data type as the array’s base type.
In Example 9-1 on page 9-13, the layouts and base alignments of s1 and s2 are
identical:
Figure 9-4. Well-Aligned and Misaligned SHARED8 Structures With Base
Alignment of 4
Example 9-1. Arrays Within Structures (page 1 of 2)
STRUCT s1 FIELDALIGN(SHARED8);
BEGIN
INT i;
INT a[0:2];
STRUCT s1[0:1];
BEGIN
INT(32)w;
INT y;
INT x;
END;
END;
02
8
46
18 20 22 24
12 1410 16
28 3026
Misaligned fields: none
02
8
46
18 20 22 24
12 1410 16
28 3026
Misaligned fields: i32a, i32b
02
8
46
18 20 22 24
12 1410 16
28 3026
Misaligned fields: none
s1 i32a s2 s3 filler i32b k fillerfiller
s1 i32a s2 s3 filler i32b k fillerfiller
s1 i32a s2 s3 filler i32b k fillerfiller
VST114.vsd










