Accelerator Manual (G06.24+, H06.03+)

Setting Accelerator Options
Accelerator Manual527303-002
5-5
Inheritance of Condition Codes
Overflow Checking
Arithmetic overflows are different between TNS and TNS/R systems. Many 16-bit
arithmetic operations that overflow on the 16-bit TNS systems do not overflow on the
32-bit TNS/R systems. The Accelerator option default setting, OvTrap_On, generates
additional code that checks 16-bit arithmetic for overflows that are not automatically
detected by TNS/R systems.
In the following example of 16-bit arithmetic overflow, X is set to 5 at run time.
PROC ovflow;
BEGIN
INT i;
i := 32000;
i := i*x; ! x=5, results in overflow trap on
! TNS systems, but not on TNS/R systems
END; ! if overflow checking is disabled
It is safe to set OvTrap_Off for a program or procedure if:
You use $OVERFLOW to check explicitly for any possible overflow in the
procedure.
You disable traps over an entire procedure or program using:
CODE (RDE; ANRI %577; SETE); ! Disables traps
Refer to the Guardian Programmers Guide for details on writing overflow traps.
OvTrap_Off is primarily intended for processes and procedures that run with traps
disabled, such as some system code, system library, and I/O processes (IOPs).
If you decide to set OvTrap_Off, thoroughly test programs to make sure they do not
rely on 16-bit overflow traps. With OvTrap_Off set, the Accelerator does not
necessarily detect when 16-bit overflows occur, except where programs or procedures
explicitly check for overflows. The Accelerator issues Warning 38 when you might have
incorrectly set OvTrap_Off; it cannot detect all such instances.
Warning 38: The following SETE instructions set the T bit
while OvTrap_Off was selected:
'<proc name>' at offset(s): <address>
The Accelerator issues Warning 38 whether or not the SETE instruction that sets the T
bit disables traps, although such programs most likely rely on overflow traps. In these
cases, you must enable overflow detection with OvTrap_On, since SETE instructions
that enable traps do not enable traps when OvTrap_Off is set. If you decide to set
OvTrap_Off, thoroughly test programs to make sure they do not rely on 16-bit overflow
traps.
Overflow checking does not significantly affect the performance of most programs.