title: What is meant by data cache and instruction cache?
body: <p>From <a href="http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Memory/introCache.html">here</a>:</p>
  
  <blockquote>
    <p>Instructions and data have different access patterns, and access
    different regions of memory. Thus, having the same cache for both
    instructions and data may not always work out.</p>
    
    <p>Thus, it's rather common to have two caches: an instruction cache that
    only stores instructions, and a data cache that only stores data.</p>
  </blockquote>
  
  <p>It's intuitive to know the distinction between instructions and data, but now I'm not show sure of the difference in this context? What constitutes as data and gets put into a data cache and what constitutes as instructions and gets put into an instruction cache?</p>
  
  <p>I know ARM assembly. Would anything requiring <code>STR</code>, <code>LDR</code>, <code>LDMF</code> or <code>STMFD</code> use the data cache? But technically speaking <code>STR</code>, <code>LDR</code>, <code>LDMF</code> and <code>STMFD</code> are all instructions so I this is why I'm confused. Must "data" always exist with an "instruction"? Is data considered anything in the <code>.data</code> section? </p>
  
  <p>For example <code>LDR R1, =myVar</code> then would LDR go into the instruction cache and the contents of myVar go into the data cache? Or does it not work like that?</p>
  
  <blockquote>
    <p>Instructions and data have different access patterns
    Could someone please elaborate?</p>
  </blockquote>
  
  <p>This comment I made on a helpful post highlights my difficulty understanding:</p>
  
  <blockquote>
    <p>"The idea is that if an instruction has been loaded from memory, it's
    likely to be used again soon" but the only way to know the next
    instruction is to read it. That means a memory read (you can't say
    it's already in cache because a new instruction is being red). So I
    still don't see the point? Say a LDR instruction just happened, so now
    LDR is in the data cache. Maybe another LDR instruction will happen,
    maybe it won't, we can't be sure so we have to actually read the next
    instruction - thus defeating the purpose of cache.</p>
  </blockquote>