Bird
0
0

You want to organize a complex ARM program by splitting tasks into subroutines that call each other. Which is the best practice for nested subroutine calls to avoid errors?

hard📝 Application Q15 of 15
ARM Architecture - Subroutines and Stack
You want to organize a complex ARM program by splitting tasks into subroutines that call each other. Which is the best practice for nested subroutine calls to avoid errors?
AAlways use BL to call and BX LR to return, saving LR if calling another subroutine
BUse BX LR to call and BL to return, no need to save LR
CAvoid calling subroutines inside subroutines to prevent errors
DUse MOV to jump between subroutines and ignore LR register
Step-by-Step Solution
Solution:
  1. Step 1: Understand call and return instructions

    BL saves return address in LR and branches to subroutine; BX LR returns to caller.
  2. Step 2: Handle nested calls safely

    If a subroutine calls another, it must save LR (e.g., on stack) before calling to avoid losing return address.
  3. Final Answer:

    Always use BL to call and BX LR to return, saving LR if calling another subroutine -> Option A
  4. Quick Check:

    BL call + BX LR return + save LR for nested calls [OK]
Quick Trick: Save LR before nested BL calls, return with BX LR [OK]
Common Mistakes:
  • Using BX LR to call instead of BL
  • Not saving LR before nested calls
  • Jumping with MOV ignoring LR

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes