pTAL Reference Manual (H06.03+)
Data Representation
HP pTAL Reference Manual—523746-005
3-10
Incrementing and Decrementing Addresses
(Stepping Pointers)
Incrementing and Decrementing Addresses (Stepping Pointers)
You can increment or decrement the value of a pointer (step a pointer) by:
•
Using Arithmetic Operations to Adjust Addresses on page 3-10
•
Computing the Number of Bytes Between Addresses on page 3-11
•
Comparing Addresses to Addresses on page 3-11
•
Comparing Addresses to Constants on page 3-11
•
Comparing PROCADDRs and PROCPTRs on page 3-11
•
Testing a Pointer for a Nonzero Value on page 3-12
Using Arithmetic Operations to Adjust Addresses
You can add an integer value to any address type except PROCADDR. The address
can be on either side of the operator.
You can subtract an integer value from any address type except PROCADDR. The
address must be on the left side of the subtraction operator and the integer must be on
the right.
You must use signed operators for operations on EXTADDRs and unsigned operators
for all other address types.
Example 3-3. 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];
Example 3-4. 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
Example 3-5. Signed and Unsigned Operators in Address Arithmetic
INT .p;
INT .EXT e;
@p := @p '-' 4; ! Unsigned arithmetic on WADDRs
@p := 4 '+' @p; ! Unsigned arithmetic on WADDRs
@e := @e + 8D; ! Signed arithmetic on EXTADDRs










