URL

https://dpetersanderson.github.io/Help/SyscallHelp.html

Table

ServiceCode in $v0ArgumentsResult
print integer1$a0 = integer to print
print float2$f12 = float to print
print double3$f12 = double to print
print string4$a0 = address of null-terminated string to print
read integer5$v0 contains integer read
read float6$f0 contains float read
read double7$f0 contains double read
read string8a1 = maximum number of characters to readSee note below table
sbrk (allocate heap memory)9$a0 = number of bytes to allocate$v0 contains address of allocated memory
exit (terminate execution)10
print character11$a0 = character to printSee note below table
read character12$v0 contains character read
open file13a1 = flags
$a2 = mode
$v0 contains file descriptor (negative if error). See note below table
read from file14a1 = address of input buffer
$a2 = maximum number of characters to read
$v0 contains number of characters read (0 if end-of-file, negative if error). See note below table
write to file15a1 = address of output buffer
$a2 = number of characters to write
$v0 contains number of characters written (negative if error). See note below table
close file16$a0 = file descriptor
exit2 (terminate with value)17$a0 = termination resultSee note below table
Services 1 through 17 are compatible with the SPIM simulator, other than Open File (13) as described in the Notes below the table. Services 30 and higher are exclusive to MARS.
time (system time)30a1 = high order 32 bits of system time. See note below table
MIDI out31a1 = duration in milliseconds
a3 = volume (0-127)
Generate tone and return immediately. See note below table
sleep32$a0 = the length of time to sleep in milliseconds.Causes the MARS Java thread to sleep for (at least) the specified number of milliseconds. This timing will not be precise, as the Java implementation will add some overhead.
MIDI out synchronous33a1 = duration in milliseconds
a3 = volume (0-127)
Generate tone and return upon tone completion. See note below table
print integer in hexadecimal34$a0 = integer to printDisplayed value is 8 hexadecimal digits, left-padding with zeroes if necessary.
print integer in binary35$a0 = integer to printDisplayed value is 32 bits, left-padding with zeroes if necessary.
print integer as unsigned36$a0 = integer to printDisplayed as unsigned decimal value.
(not used)37-39
set seed40a1 = seed for corresponding pseudorandom number generator.No values are returned. Sets the seed of the corresponding underlying Java pseudorandom number generator (java.util.Random). See note below table
random int41$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. See note below table
random int range42a1 = 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. See note below table
random float43$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. See note below table