IRET Interrupt Return Flags: O D I T S Z A P C * * * * * * * * * IRETIOv86 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+).