Bird
0
0

Given the following ARM assembly snippet, what is the value in R0 after execution?

medium📝 Analysis Q4 of 15
ARM Architecture - Subroutines and Stack
Given the following ARM assembly snippet, what is the value in R0 after execution?
func1:
  MOV R0, #5
  BL func2
  BX LR

func2:
  ADD R0, R0, #3
  BX LR
A0
B5
C8
D3
Step-by-Step Solution
Solution:
  1. Step 1: Trace initial value assignment in func1

    R0 is set to 5 before calling func2.
  2. Step 2: Analyze func2 operation

    func2 adds 3 to R0, changing it from 5 to 8, then returns.
  3. Final Answer:

    8 -> Option C
  4. Quick Check:

    R0 after nested call = 5 + 3 = 8 [OK]
Quick Trick: Nested call can modify registers before return [OK]
Common Mistakes:
  • Assuming R0 remains unchanged after call
  • Confusing return address with data register

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes