title: Understanding how `lw` and `sw` actually work in a MIPS program
body: <p>I'm having bit of a difficulty understanding what <code>sw</code> and <code>lw</code> do in a MIPS program. My understanding of the topic is that we use <code>lw</code> to transfer data from the memory into the register and vice-versa for <code>sw</code>. But how is this exactly accomplished?</p>
  
  <p>Let's say we have the following line of code:</p>
  
  <pre><code>lw Reg.Dest, Offset(Reg.Source)
  sw Reg.Source, Offset(Reg.Dest)
  </code></pre>
  
  <p>If we concentrate on <code>lw</code> it's essentially storing the data from the memory, <code>Reg.Source</code> and multiplying the address of that data with the <code>Offset</code>, always a multiple of $4$ because the registers deal with $32$ bits and the memory uses $8$ bits, into a specific address in the register which is equal to <code>Offset + Reg.Source</code> - so if we say that <code>Offset = 16, Reg.Source = $s1 = 12</code> then the register will store the data from the memory into the address $28$ in the register.</p>
  
  <p>Assuming that my understanding of <code>lw</code> is correct, my question is then how does <code>sw</code> work? </p>
  
  <p>PS: It would be great if the answers could also contain just a one liner example such as <code>sw $t0, 32($s3)</code>.</p>