RARS System Calls

Output (Printing) System Calls

Usagea7 NumberArgumentsReturns
Print Integer1a0 = integer to printNothing
Print Float2fa0 = 32-bit float to printNothing
Print Double3fa0 = 64-bit float to printNothing
Print String4a0 = address of NULL-terminated stringNothing
Print Integer as Hex34a0 = integer to print as hexNothing
Print Integer as Binary35a0 = integer to printNothing

Input (Reading) System Calls

Usagea7 NumberArgumentsReturns
Read Integer5Nothinga0 = integer that was read
Read Float6Nothingfa0 = 32-bit float that was read
Read Double7Nothingfa0 = 64-bit float that was read
Read String8a0 = address of string buffer
a1 = maximum number of bytes to read
Nothing

Heap System Call

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.

Usagea7 NumberArgumentsReturns
Allocate9a0 = number of bytes to allocatea0 = 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.

Termination System Calls

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.

Usagea7 NumberArgumentsReturns
Exit (DO NOT USE)10NothingNothing
Exit293a0 = exit numberNothing