title: STMFD/LDMFD not restoring register values?
body: <p>Why is the register r5 not being restored to its original value in the code below? It is set to #14, then modified in the subroutine, and when the subroutine completes the value is set to 0 in r5.</p>
  
  <pre><code>        mov r5, #14
          bl func ; Call subroutine func so that it can execute the calculations required.
  
  endless b endless ;End the program after the subroutine completes.
  
  func    STMFD sp!,{r5-r7} ;Save working registers in a safe place while the subroutine uses them for calculations.
          mov r5, #66
          add r0, r0, r1 ;Subroutine code.
  
          LDMFD sp!,{r5-r7}
          mov pc, lr ;Return from subroutine.
  </code></pre>