From 2d16419b1556917b7c73d5dffe546124bb8ed534 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Wed, 24 Jul 2019 13:21:09 +0100 Subject: [PATCH] Fix static string addressing --- codegen.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codegen.scm b/codegen.scm index 5303b49..25d99a1 100644 --- a/codegen.scm +++ b/codegen.scm @@ -213,7 +213,7 @@ ('bool-literal (emit "movq $~a, %rax" (if e 1 0))) ('int-literal (emit "movq $~a, %rax" e)) - ('static-string (emit "movq $~a, %rax" (cadr e))) ; move label + ('static-string (emit "movq (~a), %rax" (cadr e))) ; move label (else (error #f "don't know how to codegen this")))) @@ -279,7 +279,7 @@ (let ((transformed (extract program))) (cons strings transformed)))) -(define (codegen-string-data s) +(define (emit-string-data s) (emit "~a:" (car s)) (emit "\t.string \"~a\"" (cdr s))) @@ -350,7 +350,7 @@ (emit "\t.data") - (for-each codegen-string-data strings))) + (for-each emit-string-data strings))) (define (compile-to-binary program output) (when (not (eq? (typecheck program) 'int)) (error #f "not an int")) -- 2.30.2