title: MIPS get memory address from register
body: <p>Imagine that I have a function in C that has 5 parameter.</p>
  
  <pre><code>sum(n1,n2,n3,n4,n5);
  </code></pre>
  
  <p>In assembly. I get the first four parameter from registers 4 to 7 and the last parameter is acceded like:</p>
  
  <pre><code> lw $8, 16($29)
  </code></pre>
  
  <p><strong>First question</strong></p>
  
  <p>If <code>lw  $8, 16($29)</code> puts n5 in register $8, why doesn't this</p>
  
  <pre><code>lw      $9, 0($29)
  lw      $10, 4($29)
  lw      $11, 8($29)
  lw      $12, 12($29)
  </code></pre>
  
  <p>puts n1 to n4 in registers $9 to $12?</p>
  
  <p><strong>Second question</strong></p>
  
  <p>Since the parameters in <code>sum(n1,n2,n3,n4,n5);</code> are somewhere stored in memory and in assembly, the first parameter is in <code>$4</code> how can I get the memory address of <code>$4</code> to <code>$7</code>?</p>
  
  <p>If i do this:</p>
  
  <pre><code>    .data
  array:  .word 3,4,2,6,12,7,18,26,2,14,19,7,8,12,13
      .text
  main:
      li  $8,1
      la  $9,array
  </code></pre>
  
  <p>the last instruction puts the address location of my array in <code>$9</code>. If I do</p>
  
  <pre><code>main:
      li  $4,1
      la  $9,0($4)
  </code></pre>
  
  <p>The value on <code>$9</code>is still 1 and not the address of <code>$4</code></p>