Bird
0
0

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

medium📝 Analysis Q14 of 15
ARM Architecture - Control Flow Instructions
Identify the error in this ARM assembly if-else snippet:
CMP R2, #5
BNE else_label
MOV R3, #1
else_label:
MOV R3, #0
AMissing branch to skip else after if block
BIncorrect comparison instruction
CWrong register used in MOV
DNo labels defined
Step-by-Step Solution
Solution:
  1. Step 1: Understand the flow

    If R2 equals 5, BNE is not taken, so MOV R3, #1 executes, then execution continues to else_label and MOV R3, #0 runs.
  2. Step 2: Identify missing branch

    There is no branch to skip the else block after the if block, so both blocks run sequentially, overwriting R3.
  3. Final Answer:

    Missing branch to skip else after if block -> Option A
  4. Quick Check:

    Missing jump after if causes both blocks to run [OK]
Quick Trick: Add branch after if block to skip else [OK]
Common Mistakes:
  • Assuming else block is skipped automatically
  • Using wrong branch instruction
  • Ignoring label definitions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes