Last active
October 5, 2015 00:23
-
-
Save pathawks/cca541e8ccf8293da4f0 to your computer and use it in GitHub Desktop.
99 Bottles of Beer 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
# filename: 99Bottles.s | |
# author: Pat Hawks <[email protected]> | |
.data | |
Lyric1: | |
.asciiz " bottles of beer on the wall\n" | |
Lyric2: | |
.ascii " bottles of beer\n" | |
.asciiz "Take one down, Pass it around\n" | |
Lyric3: | |
.ascii "One last bottle of beer one the wall\n\n" | |
.ascii "One last bottle of beer one the wall\n" | |
.ascii "One last bottle of beer\n" | |
.ascii "Take it down, Pass it around\n" | |
.asciiz "No more bottles of beer one the wall\n" | |
.text | |
.globl main | |
main: | |
li $t0 99 | |
PrintAnotherVerse: | |
move $a0 $t0 | |
li $v0 1 | |
syscall | |
la $a0 Lyric1 | |
li $v0 4 | |
syscall | |
move $a0 $t0 | |
li $v0 1 | |
syscall | |
la $a0 Lyric2 | |
li $v0 4 | |
syscall | |
addi $t0 $t0 -1 | |
beq $t0 1 PrintLastVerse | |
move $a0 $t0 | |
li $v0 1 | |
syscall | |
la $a0 Lyric1 | |
li $v0 4 | |
syscall | |
li $a0 10 | |
li $v0 11 | |
syscall | |
j PrintAnotherVerse | |
PrintLastVerse: | |
la $a0 Lyric3 | |
li $v0 4 | |
syscall | |
li $v0 10 | |
syscall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment