Bird
0
0

Identify the error in this ARM function snippet:

medium📝 Analysis Q6 of 15
ARM Architecture - Subroutines and Stack
Identify the error in this ARM function snippet:
func:
  MOV r4, #10
  MOV r5, #20
  BX lr

Assuming r4 and r5 are callee-saved registers.
AMOV instructions are invalid here
BThe function uses incorrect branch instruction
CNo error, code is correct
DRegisters r4 and r5 are not preserved before modification
Step-by-Step Solution
Solution:
  1. Step 1: Check preservation of callee-saved registers

    r4 and r5 are callee-saved and must be saved/restored if modified.
  2. Step 2: Identify missing preservation

    The code modifies r4 and r5 without saving/restoring, violating the preservation rule.
  3. Final Answer:

    Registers r4 and r5 are not preserved before modification -> Option D
  4. Quick Check:

    Modifying callee-saved without saving = error [OK]
Quick Trick: Always save callee-saved before modifying [OK]
Common Mistakes:
  • Ignoring preservation rules
  • Thinking MOV is invalid
  • Confusing branch instruction correctness

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes