IRET            Interrupt Return                     Flags: O D I T S Z A P C
* * * * * * * * *
IRET IOv86
IRETD (CPU: 386+) IOv86

Logic ; Real mode
POP IP
POP CS
POPF

In real address mode, IRET pops the instruction pointer, CS, and
the flags register from the stack and resumes the interrupted
routine.

In protected mode, the action of IRET depends on the setting of
the nested task flag (NT) bit in the flags register. When popping
the new flag image from the stack, the IOPL bits in the flags
register are changed only when the current privilege level (CPL)
is zero.
- If NT = 0, IRET returns from an interrupt procedure without a
task switch. The code returned to must be equally or less
privileged than the interrupt routine (as indicated by the RPL
bits of the CS selector popped from the stack). If the
destination code is less privileged, IRET also pops the stack
pointer and SS from the stack.
- If NT = 1, IRET reverses the operation of a CALL or INT that
caused a task switch. The updated state of the task executing
IRET is saved in its task state segment. If the task is
re-entered later, the code that follows IRET is executed.

This instruction is IOPL-sensitive in V86 mode.


Note
Some assemblers support an IRET extension (IRETW) that forces a
16-bit word-style pop into the FLAGS register regardless of the
code segment's size attribute (80386+).


Opcode Format
CF IRET
CF IRETD


Length and timing
Operands Bytes 8088 186 286 386 486 Pentium
- 1 44 28 17+m 22 15 8-27 NP

32-bit return from interrupt (386+)
- 1 22 15 10-27 NP

Task switch clocks not shown