When run this program the qtspim find a problem with sw command inside the procedure. What is wrong?
.data
prompt: .asciiz "Enter an integer: "
pinA: .space 40 # allocate 40 bytes (10 integers * 4 bytes each)
.text
.globl main
# Subroutine to read 10 integers
read_integers:
move $s1, $a0 # copy the base address of the array
move $s2, $a1
read_loop:
li $v0, 4 # syscall for print string
la $a0, prompt # load address of prompt
syscall
li $v0, 5 # syscall for read integer
syscall
sw $v0, 0($s1) # store the read integer at the current index of the array
addiu $s1, $s1, 4 # increment the address of the array
addiu $s2, $s2, -1 # increment the index
bnez $s2, read_loop
jr $ra # return to the caller
main:
la $a0, pinA # load the address of the array into $a0
li $a1, 10
addiu $sp, $sp, -4
sw $ra, 0($sp)
jal read_integers # call the subroutine
lw $ra, 0($sp)
addiu $sp, $sp, 4
# The main program continues here...
# You can add code here to process the array or exit
li $v0, 10
exit syscall
syscall
I would like to make a procedure to read an array of integers in MIPS32