-
Notifications
You must be signed in to change notification settings - Fork 137
MARS syscalls
Pavel Kryukov edited this page May 8, 2017
·
8 revisions
To make simulation interactive, we use system calls in the way MARS and SPIM simulators do:
| rvice | Code in $v0 | Arguments | Result |
|---|---|---|---|
| print integer | 1 | $a0 = integer to print | |
| print float | 2 | $f12 = float to print | |
| print double | 3 | $f12 = double to print | |
| print string | 4 | $a0 = address of null-terminated string to print | |
| read integer | 5 | $v0 contains integer read | |
| read float | 6 | $f0 contains float read | |
| read double | 7 | $f0 contains double read | |
| read string | 8 | $a0 = address of input buffer | See note below table |
| $a1 = maximum number of characters to read | |||
| sbrk (allocate heap memory) |
9 | $a0 = number of bytes to allocate | $v0 contains address of allocated memory |
| exit (terminate execution) |
10 | ||
| print character | 11 | $a0 = character to print | See note below table |
| read character | 12 | $v0 contains character read | |
| open file | 13 | $a0 = address of null-terminated string containing filename | $v0 contains file descriptor (negative if error). See note below table |
| $a1 = flags | |||
| $a2 = mode | |||
| read from file | 14 | $a0 = file descriptor | $v0 contains number of characters read (0 if end-of-file, negative if error). See note below table |
| $a1 = address of input buffer | |||
| $a2 = maximum number of characters to read | |||
| write to file | 15 | $a0 = file descriptor | $v0 contains number of characters written (negative if error). See note below table |
| $a1 = address of output buffer | |||
| $a2 = number of characters to write | |||
| close file | 16 | $a0 = file descriptor | |
| exit2 (terminate with value) | 17 | $a0 = termination result | See note below table |
MIPT-V / MIPT-MIPS — Cycle-accurate pre-silicon simulation.