Created
May 2, 2012 01:19
-
-
Save ryan-beckett/2572845 to your computer and use it in GitHub Desktop.
A quick looping test in MIPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text | |
main: | |
li $t4, 1, #t4 = counter | |
i1: ori $t0, $0, 1000 | |
i2: ori $t1, $0, 2000 | |
i3: addi $t2, $t0, 100 | |
i4: #lw $t3, 0($t1) | |
i5: #lw $t4, 0($t0) | |
i6: add $t3, $t3, $t4 | |
i7: #sra $t3, $t3, 1 | |
i8: #sw $t3, 0($t0) | |
i9: #sw $t3, 0($t1) | |
i10: addi $t0, $t0, 4 | |
i11: addi $t1, $t1, 4 | |
jal print | |
addi $t4, $t4, 1 | |
i12: slt $t3, $t0, $t2 | |
i13: bne $0, $t3, i4 | |
exit: | |
li $v0, 10 | |
syscall | |
print: | |
li $v0, 1 #print counter | |
move $a0, $t4 | |
syscall | |
.data | |
newline: .asciiz "\n" | |
.text | |
li $v0, 4 | |
la $a0, newline | |
syscall | |
jr $ra |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment