pTAL Conversion Guide

Equivalenced Variables
pTAL Conversion Guide527302-002
12-11
Equivalenced Variable Must Fit Within Previous
Variable
Equivalenced Variable Must Fit Within Previous Variable
The memory referenced by an equivalenced variable—including all fields of an
equivalenced structure and all elements of an equivalenced array—must be contained
entirely within the memory allocated for the previous variable. You can index the
previous variable, but the memory referenced after applying the index must be
contained within the memory allocated for the previous variable. The equivalenced
declarations in Figure 12-2 on page 12-11 are valid in TAL but not in pTAL. The
equivalenced declarations in Figure 12-3 on page 12-12 are valid in TAL and in pTAL.
An equivalenced variable, including all elements of an equivalenced array or
equivalenced structure, must be the same size or smaller than the lowest-level
previous variable, even if an intermediate previous variable is not as long as the
equivalenced variable you are declaring.
The number of bits in an equivalenced variable (including all elements of an array or
structure) must be less than or equal to the number of bits in the previous variable.
Equivalenced variables for which the previous variable is itself an equivalenced
variable, must be contained entirely within the memory allocated for the base previous
variable—the variable for which the compiler allocates memory.
INT .EXT d[0:9]; ! Extended array
INT .EXT e = d; ! OK: e is extended pointer,
! d is extended array
EXTADDR f = d; ! ERROR: cannot equivalence
! simple variable to indirect item
@f := @f + 1; ! ERROR: cannot modify pointer that is
! equivalenced to extended array
Example 12-7. Equivalenced Variable Must Fit Within Previous Variable
FIXED i; ! i is 64 bits
INT j = i; ! OK: j is smaller than i
INT(32) k = j; ! OK: k is 32 bits, i is 64 bits
FIXED i; ! i is 64 bits
INT(32) j[0:1] = i; ! OK: j is 64 bits and coincident with i
INT k[0:1] = i; ! OK: k is 32 bits and contained within i
INT m[0:3] = k; ! OK: m is 64 bits and k is 32 bits,
! but pTAL requires only that m be
! contained within i, not within k
Figure 12-2. Equivalenced Variables That Are Valid in TAL But Not in pTAL
INT r[0:2];
INT(32) s = r[2]; ! ERROR: s is not contained within r
INT t = r[5]; ! ERROR: t is not contained within r
Example 12-6. Equivalencing Extended Pointers to Extended Items (page 2 of 2)