title: div divu in MIPS
body: <p>What is the difference between <code>div</code> and <code>divu</code> in MIPS.</p>
  
  <p>I have seen difference between <code>add</code> and <code>addu</code> (<a href="https://stackoverflow.com/questions/16634110/difference-between-add-and-addu">link for same</a>). My understanding of add and addu : both operate on 2's complement signed numbers, <strong>the only difference that add generates traps on overflow whilst addu does not</strong></p>
  
  <p>But what is difference between div and divu, I mean we wont really get overflows here right.</p>
  
  <p>I tried following cases but got pretty weird results with divu. I only loaded the quotients (with mflo) and here are the outputs:</p>
  
  <pre><code>num1 |  num2  | div num1 num2 (qoutient) | divu num1 num2 (qoutient) | 
  
  5    |   2    |            2             |            2              |
  
  -5   |   2    |           -2             |            2147483645     |
  
  5    |  -2    |           -2             |            0              |
  
  -5   |  -2    |            2             |            0              |
  </code></pre>
  
  <p>Can Someone please explain logic of what is happening!!??</p>