title: Pushing LR before BL instruction in ARM assembly
body: <p>I'm trying to get a better understanding of why you push <code>LR</code> before calling a <code>BL</code> instruction. I understand that the <code>BL</code> instruction will branch to another subroutine before restoring the PC to the instruction address following the BL call but why is the <code>LR</code> pushed before the <code>BL</code> is called? I've written the entire recursive code for factorial computation below to give context. a and b are both variables that are written in pseudo.</p>
  
  <pre><code>LDR   RO, a
  PUSH  (LR)
  BL    factorial
  STR   R0, b
  POP   (LR)
  
  factorial: 
  CMP   RO, #0
  MOVEQ R0, #1
  MOVEQ PC, LR
  MOV   R3, R0
  SUB   R0, R0, #1
  PUSH  (R3, LR)
  BL    factorial
  MUL   R0, R3, R0
  POP   (R3, LR)
  MOV   PC, LR
  </code></pre>
  
  <p>I understand how this program is supposed to flow but I'm confused about what addresses are being stored in the stack. Clearly, you want the address of the 
  "<code>STR R0, b</code>" instruction to be put on the stack after your first branch call but how is that being preserved on the stack if the <code>LR</code> is pushed prior to the <code>BL</code> call?</p>