ARM汇编调用带寄存器的函数使用C参数 [英] ARM assembly calling a function with registers as parameters using C
本文介绍了ARM汇编调用带寄存器的函数使用C参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下ARM汇编code:
I have the following ARM assembly code:
mov r0, SP
mov r1, LR
bl func
有没有呼叫FUNC使用C code函数的方法吗?像 FUNC(SP,LR)
谢谢!
推荐答案
取决于正是你想要做什么,你用什么编译器。
随着 GCC
这样的事情可以工作:
Depends on what exactly you want to do and what compiler you use.
With gcc
something like this could work:
extern void func(void*, void*);
void foo()
{
int dummy[4];
func(&dummy, __builtin_return_address(0));
}
这可能并不总是给你确切的堆栈指针,虽然。按照 godbolt 它产生下面的汇编code:
This might not always give you the exact stack pointer, though. As per godbolt it produces the following assembly code:
foo():
push {lr}
sub sp, sp, #20
mov r1, lr
mov r0, sp
bl func(void*, void*)
add sp, sp, #20
ldr pc, [sp], #4
这篇关于ARM汇编调用带寄存器的函数使用C参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文