From 8fd0a145947011f113abaab245e35f1adfb6eb48 Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Fri, 4 Feb 2022 06:16:18 -0500 Subject: Allow `builtins.c` to inject constants into program, use for syscalls We can now directly expose the `syscallN()` APIs to the program and define the `open()`, `write()` etc syscalls in the stdlib. This simplifies the implementation a decent bunch :^) --- src/generator.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/generator.c') diff --git a/src/generator.c b/src/generator.c index 2fb89b7..5da0748 100644 --- a/src/generator.c +++ b/src/generator.c @@ -3,6 +3,7 @@ */ #include "generator.h" +#include "utils.h" #include #include #include @@ -17,10 +18,7 @@ static Node *defer_stack[DEFER_STACK_SIZE]; static i64 defer_stack_count = 0; void generate_syscall(i64 syscall_no, FILE *out) { -#if __APPLE__ - syscall_no += 0x2000000; -#endif - fprintf(out, " mov rax, %lld\n", syscall_no); + fprintf(out, " mov rax, %lld\n", get_syscall_num(syscall_no)); fprintf(out, " syscall\n"); } -- cgit v1.2.3