Bird
0
0

Consider a subroutine that takes 5 integer arguments. According to AAPCS, how are these arguments passed?

medium📝 Analysis Q13 of 15
ARM Architecture - Subroutines and Stack
Consider a subroutine that takes 5 integer arguments. According to AAPCS, how are these arguments passed?
AAll 5 arguments passed in r0 to r4
BFirst 4 in r0 to r3, 5th on the stack
CAll 5 arguments passed on the stack
DFirst 3 in r0 to r2, remaining 2 in r3 and r4
Step-by-Step Solution
Solution:
  1. Step 1: Recall argument passing rules for more than 4 arguments

    AAPCS passes the first 4 arguments in registers r0 to r3. Any additional arguments are passed on the stack.
  2. Step 2: Apply to 5 arguments

    For 5 arguments, the first 4 go into r0-r3, and the 5th argument is placed on the stack.
  3. Final Answer:

    First 4 in r0 to r3, 5th on the stack -> Option B
  4. Quick Check:

    Extra args beyond 4 go on stack [OK]
Quick Trick: Only first 4 args in registers; rest go on stack [OK]
Common Mistakes:
  • Assuming all args fit in registers
  • Passing 5th arg in r4 incorrectly
  • Ignoring stack usage for extra args

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More ARM Architecture Quizzes