Bird
0
0

What is wrong with this ARM assembly code snippet according to AAPCS?

medium📝 Analysis Q7 of 15
ARM Architecture - Subroutines and Stack
What is wrong with this ARM assembly code snippet according to AAPCS?
my_subroutine:
PUSH {R4, LR}
MOV R4, R0
POP {R4}
BX LR
ABX LR should be BX SP
BR4 is not saved on stack
CPUSH and POP use wrong registers
DLR is not restored before returning
Step-by-Step Solution
Solution:
  1. Step 1: Check stack operations

    PUSH saves R4 and LR, but POP only restores R4, not LR.
  2. Step 2: Understand return mechanism

    LR must be restored before BX LR to return correctly.
  3. Final Answer:

    LR is not restored before returning -> Option D
  4. Quick Check:

    Restore LR before BX LR [OK]
Quick Trick: Always restore LR before returning with BX LR [OK]
Common Mistakes:
  • Forgetting to pop LR
  • Using BX SP instead of BX LR
  • Incorrect PUSH/POP registers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes