pTAL Conversion Guide

Hardware Indicators
pTAL Conversion Guide527302-002
20-26
Testing Condition Codes After Comparing Addresses
Testing Condition Codes After Comparing
Addresses
An IF statement’s THEN or ELSE clause cannot, in turn, test the condition code
established by the outer IF statement’s conditional expression if the outer IF
statement’s conditional expression uses signed operators (= or <>) to compare two 16-
bit, nonEXTADDR addresses, as in Example 20-16 on page 20-26.
You cannot test $CARRY or $OVERFLOW to determine if a carry or overflow occurred
while evaluating an IF statement’s conditional expression:
IF i + 1 < 100 THEN
BEGIN
IF $CARRY THEN ... ! ERROR: invalid to test $CARRY here
END
...
You can test $CARRY or $OVERFLOW by evaluating, in a separate assignment
statement, the expression in which carry or overflow could occur, and then test
$CARRY or $OVERFLOW:
INT temp;
temp := i + 1;
IF NOT $CARRY THEN
BEGIN
IF temp < 100 THEN ...
END
ELSE ! Handle $CARRY condition
Example 20-16. Testing Condition Codes After Comparing Addresses
WADDR w1, w2;
EXTADDR e1, e2;
IF e1 <> e2 THEN ! Compare two EXTADDR values
BEGIN
IF < THEN... ! OK: e1 and e2 are EXTADDR values
END;
IF w1 '<>' w2 THEN ! Compare two WADDRs with unsigned
BEGIN ! operator
IF < THEN ... ! OK: Original test is unsigned compare
END;
IF w1 <> w2 THEN ! Compare two WADDRs with signed operator
BEGIN !
IF < THEN ... ! ERROR: cannot test condition code set by
END; ! signed comparison of nonEXTADDR addresses