title: What are callee and caller saved registers?
body: <p>I'm having some trouble understanding the difference between caller and callee saved registers and when to use what. </p>
  
  <p>I am using the MSP430
  :</p>
  
  <p>procedure:</p>
  
  <pre><code>mov.w #0,R7 
  mov.w #0,R6 
  add.w R6,R7 
  inc.w R6 
  cmp.w R12,R6 
  jl l$loop 
  mov.w R7,R12
  ret
  </code></pre>
  
  <p>the above code is a callee and was used in a textbook example so it follows the convention. R6 and R7 are callee saved and R12 is caller saved. My understanding is that the callee saved regs aren't "global" in the sense that changing its value in a procedure will not affect it's value outside the procedure. This is why you have to save a new value into the callee reg at the beginning.</p>
  
  <p>R12, the caller saved is "global", for lack of better words. What the procedure does has a lasting effect on R12 after the call.</p>
  
  <p>Is my understanding correct? Am I missing other things?</p>