title: Questions about MIPS instructions in the code
body: <p>I have a question about several MIPS instruction in the code below<br>
  1. <code>addi</code> is an arithmetic instruction, what it's purpose ?<br>
  2. why there is single <code>nop</code>after <code>j</code> and <code>beq</code>, but there are multiple <code>nop</code>s after <code>addi</code> ?<br>
  Thanks !</p>
  
  <pre><code>if(a==b)  x=3; /* simple C code */
  else      x=4;
  y=5;  
  
         lw   $1,a       # possible unoptimized assembly language
         lw   $2,b       # no ($0) shown on memory access
         nop             # wait for b to get into register 2
         nop             # wait for b to get into register 2
         beq  $1,$2,lab1
         nop             # branch slot, always executed *********
         addi $1,4       # else part
         nop             # wait for 4 to get into register 1
         nop             # wait for 4 to get into register 1
         sw   $1,x       # x=4;
         j    lab2
         nop             # branch slot, always executed *********    
  lab1:  addi $1,3       # true part  
         nop             # wait for 3 to get into register 1
         nop             # wait for 3 to get into register 1
         sw   $1,x       # x=3;  
  lab2:  addi $1,5       # after if-else, always execute
         nop             # wait for 5 to get into register 1
         nop             # wait for 5 to get into register 1
         sw   $1,y       # y=5;
  </code></pre>