title: mips program can't figure out mips/mflo/sw
body: <p>I wanted to write a program that converts a decimal in to binary. For this I would use an array. Please look at the line commented below and tell me why it might not work because the spim simulator says attempting to execute non-instruction</p>
  
  <pre><code>       .text
         .globl __start
      __start:
  
          la $a0,prompt
          li $v0,4
          syscall
  
          li $v0,5
          syscall
  
          move $t1,$v0
  
          li $t0,0
          la $t2,bin
          #add $t2,$t2,124
              lop:    
              div $t1,$t1,2
          mflo $v0
          sw $v0,($t2) #right here
          add $t2,$t2,4
          add $t0,$t0,1
          ble $t0,32,lop
          j dnn
  
              ads:    
              la $a0,spc
      li $v0,4
      syscall
      j back
  
              dnn: 
          la $t0,bin
          li $t3,1
          la $a0,pr2
          li $v0,4
          syscall
          add $t0,$t0,124
              lp2:
          lw $t1,($t0)
          sub $t0,$t0,4
          add $t3,$t3,1
          move $a0,$t1
          li $v0,5
          syscall
          div $t4,$t3,4
          mflo $t4
          ble $t4,0,ads
              back:   
              ble $t3,33,lp2
  
          li $v0,10
          syscall
  
          .data
              prompt: .asciiz "Enter decimal: "
              spc:    .asciiz " "
              pr2:    .asciiz "\nbinary value:\n"
              bin:    .space 128
  </code></pre>
  
  <p>EDIT: I made some changes, like now all the 'add's are 'addi's and '.align 2' comes after .data
  also in The spim simulator (PCSpim) I noticed something interesting:</p>
  
  <pre><code>   [0x00400020]        0x3c011001  lui $1, 4097 [bin]              ; 15: la $t2,bin
     [0x00400024]        0x342a0022  ori $10, $1, 34 [bin]
     [0x00400028]        0x34010002  ori $1, $0, 2                   ; 17: div $t1,$t1,2
     [0x0040002c]        0x0121001a  div $9, $1
     [0x00400030]        0x00004812  mflo $9
     [0x00400034]        0x00001012  mflo $2                         ; 18: mflo $v0
     [0x00400038]        0xad420000  sw $2, 0($10)                   ; 19: sw $v0,($t2)
  </code></pre>
  
  <p>why is mflo done twice?</p>