Hi All,
Instead of using embedded asm ( __asm), how could I write a arm64.s file and integrate to a command line test project with c files ?
#include <stdio.h> extern int myadd(int a, int b); int main(int argc, const char * argv[]) { // insert code here... printf("Hello, World!\n"); int r = myadd( 10 , 4); return 0; }
And .s file .global myadd .p2align 2 .type myadd,%function
myadd: // Function "myadd" entry point. .fnstart add r0, r0, r1 // Function arguments are in R0 and R1. Add together // and put the result in R0. bx lr // Return by branching to the address in the link // register. .fnend
Error -- /Users/prokashsinha/Arm/ArmAndC/asmfunction.s:9:1: error: unknown directive .type myadd,%function ^ /Users/prokashsinha/Arm/ArmAndC/asmfunction.s:12:1: error: unknown directive .fnstart ^ /Users/prokashsinha/Arm/ArmAndC/asmfunction.s:13:5: error: invalid operand for instruction add r0, r0, r1 ^ /Users/prokashsinha/Arm/ArmAndC/asmfunction.s:15:1: error: unrecognized instruction mnemonic, did you mean: b, bcax, bl, br, sb, tbx? bx lr ^ /Users/prokashsinha/Arm/ArmAndC/asmfunction.s:17:1: error: unknown directive .fnend ^