[英]How to get asm to jump to a variable address in c?
Right now, I call the jump instruction with inline assembly in c as follows:现在,我在 c 中调用带有内联汇编的跳转指令,如下所示:
int register eax asm("eax") = addr; // addr is a memory address
asm("jmp *%eax");
I want to do it without having to set any other register values (eg I want to do is something like this):我想这样做而不必设置任何其他寄存器值(例如,我想做的是这样的):
asm("jmp *(addr)");
What is the right way to do that?这样做的正确方法是什么? That is, how can I "insert" ac variable into the asm call?
也就是说,如何将 ac 变量“插入”到 asm 调用中?
Ubuntu 12.04 64-bit, Intel x86 64-bit processor, gcc version 4.7.4. Ubuntu 12.04 64 位,Intel x86 64 位处理器,gcc 版本 4.7.4。
asm volatile("jmp *%0" : : "r" (addr));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.