Bird
0
0

Given this ARM assembly code snippet:

medium📝 Analysis Q4 of 15
ARM Architecture - Control Flow Instructions
Given this ARM assembly code snippet:
MOV R1, #4
loop:
SUBS R1, R1, #1
BNE loop

How many times will the loop execute?
AInfinite loop
B5 times
C3 times
D4 times
Step-by-Step Solution
Solution:
  1. Step 1: Analyze initial register value

    R1 starts at 4, so the loop will count down from 4.
  2. Step 2: Understand SUBS and BNE behavior

    SUBS subtracts 1 and updates flags; BNE loops while R1 not zero.
  3. Final Answer:

    4 times -> Option D
  4. Quick Check:

    Loop count = initial value 4 [OK]
Quick Trick: Loop runs as many times as initial register value [OK]
Common Mistakes:
  • Counting one extra iteration
  • Assuming infinite loop
  • Ignoring SUBS flag update

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes