Object Code Accelerator Manual

Preparing Your Program for TNS/E Systems
Object Code Accelerator Manual528144-003
2-2
Checking Segment Limits
Detection Guideline
Examine source code that explicitly disables overflow traps to make sure it tests for
arithmetic overflow with the $OVERFLOW function. Also look for user written trap
handlers that return after an overflow. It is good coding practice always to test for
overflow, not just after multiplication and division operations.
Required Changes
Programs that expect multiplication or division operations to overflow must
explicitly test for overflow and establish the desired overflow answer. Programs can
test for overflow by:
Using the TAL $OVERFLOW function or the COBOL85 ONSIZE error clause
immediately after the arithmetic statement that might overflow
Examining the bits of the operands
Refer to the Guardian Programmers Guide for information on writing overflow
traps handlers.
Example
The following TAL code explicitly tests for overflow.
FIXED(0) count, time, result;
CODE (RDE; ANRI %577; SETE); ! Disable overflow traps
result := count * time;
IF $OVERFLOW THEN ! Test immediately for overflow
result := 0D; ! Fix the overflow result
Checking Segment Limits
Erroneous programs which access memory beyond the logical end of a memory
segment may fail differently and at different moments on TNS, TNS/R, and TNS/E
systems, due to differences in memory page sizes. A segment's requested logical size,
in bytes, is rounded up to a whole number of pages, where the page size depends on
the host machine and NSK software release. Memory pages are 2Kbytes each on TNS
CISC systems, 4K or 16Kbytes on TNS/R systems, and 16K or 64Kbytes each on
TNS/E systems. Erroneous program references beyond the requested logical end of
the segment, but before the actual end of that last memory page, will go undetected.
As a result of these differences, addressing past the logical end of segments may fail
later or not at all depending on the system. You can notice this difference when
debugging addressing errors.
Detection Guidelines
Addressing errors are reported as "illegal address reference" traps which are
generally fatal. Earlier machines are stricter than newer machines and trap out on