简体   繁体   English

Tiny C编译器:“错误:未知的操作码'jmp'”

[英]Tiny C Compiler: “error: unknown opcode 'jmp'”

Given this code: 给出以下代码:

int main(void)
{
    __asm volatile ("jmp %eax");

    return 0;
}

32-bit TCC will complain with: 32位TCC会抱怨:

test.c:3: error: unknown opcode 'jmp'

but the 64-bit version will compile just fine. 但是64位版本可以正常编译。

What's the problem with the 32 bit code? 32位代码有什么问题?

The solution is to simply add a star (*) before the register, like this: 解决方案是在寄存器之前简单地添加一个星号(*),如下所示:

__asm volatile ("jmp *%eax");

I'm not exactly sure what the star means. 我不确定这颗星是什么意思。 According to this SO post: 根据 SO帖子:

The star is some syntactical sugar indicating that control is to be passed indirectly, by reference/pointer. 星号是某种语法糖,指示控制权将通过引用/指针间接传递。

As for why it works with 64-bit TCC, I assume that it's a bug; 至于为什么它可以与64位TCC一起使用,我认为这是一个错误。 64-bit GCC complains with Error: operand type mismatch for 'jmp' , as it should. 64位GCC会Error: operand type mismatch for 'jmp' ,应该这样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM