Bird
0
0

You want to implement an if-else in ARM assembly that sets R0 to 100 if R1 is less than 50, else sets R0 to 200. Which sequence correctly implements this?

hard📝 Application Q8 of 15
ARM Architecture - Control Flow Instructions
You want to implement an if-else in ARM assembly that sets R0 to 100 if R1 is less than 50, else sets R0 to 200. Which sequence correctly implements this?
ACMP R1, #50\nBLT less_than\nMOV R0, #200\nB end\nless_than:\nMOV R0, #100\nend:
BCMP R1, #50\nBGT less_than\nMOV R0, #100\nB end\nless_than:\nMOV R0, #200\nend:
CCMP R1, #50\nBEQ less_than\nMOV R0, #100\nB end\nless_than:\nMOV R0, #200\nend:
DCMP R1, #50\nBNE less_than\nMOV R0, #200\nB end\nless_than:\nMOV R0, #100\nend:
Step-by-Step Solution
Solution:
  1. Step 1: Understand condition

    Set R0=100 if R1 < 50, else R0=200.
  2. Step 2: Match branch instruction

    BLT branches if less than, so BLT less_than is correct.
  3. Step 3: Verify else part

    If not less, MOV R0, #200 runs, then branch to end.
  4. Final Answer:

    Option A correctly implements the if-else logic -> Option A
  5. Quick Check:

    BLT for less than, else MOV 200 [OK]
Quick Trick: Use BLT for less than condition in ARM if-else [OK]
Common Mistakes:
  • Using BGT instead of BLT
  • Confusing BEQ with less than
  • Misplacing MOV instructions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes