我有以下适用于 x86 的代码,我需要将其转换为 gcc/arm7 内联汇编。
似乎替换堆栈只是将堆栈指针移入r15
而不是 的简单问题esp
,但我不知道如何调用该函数,或将实际变量放入 arm 汇编代码中。
Object *c;
unsigned long _stack = (unsigned long)c->stack + 65535;
void (Object::*_run)() = &Object::_run;
__asm
{
mov ecx, _this // store pointer to this Object
mov edx, _run // store address of _run() function
mov esp, stack // replace stack pointer with Object's internal stack
call edx // call the _run() function
}
编辑:
到目前为止,我有这个:
unsigned long _stack = (unsigned long)c->stack + 65535;
void (Object::*_run)() = &Object::_run;
asm volatile("mov %[__this], %r0\n\t"
"mov %[__run], %r5\n\t"
"mov %[__stack], %%sp\n\t"
"blx %r5\n\t"
: /* no output operands */
: [__stack] "r" (_stack),
[__this] "r" (_this),
[__run] "r" (_run)
: /* no clobbers */);
问:在 x86 asm 中,使用 thiscall 调用约定,“this”指针进入 ecx。它在哪里?
编辑:
编辑:
我正在尝试做的事情的完整实现在这里: http: //pastebin.com/6mrUC7td
它在视觉工作室中完美运行,但我无法让它在 XCode/iOS 中正常运行