Currently, I am working with MIPS, and I was wondering what modifications should I make to following code(recursive function to print list):
printList:
addi $sp, $sp, -8
sw $ra, 0($sp)
beqz $a0, endRec
lw $t0, 0($a0)
sw $t0, 4($sp)
lw $a0, 4($a0)
jal printList
lw $a0, 4($sp)
li $v0, 1
syscall
la $a0, str
li $v0, 4
syscall
endRec:
lw $ra, 0($sp)
addi $sp, $sp, 8
jr $ra
such that it prints list in "normal" order(for example if I am adding elements on the end, 1 2 3, I want it to print it like that and not like 3 2 1). NOTE: str is blanco defined in data segment. I also know that I could do reverse list and then call that function, but is there easier way?