Bird
0
0

Analyze the following ARM assembly snippet:

medium📝 Analysis Q5 of 15
ARM Architecture - Control Flow Instructions
Analyze the following ARM assembly snippet:
CMP R1, #0
BEQ zero_case
MOV R0, #10
B done
zero_case:
MOV R0, #20
done:
What is the value of R0 if R1 equals 0?
A0
B20
C10
DUndefined
Step-by-Step Solution
Solution:
  1. Step 1: Compare R1 with zero

    R1 is 0, so zero flag is set by CMP.
  2. Step 2: Branch if equal

    BEQ jumps to 'zero_case' label.
  3. Step 3: Execute MOV at zero_case

    MOV R0, #20 sets R0 to 20.
  4. Final Answer:

    R0 will be 20 -> Option B
  5. Quick Check:

    R1=0 triggers BEQ, R0=20 [OK]
Quick Trick: BEQ jumps to zero_case setting R0=20 when R1=0 [OK]
Common Mistakes:
  • Choosing MOV R0, #10 ignoring branch
  • Assuming R0 remains 0
  • Thinking branch is unconditional

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes