Can someone help me with this code? (ASM/C)

On an ARM linux distribution. Couldn’t tell you which.

worker.S:


.globl _asm_task

.code 32

_asm_task:
MOV r11, r13	;
SUB r11, r11 , #4 ;
SUB r13, r6, #20;
MOV r1, r0	;
STR r1, [r11, #4];
ADD r11, r11, #4 ;
MOV r13, r11	;
B r14	;

All this one really does is run a basic program which allocates a variable, saves it in a stack pointer, and returns. This is not quite as important; the problems are here:

main.c


#include <stdio.h>
extern void _asm_task(int a);

int main(int argc, char **argv) {

_asm_task(stoi(argv[1]));

return 0;

} 

The compiler tells me that it doesn’t recognize _asm_task and that it doesn’t know stoi(). Both of these confuse me to no end - _asm_task is explicitly stated as external and exists in the same directory. As far as I am aware, this distribution has a built-in makefile. I’m building with gcc -o main main.c. It should recognize stoi(), right? Or am I missing an include somewhere?

You should probably use atio, not stoi. atoi is in the standard c library, stoi i C++. And it’s usually in stdlib.h.

And when you compile and link at the same time, you need to add the .o file from compiling your asm file to the command line.

Yeah, a friend of mine informed me that stoi was false. I have no idea what a -o file is; we didn’t deal with that in the tutor lesson whatsoever. It doesn’t really matter at this point; it’s due in about two hours and I don’t even know if it’s graded or not. I just couldn’t figure out the error. It might just be that it’s not finding _asm_work because I didn’t configure my VPN right - given the sheer bloody-minded ridiculous number of fucking moving parts involved in just getting the damn thing to run anything at all, this would not surprise me.

Did you #include the file with your _asm_task routine in it?
Or, specify it to the linker?
If not, the linker is not going to be able to find it, no matter how obvious it is to you….

(I often yell at my development system** “IT’S RIGHT THERE!”** you damn so-and-so, when I have these sort of issues).