The C compiler will follow the standard calling conventions, though may have some options for different behavior.
Generally speaking first int
or pointer type parameter goes in $a0
, second in $a1
, third in $a2
, fourth in $a3
.? int
or pointer type return values goes into $v0
.
The order of populating the registers doesn't matter as long as the right values have been placed in the right registers before the call instruction (jal
).? So, you can first put argument 2 in $a1
, then next put argument 1 in $a0
, and it will still work the same.
For more information see here: https://www.dyncall.org/docs/manual/manualse11.html and scroll down to your architecture & ABI.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…