-
-
Notifications
You must be signed in to change notification settings - Fork 0
Trap Handlers
NOTE: These docs will apply starting in 0.4.x. At time of writing, the current version is 0.3.60329 and these docs are not accurate.
Zarem utilizes "Trap Handlers" to take care of syscalls, traps, execptions, etc when in hosted emulation. The trap handler can be changed by modifying the TrapHost value under the emulator config in a .zrmp project file. If you remove the TrapHost entirely, the emulator will run as a fully emulated machine, where traps and exceptions will jump to trap/exception vector.
Zarem has a collection of provided trap handlers that can be selected from. This is primarily to retain backwards compatibility with other emulator systems. For new projects the Zarem Trap Handler is recommended.
To use the Zarem trap handler, set the TrapHost value to Zarem.
This trap handler works with MIPS and RISC-V.
| Architecture | ID Register | Argument Registers | Result registers | Float Arg Register | Float Result Register |
|---|---|---|---|---|---|
| MIPS | $v0 | $a0 - $a2 | $v0 - $v1 | $f12 | $f0 |
| RISC-V | a7 | a0 - a2 | a0 - a1 | f12 | f0 |
| Operation | Syscall ID | Description | Arguments & Results |
|---|---|---|---|
| Print Integer | 1 | Prints an integer | arg0 - The integer to print |
| Read Integer | 2 | Reads an integer | ret0 - The integer read |
| Print String | 3 | Prints a null-terminated string |
arg0 - Address of null-terminated string arg2 - The encoding of the string* |
| Read String | 4 | Reads a null-terminated string to an input buffer |
arg0 - The buffer's address arg1 - The buffer's size arg2 - The encoding of the string* |
| Print Float | 5 | Prints a single-precision floating-point value | farg - The float to print |
| Read Float | 6 | Reads a single-precision floating-point value | fret - The float read |
| Print Double | 7 | Prints a double-precision floating-point value | farg - The double to print |
| Read Double | 8 | Reads a double-precision floating-point value | fret - The double read |
| Exit | 9 | Ends the program |
*Encoding: 0-ascii, 1-utf8, 2-utf16
Not currently supported. Plug-in system in the works.