title: Strange jump in MIPS assembly
body: <p>I'm probably missing something really obvious here, but I've been going over this over and over and I'm decidedly stuck. In the code below, <code>$8</code> is incremented only if <code>$2 != $0</code>. Now I double and triple checked and the <code>beq</code> instruction works (for example if I change lop to end2, it does go there).</p>
  
  <p>However, for some reason, <code>$8</code> is incremented regardless, even if the branch is executed.</p>
  
  <pre><code>lop:   beq $3, $0, end2
         and $2, $3, $4
  
         sll $3, $3, 1
  
         beq $2, $0, lop     
  
         addi $8, $8, 1
  
         j lop
  </code></pre>
  
  <p>I've got to admit I'm completely stumped.</p>