The INT n instruction generates a call to the interrupt or exception handler specified with the destination operand (see the section titled "Interrupts and {exceptions}" in Chapter 6 of the IA-32 Intel Architecture Software Developer's Manual, Volume 1). The destination operand specifies an interrupt vector number from 0 to 255, encoded as an 8-bit unsigned intermediate value. Each interrupt vector number provides an index to a gate descriptor in the IDT. The first 32 interrupt vector numbers are reserved by Intel for system use. Some of these interrupts are used for internally generated exceptions.
The INT n instruction is the general mnemonic for executing a software-generated call to an interrupt handler. The INTO instruction is a special mnemonic for calling overflow exception (#OF), interrupt vector number 4. The overflow interrupt checks the OF flag in the EFLAGS register and calls the overflow interrupt handler if the OF flag is set to 1.
The INT 3 instruction generates a special one byte opcode (CC) that is intended for calling the debug exception handler. (This one byte form is valuable because it can be used to replace the first byte of any instruction with a breakpoint, including other one byte instructions, without over-writing other code). To further support its function as a debug breakpoint, the interrupt generated with the CC opcode also differs from the regular software interrupts as follows: - Interrupt redirection does not happen when in VME mode; the interrupt is handled by a protected-mode handler.
The virtual-8086 mode IOPL checks do not occur. The interrupt is taken without faulting at any IOPL level.
Note that the "normal" 2-byte opcode for INT 3 (CD03) does not have these special features.
Intel and Microsoft assemblers will not generate the CD03 opcode from any mnemonic, but this opcode can be created by direct numeric code definition or by self-modifying code.
The action of the INT n instruction (including the INTO and INT 3 instructions) is similar to that of a far call made with the CALL instruction. The primary difference is that with the INT n instruction, the EFLAGS register is pushed onto the stack before the return address. (The return address is a far address consisting of the current values of the CS and EIP registers.) Returns from interrupt procedures are handled with the IRET instruction, which pops the EFLAGS information and return address from the stack.
The interrupt vector number specifies an interrupt descriptor in the interrupt descriptor table (IDT); that is, it provides index into the IDT. The selected interrupt descriptor in turn contains a pointer to an interrupt or exception handler procedure. In protected mode, the IDT contains an array of 8-byte descriptors, each of which is an interrupt gate, trap gate, or task gate. In realaddress mode, the IDT is an array of 4-byte far pointers (2-byte code segment selector and a 2-byte instruction pointer), each of which point directly to a procedure in the selected segment.
(Note that in real-address mode, the IDT is called the interrupt vector table, and its pointers are called interrupt vectors.)
The following decision table indicates which action in the lower portion of the table is taken given the conditions in the upper portion of the table. Each Y in the lower section of the decision table represents a procedure defined in the "Operation" section for this instruction (except #GP).
Decision Table
PE | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
VM | Don't care | Don't care | Don't care | Don't care | Don't care | 0 | 1 | 1 |
IOPL | Don't care | Don't care | Don't care | Don't care | Don't care | Don't care | <3 | =3 |
DPL/CPL RELATIONSHIP | Don't care | DPL < CPL | Don't care | DPL > CPL | DPL = CPL or C | DPL < CPL & NC | Don't care | Don't care |
INTERRUPT TYPE | Don't care | S/W | Don't care | Don't care | Don't care | Don't care | Don't care | Don't care |
GATE TYPE | Don't care | Don't care | Task Trap or Interrupt | Trap or Interrupt | Trap or Interrupt | Trap or Interrupt | Trap or Interrupt |
REAL-ADDRESS-MODE | Action taken | No action | No action | No action | No action | No action | No action | No action |
PROTECTED-MODE | No action | Action taken | Action taken | Action taken | Action taken | Action taken | Action taken | Action taken |
TRAP-OR-INTERRUPT-GATE | No action | No action | No action | Action taken | Action taken | Action taken | Action taken | Action taken |
INTER-PRIVILEGE-LEVEL-INTERRUPT | No action | No action | No action | No action | No action | Action taken | No action | No action |
INTRA-PRIVILEGE-LEVEL-INTERRUPT | No action | No action | No action | No action | Action taken | No action | No action | No action |
INTERRUPT-FROM-VIRTUAL-8086-MODE | No action | No action | No action | No action | No action | No action | No action | Action taken |
TASK-GATE | No action | No action | Action taken | No action | No action | No action | No action | No action |
#GP | No action | Action taken | No action | Action taken | No action | No action | Action taken | No action |
When the processor is executing in virtual-8086 mode, the IOPL determines the action of the INT n instruction. If the IOPL is less than 3, the processor generates a general protection exception (#GP); if the IOPL is 3, the processor executes a protected mode interrupt to privilege level 0. The interrupt gate's DPL must be set to 3 and the target CPL of the interrupt handler procedure must be 0 to execute the protected mode interrupt to privilege level 0.
The interrupt descriptor table register (IDTR) specifies the base linear address and limit of the IDT. The initial base address value of the IDTR after the processor is powered up or reset is 0.
|