TAL Programmer's Guide

Testing Hardware Indicators
Using Expressions
5–26 096254 Tandem Computers Incorporated
Carry Indicator The carry indicator is bit 9 in the environment register (ENV.K). The carry indicator is
affected as follows:
Operation Carry Indicator
Integer addition On if carry out of bit <0>
Integer subtraction or negation On if no borrow out from bit <0>
INT(32) multiplication and division Always off
Multiplication and division except INT(32) Preserved
SCAN or RSCAN operation On if scan stops on a 0 (zero) byte
Array indexing and extended structure addressing Undefined
Shift operations Preserved
To check the state of the carry indicator, use $CARRY in an IF statement immediately
after the operation that affects the carry bit. If the carry indicator is on, $CARRY is –1
(true). If the carry indicator is off, $CARRY is 0 (false). The following example tests
the state of the carry indicator after addition:
INT i, j, k; !Declare variable
i := j + k;
IF $CARRY THEN ... ; !Test state of carry bit from +
The following operations are not portable to future software platforms:
Testing $CARRY after multiplication or division
Passing the carry bit as an implicit parameter into a procedure or subprocedure
Returning the carry bit as an implicit result from a procedure or subprocedure
Overflow Indicator The overflow indicator is bit 8 in the environment register (ENV.V). The overflow
indicator is affected as follows:
Operation Overflow Indicator
Unsigned INT addition, subtraction, and negation Preserved
Addition, subtraction, and negation except unsigned INT On or off
Division and multiplication On or off
Type conversions On, off, or preserved
Array indexing and extended structure addressing Undefined
Assignment or shift operation Preserved
For example, the following operations turn on the overflow indicator (and interrupt
the system overflow trap handler if the overflow trap is armed through ENV.T):
Division by 0
Floating-point arithmetic result in which the exponent is too large or too small
Signed arithmetic result that exceeds the number of bits allowed by the data type
of the expression
For overflowed integer addition, subtraction, or negation, the result is truncated. For
overflowed multiplication, division, or floating-point operation, the result is
undefined.