Register Guide

RISC-V a1 / x11 Register: Argument / Return value

Function argument register 1 / return-value register 1. Passes the second argument and may be used with a0 for values returned in two argument registers.

ABI name: a1; physical register: x11.
Save rule: Caller.
Read it through its psABI role first, then inspect how each instruction reads or writes it.
Physical Name x11ABI Name a1Save Rule Caller
Role
Argument / Return value
Convention
Caller-saved
Remember This First
a* registers are caller-saved, so callees may overwrite them.
psABI Reference

Argument/return-value register

The psABI uses a0-a7 as argument registers, with a0-a1 also carrying return values. They are not callee-saved and may be overwritten by calls.

Preserved across calls: No
RISC-V psABI integer register convention
Quick Understanding & Search Notes

a1 / x11 belongs to the a0-a7 argument-register group. The psABI uses a0-a7 for arguments and a0-a1 for return values; these registers are not preserved across calls.

a0-a7 are argument registers, and a0-a1 are also used for return values.
a1 is not preserved across calls, so a callee may overwrite it.

When It Fits Best

  • - Carry function arguments before the call; a1 is the second argument register.
  • - a1 is also part of the a0-a1 return-value register pair.
  • - Read a0-a7 first as function argument registers under the psABI.

When Not To Use It This Way

  • - Do not assume a* registers keep their old values after a call.
  • - If an a* value must survive a call, save it into s* or the stack first.

What Happens Around A Call

1

a* registers are caller-saved, so callees may overwrite them.

2

After a call returns, a0 / a1 should usually be interpreted as return values, not old arguments.

3

When arguments exceed a0-a7, the extra ones go on the stack.

Arguments And Return Values

Examples explain the rule, not a complete program
addi a0, zero, 3  # first argument
addi a1, zero, 4  # second argument
call add2
# after return, a0 holds the return value

FAQ

Does a1 / x11 keep its old argument value after a call?

Do not assume so. a0-a7 are not preserved across calls, and the callee may overwrite them.

Which a registers carry return values?

The psABI uses a0-a1 for return values as well as arguments.