pTAL Conversion Guide

Equivalenced Variables
pTAL Conversion Guide527302-002
12-12
Declaring Structures in Equivalenced Declarations
Declaring Structures in Equivalenced Declarations
The memory referenced in an equivalenced declaration must fit within the memory
allocated for the previous variable. When you determine the length of a structure, you
must account for filler that pTAL adds to the structure.
The equivalenced declaration in Example 12-8 on page 12-12 is invalid, because b is
four bytes, but a is only three bytes. pTAL adds an extra byte at the end of b so that its
total length is an integral multiple of its longest component, i.
Figure 12-3. Equivalenced Arrays
INT(32) i;
INT j[0:1] = i;
INT k[0:3] = i; ! ERROR: k is not contained within i
Example 12-8. Invalid Equivalenced Structure Declaration
STRUCT a FIELDALIGN(SHARED2); ! Structure a is 3 bytes
BEGIN
STRING i;
STRING j;
STRING k;
END;
STRUCT b FIELDALIGN(AUTO) = a; ! Structure b is 4 bytes
BEGIN
INT i;
STRING j; ! pTAL adds a byte after field j
END; ! b's total length is four bytes,
! which is longer than a
Figure 12-2. Equivalenced Variables That Are Valid in TAL But Not in pTAL
0123456
r[0] r[1] r[2] t
s
INT r[0:2]; INT(32) s = r[2]; INT t = r[5];
VST005.vsd
0123456
k[2]
i
k[0]
j[0]
k[1]
j[1]
k[3]
VST006.vsd