11.6 Interrupt functions
-------------------------
An interrupt function is defined as follows:
interrupt function_name ()
{
// here must be a code of processing
}
Interrupt functions do not automatically save any registers, and no
registers are of themselves loaded before passing control to the interrupt
processor, so that you are responsible for saving the register values to
the stack and returning them, and then loading register DS with the
necessary value.
Here is an example of an interrupt handler which contains the values of
all registers and loads register DS:
interrupt safe_handle ()
{
$ PUSH DS
$ PUSH ES
$ PUSHA // this command requires at least a 286
DS = CS; // here DS is loaded for operation with memory model 'tiny'
/* here you make its processing /
$ POPA // this command requires at least a 286
$ POP ES
$ POP DS
}
When the interrupt function finishes, it automatically generates an
instruction to exit interrupt processing - IRET.