It seems like you're asking about the calling convention (which registers / where on the stack arguments & return values are stored before branching to a function).
It depends a lot on the target ABI and even then it's fairly complicated. For ARMv5/6/7, the Procedure call standard [pdf] is your bible.
You should really read the whole thing if you actually care, but here are the parts you're interested in:
- A Composite Type not larger than 4 bytes is returned in r0.
- A Composite Type larger than 4 bytes, or whose size cannot be determined statically by both caller and callee, is stored in memory at an address passed as an extra argument when the function was called.
- If the subroutine is a function that returns a result in memory, then the address for the result is placed in r0 and the NCRN is set to r1.
- If the size in words of the argument is not more than r4 minus NCRN, the argument is copied into core registers, starting at the NCRN
Also
- For C++, an implicit
this
parameter is passed as an extra argument that immediately precedes the first user argument.
So in most cases the address of a returned composite value is in $r0
and the implicit this
pointer is in $r1
.