TAL Reference Manual
Compiler Directives
TAL Reference Manual—526371-001
16-15
Example of ASSERTION Directive
1. Place an ASSERTION directive in the source code where you want to start
debugging. In the directive, specify an assertion-level and an error-handling
procedure such as the D-series PROCESS_DEBUG_ or the C-series DEBUG
procedure:
?ASSERTION 5, PROCESS_DEBUG_ !Assertion-level is 5
2. Place an ASSERT statement at the point where you want to invoke the error-
handling procedure when some condition occurs. In the ASSERT statement,
specify an assert-level that is equal to or higher than the assertion-level and
specify an expression that tests a condition. For example, the standard function
$CARRY returns true if the carry indicator is on and false if it is off:
ASSERT 10 : $CARRY; !Assert-level is 10
3. During program execution, if an ASSERT statement assert-level is equal to or
higher than the current ASSERTION directive assertion-level and the associated
condition is true, the compiler invokes the error-handling procedure.
4. After you debug the program, you can nullify all or some of the ASSERT
statements by specifying an ASSERTION directive with an assertion-level that is
higher than the highest ASSERT statement assert-level you want to nullify:
?ASSERTION 11, PROCESS_DEBUG_ !Assertion-level nullifies
! assert-level 10 and below
Example of ASSERTION Directive
This example invokes PROCESS_DEBUG_ whenever a carry or overflow condition
occurs:
?SOURCE $SYSTEM.SYSTEM.EXTDECS (PROCESS_DEBUG_)
?ASSERTION 5, PROCESS_DEBUG_
!Assertion-level 5 activates all ASSERT conditions
SCAN array WHILE " " -> @pointer;
ASSERT 10 : $CARRY;
!Lots of code
ASSERT 10 : $CARRY;
!More code
ASSERT 20 : $OVERFLOW;
!$OVERFLOW function tests for arithmetic overflow
If you change the assertion-level in the ASSERTION directive to 15, you nullify the two
ASSERT statements that specify
assert-level 10 and the $CARRY condition.