Bird
0
0

Given the following ARM assembly snippet following AAPCS, what will be the value in R0 after the subroutine returns?

medium📝 Analysis Q4 of 15
ARM Architecture - Subroutines and Stack
Given the following ARM assembly snippet following AAPCS, what will be the value in R0 after the subroutine returns?
MOV R0, #5
MOV R1, #3
BL add_two_numbers

; Subroutine add_two_numbers:
; Adds R0 and R1, returns result in R0
add_two_numbers:
ADD R0, R0, R1
BX LR
A3
B8
C5
D0
Step-by-Step Solution
Solution:
  1. Step 1: Analyze initial register values before call

    R0 = 5, R1 = 3 before calling add_two_numbers.
  2. Step 2: Understand subroutine operation

    Subroutine adds R0 and R1, stores result in R0, then returns.
  3. Step 3: Calculate result

    5 + 3 = 8, so R0 will hold 8 after return.
  4. Final Answer:

    R0 contains 8 after subroutine -> Option B
  5. Quick Check:

    Return value = 5 + 3 = 8 [OK]
Quick Trick: Return value is sum stored in R0 after subroutine [OK]
Common Mistakes:
  • Ignoring addition in subroutine
  • Assuming R1 is returned
  • Forgetting BX LR returns control

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes