pTAL Conversion Guide

Pointers
pTAL Conversion Guide527302-002
10-34
Using Addresses in Expressions
Using pointer arithmetic described in the preceding topics, you can rewrite the
expression in Figure 10-4 on page 10-33 so that it is valid in pTAL. Figure 10-5 on
page 10-34 shows how you can create an expression with valid operations on
addresses. BASE0 is a WADDR value equal to zero. Subtracting BASE0 from @x
produces a 16-bit INT for which addition, multiplication, and division are defined.
Adding the result of the expression inside the parentheses to BASE0 produces a
WADDR value, which you can assign to @x.
Using Addresses in Expressions
TAL
You can use an address in an expression wherever an operand of the address
type—INT or INT(32)—is valid.
You can use built-in routines such as $INT and $UDBL to convert an address to
the required length.
You can assign the value of an arithmetic expression to a pointer.
The value you assign must be a 32-bit integer for an extended pointer and a 16-bit
integer for any other pointer.
Example 10-15 on page 10-35 declares pointer p, uses p’s value in an expression, and
assigns the resultant 16-bit value to p.
Figure 10-5. A Valid Arithmetic Expression in pTAL
INT .x;
WADDR base0 := 0;
@x := base0 ‘+’ (((@x + base0) + 3) / 4 * 4;
WADDR
WADDR
WADDR
INT
INT
INT
WADDR
WADDR
INT
INT
INT
INT
VST033.vsd