Bird
0
0

What will be the value of R1 after executing this code?

medium📝 Analysis Q5 of 15
ARM Architecture - Subroutines and Stack
What will be the value of R1 after executing this code?
funcA:
  MOV R1, #2
  BL funcB
  BX LR

funcB:
  MOV R1, #7
  BL funcC
  BX LR

funcC:
  ADD R1, R1, #1
  BX LR
A8
B7
C2
D0
Step-by-Step Solution
Solution:
  1. Step 1: Follow R1 changes in funcA and funcB

    R1 is set to 2 in funcA, then overwritten to 7 in funcB.
  2. Step 2: Analyze funcC effect on R1

    funcC adds 1 to R1 (7 + 1 = 8) before returning.
  3. Final Answer:

    8 -> Option A
  4. Quick Check:

    R1 final value after nested calls = 8 [OK]
Quick Trick: Inner subroutine can overwrite and modify registers [OK]
Common Mistakes:
  • Ignoring changes made in funcC
  • Assuming R1 remains 2 or 7 after all calls

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes