arm64 汇编调用C函数
main.s
c
.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
c
#include <stdio.h>
int add(int a, int b)
{
printf("a=%d,b=%d\n",a,b);
return a+b;
}
编译
c
gcc -g main.s add.c
调试
c
gdb a.out
b main