Register usage

Table 8 shows the registers available on MIPS.


Table 8: MIPS register summary
    CALLEE
REGISTER USAGE SAVE
$0 Always zero n/a
$1/$at assemb temp NO
$2-$3 integer return NO
$4-$11 1$^{\rm st}$ 8 iargs NO
$12-$15 scratch NO
$16-$23 saved regs YES
$24-$25 scratch NO
$26-$27 reserved for kernel n/a
$28 ($gp) global pointer YES
$29 ($sp) stack pointer YES
$30 optional frame ptr YES
$31 return address NO
Floating Point Registers for -64
$f0,$f2 fp func return vals NO
$f1,$f3 scratch NO
$f4-$f11 scratch NO
$f12-$f19 1$^{\rm st}$ 8 fp args NO
$f20-$f23 scratch NO
$f24-$f31 scratch YES
Floating Point Registers for -n32
$f0,$f2 fp func return vals NO
$f1,$f3 scratch NO
$f4-$f11 scratch NO
$f12-$f19 1$^{\rm st}$ 8 fp args NO
$f21,23,25,27,29,31 scratch NO
$f20,22,24,26,28,30 scratch YES


Note that in parameter passing, you can only pass 8 args in registers, regardless of what type, and args always consume a register of the correct type, and cause a skip of the other type. So, here's the register passing of a simple routine with mixed arguments:

//          $f12    $5       $f14     $7
void bob(float s, int i, double d, int k);

Clint Whaley 2012-07-10