X-Git-Url: https://git.lukelau.me/?p=scheme.git;a=blobdiff_plain;f=codegen.scm;h=968a428cd2f442bf820ea37c0a01a3e92047e4b5;hp=a19b53df53fa239bc700a5d06cccfd86298d7601;hb=9ee429534c3011b0ed413dc01e81db13f71ac884;hpb=25a4c23da2d76f3bb951d01b1c3175be80441a0a diff --git a/codegen.scm b/codegen.scm index a19b53d..968a428 100644 --- a/codegen.scm +++ b/codegen.scm @@ -290,12 +290,14 @@ (for-each codegen-lambda lambdas) - (emit ".globl _scheme_entry") - (emit "_scheme_entry:") + (emit ".globl _start") + (emit "_start:") + (codegen-expr xform-prog 0 '()) - - (amd64-abi - (lambda () (codegen-expr xform-prog 0 '()))))) + ; exit syscall + (emit "mov %rax, %rdi") + (emit "mov $60, %rax") + (emit "syscall"))) (define (compile-to-binary program output) (when (not (eq? (typecheck program) 'int)) (error #f "not an int")) @@ -303,4 +305,4 @@ (when (file-exists? tmp-path) (delete-file tmp-path)) (with-output-to-file tmp-path (lambda () (codegen program))) - (system (format "clang -fomit-frame-pointer /tmp/a.s rts.c -o ~a" output)))) + (system (format "clang -nostdlib /tmp/a.s -o ~a" output))))