Created
April 30, 2013 15:17
-
-
Save flags/5489400 to your computer and use it in GitHub Desktop.
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
#Register use: | |
# $t1 = a | |
# $t2 = b | |
# $t3 = temp | |
#data segment begins here | |
.data | |
intro: .asciiz "CS230 Assignment#7. Written by:\n" | |
enter: .asciiz "Enter an integer (>= 2): " | |
astr: .asciiz "*" | |
done: .asciiz "Done!" | |
#text segment begins here | |
.text | |
li $v0, 4 | |
la $a0, intro | |
syscall | |
li $v0, 4 | |
la $a0, enter | |
syscall | |
li $v0, 5 | |
syscall | |
move $t1, $v0 | |
li $t2,2 | |
loop: | |
ble $t1,1,exit | |
rem $t3,$t1,$t2 | |
bgt $t3,0,endif | |
div $t1,$t1,$t2 | |
li $v0, 1 | |
move $a0, $t2 | |
syscall | |
bgt $t1,1,print | |
j loop | |
print: | |
li $v0, 4 | |
la $a0, astr | |
syscall | |
j loop | |
endif: | |
add $t2,$t2,1 | |
j loop | |
exit: | |
li $v0, 10 # to end program execution | |
syscall # end program execution | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment