【问题标题】:unsupported instruction `lidt`不支持的指令“lidt”
【发布时间】:2015-04-16 19:43:11
【问题描述】:

我正在构建一个用于教育目的的内核。

正确的我的操作系统启动如下: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

我正在使用 gas 进行编译,所以我使用的是 at&t 语法。
但是,当我尝试编译它时,编译器似乎无法识别 lidt 指令。

gcc -Wa,--32 -MMD -c -o boot.o boot.S boot.S:汇编程序消息:
boot.S:65:错误:不支持的指令“lidt”:
的配方 目标 'boot.o' 失败 make: *** [boot.o] 错误 1

那么正确的指令是什么?

编辑:我尝试使用lidtl,这也不起作用

【问题讨论】:

    标签: assembly x86 gnu-assembler att


    【解决方案1】:

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

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

    【讨论】:

    • 太好了,它有效!这很奇怪,因为我的 gas 版本是 2.24,但我得到了不受支持的指令错误。哦,好吧,至少它现在有效。谢谢
    猜你喜欢
    • 2022-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-18
    • 2021-02-12
    • 2017-08-24
    • 2013-08-26
    相关资源
    最近更新 更多