Bird
0
0

Which ARM assembly sequence correctly sets up a stack frame that saves R4, R5, LR and reserves 24 bytes for local variables?

hard📝 Application Q8 of 15
ARM Architecture - Subroutines and Stack
Which ARM assembly sequence correctly sets up a stack frame that saves R4, R5, LR and reserves 24 bytes for local variables?
ASUB SP, SP, #24 PUSH {R4, R5, LR}
BPUSH {R4, R5} SUB SP, SP, #28 PUSH {LR}
CSUB SP, SP, #32 PUSH {R4, R5, LR}
DPUSH {R4, R5, LR} SUB SP, SP, #24
Step-by-Step Solution
Solution:
  1. Step 1: Save registers first

    PUSH {R4, R5, LR} decreases SP by 12 bytes (3 registers x 4 bytes).
  2. Step 2: Allocate locals

    SUB SP, SP, #24 reserves 24 bytes for local variables.
  3. Step 3: Correct order

    Saving registers before allocating locals avoids overwriting saved data.
  4. Final Answer:

    PUSH {R4, R5, LR} SUB SP, SP, #24 -> Option D
  5. Quick Check:

    Push registers first, then allocate locals [OK]
Quick Trick: Push registers before allocating locals [OK]
Common Mistakes:
  • Allocating locals before pushing registers
  • Incorrect total stack space calculation
  • Splitting LR push separately

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes