For Loops in MIPS assembly
Posted
by John Moffitt
on Stack Overflow
See other posts from Stack Overflow
or by John Moffitt
Published on 2010-04-24T21:46:03Z
Indexed on
2010/04/24
21:53 UTC
Read the original article
Hit count: 355
I'm having problems getting my processor to simulate correctly and I think I've narrowed it down to the program I'm giving it.
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. bnq $R7, $zero, -9
It should iterate through the bottom portion 20 times and then exit. I'm particularly unsure about the branch instruction but I can't find anything wrong with it so : /
© Stack Overflow or respective owner