(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"))
(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))))