Skip to content

Instantly share code, notes, and snippets.

@pathawks
Last active October 5, 2015 00:23
Show Gist options
  • Select an option

  • Save pathawks/cca541e8ccf8293da4f0 to your computer and use it in GitHub Desktop.

Select an option

Save pathawks/cca541e8ccf8293da4f0 to your computer and use it in GitHub Desktop.

Revisions

  1. pathawks revised this gist Oct 5, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions 99Bottles.s
    Original file line number Diff line number Diff line change
    @@ -20,21 +20,21 @@ main:
    li $t0 99
    PrintAnotherVerse:
    move $a0 $t0
    li $v0 1
    li $v0 1
    syscall
    la $a0 Lyric1
    li $v0 4
    syscall
    move $a0 $t0
    li $v0 1
    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
    li $v0 1
    syscall
    la $a0 Lyric1
    li $v0 4
  2. pathawks created this gist Oct 4, 2015.
    52 changes: 52 additions & 0 deletions 99Bottles.s
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    # 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