ISA & Assembly
In the standard RISC-V calling convention, which registers pass integer arguments and return values?
- AArguments in s0-s7; return value in ra
- BArguments in a0-a7; return value in a0 (and a1)
- CAll arguments on the stack; return value in sp
Show answer and explanation
Answer: B. Arguments in a0-a7; return value in a0 (and a1)
In the standard RISC-V calling convention, up to eight integer arguments are passed in a0-a7 (x10-x17), and the return value comes back in a0, or in a0 and a1 for values such as 64-bit integers on RV32. Passing through registers, which are faster than memory, keeps call overhead low. Arguments beyond eight go on the stack. Floating-point arguments use fa0-fa7.
- A. s registers are saved registers; ra is the return address.
- B. Correct. The a stands for argument.
- C. Up to eight go in registers; sp is the stack position.