4-17
PROCEDURE CALLS, INTERRUPTS, AND EXCEPTIONS
4.4.2.Calls to Interrupt or Exception Handler Tasks
Interrupt and exception handler routines can also be executed in a separate task. Here, an inter-
rupt or exception causes a task switch to a handler task. The handler task is given its own address
space and (optionally) can execute at a higher protection level than application programs or
tasks.
The switch to the handler task is accomplished with an implicit task call that references a task
gate descriptor. The task gate provides access to the address space for the handler task. As part
of the task switch, the processor saves complete state information for the interrupted program or
task. Upon returning from the handler task, the state of the interrupted program or task is
restored and execution continues. Refer to Chapter 5, Interrupt and Exception Handling, of the
Intel Architecture Software Developers Manual, Volume 3, for a detailed description of the
processors mechanism for handling interrupts and exceptions through handler tasks.
4.4.3.Interrupt and Exception Handling in Real-Address Mode
When operating in real-address mode, the processor responds to an interrupt or exception with
an implicit far call to an interrupt or exception handler. The processor uses the interrupt or
exception vector number as an index into an interrupt table. The interrupt table contains instruc-
tion pointers to the interrupt and exception handler procedures.
The processor saves the state of the EFLAGS register, the EIP register, the CS register, and an
optional error code on the stack before switching to the handler procedure.
A return from the interrupt or exception handler is carried out with the IRET instruction.
Refer to Chapter 16, 8086 Emulation, of the Intel Architecture Software Developers Manual,
Volume 3, for more information on handling interrupts and exceptions in real-address mode.
4.4.4.INT n, INTO, INT 3, and BOUND Instructions
The INT n, INTO, INT 3, and BOUND instructions allow a program or task to explicitly call an
interrupt or exception handler. The INT n instruction uses an interrupt vector as an argument,
which allows a program to call any interrupt handler.
The INTO instruction explicitly calls the overflow exception (#OF) handler if the overflow flag
(OF) in the EFLAGS register is set. The OF flag indicates overflow on arithmetic instructions,
but it does not automatically raise an overflow exception. An overflow exception can only be
raised explicitly in either of the following ways:
Execute the INTO instruction.
Test the OF flag and execute the INT n instruction with an argument of 4 (the vector
number of the overflow exception) if the flag is set.
Both the methods of dealing with overflow conditions allow a program to test for overflow at
specific places in the instruction stream.
The INT 3 instruction explicitly calls the breakpoint exception (#BP) handler.