title: In a MIPS assembly `addi` instruction, how is a hexadecimal immediate interpreted?
body: <p>Is there is a standard or recommendation for how the <code>addi</code> instruction (and others) should be interpreted in assembly, when hexadecimal immediate values are used?</p>
  
  <p>Example:</p>
  
  <pre><code>addi $t0, $zero, 0xffff
  </code></pre>
  
  <p>I was expecting this to mean the same as <code>addi $t0, $zero, -1</code> where <code>0xffff</code> would be sign extended to <code>0xffffffff</code>, as is done by the processor, but was surprised by the fact that the assembler of the Mars simulator interprets hexadecimals as 32bit unsigned numbers and tries to do <code>addi $t0, $zero, 0x0000ffff</code> as a pseudo-instruction (if pseudo-instructions are enabled).</p>
  
  <p>To be clear, MARS's assembler assembles that <code>addi $t0, $zero, 0xffff</code> pseudo-instruction to multiple machine instructions which create that constant (65535 = 0xffff) in a register and then add it, if pseudo-instructions are enabled.  MARS's simulator <em>simulates</em> instructions like <code>0x2008ffff</code> (<code>addi $t0, $zero, -1</code>) correctly.</p>
  
  <p>The SPIM assembler just aborts with an error.</p>
  
  <p>What I would like to know is if assemblers always interpret this way, and if there is someplace where this is written or explained as I could not find anything.</p>