.text
.global main
main:
adr r0,format
ldr r1,=number
bl scanf
ldr r2,=number
ldr r2,[r2]
mov r3,#1
loop:
mov r1,r3
adr r0,format1
bl printf
add r3,r3,#1
cmp r3,r2
blt loop
mov r0,#1
bl exit
format: .asciz "%d"
format1: .asciz "%dn"
.data
number: .word 0
here are the compilation and execution commands
arm-linux-gnueabi-gcc print_first_n.S -o print_first_n n
qemu-arm -L /usr/arm-linux-gnueabi ./print_first_n
when i execute the code and provide 5 as input
it is just printing 1
can somebody explain where is my mistake
i initially thought number variable wasnt referenced properly
but now everything looks good
New contributor
ggz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.