Syscalls

Service $v0 Code Argument 1 Argument 2 Argument 3 Result
print_int 1 $a0 - integer
print_float 2 $f12 - float
print_double 3 $f12 - double
print_string 4 ($a0) - string
read_int 5 $v0 - integer
read_float 6 $f0 - float
read_double 7 $f0 - double
read_string 8 ($a0) - buffer $a1 - length
sbrk 9 $a0 - number of bytes $v0 - address of allocation
exit 10 exit(0)
print_character 11 $a0 - char
read_character 12 $v0 - char
open 13 ($a0) - filename $a1 - flags $a2 - mode $v0 - file descriptor
opens a file, man 2 open for more info
read 14 $a0 - file descriptor ($a1) - buffer $a2 - length $v0 - chars read
man 2 read for more info
write 15 $a0 - file descriptor $a1 - flags $a2 - mode $v0 - chars written
man 2 write for more info
close 16 $a0 - file descriptor File closed :)
exit2 17 $a0 - return code exit($a0)

Registers

Register A.K.A. Use ... Register A.K.A. Use
$0 zero Always = 0 $24, $25 $t8, $t9 Temporary
$1 $at Assembler Temporary (reserved) $26, $27 $k0, $k1 Kernel (reserved for OS)
$2, $3 $v0, $v1 Value returned by a subroutine $28 $gp Global Pointer
$4-$7 $a0-$a3 Arguments to a subroutine $29 $sp Stack Pointer
$8-$15 $t0-$t7 Temporary (not preserved across a function call) $30 $fp Frame Pointer
$16-$23 $s0-$s7 Saved registers (preserved across a function call) $31 $ra Return Address