Bird
0
0

A programmer notices that after a subroutine call, the value in register r4 is unexpectedly changed. What is the most likely cause under AAPCS?

medium📝 Analysis Q14 of 15
ARM Architecture - Subroutines and Stack
A programmer notices that after a subroutine call, the value in register r4 is unexpectedly changed. What is the most likely cause under AAPCS?
Ar4 is a caller-saved register and was not preserved by the caller
Br4 holds the return address and was corrupted
Cr4 is used to pass arguments and was overwritten
Dr4 is a callee-saved register and the callee did not save it
Step-by-Step Solution
Solution:
  1. Step 1: Understand register saving responsibilities

    Under AAPCS, registers r4 to r11 are callee-saved, meaning the called function must save and restore them if it uses them.
  2. Step 2: Identify the cause of unexpected change

    If r4 changed unexpectedly, it means the callee did not save and restore it properly, causing corruption.
  3. Final Answer:

    r4 is a callee-saved register and the callee did not save it -> Option D
  4. Quick Check:

    Callee must save r4-r11 [OK]
Quick Trick: Callee saves r4-r11; caller saves r0-r3 [OK]
Common Mistakes:
  • Thinking r4 is caller-saved
  • Confusing argument registers with saved registers
  • Assuming r4 holds return address

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes