For loops in MIPS assembly
I am having trouble mimicking my processor properly and I think I have narrowed it down to the program I give it to her.
1. li $R1, 0
2. li $R2, 0x100
3. li $R6, 1
4. li $R8, 0
5. li $R9, 20
6. lw $R3, 0($R1)
7. lw $R4, 4($R1)
8. add $R5, $R3, $R4
9. srlv $R5, $R5, $R6
10. sw $R5, 0($R2)
11. addi $R1, $R1, 4
12. addi $R2, $R2, 4
13. addi $R8, $R8, 1
14. slt $R7, $R8, $R9
15. bne $R7, $zero, -9
It has to iterate through the bottom 20 times and then exit. I'm especially unsure about the branch instructions, but I can't seem to find anything wrong with it: /
+2
a source to share
1 answer