System access instructions provide program access to services provided by the operating system. MAL has only system access instruction: the syscall instruction. It can invoke a large number of system services by using a system call code. It is one of three kinds of interrupts, which are the gateway to the operating system.

The syscall Instruction

Instruction Operation
syscall call on operating system services

The MIPS processor supports a large number of operating system calls with a single syscall instruction. This is accomplished by using the register $v0 to indicate the particular operating system service that is needed. Thus all system calls have at least the following code.

    li      $v0, system call code
    syscall
      

An additional instruction or two may be needed before the syscall instruction to set up parameters for the system call. These instructions will load registers with the required parameters. Some system calls will return a value in a register.

System Call Codes

The table below shows some of the system call codes, parameters, and return values for the system calls provided by MIPS simulators. A real operating system would provide many more system calls.

Service Code Parameters Return Values
print_int 1 integer ($a0)
print_float 2 float ($f12)
print_double 3 double ($f12)
print_string 4 string address ($a0)
read_int 5 integer ($v0)
read_float 6 float ($f0)
read_double 7 double ($f0)
read_string 8 buffer address ($a0), length ($a1)
sbrk 9 number of bytes ($a0) address of block ($v0)
exit 10
print char 11 character ($a0)
read char 12 character ($v0)

System Call Codes

The table below shows some of the system call codes, parameters, and return values for the system calls provided by MIPS simulators. A real operating system would provide many more system calls.

Service Code Parameters Return Values
print_int 1 integer ($a0)
print_string 4 string address ($a0)
read_int 5 integer ($v0)
read_string 8 buffer address ($a0), length ($a1)
sbrk 9 number of bytes ($a0) address of block ($v0)
exit 10
print char 11 character ($a0)
read char 12 character ($v0)

A system call is one of three ways that operating system services can be invoked. Generally, the mechanisms for invoking the operating system are called interrupts. They are the gateways to the operating system.

Modern computers will go into a special mode called system mode when they handle an interrupt. In system mode, the computer can do things that it cannot do in the normal mode, called user mode. It may be able to execute special instructions, or it may be able to access parts of memory that are inaccessible in user mode. System mode is the foundation of operating system security.

The three types of interrupts are