Lecture 8: System calls

Preparation

Recap

Exceptions

Device interrupts

Software interrupts

#include <sys/syscall.h>
#include <unistd.h>
void _start(void)
{
        int fd = 1;
        char buf[] = "hello world!\n";
        size_t count = sizeof(buf) - 1;
        asm volatile ("int $0x80"
                : /* ignore output */
                : "a"(__NR_write), "b"(fd), "c"(buf), "d"(count)
                : "cc", "edi", "esi", "memory"
        );
        asm volatile ("int $0x80"
                : /* no output */
                : "a"(__NR_exit), "b"(0)
        );
}

Discussions