pTAL Conversion Guide

Expressions
pTAL Conversion Guide527302-002
13-7
Comparing Nonextended Addresses
Comparing Nonextended Addresses
The following rules apply when you compare nonextended addresses:
Use unsigned comparison operators ( '<', '=', '>', '<=', '<>', '>='), a signed equality
operator (=), or a signed inequality operator (<>) to compare nonextended
addresses. The signed and unsigned equality operators produce the same results.
Similarly, the signed and unsigned inequality operators produce the same results.
Do not compare nonextended addresses using signed operators that test for
greater than or less than (<, <=, >, >=).
These comparisons are valid:
INT .p, .q;
IF @p = 0 THEN ...
IF @p <> 0 THEN ...
IF @p = @q THEN ...
Both operands must be the same address type:
STRING .s;
BADDR .b;
IF @s = b THEN ... ! OK: @s is BADDR, b is BADDR
IF @s = @b THEN ... ! ERROR: @s is BADDR, @b is WADDR
If one operand of a relational operator is a nonextended address and the other is a
constant, the constant must be 16 bits in length:
INT .p;
IF @p = 100 THEN ... ! OK
IF @p = 100D THEN ... ! ERROR
Example 13-5. Comparing Extended Addresses
EXTADDR e;
INT .EXT i;
IF e < @i THEN ... ! OK: e and @i are both EXTADDR
IF @i >= 0D THEN ... ! OK: @i is EXTADDR, 0D is 32 bits
IF e = 0D THEN ... ! OK
IF e <> 0D THEN ... ! OK
IF e THEN ... ! OK
IF NOT e THEN ... ! OK
IF e > i THEN ... ! ERROR: e is EXTADDR, i is INT
IF e '<' @i THEN ... ! ERROR: Unsigned operators are invalid
! with EXTADDRs