SPIM provides a small set of operating
system-like services through the system call (syscall)
instruction. To request a service, a program loads the system
call code (see table below) into register $v0 and arguments into
registers $a0...$a3 (or $f12 for floating-point values). System
calls that return values put their results in register $v0 (or
$f0 for floating-point results).
Service Name |
System call code |
Arguments |
Results |
Print Integer |
1 |
$a0 = integer |
|
Print Float |
2 |
$f12 = float |
|
Print Double |
3 |
$f12 = double |
|
Print String |
4 |
$a0 = string |
|
Read Integer |
5 |
|
Integer value in $v0 |
Read Float |
6 |
|
Floating-Point value in $f0 |
Read Double |
7 |
|
Double in $f0 |
Read String |
8 |
$a0 = Buffer, $a1 = length |
|
sbrk |
9 |
$a0 = amount |
Address in $v0 |
exit |
10 |
|
Sbrk returns a pointer to a block of memory containing n
additional bytes. Exit stops a program from running.