pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
offset
is an INT constant that specifies a word offset from previous-identifier, which can be
a direct or indirect variable. If previous-identifier is indirect, the offset is from the
location of the pointer, not from the location of the data pointed to.
The following are valid equivalenced declarations:
INT a;
INT b = a;
INT(32) c[0:3];
INT d[0:7] = c;
Topics:
• Memory Usage for Nonstructured Equivalenced Variables (page 181)
• Equivalenced Arrays (page 181)
• Indirect Arrays (page 182)
• Equivalenced Simple Variables (page 182)
• Equivalenced Simple Pointers (page 183)
Memory Usage for Nonstructured Equivalenced Variables
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.
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 the equivalenced variable you are declaring:
INT h;
FIXED i;
INT j = i; ! OK: j is smaller than I
INT(32) k = j; ! OK: k is 32 bits, i is 64 bits
FIXED l = h; ! ERROR: l > h
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 previous variable for which the compiler allocates memory.
Example 124 Memory Usage for Nonstructured Equivalenced Variables
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: Although m is 64 bits and k is
! 32 bits, pTAL requires only that
! m be contained within i, not k.
INT x[0:15];
FIXED y = x[10]; ! ERROR: y does not fit entirely within x
Equivalenced Arrays
Use the lower-bnd1 and upper-bnd2 parameters as shown in the nonstructure declaration
syntax.
Declaring Nonstructure Equivalenced Variables 181