Bird
0
0

Identify the mistake in this ARM assembly loop:

medium📝 Analysis Q6 of 15
ARM Architecture - Control Flow Instructions
Identify the mistake in this ARM assembly loop:
MOV R2, #10
loop:
SUB R2, R2, #1
BNE loop
AMOV should be MOVS to set flags
BSUB should be SUBS to update flags
CBNE should be BEQ for loop
DLabel 'loop' is missing colon
Step-by-Step Solution
Solution:
  1. Step 1: Understand loop condition

    BNE branches if zero flag is not set, so flags must be updated.
  2. Step 2: Check instruction usage

    SUB does not update flags; SUBS does.
  3. Step 3: Verify other options

    MOVS not needed here; label has colon; BNE is correct.
  4. Final Answer:

    SUB should be SUBS -> Option B
  5. Quick Check:

    Use SUBS to update flags for BNE [OK]
Quick Trick: Use SUBS to update flags for conditional branch [OK]
Common Mistakes:
  • Using SUB instead of SUBS
  • Confusing BNE with BEQ
  • Omitting colon in label

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes