pTAL Conversion Guide

Pointers
pTAL Conversion Guide527302-002
10-23
Converting Between Address Types
$WADDR_TO_BADDR(x)
$WADDR_TO_EXTADDR(x)
These routines are described in Section 17, TAL Standard Routines.
The $DBL and $INT routines accept address arguments.
$DBL accepts an EXTADDR address as an argument and converts it to a 32-bit
integer.
$INT accepts a variable whose data type is any of SGBADDR, SGWADDR,
SGXBADDR, and SGXWADDR as an argument, and returns a 16-bit integer. No other
address types can be used as an argument to $INT.
For more information about $DBL and $INT see Section 17, TAL Standard Routines.
Low-Level Address Conversions Using Arithmetic
Operations
You can convert between address types using shift operations and low-level routines.
These conversions are supported in pTAL for compatibility with TAL programs. Use the
equivalent pTAL routine when you write new pTAL code.
Table 10-7 on page 10-23 shows all low-level conversions as well as the equivalent
built-in routines. For example, in the first three conversions, you can use only a logical
shift, you must shift by exactly one bit, and you must use a left shift for a word-oriented
address to a byte-oriented address, and a right shift for a byte-oriented address to a
word-oriented address.
The following examples show valid and invalid shifts of addresses:
Table 10-7. Low-Level Conversions Between Address Types
Expression Type of Operand Built-In Routine
e ‘<<‘ 1
e ‘<<‘ 1
e ‘<<‘ 1
WADDR
SGWADDR
SGXWADDR
$WADDR_TO_BADDR(e)
$SGWADDR_TO_SGBADDR(e)
$SGWADDR_TO_SGBADDR(e)
e ‘>>‘ 1
e ‘>>‘ 1
e ‘>>‘ 1
BADDR
SGBADDR
SGXBADDR
$BADDR_TO_WADDR(e)
$SGBADDR_TO_SGWADDR(e)
$SGBADDR_TO_SGWADDR(e)
$UDBL(e)
$DBLL(0,e)
BADDR
BADDR
$BADDR_TO_EXTADDR(e)
$BADDR_TO_EXTADDR(e)
$UDBL(e) ‘<<‘ 1
$DBLL(0,e) ‘<<‘ 1
WADDR
WADDR
$WADDR_TO_EXTADDR(e)
$WADDR_TO_EXTADDR(e)