如何禁用一条指令的中断?
How to disable interrupts for one instruction?
除了使用 CLI
指令外,还有其他方法可以在 x86 中的 只有一条指令 期间禁用中断吗?
是的,用 MOV
加载 SS
将禁止下一条指令的外部中断。指令集参考是这样说的:
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.
这段代码片段可以解决问题:
pushf
pop ax
and ax, FDFFh
push ax
popf ;This disables interrupts, You didn't use "CLI"
; Here IF is clear
sti
除了使用 CLI
指令外,还有其他方法可以在 x86 中的 只有一条指令 期间禁用中断吗?
是的,用 MOV
加载 SS
将禁止下一条指令的外部中断。指令集参考是这样说的:
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.
这段代码片段可以解决问题:
pushf
pop ax
and ax, FDFFh
push ax
popf ;This disables interrupts, You didn't use "CLI"
; Here IF is clear
sti