pTAL Conversion Guide

Equivalenced Variables
pTAL Conversion Guide527302-002
12-9
Equivalencing Standard Pointers to Indirect Items
Table 12-1 on page 12-10 identifies all valid equivalenced declarations. The semantics
in Table 12-1 on page 12-10 are clarified and additional requirements are specified in
the topics that follow the table.
Equivalencing Standard Pointers to Indirect Items
You can equivalence a standard pointer to an indirect array or indirect structure but you
cannot equivalence an indirect array or indirect structure to a standard pointer. A
pointer equivalenced to an indirect item is a read-only pointer—you can read the
address in the pointer, but you cannot store an address into the pointer.
Example 12-4. Valid and Invalid Equivalenced Declarations
WADDR a; ! a is 16 bits on TNS architecture,
! 32 bits on native architecture
INT .EXT b; ! b is 16 bits on TNS architecture,
! 32 bits on native architecture
INT c = a; ! OK: bits in c are <= bits in a
! on TNS and native architectures
WADDR d = b; ! OK: bits in d are <= bits in b
! on TNS and native architectures
BADDR e = a; ! OK: bits in e and a are same:
! 16 bits on TNS and native architectures
! Values are compatible
! on native architectures,
! but not on TNS architecture
EXTADDR f = d; ! ERROR: On TNS architecture,
! number of bits in f (32) is greater than
! number of bits in d (16)
Example 12-5. Equivalencing Standard Pointers to Indirect Items
INT .a[0:3]; ! Indirect array
INT .b; ! Standard pointer
INT .c = a; ! OK: equivalence pointer to indirect array
! (c is read-only)
INT .d[0:3] = b; ! ERROR: cannot equivalence an indirect item
! to a pointer
@c := @c + 1; ! ERROR: cannot modify a pointer that is
! equivalenced to an indirect item