[ad_1]
so I have these two files, one is a .c and one is a .s. These are just test files so I can get the hang of working c with ARM scripts, but for the life of me I can't get them to work together. I was wondering if I could make this easier by using either Visual Studio or VS code (or any other IDE if y'all know).
Here's my code:
ARM
.global add2
add2:
stmfd sp!, v1-v6, lr @ 'standard' entry, save registers on the stack
add a1, a1, a2 @ do the addition requested
ldmfd sp!, v1-v6, pc
C
#include <stdio.h> /* standard input and output */
#include <stdlib.h> /* standard library */
extern int add2(int i, int j); /* tell the compiler that the routine is not defined here */
int main(int argc, char * argv[]) /* entry point to the program */
int i, j; /* declare the variable types */
int answer;
i = 5; /* give the variables values */
j = 20;
answer = add2(i, j); /* call the assembly language routine */
printf("result is : %dn", answer); /* print out the answer */
exit(0); /* leave the driver program */
Currently the weird java program I've been using to link them is giving me the error "D:JoeCollege StuffCS 252add.s:1: Error: bad instruction ` .global add2'"
Any help would be appreciated
[ad_2]
لینک منبع