Syscall ABI

The InstantOS system-call convention and the instantos stdlib modules.

InstantOS uses its own syscall register convention. @syscall(num, a1..a5) on the x86_64_instantos target lowers to:

RegisterMeaning
raxsyscall number
rbxarg 1
r10arg 2
rdxarg 3
r8arg 4
r9arg 5

The result comes back in rax. (This differs from Linux, which uses rdi/rsi/rdx/r10/r8/r9.)

Use the stdlib wrappers

Rather than raw @syscall, use the instantos modules:

module main

import instantos::io

fun main() -> i32 {
    io.println("hello from InstantOS")
    return 0
}
  • instantos::sysexit, write, read, open, close, getpid, seek, yield_now, sleep_ms, plus nr_*() syscall-number accessors.
  • instantos::ioprint, println, print_int, read_stdin.
  • instantos::memmap, map_rw, unmap, protect.

Next: building for InstantOS.