### compiled by Neal Wagner on
#     Fri Dec 12 12:23:39 2014
main:   move    $s7, $ra
        la      $s1, M # data addr
# Print your name
        li      $v0, 4
        la      $a0, Name
        syscall
### Compiled code starts here
# Read M[18]
        li      $v0, 7
        syscall
        s.d     $f0, 144($s1)
# Read M[19]
        li      $v0, 7
        syscall
        s.d     $f0, 152($s1)
# Output M[18]
        li      $v0, 3
        l.d     $f12, 144($s1)
        syscall
# Output Blank
        li      $v0, 4
        la      $a0, Blank
        syscall
# Output M[19]
        li      $v0, 3
        l.d     $f12, 152($s1)
        syscall
# Output NewL
        li      $v0, 4
        la      $a0, NewL
        syscall
# Output NewL
        li      $v0, 4
        la      $a0, NewL
        syscall
# M[23] = M[1]
        l.d     $f2, 8($s1)
        s.d     $f2, 184($s1)
WhileStart0:
# M[36] = M[2] * M[5]
        l.d     $f2, 16($s1)
        l.d     $f4, 40($s1)
        mul.d   $f6, $f2, $f4
        s.d     $f6, 288($s1)
# M[37] = M[36] - M[23]
        l.d     $f2, 288($s1)
        l.d     $f4, 184($s1)
        sub.d   $f6, $f2, $f4
        s.d     $f6, 296($s1)
        l.d     $f2, 296($s1)
        l.d     $f4, 0($s1)
        c.eq.d  $f2, $f4
        bc1t    WhileEnd0
# WhileBody0
# M[11] = M[1]
        l.d     $f2, 8($s1)
        s.d     $f2, 88($s1)
# Output M[23]
        li      $v0, 3
        l.d     $f12, 184($s1)
        syscall
# Output Blank
        li      $v0, 4
        la      $a0, Blank
        syscall
# M[38] = M[18] ^ M[19]
        l.d     $f2, 144($s1)
        l.d     $f4, 152($s1)
        jal     pow
        s.d     $f6, 304($s1)
# M[39] = M[23] ^ M[38]
        l.d     $f2, 184($s1)
        l.d     $f4, 304($s1)
        jal     pow
        s.d     $f6, 312($s1)
# M[14] = M[39]
        l.d     $f2, 312($s1)
        s.d     $f2, 112($s1)
# M[40] = M[18] ^ M[19]
        l.d     $f2, 144($s1)
        l.d     $f4, 152($s1)
        jal     pow
        s.d     $f6, 320($s1)
# M[41] = M[23] ^ M[40]
        l.d     $f2, 184($s1)
        l.d     $f4, 320($s1)
        jal     pow
        s.d     $f6, 328($s1)
# M[15] = M[41]
        l.d     $f2, 328($s1)
        s.d     $f2, 120($s1)
# M[42] = M[23] ^ M[18]
        l.d     $f2, 184($s1)
        l.d     $f4, 144($s1)
        jal     pow
        s.d     $f6, 336($s1)
# M[43] = M[42] ^ M[19]
        l.d     $f2, 336($s1)
        l.d     $f4, 152($s1)
        jal     pow
        s.d     $f6, 344($s1)
# M[16] = M[43]
        l.d     $f2, 344($s1)
        s.d     $f2, 128($s1)
# Output M[14]
        li      $v0, 3
        l.d     $f12, 112($s1)
        syscall
# Output Tab
        li      $v0, 4
        la      $a0, Tab
        syscall
# Output M[15]
        li      $v0, 3
        l.d     $f12, 120($s1)
        syscall
# Output Tab
        li      $v0, 4
        la      $a0, Tab
        syscall
# Output M[16]
        li      $v0, 3
        l.d     $f12, 128($s1)
        syscall
# Output NewL
        li      $v0, 4
        la      $a0, NewL
        syscall
# M[44] = M[23] + M[1]
        l.d     $f2, 184($s1)
        l.d     $f4, 8($s1)
        add.d   $f6, $f2, $f4
        s.d     $f6, 352($s1)
# M[23] = M[44]
        l.d     $f2, 352($s1)
        s.d     $f2, 184($s1)
        j       WhileStart0
WhileEnd0:
# Stuff at end
        move    $ra, $s7
        jr      $ra  # ret to sys

### double to truncated double
pow:
# truncate $f4
        trunc.w.d $f4, $f4
        cvt.d.w $f4, $f4
        l.d     $f6, 8($s1)
# check if $f4 == 0
        l.d     $f8, 0($s1)
        c.eq.d  $f4, $f8
        bc1t    end
# check if $f4 > 0
        l.d     $f8, 0($s1)
        c.lt.d  $f8, $f4
        bc1t  next
        l.d     $f8, 8($s1)
        div.d   $f2, $f8, $f2
        neg.d   $f4, $f4
# loop as long as $f4 == 0
next:   l.d  $f8, 0($s1)   
        c.eq.d  $f4, $f8
        bc1t  end
        mul.d $f6, $f6, $f2  
        l.d  $f8, 8($s1)
        sub.d $f4, $f4, $f8
        b next
end:    jr    $ra
# data declarations
        .data
        .align  3
M:      .double 0.,1.,2.,3.,4.,5.
        .double 6.,7.,8.,9. # cons
        .space  208  # a to z
        .space  1000 # 125 temps
Blank:  .asciiz " "
NewL:   .asciiz "\n"
Tab:    .asciiz "\t"
Name:   .asciiz "Executed by Neal Wagner\n"
### tiny source program:
# # exp2.t: test exponentiation
# > i; > j; 
# < i; < B; 
# < j; < N; < N;
# n = 1;
# { 2*5 - n ?
#      b = 1;
#      < n; < B;
#      e = n ^ i ^ j;
#      f = n ^ (i ^ j);
#      g = (n ^ i) ^ j;
#      < e; < T; 
#      < f; < T; 
#      < g; < N;
#      n = n + 1;
# }$