MIPS architecture syscall instruction

Bob Jamaica picture Bob Jamaica · May 9, 2011 · Viewed 20.5k times · Source

What is the role of syscall instruction in MIPS?

Answer

Mike Kwan picture Mike Kwan · May 9, 2011

The syscall is used to request a service from the kernel. For MIPS, the service number/code must be passed in $v0 and arguments are passed in a few of the other designated registers. For example, to print we might do:

li $v0, 1
add $a0, $t0, $zero
syscall

In this case, 1 is the service code for print integer. The second instruction effectively performs a copy from $t0 to $a0 which is the designated register where the argument is held ( in this case, the integer to be printed ). A list of the services and corresponding arguments is given: http://courses.missouristate.edu/KenVollmar/Mars/Help/SyscallHelp.html