pTAL Conversion Guide

Pointers
pTAL Conversion Guide527302-002
10-19
Converting Between Addresses and Numbers
Numeric Conversions With SGBADDR, SGWADDR,
SGXBADDR, and SGXWADDR Addresses
You can move any 16-bit integer value—a constant or variable—into any of the four
system global address types: SGBADDR, SGWADDR, SGXBADDR, and
SGXWADDR. Conversely, you can move the value of any of the system global data
types into a 16-bit integer.
Example 10-4. Numeric Conversions With BADDR and WADDR Addresses
(pTAL)
Invalid:
INT i;
INT .j;
STRING .s;
i := @j; ! ERROR: Cannot move WADDR (@j) to INT (i)
i := @s; ! ERROR: Cannot move BADDR (@s) to INT (i)
@j := i; ! ERROR: Cannot move variable INT (i) to WADDR (@j)
@s := i; ! ERROR: Cannot move variable INT (i) to BADDR (@s)
i := @p; ! ERROR: Cannot convert address to INT
Valid:
DEFINE nil = 0#;
STRUCT s(*);
BEGIN
WADDR next;
END;
INT i;
INT .p;
INT .p2(s);
@p := nil; ! Assign program-defined nil value to p
@p2 := %H8000; ! Assign to p2 the address of what would be the
! first word in upper 32K words
! of TNS user data segment
Example 10-5. Numeric Conversions With System Global Addresses
(pTAL) (page1of2)
STRING .str1;
INT i;
INT .SG sg1;
STRING .SGX str2;
SGBADDR .SG sg2;