pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

1
64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information,
see Appendix E, “64-bit Addressing Functionality” (page 531).
You can index a variable that participates in an equivalenced declaration either as the equivalenced
variable or as the previous variable even if none of the variables in the equivalenced group specify
array bounds.
Example 122 Declaring Equivalenced Variables
INT a; ! a is a simple variable, and cannot be indexed
INT b; ! "Previous variable" for the next decl
INT c = b; ! b and c can be indexed
INT d = c; ! c and d can be indexed
! Variables b, c, and d can be indexed because each appears in
! an equivalenced declaration:
c[2] := b[1]; ! OK: b and c appear in equivalenced declaration
d[2] := c[1]; ! OK: c and d appear in equivalenced declaration
d[2] := a; ! OK: d appears in equivalenced declaration
! and can be indexed.
a[1] := d; ! ERROR: a cannot be indexed
Memory Allocation
pTAL does not allocate memory for equivalenced variables. In the following example, pTAL allocates
memory only for base_previous:
INT base_previous;
INT equivalenced1 = base_previous;
INT equivalenced2 = equivalenced1;
An equivalenced variable is an alias for memory allocated for a previously declared variable. The
equivalenced declaration can specify different attributes; for example, a different data type than
those of the previous variable. In the following example, pTAL allocates 32 bits for i. The
equivalenced declaration for j references the memory allocated for i, but specifies that the bits
be treated as a REAL number:
INT(32) i;
REAL j = i;
If an equivalenced variable is a standard or extended pointer and the previous variable is the
implicit pointer of an indirect array or indirect structure, the equivalenced variable is a read-only
pointer. You can use the value of the pointer in an expression, but you cannot store an address or
other value into the pointer because doing so would be the same as storing an address into the
implicit pointer of the array or structure. You can, however, use a pointer to read or write the data
to which the pointer points.
Example 123 Equivalenced Pointers
INT .a[0:3];
INT .p = a;
WADDR w;
PROC p1;
BEGIN
a[1] := a[1] + 1; ! Increment second word of a
p[1] := p[1] + 1; ! Increment second word of p (= a)
w := @a; ! Assign address of first word of a to w
w := @p; ! Assign address of first word of p (= a)
! to w
END;
PROC p2;
BEGIN
@p := w; ! ERROR: Cannot assign to an equivalenced pointer
! when it is equivalenced to an indirect or
Memory Allocation 179