Last modified on 8 March 2013, at 06:06

MIPS Assembly/System Instructions

This page is going to discuss some of the more advanced MIPS instructions that might not be used in every-day programming tasks.

Instruction:
syscall
type:
R Type

syscall allows you to call upon the basic system functions. To use syscall, first set $v0 with the code of the function you want to call, then use syscall. The exact codes available may depend on the specific system used, but the following are examples of common sytem calls.

code call arguments results
1 print integer $a0 = integer to print
2 print float $f12 = float to print
3 print double $f12 = float to print
4 print string $a0 = address of beginning of string
5 read integer integer stored in $v0
6 read float float stored in $f0
7 read double double stored in $f0
8 read string $a0 = pointer to buffer, $a1 = length of buffer string stored in buffer
9 sbrk (allocate memory buffer) $a0 = size needed $v0 = address of buffer
10 exit
Example: printing the number 12
li $a0, 12→;loads the number we want printed, 12 in this case, into the first argument register
li $v0, 1→;stores the code for the print integer call into $v0
syscall→;Executes system call


Instruction:
break
type:
R Type
Instruction:
sync
type:
R Type
Instruction:
cache
type:
R Type
Instruction:
pref
type:
R Type