I'm currently trying to store 5 user input values into an array of size 5. I'm having trouble looping the scanf and printf functions into my loop as well as storing the values into an array. I've tried debugging, but am unsure on where to put the breakpoints.
.data
.balign 4
m1: .asciz "User number:"
.balign 4
scan_p: .asciz "%d"
.balign 4
number_read: .word 0
.balign 4
return: .word 0
.balign 4
a: .skip 20
.balign 4
i: .word
.global main
main:
LDR R1, address_of_return
STR LR, [R1]
LDR R3, addressOfA
LDR R4, addressOfI
MOV R5, #0
STR R5, [R4]
loop:
LDR R5, [R4]
CMP R5, #5
BEQ end
ADD R6, R3, R5, LSL #2
LDR R0, address_of_m1
BL printf
LDR R0, address_of_scan_p
LDR R1, address_of_number_read
BL scanf
STR R1, [R6] // Store a[i] = *address_of_number_read
ADD R5, R5, #1
STR R5, [R4]
b loop
end:
LDR R1, address_of_return
LDR R1, [R1]
BX LR
address_of_m1: .word m1
address_of_scan_p: .word scan_p
address_of_number_read: .word number_read
address_of_return: .word return
addressOfA: .word a
addressOfI: .word i
.global printf
.global scanf
Getting a segmentation fault 139