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

Using Arithmetic Operations to Adjust Addresses
You can add an integer value to any address type except PROCADDR, PROC32ADDR, and
PROC64ADDR. The address can be on either side of the operator.
Example 7 Adding Integer Values to Addresses
INT .p;
@p := @p '+' 4; ! Increment WADDR pointer by four 16-bit words
@p := 4 '+' @p; ! Increment WADDR pointer by four 16-bit words
@p := @p[2];
You can subtract an integer value from any address type except PROCADDR, PROC32ADDR, and
PROC64ADDR. The address must be on the left side of the subtraction operator and the integer
must be on the right.
Example 8 Subtracting Integer Values From Addresses
INT .p;
@p := @p '-' 4; ! Decrement WADDR pointer by four 16-bit words
@p := 4 '-' @p; ! ERROR: The address must be on the right,
! the integer on the left
You must use signed operators for operations on EXTADDRs and unsigned operators for all other
address types.
Example 9 Signed and Unsigned Operators in Address Arithmetic
INT .p;
INT .EXT e;
INT .EXT32 e32;
INT .EXT64 e64;
@p := @p '-' 4; ! Unsigned arithmetic on WADDRs
@p := 4 '+' @p; ! Unsigned arithmetic on WADDRs
@e := @e + 4D; ! Signed arithmetic on EXTADDRs
@e32 := @e32 + 4D; ! Signed arithmetic on EXT32ADDRs
@e64 := @e64 + 8F; ! Signed arithmetic on EXT32ADDRs
If you increment or decrement a pointer, the number that you add to, or subtract from, a byte
address (such as BADDR) is the number of bytes to move the pointer. Similarly, the number that
you add to a word address (such as WADDR) is the number of 16-bit words to move the pointer,
not the number of 32-bit words.
If you step a byte address (such as BADDR), the number you specify is added to, or subtracted
from, the address in the pointer.
If you step a word address (such as WADDR), the address is incremented decremented by twice
the number you specify, because addresses on TNS/R and TNS/E architecture are represented
as byte addresses.
Computing the Number of Bytes Between Addresses
You can subtract two addresses except PROCADDR, PROC32ADDR, and PROC64ADDR addresses.
The address types of both operands must be the same except that SGBADDR and SGXBADDR are
interchangeable, and SGWADDR and SGXWADDR are interchangeable.
NOTE: The address types, EXT32ADDR, EXT64ADDR, PROC32ADDR, and PROC64ADDR are
available in the 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).
Address Types 55