X-Git-Url: http://git.lukelau.me/?a=blobdiff_plain;f=codegen.scm;h=c73677325f899e064200b678182e6290d9fe6b2d;hb=6cad928374127b2fae65d7023fd31a725f4bd1d9;hp=7c1c3a150727c969a991021fd2c3470e221f573e;hpb=8519507b78d723100bca15fe0332ff99890e77fa;p=scheme.git diff --git a/codegen.scm b/codegen.scm index 7c1c3a1..c736773 100644 --- a/codegen.scm +++ b/codegen.scm @@ -46,9 +46,9 @@ (codegen-expr a si env) (emit "movq %rax, ~a(%rbp)" si) (codegen-expr b (- si wordsize) env) - (emit "subq ~a(%rbp), %rax" si) - (emit "not %rax") - (emit "andq $1, %rax")) + (emit "## ~a = ~b" a b) + (emit "cmpq ~a(%rbp), %rax" si) + (emit "sete %al")) ; 'write file handle addr-string num-bytes @@ -249,11 +249,6 @@ (emit "pop %rbp") ; restore caller's base pointer (emit "ret"))) -(define (codegen-string label) - (case target - ('darwin (emit "movq ~a@GOTPCREL(%rip), %rax" label)) - ('linux (emit "lea $~a, %rax" label)))) - (define cur-label 0) (define (fresh-label) (set! cur-label (+ 1 cur-label)) @@ -300,7 +295,8 @@ ('bool-literal (emit "movq $~a, %rax" (if e 1 0))) ('int-literal (emit "movq $~a, %rax" e)) - ('static-string (codegen-string (cadr e))) + ('static-string (emit "movq ~a@GOTPCREL(%rip), %rax" + (cadr e))) (else (error #f "don't know how to codegen this"))))