diff options
| author | Mustafa Quraish <[email protected]> | 2022-02-04 06:16:18 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-02-05 08:56:15 -0500 |
| commit | 8fd0a145947011f113abaab245e35f1adfb6eb48 (patch) | |
| tree | 957bcf38c33d697c2fe5dd997bc294ae28adcaec /src/generator.c | |
| parent | Update README.md (diff) | |
| download | cup-8fd0a145947011f113abaab245e35f1adfb6eb48.tar.xz cup-8fd0a145947011f113abaab245e35f1adfb6eb48.zip | |
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 :^)
Diffstat (limited to 'src/generator.c')
| -rw-r--r-- | src/generator.c | 6 |
1 files changed, 2 insertions, 4 deletions
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 <stdlib.h> #include <string.h> #include <assert.h> @@ -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"); } |