How to disable interrupts for one instruction?

一笑奈何 提交于 2019-12-22 10:57:37

问题


Is there any other way to disable interrupts for the duration of only one instruction in x86 than using the CLI instruction?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/33330911/how-to-disable-interrupts-for-one-instruction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!