pTAL Conversion Guide

Hardware Indicators
pTAL Conversion Guide527302-002
20-14
Setting Hardware Indicators
If you want to ensure that overflow is detected on a particular operation by TNS and
native processes, you must write your code so that if overflow occurs, it occurs during
execution of the root operator—the last operator executed—on the right side of the
assignment statement, as in Example 20-6 on page 20-14.
Setting Hardware Indicators
Many TNS instructions alter the values of the hardware indicators. Accordingly, many
TAL statements alter the values of the hardware indicators. The meaning of the
hardware indicators, however, especially the condition code, can be difficult to
determine because they are affected by:
When you test the indicator relative to the statement that alters the indicator
In which portion of TNS memory the variable is stored
The components of the expression or statement that sets the indicator
Native architecture does not have the hardware indicators that are on TNS
architecture. The object code generated by the native compiler, therefore, implements
much the same capability as TNS hardware indicators provide for TAL programs.
In pTAL, the following constructs can set the hardware indicators:
Assignment statements
SCAN and RSCAN statements
IF statements
RETURN statements
Built-in routines
Topics:
Setting Hardware Indicators in TAL on page 20-15
Setting $CARRY on page 20-20
Setting $OVERFLOW on page 20-21
Example 20-6. Ensuring That Overflow is Detected
PROC p;
BEGIN
INT a := 32767;
INT b := 1000;
a := a + 1; ! Overflow is detected by TNS
IF NOT $OVERFLOW THEN ! and native processes for
a := a - b ! both arithmetic operations
ELSE
... ! Handle overflow
END;