The STI and CLI instructions
Setting and clearing the interrupt flag IF.
The STI instruction format
| Instruction | Description |
|---|---|
| STI | Set the interrupt flag (IF = 1). Enables maskable interrupts. |
The CLI instruction format
| Instruction | Description |
|---|---|
| CLI | Clear the interrupt flag (IF = 0). Disables maskable interrupts. |
These instructions control the interrupt flag IF. When IF = 1, the processor responds to maskable hardware interrupts (INTR). When IF = 0, these interrupts are ignored. Non-maskable interrupts (NMI) do not depend on this flag.
Usage example
title .model small .stack 100h code segment public ; Start of the code segment assume cs:code main proc ; Start of the code segment cli ; Disable hardware interrupts (IF = 0) ; ... the critical section of the code is executed here ... sti ; Enable hardware interrupts (IF = 1) mov ax, 4C00h ; Copy the process termination function number into ah and the value into al int 21h ; Call the interrupt main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".
Processor status flags
CF
NoPF
NoAF
NoZF
NoSF
NoTF
NoIF
YesDF
NoOF
No