iret

Interrupt return, default size

Returns from an interrupt by popping the instruction pointer, cs and the flags, and in 64-bit mode the stack pointer and ss as well, then continuing at the popped address.

8086 and later

Intel's reference: IRET/IRETD/IRETQ

CFPFAFZFSFTFIFDFOF ●●●●●●●●●
  • ● set from the result
  • CF Loaded from the stack.
  • PF Loaded from the stack.
  • AF Loaded from the stack.
  • ZF Loaded from the stack.
  • SF Loaded from the stack.
  • TF Loaded from the stack.
  • IF Loaded from the stack only with the privilege to change it, which a Linux program lacks.
  • DF Loaded from the stack.
  • OF Loaded from the stack.

Forms

  • iret

Only the flags the privilege level allows are restored.

Under BITS 64, NASM assembles iret with the 32-bit operand size, as iretd: it pops 4-byte slots and loads only eip and esp. A 64-bit handler returns with iretq. A Linux program has no interrupt handlers of its own to return from.