Bird
0
0

Analyze this ARM function:

medium📝 Analysis Q4 of 15
ARM Architecture - Subroutines and Stack
Analyze this ARM function:
func:
  PUSH {r4, r5}
  MOV r4, #7
  MOV r5, #14
  POP {r4, r5}
  BX lr

If r4 was 30 before the call, what is its value after returning?
A14
B7
C30
DUndefined
Step-by-Step Solution
Solution:
  1. Step 1: Understand PUSH and POP

    PUSH saves original r4 and r5 values on stack.
  2. Step 2: MOV modifies r4 and r5 locally

    Values changed inside function but not permanently.
  3. Step 3: POP restores original values

    r4 and r5 restored to pre-call values before return.
  4. Final Answer:

    30 -> Option C
  5. Quick Check:

    Registers restored by POP [OK]
Quick Trick: PUSH/POP restore original register values [OK]
Common Mistakes:
  • Assuming MOV changes persist after POP
  • Ignoring stack restore operations

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes