Index
Related
Introduction
Definition
A system call (syscall) in MIPS assembly is a way for a program to request a service from the operating system.
- The syscall instruction is used, with the type of call specified in the
$v0
register. Arguments for the syscall are placed in registers$a0
,$a1
,$a2
, and$a3
as needed. Results are usually returned in$v0
and sometimes$v1
.
We can categorize the system calls (syscalls) in MIPS assembly in 3 category:
-
Print Syscalls: These syscalls are used to output data. They can print different types of data including integers, floating-point numbers, and strings. The data to be printed is typically passed in a specific register (like
$a0
or$f12
). -
Read Syscalls: These syscalls are used to read input data from the user. They can read different types of data including integers, floating-point numbers, and strings. The read data is typically returned in a specific register (like
$v0
or$f0
), or stored in a buffer whose address is passed in a specific register (like$a0
). -
Exit Syscall: This syscall is used to terminate the program. It doesn’t require any arguments and doesn’t return any result.
Note
Remember, these are just some of the basic syscalls. MIPS provides many other syscalls for various purposes, such as file I/O, memory allocation, and process control.
Print Syscalls
Print syscalls are used to output data. They can print different types of data including integers, floating-point numbers, and strings. The data to be printed is typically passed in a specific register (like $a0
or $f12
).
Print integer
Print float
Print string
Read Syscalls
Read syscalls are used to read input data from the user. They can read different types of data including integers, floating-point numbers, and strings. The read data is typically returned in a specific register (like $v0
or $f0
), or stored in a buffer whose address is passed in a specific register (like $a0
).
Read integer
Read float
Read string
Exit Syscall
The exit syscall is used to terminate the program. It doesn’t require any arguments and doesn’t return any result.
Exit