arm64 汇编调用C函数
main.s
.section .text
.globl main
main:
stp x29, x30, [sp, -16]! //store fp x29 lr x30
mov x0, #0
mov x1, #1
bl add
mov x1, x0 // x0 return
ldp x29, x30, [sp], 16 //restore fp lr
ret
add.c
#include <stdio.h>
int add(int a, int b)
{
printf("a=%d,b=%d\n",a,b);
return a+b;
}
编译
gcc -g main.s add.c
调试
gdb a.out
b main