title: Arm Assembly proper way to PUSH POP link register and pc in a subroutine and calling a subroutine within a subroutine
body: <p>For ARM assembly</p>
  
  <p>I have been doing the following in my subroutines:</p>
  
  <pre><code>SubRoutine:
    PUSH {r1,r2,lr}
    //code that changes r1 and r2
    POP {r1,r2,lr}
    bx lr
  </code></pre>
  
  <p>Is this the correct way to return from a subroutine and continue with code in your main function? I have seen around that people are doing the following:</p>
  
  <pre><code>SubRoutine:
    PUSH {r1,r2,lr}
    //code that changes r1 and r2
    POP {r1,r2,pc}
    bx lr
  </code></pre>
  
  <p>But I don't know why you would POP the PC when you PUSHed the LR. Which is the correct way and why?</p>
  
  <p>Also, If you call a subroutine within  a subroutine, do you do the following:</p>
  
  <pre><code>SubRoutine:
     PUSH {r1,r2,lr}
  
    //code that changes r1 and r2
    PUSH {lr}
    bl AnotherRoutine (where bx lr will be used to return from it)
    POP {lr}
  
    POP {r1,r2,pc}
    bx lr
  </code></pre>
  
  <p>OR do you do it like this instead:</p>
  
  <pre><code>SubRoutine:
     PUSH {r1,r2,lr}
  
    //code that changes r1 and r2
    PUSH {lr}
    bl AnotherRoutine(where bx lr will be used to return from it)
    POP {pc}
  
    POP {r1,r2,pc}
    bx lr
  </code></pre>