title: Direct Map Cache and cache misses
body: <p>I am working on my homework, but I am not sure how to calculate the total cache misses. I have been trying to understand it but it just is not making sense to me. I am given some Mips code and I need to calculate the number of cache misses. Here is the problem: </p>
  
  <p>Direct-map cache.  We are given a direct-map cache with 1024 blocks.  Each 
  block is a MIPS word (32 bits).  The cache uses write-back whenever a write miss 
  happens.  The main memory consists of 2^30 words.  Initially, the cache is empty.<br>
  Determine the total number of cache misses for the following instruction sequences. </p>
  
  <pre><code>lw $s0, 4($sp) 
  lw $s0, 8($sp) 
  sw $s0, 8($sp) 
  sw $s1, 4($sp) 
  lw $s0, 4($sp)
  </code></pre>
  
  <p>I am not looking for the answer. I want to learn how to do this because I have many more problems like this on the homework assignment. I would like a walkthrough on this. In the meantime I will be researching this topic trying to figure out the answer.</p>