Register Use Conventions


On the MIPS, a register holds 32 bits. There are many registers in the processor, but only some of them are visible in assembly language. The others are used by the processor in carrying out its operations. The registers that are visible in assembly language are called general purpose registers and floating point registers. There are 32 general purpose registers.

Each general purpose register holds a 32 bit pattern. In assembly language, these registers are named $0, $1, $2, ... , $31. There are 32 floating point registers named $f0, $f1, $f2, ... , $f31. By convention (and sometimes by hardware) different registers are used for different purposes.
Register
Number
Mnemonic
Name
Conventional Use
     $0   $zero Hardwired constant 0
     $1     $at Reserved for assembler
 $2- $3 $v0-$v1 Return results from functions
 $4- $7 $a0-$a3 Used for subroutine arguments
 $8-$15 $t0-$t7 “Temporary,” not saved across a call
$16-$23 $s0-$s7 “Saved,” saved across a call
$24-$25 $t8-$t9 More temporary
$26-$27 $k0-$k1 “Kernel”—reserved for OS use
    $28     $gp Pointer to global data area
    $29     $sp Stack pointer
    $30     $fp Frame pointer
    $31     $ra Return address of subroutine

In addition to a number $0 - $31, registers have a mnemonic name (a name that reminds you of its use). For example, register $4 has the mnemonic name $a0. The table shows the 32 registers and their conventional use. Registers $0 and $31 are the only two that behave differently from the others. Register $0 is hard-wired to always contain the value 0x00000000 (all zero bits). Register $31 is automatically used by some subroutine linkage instructions to hold the return address.




      “Life would be tragic if it weren’t funny.”    
      ― Stephen Hawking