.data
A: .word 21 16 -12 25 -25 12 -32 -56 19 -11
.text
main:
la $a0, A #argument 1 : array address
li $a1, 10 #argument 2 : number of elements in array
jal print
li $v0, 10
syscall
print:
addi $sp, $sp, -12
sw $ra, 0($sp)
sw $a0, 4($sp)
sw $a1, 8($sp)
li $t0, 1
bne $a0, $t0, print_recursive
li $v0, 1
addi $sp, $sp, 8
jr $ra
print_recursive:
addi $a0, $a0, -1
jal print
li $t1, 0 #comparison variable
lw $ra, 0($sp)
lw $a0, 4($sp)
lw $a1, 8($sp)
addi $sp, $sp, 12
lw $t0, 0($a0)
bgt $t0, $t1, update
addi $sp, $sp, 12
move $v0, $t0
jr $ra
update:
move $v0, $t0
Currently I’m learning MIPS in college and this is printing array’s elements recursively. However, it makes error with “Can’t expand stack segment by 8 bytes to 524288 bytes.” I’m totally beginner of MIPS so I cannnot figure out what is the problem. Appreciate for advices.
printing array’s elements
New contributor
Yoochan Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.