pTAL Conversion Guide

Hardware Indicators
pTAL Conversion Guide527302-002
20-2
Managing Overflow Traps in TAL
OVERFLOW_TRAPS Procedure Attribute on page 20-5
ENABLE_OVERFLOW_TRAPS Block Attribute on page 20-6
Running Programs With Overflow Traps Disabled on page 20-8
Comparing Overflow Trapping in Native Processes on page 20-8
Managing Overflow Traps in TAL
TNS processes check for and can report overflow during certain arithmetic operations.
In addition, they also report overflow if a process attempts to divide a number by 0.
The following bits in the TNS environment register pertain to overflow conditions in
TNS processes:
The T bit (trap-enable bit = bit 8), which programs set to enable traps, and reset to
disable traps
The V bit (overflow bit = bit 10), which the process sets or resets following certain
TNS instructions to indicate whether overflow occurred during instruction execution
Topics:
Handling Overflow and Traps Within TAL Procedures on page 20-2
Handling Overflow and Traps Across TAL Procedures on page 20-3
Handling Overflow and Traps Within TAL Procedures
The following actions take place when overflow occurs while a TNS process is
executing an instruction:
The process sets the V bit in the TNS environment register.
If the T bit is set, the process traps to the current trap handler, as follows:
°
If the process has established a trap handler (by calling the ARMTRAP
operating system routine), the process traps to the process’s trap handler.
°
If the process has not established a trap handler, the process traps to the
system trap handler.
If the T bit is not set, the process continues executing with the V bit set. The
program must check $OVERFLOW to determine if overflow occurred.
A TAL program, therefore, can perform the following actions that relate to traps:
Enable or disable traps by using TAL CODE statements to set or reset the T bit
If traps are disabled, check explicitly for overflow (by testing $OVERFLOW) after all
statements that could cause overflow
If traps are enabled, provide (optionally) a trap handler to process traps when they
occur