The STI and CLI instructions

Setting and clearing the interrupt flag IF.

The STI instruction format

InstructionDescription
STISet the interrupt flag (IF = 1). Enables maskable interrupts.

The CLI instruction format

InstructionDescription
CLIClear 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 Author: Evgeny Sergeevich Dovgopolov

.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
No
PF
No
AF
No
ZF
No
SF
No
TF
No
IF
Yes
DF
No
OF
No