pTAL Guidelines for TAL Programmers

Coding Guidelines
pTAL Guidelines for TAL Programmers527256-002
2-19
Comparing Addresses to Addresses
Comparing Addresses to Addresses
Guideline: Use only those relational operators that are defined for pTAL, as described
in this guideline.
In TAL, you can compare two addresses using any relational operator.
In pTAL, you can compare two addresses according to the following rules:
Compare extended addresses (addresses whose data type is EXTADDR) using
only signed relational operators (<, <=, =, <>, >=, >).
Compare nonextended addresses (all address types except EXTADDR) using only
unsigned relational operators ('<', '<=', '=', '<>', '>=', '>'), signed equals (=), and
signed not equals (<>).
The operands to the comparison must be the same address type.
Comparing Addresses to Constants
Guideline: Compare addresses to constants only as described in this guideline.
You might need to compare an address to a constant; for example, to test for a null
value or to test for zero.
You can compare the following address types to an INT constant:
WADDR
SGWADDR
SGXWADDR
BADDR
SGBADDR
SGXBADDR
You can compare an EXTADDR only to an INT(32) constant.
You cannot compare CWADDR, CBADDR, or PROCADDR address types to a
constant value.
Example 2-14. Comparing Addresses to Addresses
WADDR w1, w2;
EXTADDR e1, e2;
IF e1 <> e2 THEN; ! OK
IF w1 '<>' w2 THEN; ! OK
IF w1 = w2 THEN; ! OK
IF e1 '<>' e2 THEN; ! ERROR: EXTADDRs require signed operator
IF w1 '<>' e1 THEN; ! ERROR: Cannot compare WADDR to EXTADDR
IF w1 < w2 THEN; ! ERROR: Unsigned 'less than' required
! with addresses