MIPS syscall is a special instruction used in MIPS instruction set to do a service. It is a “Software Interrupt ” to invoke OS for an action. MIPS syscall instruction provides many services. It may be to print a number or to terminate a program.
There is almost 39 MIPS syscall service. These services will be explained in details below. See the complete table to understand basic functionalities of syscall services.
MIPS Syscall Services Table
| Service | Service Code | Arguments | Result |
|---|---|---|---|
| print_integer | 1 | $a0 =int value | |
| print_float | 2 | $f12 = float value | |
| print_double | 3 | $f12 = double value | |
| print_string | 4 | $a0 = address of string | |
| read_integer | 5 | $v0 contains integer to read | |
| read_float | 6 | $f0 contains float to read | |
| read_double | 7 | $f0 contains double to read | |
| read_string | 8 | $a0 = address of input buffer $a1 = max characters to read |
See note below table |
| sbrk | 9 | $a0 = total bytes to allocate | $v0 = address of allocated memory |
| exit (terminate program) | 10 | ||
| print_character | 11 | $a0 = character to print | See note below table |
| read_character | 12 | $v0 = character to read | |
| open_file | 13 | $a0 = string containing filename $a1 = flags $a2 = mode |
$v0 = file descriptor |
| read_from_file | 14 | $a2 = maximum number of characters to read $a1 = address of input buffer $a0 = file descriptor |
$v0 = number of characters read |
| write_to_file | 15 | $a2 = number of characters to write $a1 = address of output buffer $a0 = file descriptor |
$v0 = number of characters written |
| close_file | 16 | $a0 = file descriptor | |
| exit2 (terminate_with value) | 17 | $a0 = termination result | |
| time (system_time) | 30 | $a0 = low order 32-bits of system time $a1 = high order 32-bits of system time. |
|
| MIDI_out | 31 | $a0 = pitch (0-127) $a1 = duration in milliseconds $a2 = instrument (0-127) $a3 = volume (0-127) |
Generate tone and return immediately. |
| sleep | 32 | $a0 = length of time to sleep in milliseconds. | Causes the MARS Java thread to sleep for (at least) the specified number of milliseconds. |
| MIDI_out_synchronous | 33 | $a0 = pitch (0-127) $a1 = duration in milliseconds $a2 = instrument (0-127) $a3 = volume (0-127) |
Generate tone and return upon tone completion. |
| print_integer_in_ hexadecimal | 34 | $a0 = integer to print | |
| print_integer_in_binary | 35 | $a0 = integer to print | |
| print_integer_unsigned | 36 | $a0 = integer to print | |
| (not used) | 37-39 | ||
| set_seed | 40 | $a0 = i.d. of pseudorandom number generator (any int). $a1 = seed for corresponding pseudorandom number generator. |
No values are returned. Sets the seed of the corresponding underlying Java pseudorandom number generator (java.util.Random). |
| random_int | 41 | $a0 = i.d. of pseudorandom number generator (any int). | $a0 contains the next pseudorandom, uniformly distributed int value from this random number generator’s sequence. |
| random_int_range | 42 | $a0 = i.d. of pseudorandom number generator (any int). $a1 = upper bound of range of returned values. |
$a0 contains pseudorandom, uniformly distributed int value in the range 0 <= [int] < [upper bound], drawn from this random number generator’s sequence. |
| random_float | 43 | $a0 = i.d. of pseudorandom number generator (any int). | $f0 contains the next pseudorandom, uniformly distributed float value in the range 0.0 <= f < 1.0 from this random number generator’s sequence. |
| random_double | 44 | $a0 = i.d. of pseudorandom number generator (any int). | $f0 contains the next pseudorandom, uniformly distributed double value in the range 0.0 <= f < 1.0 from this random number generator’s sequence. |
| (not used) | 45-49 | ||
| Confirm_Dialog | 50 | $a0 = address of null-terminated string that is the message to user | $a0 contains value of user-chosen option 0: Yes 1: No 2: Cancel |
| Input_Dialog_Int | 51 | $a0 = address of null-terminated string that is the message to user | $a0 contains int read $a1 contains status value 0: OK status 1: input data cannot be correctly parsed 2: Cancel was chosen 3: OK was chosen but no data had been input into field |
| Input_Dialog_Float | 52 | $a0 = address of null-terminated string that is the message to user | $f0 contains float read $a1 contains status value 0: OK status -1: input data cannot be correctly parsed -2: Cancel was chosen -3: OK was chosen but no data had been input into field |
| Input_Dialog_Double | 53 | $a0 = address of null-terminated string that is the message to user | $f0 contains double read $a1 contains status value 0: OK status -1: input data cannot be correctly parsed -2: Cancel was chosen -3: OK was chosen but no data had been input into field |
| Input_Dialog_String | 54 | $a0 = address of null-terminated string that is the message to user $a1 = address of input buffer $a2 = maximum number of characters to read |
See Service 8 note below table $a1 contains status value 0: OK status. Buffer contains the input string. -2: Cancel was chosen. No change to buffer. -3: OK was chosen but no data had been input into field. No change to buffer. -4: length of the input string exceeded the specified maximum. Buffer contains the maximum allowable input string plus a terminating null. |
| Message_Dialog | 55 | $a0 = address of string that is the message to user $a1 = the type of message to be displayed: 0: error message, indicated by Error icon 1: information message, indicated by Information icon 2: warning message, indicated by Warning icon 3: question message, indicated by Question icon other: plain message (no icon displayed) |
N/A |
| Message_Dialog_Int | 56 | $a1 = int value to display in string form after the first string $a0 = address of null-terminated string that is an information-type message to user |
N/A |
| Message_Dialog_Float | 57 | $a0 = address of null-terminated string that is an information-type message to user $f12 = float value to display in string form after the first string |
N/A |
| Message_Dialog_Double | 58 | $a0 = address of null-terminated string that is an information-type message to user $f12 = double value to display in string form after the first string |
N/A |
| Message_Dialog_String | 59 | $a1 = address of null-terminated string to display after the first string $a0 = address of null-terminated string that is an information-type message to user |
N/A |
If you have still any queries ask me in the comment box. Comment to show me that you are alive!
