How to disable interrupts for one instruction?

微笑、不失礼 提交于 2019-12-06 03:26:26

Yes, loading SS with a MOV will inhibit external interrupts for the next instruction. This is what the instruction set reference says:

Loading the SS register with a MOV instruction inhibits all interrupts until after the execution of the next instruction. This operation allows a stack pointer to be loaded into the ESP register with the next instruction (MOV ESP, stack-pointer value) before an interrupt occurs.

This code snippet does the trick:

pushf
pop  ax
and  ax, FDFFh
push ax
popf               ;This disables interrupts, You didn't use "CLI"
; Here IF is clear
sti
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!