62
K
A
DAK
Interrupt Service Procedures
Note that the C trap handler receives a structure amxregs passed by value. If your C
compiler does not allow such declarations, you can use casts to coerce access to the
parameters on the stack as follows:
#include "amx831sd.h" /* AMX Structure Definitions*/
void cdecl tdiverr(int dummy)
{struct amxregs *regp; /* Pointer to registers */
void FAR *faultp; /* Fault pointer */
regp = (struct amxregs *)&dummy;
faultp = *((void FAR **)(regp + 1));
:
Process the error
:
}
The task trap handler can be coded in assembly language as a FAR procedure. Upon entry
to the procedure, the following conditions exist:
Interrupts are as they were at the time of the fault.
All registers are free for use.
DS,ES DGROUP Segment
SS:SP Task stack ready for use
SS:BP A(parameters on stack)
The direction flag is set to forward.
The parameters on the stack include a register structure AMXREGS (see Appendix D.2)
followed by a FAR pointer to the fault location. For the overflow trap, the address points
to the instruction following the INTO instruction. For the 8086/88 and 80186/188 DIV,
IDIV or BOUND instruction, the address points to the instruction following the instruction
which caused the fault. For the 80286 and 80386 DIV, IDIV or BOUND instruction, the
address points to the instruction (including any instruction prefixes) which caused the
fault.
If the overflow trap handler issues a FAR return instruction, it will cause execution to
resume following the INTO instruction. If the divide or bound trap handler issues a FAR
return instruction, the effect will be processor dependent. The 8086/88 and 80186/188
will resume execution following the instruction which caused the fault. For the 80286
and 80386, the instruction which caused the fault will be executed again. Note that
recovery from divide and bound errors may be next to impossible in some applications.