# `iret`

[x86-64 Documentation](https://asm-editor.specy.app/documentation/x86.md) › [Instructions](https://asm-editor.specy.app/documentation/x86/instruction.md)

Web page: https://asm-editor.specy.app/documentation/x86/instruction/iret

**Interrupt return, default size**

Category: System

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](https://intel.github.io/SDM/instruction/IRET-IRETD-IRETQ.html)

## Flags

| Flag | Effect |
| --- | --- |
| 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. Loaded only when the program has the privilege to change it. A program in the editor does not, so IF keeps its value. |
| DF | loaded from the stack |
| OF | loaded from the stack |

## Forms

- `iret`

## Description

Only the flags the privilege level allows are restored.

Under `BITS 64`, NASM assembles `iret` with the 32-bit operand size, as [`iretd`](https://asm-editor.specy.app/documentation/x86/instruction/iretd.md): it pops 4-byte slots and loads only `eip` and `esp`. A 64-bit handler returns with [`iretq`](https://asm-editor.specy.app/documentation/x86/instruction/iretq.md). A Linux program has no interrupt handlers of its own to return from.
