Call Assembly Function From C On ARMPosted: November 18, 2012 Introduction For first test in making sure my naken_asm can assemble ARM code properly I decided to try and link some code with a C program compiled with gcc on the Raspberry Pi. I decided to do just a simple number adding function (only 2 lines of assembly). For a full example of this working check out my Easy Match library. Related Projects @mikekohn.net
asm_module.asm .arm add_numbers_asm: add r0, r0, r1 bx lr test_arm.c #include <stdio.h> #include <stdlib.h> int add_numbers_asm(int a, int b); int main(int argc, char *argv[]) { printf("%d\n", add_numbers_asm(7,8)); return 0; } To Build it naken_asm -l -e -o asm_module.o asm_module.asm gcc -o test_arm test_arm.c asm_module.o -Wall
Copyright 1997-2024 - Michael Kohn
|