pTAL Conversion Guide

Pointers
pTAL Conversion Guide527302-002
10-36
Pointers That Have Different Widths on TNS and
Native Architectures
pTAL
On native architecture, every pointer holds a 32-bit byte address.
pTAL preserves the TAL semantics of standard pointers by:
Converting 16-bit pointers to 32 bits
Using address types to control the addresses you store into pointers
Adjusting operations on addresses to compensate for the differences between how
you address memory on TNS and native architectures
pTAL adjusts addresses to compensate for the different addressing characteristics of
TNS and native architectures.
pTAL adjusts operations on word addresses to use the byte address required by native
architecture.
INT .p := %H100 ! @p := %H200;
%H100, a word address on TNS architecture, must be converted to a byte address
on native architecture. pTAL multiplies the word address by 2 to produce the
equivalent byte address.
STRING .sp := @p '<<' 1; ! @sp := %H200;
A byte address on TNS architecture is the same as a byte address on native
architecture. The address in p is already a byte address as a result of the previous
statement and can be moved to sp without shifting it.
@p := @p '+' 1; ! @p := %H202;
Adding 1 to a word address, p, on TNS architecture requires adding 2 to that word
address on native architecture because the address in p is maintained as a byte
address on native architecture.
Example 10-16. Pointers That Have Different Widths on TNS and Native
Architectures (pTAL)
INT .p := %H100; ! Declare p and store %H200 in it
STRING .sp := @p '<<' 1; ! Declare sp and store %H200 in it
INT .EXT e; ! Declare e
@p := @p '+' 1; ! Increment @p from %H200 to %H202
@sp := @sp '+' 2; ! Increment @sp from %H200 to %H202
@p := @p[3]; ! Increment @p from %H202 to %H208
@sp := @sp[3]; ! Increment @sp from %H202 to %H205
@e := $UDBL(@p) '<<' 1; ! Assign %H208 to @e
Note. The following explanations are subject to change. Your program must not depend on
the specific implementation described.