pTAL Conversion Guide

Statements
pTAL Conversion Guide527302-002
15-6
Address Types Must Match
You can remove the semantic errors in the last two statements in Example 15-5 on
page 15-5 by using the $LADR and $XADR routines. TAL compiles these statements
without errors:
@p := $LADR(j); ! Convert 32-bit address of j to 16-bit address
@r := $XADR(i); ! Convert 16-bit address of i to 32-bit address
TAL compiles the first statement, but the statement executes correctly only if j is the
address of a data item in the user data segment. In all other cases, the conversion fails
at run time because $LADR discards the upper half of the pointer j, which holds the
segment number.
TAL compiles and executes the second statement (@r := $XADR(I)) correctly
because TAL can convert a 16-bit address in the user data segment to an equivalent
extended address.
pTAL
The values you store into pointers are more controlled than in TAL.
The result of applying an @ operator to a variable or pointer does not produce a value
of type INT or INT(32) as it does in TAL. Instead, the result is an address whose data
type is one of the pTAL address types.
In an assignment statement, one of the following must be true:
Both operands are the same address type.
Neither operand is an address type.
You can use type-conversion standard routines to convert some address types to other
address types. See Section 17, TAL Standard Routines, for more information on type-
conversion standard routines. See Section 13, Expressions, for more information on
converting addresses. See Section 10, Pointers, for more information about address
types.
pTAL does not support the $LADR routine.
@p := @i; ! OK: 16-bit address to 16-bit pointer
@p := i; ! OK: 16-bit value to 16-bit pointer
@r := @j; ! OK: 32-bit address to 32-bit pointer
@r := s; ! OK: 32-bit value to 32-bit pointer
@p := @j; ! ERROR: 32-bit address to 16-bit pointer
@r := @i; ! ERROR: 16-bit address to 32-bit pointer
Example 15-5. Pointer Assignments (TAL) (page2of2)