Bird
0
0

You wrote this ARM assembly code to call a subroutine:

medium📝 Analysis Q14 of 15
ARM Architecture - Subroutines and Stack
You wrote this ARM assembly code to call a subroutine:
BL my_subroutine
MOV R1, #10
BX LR

But the program crashes after returning from my_subroutine. What is the likely error?
AThe subroutine name is case-sensitive and must be uppercase
BThe MOV instruction is invalid after a subroutine call
CThe BX LR instruction should be replaced with BL
DThe subroutine did not preserve the link register (LR) before returning
Step-by-Step Solution
Solution:
  1. Step 1: Understand link register usage

    ARM uses the link register (LR) to store return address when calling subroutines with BL.
  2. Step 2: Identify common mistake

    If the subroutine modifies LR without saving/restoring it, the return address is lost, causing a crash on BX LR.
  3. Final Answer:

    The subroutine did not preserve the link register (LR) before returning -> Option D
  4. Quick Check:

    LR must be saved/restored in subroutines [OK]
Quick Trick: Always save LR in subroutines to avoid crashes [OK]
Common Mistakes:
  • Thinking MOV after BL causes crash
  • Replacing BX LR with BL incorrectly
  • Assuming subroutine names are case-sensitive

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes