pTAL Guidelines for TAL Programmers

Differences Between TAL and pTAL
pTAL Guidelines for TAL Programmers527256-002
3-26
ENABLE_OVERFLOW_TRAPS Block Attribute
When to Use Overflow Trap Attributes
A TAL program can enable or disable overflow traps only using block-level attributes.
Each time you enter or exit a block that specifies a block-level trapping attribute, your
program executes a small number of TNS machine instructions that set or reset a
hardware bit to enable or disable overflow traps. The TAL compiler does not generate
machine code for procedure or subprocedure attributes.
A pTAL program compiled to native instructions can enable or disable overflow traps
using directives, procedure/subprocedure attributes, or block-level attributes. Overflow
conditions are detected only by code generated by the native compiler, not by
information in a hardware register.
If you can ensure that a procedure or subprocedure always has the overflow trapping
state of its callers, you can use procedure attributes to specify the trapping state of the
procedure. A pTAL program running as a TNS process behaves correctly because the
procedure inherits the overflow trapping state of its caller. A pTAL program running as
native process behaves correctly because the procedure or subprocedure specifies the
desired trapping attribute.
In Example 3-17 on page 3-26, procedure p is called only by procedure q, which
specifies the trapping state using block-level attributes; therefore, you can specify the
trapping state of p using a procedure attribute.
In some situations, you cannot ensure the trapping state of a procedure or
subprocedure—for example, if it is called from multiple procedures, some of which
enable overflow traps and others of which disable overflow traps. You can, however,
ensure that the trapping behavior of the called procedure or subprocedure is
independent of its callers by using the ENABLE_OVERFLOW_TRAPS or
DISABLE_OVERFLOW_TRAPS block-level attributes. For both TNS and native
processes, the block-level attributes establish the trapping state of a block, regardless
of the trapping state of a procedure’s or subprocedure’s caller or of the code
surrounding a BEGIN-END block, as in Example 3-18 on page 3-27.
Example 3-17. NOOVERFLOW_TRAPS With DISABLE_OVERFLOW_TRAPS
PROC p(i, j) NOOVERFLOW_TRAPS;
INT i, j;
BEGIN
...
END;
PROC q;
BEGIN: DISABLE_OVERFLOW_TRAPS
...
CALL p(1, 2);
END;