Bird
0
0

Analyze the effect on the stack pointer (SP) after executing this ARM code:

medium📝 Analysis Q4 of 15
ARM Architecture - Subroutines and Stack
Analyze the effect on the stack pointer (SP) after executing this ARM code:
PUSH {LR}
SUB SP, SP, #8
ASP remains unchanged
BSP decreases by 8 bytes
CSP increases by 4 bytes
DSP decreases by 12 bytes
Step-by-Step Solution
Solution:
  1. Step 1: Understand PUSH {LR}

    PUSH stores LR on stack, decreasing SP by 4 bytes (ARM 32-bit).
  2. Step 2: SUB SP, SP, #8

    Subtracting 8 further decreases SP by 8 bytes.
  3. Step 3: Total SP change

    4 + 8 = 12 bytes decrease.
  4. Final Answer:

    SP decreases by 12 bytes -> Option D
  5. Quick Check:

    PUSH decreases SP by 4, SUB decreases by 8 [OK]
Quick Trick: PUSH decreases SP by 4 bytes [OK]
Common Mistakes:
  • Assuming PUSH does not affect SP
  • Ignoring order of instructions
  • Confusing increase with decrease

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes