projects
/
scheme.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove C dependency, directly emit _start
[scheme.git]
/
codegen.scm
diff --git
a/codegen.scm
b/codegen.scm
index a19b53df53fa239bc700a5d06cccfd86298d7601..968a428cd2f442bf820ea37c0a01a3e92047e4b5 100644
(file)
--- a/
codegen.scm
+++ b/
codegen.scm
@@
-290,12
+290,14
@@
(for-each codegen-lambda lambdas)
(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"))
(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)))
(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))))