title: MIPS, how to invert a series of numbers in a while loop (a rapid method)
body: <p>I coding an exercise but I have find a little problem... My exercise ask me that convert a character (keyboard input) in:</p>
  
  <ul>
  <li>ASCII code</li>
  <li>Binary code</li>
  <li>Hex code</li>
  </ul>
  
  <p>without the MIPS syscall. 2 points on 3 are solved for now but in the point 2 I have find my problem... When I insert a letter for example, the binary code is invertited (see below)</p>
  
  <p>Give me a character: a
  ASCII: 97
  Binary 10000110 (The real is 01100001)</p>
  
  <p>Exist an easy method to invert this number? I leave the code below.</p>
  
  <pre><code>print_binary:
  #move the function parameter in t0
  move $t0, $a0
  
  #Show a message
  li $v0, 4
  la $a0, m3
  syscall
  
  
  while:
      #check if my counter is 8(conversion on 8 bit)
      beq $t2, 8, end_loop
      #Divide the number
      div $t1, $t0, 2
      #move hi in t4 to show in video
      mfhi $t4
      #Counter
      add $t2, $t2, 1
      #move for another division
      move $t0, $t1
  
      #Show hi for every division
      li $v0, 1
      move $a0, $t4
      syscall
  
      j while
  
  
  end_loop:
      jr $ra
  </code></pre>
  
  <p>I don't use the array very well, so I would avoid this method if possible...</p>
  
  <p>Thank you</p>