Bird
0
0

What is the likely consequence if a function changes a callee-saved register but does NOT restore it before returning?

medium📝 Analysis Q5 of 15
ARM Architecture - Subroutines and Stack
What is the likely consequence if a function changes a callee-saved register but does NOT restore it before returning?
AThe callee-saved registers are automatically restored by hardware
BThe function will execute faster without saving registers
CThe caller may observe corrupted register values leading to incorrect behavior
DNo effect since callee-saved registers are not used by the caller
Step-by-Step Solution
Solution:
  1. Step 1: Role of callee-saved registers

    They must be preserved to maintain caller's context.
  2. Step 2: Effect of not restoring

    Caller sees unexpected register values, causing bugs.
  3. Final Answer:

    The caller may observe corrupted register values leading to incorrect behavior -> Option C
  4. Quick Check:

    Unrestored registers cause caller errors [OK]
Quick Trick: Not restoring callee-saved registers corrupts caller state [OK]
Common Mistakes:
  • Believing hardware restores callee-saved registers automatically
  • Assuming no impact if registers are not restored

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes