Bird
0
0

Identify the error in this ARM assembly if-else snippet:

medium📝 Analysis Q6 of 15
ARM Architecture - Control Flow Instructions
Identify the error in this ARM assembly if-else snippet:
CMP R3, #10
BGT greater
MOV R0, #5
greater:
MOV R0, #15
AIncorrect CMP instruction
BMissing unconditional branch after MOV R0, #5
CWrong label name
DMOV instruction syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Analyze flow after MOV R0, #5

    Without a branch, code continues to 'greater' label, overwriting R0.
  2. Step 2: Identify missing branch

    To prevent fall-through, an unconditional branch is needed after MOV R0, #5.
  3. Final Answer:

    Missing unconditional branch after MOV R0, #5 -> Option B
  4. Quick Check:

    Missing branch causes fall-through error [OK]
Quick Trick: Add unconditional branch to avoid fall-through in if-else [OK]
Common Mistakes:
  • Assuming CMP is wrong
  • Thinking label is incorrect
  • Believing MOV syntax is faulty

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes