3-321
INSTRUCTION SET REFERENCE
IRET/IRETDInterrupt Return
Description
These instructions return program control from an exception or interrupt handler to a program
or procedure that was interrupted by an exception, an external interrupt, or a software-generated
interrupt. These instructions are also used to perform a return from a nested task. (A nested task
is created when a CALL instruction is used to initiate a task switch or when an interrupt or
exception causes a task switch to an interrupt or exception handler.) Refer to Section 6.4., Task
Linking in Chapter 6, Task Management of the Intel Architecture Software Developers Manual,
Volume 3.
IRET and IRETD are mnemonics for the same opcode. The IRETD mnemonic (interrupt return
double) is intended for use when returning from an interrupt when using the 32-bit operand size;
however, most assemblers use the IRET mnemonic interchangeably for both operand sizes.
In Real-Address Mode, the IRET instruction preforms a far return to the interrupted program or
procedure. During this operation, the processor pops the return instruction pointer, return code
segment selector, and EFLAGS image from the stack to the EIP, CS, and EFLAGS registers,
respectively, and then resumes execution of the interrupted program or procedure.
In Protected Mode, the action of the IRET instruction depends on the settings of the NT (nested
task) and VM flags in the EFLAGS register and the VM flag in the EFLAGS image stored on
the current stack. Depending on the setting of these flags, the processor performs the following
types of interrupt returns:
Return from virtual-8086 mode.
Return to virtual-8086 mode.
Intra-privilege level return.
Inter-privilege level return.
Return from nested task (task switch).
If the NT flag (EFLAGS register) is cleared, the IRET instruction performs a far return from the
interrupt procedure, without a task switch. The code segment being returned to must be equally
or less privileged than the interrupt handler routine (as indicated by the RPL field of the code
segment selector popped from the stack). As with a real-address mode interrupt return, the IRET
instruction pops the return instruction pointer, return code segment selector, and EFLAGS
image from the stack to the EIP, CS, and EFLAGS registers, respectively, and then resumes
execution of the interrupted program or procedure. If the return is to another privilege level, the
IRET instruction also pops the stack pointer and SS from the stack, before resuming program
execution. If the return is to virtual-8086 mode, the processor also pops the data segment regis-
ters from the stack.
Opcode
Instruction
Description
CF
IRET
Interrupt return (16-bit operand size)
CF
IRETD
Interrupt return (32-bit operand size)