< MIPS Assembly

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 system calls.

codecallargumentsresults
1print integer$a0 = integer to print
2print float$f12 = float to print
3print double$f12 = float to print
4print string$a0 = address of beginning of string
5read integerinteger stored in $v0
6read floatfloat stored in $f0
7read doubledouble stored in $f0
8read string$a0 = pointer to buffer, $a1 = length of bufferstring stored in buffer
9sbrk (allocate memory buffer)$a0 = size needed$v0 = address of buffer
10exit
11print character$a0 = character to print
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
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.