Interrupt Flag Management
The popf and iret instructions may not modify the state of
the interrupt flag since most DPMI implementations will run
programs with IOPL < DPL. Programs must execute cli or sti
to modify the interrupt flag state.
This means that the following code sequence will leave
interrupts disabled:
;
; (Assume interrupts are enabled at this point)
;
pushf
cli
.
.
popf ; Interrupts are still OFF!
Note that since some implementations of DPMI will maintain a
virtual interrupt state for protected mode DOS programs, the
current value of the interrupt flag may not reflect the
current virtual interrupt state. Protected mode programs
should use the virtual interrupt state services to determine
the current interrupt flag state.
Since cli and sti are privileged instructions, they will
cause a protection violation and the DPMI provider will
simulate the instruction. Because of the overhead involved
in processing the exception, cli and sti should be used as
little as possible. In general, you should expect either of
these instructions to require at least 300 clocks.