pTAL Conversion Guide

Hardware Indicators
pTAL Conversion Guide527302-002
20-20
Setting $CARRY
Setting $CARRY
You can test $CARRY if the last operator—the root operator—executed on the right
side of an assignment statement is one of the following:
Signed integer add, subtract, or unary minus
Unsigned integer add, subtract, or unary minus
A value parameter:
PROC p(i);
BEGIN
INT i;
i := ...
A pointer:
INT .p;
p := ...
Be an expression that
evaluates to a floating-point
type [REAL or REAL(64)]:
REAL r;
... := r + 1.0E1
An implicit pointer:
INT .p[0:9];
p := ...
Be a constant or constant
expression:
... := 4 + 5;
A variable containing
indexing, field selection,
or bit selection:
INT a[0:99];
STRUCT s;
BEGIN
INT i;
END;
a[9] := ...
a.<0:3> := ...
s.i := ...
Example 20-8. Testing $CARRY
INT i, j, k;
i := j + k; ! $CARRY can be tested after this statement
i := j '+' k; ! $CARRY can be tested after this statement
i := j / 2; ! $CARRY is not set by division
i := -i; ! $CARRY can be tested after this statement
Table 20-3. Setting Condition Codes in Assignment Statements (page 2 of 2)
To test condition codes after an assignment statement:
Left side must be one of: Left side cannot be: Right side cannot: *
* If the expression on the right side of an assignment statement is a function that specifies RETURNSCC, the
restrictions described above on the right side do not apply: you can test the condition code regardless of the data
type of the value returned by the function.
** An INT function that returns a one-byte value is allowed on the right side of the assignment.