Bird
0
0

Identify the error in this ARM code snippet:

medium📝 Analysis Q6 of 15
ARM Architecture - Control Flow Instructions
Identify the error in this ARM code snippet:
SUB R0, R1, R2
BEQ equal_label

Assuming we want to branch if R1 equals R2.
ANo error, code is correct
BBEQ should be BNE
CLabels are missing
DSUB should be SUBS to set flags
Step-by-Step Solution
Solution:
  1. Step 1: Check flag setting instruction

    SUB does not update flags; SUBS updates flags needed for conditional branch.
  2. Step 2: Confirm branch condition

    BEQ depends on zero flag set by SUBS. Without SUBS, flags are not updated, so branch may fail.
  3. Final Answer:

    SUB should be SUBS to set flags -> Option D
  4. Quick Check:

    Use SUBS to update flags before BEQ [OK]
Quick Trick: Use SUBS, not SUB, to update flags for branch [OK]
Common Mistakes:
  • Using SUB without S suffix
  • Changing branch condition incorrectly
  • Ignoring flag updates

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes