这是将cpu切换为32位模式的标准代码。
cli
lgdt [gdt_descriptor] ; Assume a well-defined GDT
mov eax, cr0
or eax, 0x1
mov cr0, eax; Is this the exact moment when the processor switches to 32 bit mode?
jmp CODE_SEG:pipeline_flush ; Here CODE_SEG is 0x08,i.e, the segment descriptor after the NULL descriptor in the GDT
[bits 32]
pipeline_flush:
这里的远跳转指令是16位(?)编码的指令....但是处理器处于32位模式....如果我将代码更改为:
[bits 32]
jmp CODE_SEG:pipeline_flush
该代码停止工作...
为什么是这样??
将CR0的位0置1后,处理器处于16位保护模式,因此指令将作为16位指令执行。
BITS 32指令使jmp指令的32位汇编为偏移量部分。处理器将偏移量的高16位视为段。由于它不是有效的代码段,因此引发#GP。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句