Просмотр исходного кода

Implement integer->char and char->integer

Lucas Stadler лет назад: 8
Родитель
Сommit
53cebb22ad
1 измененных файлов с 9 добавлено и 2 удалено
  1. 9 2
      scm/inc/compiler.scm

+ 9 - 2
scm/inc/compiler.scm

@ -38,7 +38,14 @@
38 38
     (case (primcall-op x)
39 39
       ((add1)
40 40
        (emit-expr (primcall-operand1 x))
41
        (emit "addl $~a, %eax" (immediate-rep 1)))))))
41
        (emit "addl $~a, %eax" (immediate-rep 1)))
42
       ((integer->char)
43
        (emit-expr (primcall-operand1 x))
44
        (emit "shl $6, %eax")
45
        (emit "xorl $15, %eax"))
46
       ((char->integer)
47
        (emit-expr (primcall-operand1 x))
48
        (emit "shrl $6, %eax"))))))
42 49
43 50
(define (compile-program x)
44 51
  (display ".globl scheme_entry\n\n")
@ -47,4 +54,4 @@
47 54
  (emit-expr x)
48 55
  (emit "ret"))
49 56
50
(compile-program '(add1 41))
57
(compile-program '(char->integer #\y))