title: Converting Assembly to Machine Code
body: <p>I'm taking a course now about computer organization and architecture. 
  We've been given some exercises to do. One of them is to convert assembly code into machine instructions.</p>
  
  <p>I'm stuck on converting <code>movia</code> into a machine instruction.</p>
  
  <p>I know it consists of 2 operations, <code>orhi</code> and <code>addi</code>.</p>
  
  <p>This is the code in assembly:</p>
  
  <pre><code>movia r8, 50000 
  </code></pre>
  
  <p>The exercise states that <code>r0</code> is <code>0x0</code>, and <code>r8</code> is <code>0x8</code>.</p>
  
  <p>So, the <code>orhi</code> would be: <code>orhi r8, r0, %hiadj(50000)</code> and the add would be: <code>addi r8, r8,%lo(50000)</code>   </p>
  
  <p>I've gotten the <code>orhi</code> to:</p>
  
  <pre><code>    00000 01000 1100001101010000 110100    
  ___________________r0____r8_______50000________0x34(opcode)
  </code></pre>
  
  <p>But I have to use the <code>%hiadj</code> on the 50000! I don't know how to? I've searched around for it a bit but haven't found an answer clear enough. </p>
  
  <p>I'm very new at this but really want to understand! So, how do you use the <code>%hiadj</code>? Sorry if the question isn't clear, but if you'd like to help, I'll try and explain more.</p>