pTAL Conversion Guide

Statements
pTAL Conversion Guide527302-002
15-5
Address Types Must Match
In TAL and pTAL, when an INT variable is assigned to a STRING variable, the upper
eight bits of the INT variable are not retained in any way in the STRING variable. In
Example 15-4 on page 15-5, the comparison of i1 to i2 in the final statement fails
because i2 still holds the full 16 bits that were assigned to it at the beginning of the
code, but i1 holds only the lower eight bits. The upper eight bits of i1 are not
transferred to s in the assignment statement s := i1.
As in TAL, use type-transfer routines to convert between data types. For differences
between TAL standard routines and pTAL built-in routines, see Section 17, TAL
Standard Routines.
Address Types Must Match
Topics:
TAL on page 15-5
pTAL on page 15-6
TAL
You can assign any value to a pointer as long as the number of bits in the value is the
same as the number of bits in the pointer. You must ensure that the value you assign
to a pointer is formatted correctly for the data the pointer will reference.
All pointers are located in the user data segment. The data referenced by pointers can
be in the user data segment or in an extended data segment, usually the automatic
extended data segment allocated by the TAL compiler. Addresses and pointers are
either 16 bits or 32 bits.
Example 15-4. Assigning INT to STRING and the Reverse
INT i1 := %HFFFF,
i2;
STRING s;
i2 := i1;
s := i1; ! Assign 16-bit INT to 8-bit STRING
i1 := s; ! Assign 8-bit STRING to 16-bit INT
IF i1 = i2 THEN; ! i1 (%HFF) is not equal to i2 (%HFFFF)
Example 15-5. Pointer Assignments (TAL) (page1of2)
INT i; ! Simple variable in data stack
INT .EXT j; ! Extended pointer
INT .p; ! Standard pointer to data in data stack
INT .EXT r; ! Extended pointer
INT(32) s; ! 32-bit simple variable in data stack