pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11- 6
Pictorial Overview of pTAL Structure Alignment
Figure 11-3 on page 11-6 shows a structure that is declared FIELDALIGN(SHARED8).
The widest fields in s2, i32a and i32b, are each four bytes; therefore, although the
field alignment of s2 is SHARED8, the base alignment of s2 is four, not eight. s2 is
well-aligned in memory if the base of the structure begins at any address that is a
multiple of four.
Figure 11-3. Alignment of a SHARED8 Structure With Base Alignment of 4
STRUCT s2 FIELDALIGN(SHARED8); ! Base alignment is 4
BEGIN
STRING s1 ! Begins at offset 0
FILLER 3; ! 3 bytes of filler required
INT(32) i32a; ! Begins at offest 4
STRING s2 ! Begins at offset 8
STRING s3 ! Begins at offset 9
FILLER 2; ! 2 bytes of filler required
INT(32) i32b; ! Begins at offest 12
INT k; ! Begins at offest 16
FILLER 2; ! Must pad to multiple of base alignment
END; ! Total length of s2: 20 bytes
Filler required to align next field,
i32a, on a 4-byte boundary.
0
s1
2
8
filler
s2 s3
46
i32a i32b
12 14
10
filler
16
k
18
filler
20
Filler required to align next field,
i32b, on a 4-byte boundary.
Filler required to make length of
the structure an integral multiple
of its widest field, i32a and i32b.
VST997.vsd