Bird
0
0

Why does this ARM assembly loop cause an infinite loop?

medium📝 Analysis Q7 of 15
ARM Architecture - Control Flow Instructions
Why does this ARM assembly loop cause an infinite loop?
MOV R4, #2
loop:
ADD R4, R4, #1
BNE loop
ASUBS instruction missing to update flags
BMOV instruction is incorrect
CLabel syntax is wrong
DADD instruction should be SUB
Step-by-Step Solution
Solution:
  1. Step 1: Understand flag updates for branching

    BNE depends on condition flags set by instructions like SUBS.
  2. Step 2: Identify missing flag update

    ADD does not update flags here, so BNE always branches causing infinite loop.
  3. Final Answer:

    SUBS instruction missing to update flags -> Option A
  4. Quick Check:

    Branch needs flag update instruction [OK]
Quick Trick: Use SUBS to update flags for BNE to work [OK]
Common Mistakes:
  • Assuming ADD updates flags
  • Blaming label syntax
  • Confusing MOV with flag update

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes