2015-04-16 54 views
2

我正在为教育目的构建一个内核。不受支持的指令`lidt`

右键我的操作系统启动如下:GRUB -> boot.S -> init.c

boot.S我要加载中断描述符表。这是我的文件的摘录:

# load_idt - Loads the interrupt descriptor table (IDT). 
# stack: [esp + 4] the address of the first entry in the IDT 
#  [esp ] the return address 
load_idt: 
    movl 4(%esp),%eax # load the address of the IDT into register eax 
    lidt %eax   # load the IDT 
    ret      # return to the calling function 

我使用的气体进行编译,所以我在在& T语法工作。
但是,当我尝试编译这个时,编译器似乎无法识别lidt指令。

gcc -Wa,--32 -MMD -c -o boot.o boot.S boot.S: Assembler messages:
boot.S:65: Error: unsupported instruction `lidt' : recipe for
target 'boot.o' failed make: *** [boot.o] Error 1

那么正确的指令是什么呢?

编辑:我使用lidtl试过了,这不也是工作

回答

3

lidt需要一个内存引用。正确的语法是lidt (%eax)。诚然,错误信息可能会更好。然后再次,我的gas版本(从GNU Binutils for Debian 2.22)确实说operand type mismatch for 'lidt'

PS:gas可以切换到intel语法,所以没有理由在& t处使用。 intel的语法当然是lidt [eax],而lidt eax会产生相同的错误。

+0

太棒了,它的工作原理!它的奇怪,因为我的天然气版本是2.24,但我得到不受支持的指令错误。哦,至少现在起作用了。谢谢 – Krimson