pTAL Conversion Guide

Structures
pTAL Conversion Guide527302-002
11- 4
Pictorial Overview of pTAL Structure Alignment
Figure 11-2 on page 11-5 shows which fields of s1 are misaligned if the base of the
structure in memory is not at an integral multiple of its base alignment. Only structures
whose base is at an even-byte address are shown. Accessing structures whose base
is at an odd-byte offset produces undefined results. For more information, see
Overview of Field Alignment on page 11-7.
Figure 11-1. Alignment of a SHARED8 Structure With Base Alignment of 8
STRUCT s FIELDALIGN(SHARED8); ! Base alignment of s1 is 8
BEGIN
INT i; ! Begins at offset 0
FILLER 2; ! 2 bytes of filler required
INT(32) i32; ! Begins at offset 4
STRING s1; ! Begins at offset 8
STRING s2; ! Begins at offset 9
FILLER 6; ! 6 bytes of filler required
FIXED f; ! Begins at offset 16
INT k; ! Begins at offset 24
FILLER 6; ! Must pad to multiple of widest field, f
END; ! Total length of s1: 32 bytes
Filler required to align next field,
i32, on a 4-byte boundary.
02
8
46
i32
Filler required to align next field,
f, on an 8-byte boundary.
i
filler
s1 s2
k
18 20 22 24
f
12 1410
filler
16
28 30
filler
Filler required to make length of
the structure an integral multiple
of its widest field, f.
26
VST007.vsd