forked from kvakil/venus
-
Notifications
You must be signed in to change notification settings - Fork 23
Environmental Calls
Stephan K edited this page Sep 19, 2018
·
6 revisions
To use an environmental call, load the ID into register a0
, and load any arguments into a1
- a7
. Any return values will be stored in argument registers.
The following environmental calls are currently supported.
ID (a0 ) |
Name | Description |
---|---|---|
1 | print_int | prints integer in a1
|
4 | print_string | prints the null-terminated string whose address is in a1
|
9 | sbrk | allocates a1 bytes on the heap, returns pointer to start in a0
|
10 | exit | ends the program |
11 | print_character | prints ASCII character in a1
|
13 | openFile | Opens a file WIP |
14 | readFile | Read a file WIP |
15 | writeFile | Write a file WIP |
16 | closeFile | Closes a file WIP |
17 | exit2 | ends the program with return code in a1
|
34 | printHex | prints hex in a1
|
The environmental calls are intended to be somewhat backwards compatible with SPIM's syscalls.
As an example, the following code prints the integer 42
to the console:
addi a0 x0 1 # print_int ecall
addi a1 x0 42 # integer 42
ecall
- Currently maintained by ThaumicMekanism
- Originally made by kvakil