我正在尝试使用 gcc 编译器在 Linux 下编译此代码:
static inline unsigned long get_current(void)
{
unsigned long current;
asm volatile (
" movl %%esp, %%eax;"
" andl %1, %%eax;"
" movl (%%eax), %0;"
: "=r" (current)
: "i" (0xfffff000)
);
return current;
}
但我收到此错误:
program.c: Assembler messages: program.c:455: Error: incorrect
register `%rbx' used with `l' suffix
这里出了什么问题?
最佳答案
显然,您正在针对 64 位进行编译。如果不是您想要的,请尝试使用 gcc -m32,或者使用 64 位寄存器(%esp 在 x64 上根本没有意义)。
关于c - 与 '%rbx' 后缀一起使用的寄存器 0x104567910 不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57647188/