TAL Programmer's Guide
CRE Guidelines for TAL
Mixed-Language Programming
096254 Tandem Computers Incorporated 17–49
Handling Errors in
CRE Math Routines
The CRE provides libraries of math routines, such as sine and cosine routines, that
your program can call.
When a CRE math routine receives an invalid parameter or produces an invalid result,
an arithmetic fault occurs when control returns to the caller. The caller’s run-time
library (except TAL) determines the program’s behavior.
A TAL caller can determine the effect of the error by setting or resetting the trap-
enable bit of the environment register. You should ensure that the trap-enable bit is
appropriately set before your program calls a CRE math routine.
If traps are disabled when a CRE math routine detects an error, the system returns
control to the caller:
REAL r, s;
r := -1.0E0;
CALL disable_overflow_traps; !A user-written routine that
s := RTL_SQRT_REAL32_(r); ! disables overflow traps
IF $OVERFLOW THEN !Control returns here; test
BEGIN ! error in RTL_SQRT_REAL32_.
CALL enable_overflow_traps; !Enable overflow traps
!Lots of code
END;
CALL enable_overflow_traps; !Enable overflow traps
If traps are enabled when a CRE math routine detects an error, the system returns
control to the current trap handler:
REAL r, s;
r := -1.0E0;
CALL enable_overflow_traps; !A user-written routine that
s := RTL_SQRT_REAL32_(r); ! enables overflow traps
IF $OVERFLOW THEN !If RTL_SQRT_REAL32_ causes
BEGIN ! overflow, the program does
!Lots of code! ! not reach this statement
END; ! because control transfers
! to the current trap handler
The Extended Stack The CRE supports the extended stack, which defines the following data blocks:
$EXTENDED#STACK
EXTENDED#STACK#POINTERS
These data blocks are described in Section 4, “Introducing the Environment.”