Bird
0
0

Consider this ARM assembly snippet:

medium📝 Analysis Q13 of 15
ARM Architecture - Control Flow Instructions
Consider this ARM assembly snippet:
BL subroutine
MOV R0, #0
B end
subroutine:
MOV R0, #1
BX LR
end:

What value will register R0 hold after execution?
A1
B0
CUndefined
DThe program will crash
Step-by-Step Solution
Solution:
  1. Step 1: Follow the BL instruction

    The BL instruction jumps to subroutine and saves the return address (address of MOV R0, #0) in LR.
  2. Step 2: Execute subroutine and return

    Inside subroutine, MOV R0, #1 sets R0 to 1, then BX LR returns to MOV R0, #0.
  3. Step 3: Continue after BL

    MOV R0, #0 overwrites R0 to 0, followed by B end.
  4. Final Answer:

    0 -> Option B
  5. Quick Check:

    Post-return MOV R0, #0 overwrites subroutine value [OK]
Quick Trick: BL returns to next instr MOV R0, #0 overwriting subroutine's R0=1 [OK]
Common Mistakes:
  • Assuming R0 remains 1 after subroutine return
  • Misidentifying the BL return address
  • Thinking instructions after BL are skipped

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes