Bird
0
0

Given the ARM assembly snippet:

medium📝 Analysis Q13 of 15
ARM Architecture - Control Flow Instructions
Given the ARM assembly snippet:
SUBS R0, R1, R2
BEQ equal_label
BNE notequal_label

If R1 equals R2, which label will the program jump to?
Aequal_label
Bnotequal_label
CNo jump, continue sequentially
DUndefined behavior
Step-by-Step Solution
Solution:
  1. Step 1: Understand the SUBS instruction effect on flags

    SUBS subtracts R2 from R1, updates flags including zero flag if result is zero.
  2. Step 2: Check condition when R1 equals R2

    If R1 equals R2, subtraction result is zero, so zero flag is set.
  3. Step 3: Determine which branch executes

    BEQ branches if zero flag set, so program jumps to equal_label.
  4. Final Answer:

    equal_label -> Option A
  5. Quick Check:

    Equal inputs set zero flag, BEQ jumps [OK]
Quick Trick: If subtraction zero, BEQ jumps to equal_label [OK]
Common Mistakes:
  • Choosing BNE which jumps if zero flag clear
  • Assuming no jump happens on equality
  • Confusing SUBS with non-flag updating SUB

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes