I am learning MIPS assembly language. This is an exercise I am trying to understand. The question is:
What does the following code correspond to?
Name: move $t0, $zero
Loop: add $t1, $t0, $t0
add $t1, $t1, $t1
add $t2, $a0, $t1
sw $zero, 0($t2)
addi $t0, $t0, 1
slt $t3, $t0, $a1
bne $t3, $zero, Loop
jr $ra
I already know the meaning of each instruction, how the directives work and what a for loop is. When I try to run the code in MIPS Mars Simulator it ends with error, probably because values contained in the registers $a0 and $a1 are needed to begin with.
I don't get the bigger picture. What happens during each loop iteration? Is it just a part of a bigger algorithm? What is it supposed to do?