8 (define (compile-add xs)
11 (emit "movq %rbx, %rax")
13 (emit "addq $~a, %rbx" (car ys))
16 (emit "movq $0, %rbx")
19 (define (compile-expr e)
20 (if (and (list? e) (eq? (car e) '+))
22 (emit "movq $~a, %rax" e)))
24 (define (compile-program program)
26 (emit ".p2align 4,,15")
27 (emit ".globl _scheme_entry")
28 (emit "_scheme_entry:")
30 ; handle incoming call from C
40 (compile-expr program)
42 ; restore preserved registers
53 (define (compile-to-binary program)
54 (when (not (eq? (typecheck program) 'int)) (error #f "not an int"))
55 (let ([tmp-path "/tmp/a.s"])
56 (when (file-exists? tmp-path) (delete-file tmp-path))
57 (with-output-to-file tmp-path
58 (lambda () (compile-program program)))
59 (system "clang -fomit-frame-pointer /tmp/a.s rts.c")))