Bird
0
0

Consider this ARM assembly loop snippet:

medium📝 Analysis Q13 of 15
ARM Architecture - Control Flow Instructions
Consider this ARM assembly loop snippet:
MOV R0, #3
loop:
SUBS R0, R0, #1
BNE loop
How many times will the instructions inside the loop execute?
A2 times
BInfinite loop
C3 times
D4 times
Step-by-Step Solution
Solution:
  1. Step 1: Analyze initial register value

    R0 starts at 3, so the loop counter is 3.
  2. Step 2: Understand SUBS and BNE behavior

    SUBS subtracts 1 and updates flags; BNE branches if result is not zero, so loop runs while R0 > 0.
  3. Final Answer:

    3 times -> Option C
  4. Quick Check:

    Loop runs 3 times as R0 counts down from 3 [OK]
Quick Trick: Loop runs as many times as initial counter value [OK]
Common Mistakes:
  • Counting one less iteration
  • Assuming infinite loop
  • Confusing BNE with BEQ

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes