Abstract
What is the purpose of register zero?
We can use it to assign the value of one variable to another, like
add $s0, $s1, $zero
, which is equivalent to$s0 = $s1
.
Important
$v0
and$v1
are used by functions to return values.
$a0
,$a1
,$a2
, and$a3
are used to pass arguments to functions.
$at
is used by the assembler to store temporary values for pseudo-instructions.
$t0
through$t9
are not preserved across function calls. If a function calls another function, the values in$t0
through$t9
may be overwritten when the called function returns. We can push the values in$t0
through$t9
onto the stack before calling the function and restore the values back to the registers when the called function returns.
$s0
through$s7
are preserved across functions calls!
$v0
is same as$2
!