| Usage | a7 Number | Arguments | Returns |
|---|---|---|---|
| Print Integer | 1 | a0 = integer to print | Nothing |
| Print Float | 2 | fa0 = 32-bit float to print | Nothing |
| Print Double | 3 | fa0 = 64-bit float to print | Nothing |
| Print String | 4 | a0 = address of NULL-terminated string | Nothing |
| Print Integer as Hex | 34 | a0 = integer to print as hex | Nothing |
| Print Integer as Binary | 35 | a0 = integer to print | Nothing |
| Usage | a7 Number | Arguments | Returns |
|---|---|---|---|
| Read Integer | 5 | Nothing | a0 = integer that was read |
| Read Float | 6 | Nothing | fa0 = 32-bit float that was read |
| Read Double | 7 | Nothing | fa0 = 64-bit float that was read |
| Read String | 8 | a0 = address of string buffer a1 = maximum number of bytes to read | Nothing |
Recall that the heap is managed by the operating system, and we use a function to allocate memory, either new (C++) or malloc (C). These functions boil down to a system call.
| Usage | a7 Number | Arguments | Returns |
|---|---|---|---|
| Allocate | 9 | a0 = number of bytes to allocate | a0 = memory address of allocated block |
There is no de-allocation system call. You have the heap memory for the duration of the running program. However, unlike the stack, we can ask for as many bytes as we want without considering alignment.
A program does't actually quit after main returns. When this occurs, the program goes back into assembly, which then calls the exit system call. This is how programs actually terminate. There are two exit system calls in RARS. One that takes a parameter (a7=93), and one that does not (a7=10). Do not use the one that does NOT take a parameter (a7=10). The one that does not take a parameter has a bug.
| Usage | a7 Number | Arguments | Returns |
|---|---|---|---|
| Exit (DO NOT USE) | 10 | Nothing | Nothing |
| Exit2 | 93 | a0 = exit number | Nothing |