I am new to ARM Assembler. Using qemu emulator.
This solution didn't work for me.
I have this C file md1_main.c:
#include <stdio.h>
#include <stdlib.h>
#include "md1.h"
int main (void)
{
int n;
scanf("%d", &n);
printf("Result = %u\n", asum(n));
return 0;
}
and .h file contains function prototype unsigned int asum(unsigned int n);
I am really confused, how to pass n
into the assembler code.
Assembler code is md1.s:
.text
.align 2
.global asum
.type asum, %function
asum:
mov r1, #0
mov r2, #1
loop:
cmp r2, #3 ; instead of 3 there should be my input
bgt end
add r1, r1, r2
add r2, r2, #1
b loop
end:
mov r0, r1
bx lr
Just can't get it.