HP Pascal/iX Programmer's Guide (31502-90023)

11- 17
END; {divide by zero}
END; {IEEE_trap_handler}
{user main program}
VAR
l1, l2, l3 : longreal;
oldmask,
oldplabel : integer;
BEGIN {main program}
ARITRAP (1); {see "ARITRAP and HPENBLTRAP Intrinsics" for details}
XARITRAP (IEEE_mask, BAddress (IEEE_trap_handler), oldmask, oldplabel);
l1 := 233.0;
l2 := 0.0;
l3 := l1/l2; {oops! divide by zero!}
writeln (l3); {the trap handler should have fixed the result of the
previous operation to maxlongreal (1.79769e+308)}
END. {main program}
XCONTRAP Intrinsic
The MPE intrinsic XCONTRAP specifies a user-defined routine (Subsystem
Break Handler) that will be called when the user enters a subsystem break
(CONTROL Y) on the keyboard. When XCONTRAP is enabled and the user
enters CONTROL Y:
* Program control is transferred to the specified user-defined
routine.
* The subsystem break function is temporarily disabled to reduce the
chance of race conditions.
If normal program execution is to resume after the interrupt, the
user-defined routine must re-enable the subsystem break by calling the
intrinsic RESETCONTROL just before it ends. On MPE/iX, a normal exit
from the user-defined routine is sufficient to return control to the
point in the program where the subsystem break was trapped.
Syntax
To arm your Subsystem Break Handler, call XCONTRAP this way:
XCONTRAP (
plabel, oldplabel
);
Call RESETCONTROL this way:
RESETCONTROL;
Declare XCONTRAP and RESETCONTROL this way:
PROCEDURE XCONTRAP; INTRINSIC;
PROCEDURE RESETCONTROL; INTRINSIC;
Parameters
oldplabel
A 32-bit integer, passed by reference, in which the old
value of
plabel
is returned. If the subsystem break
handler is not armed, this value is zero.
plabel
A 32-bit integer, passed by value, which is the address of
your Subsystem Break Handler.
Example
The main program is a loop. Whenever the user enters CONTROL Y on the