Skip to content

Commit

Permalink
comparison operators
Browse files Browse the repository at this point in the history
  • Loading branch information
tca committed Mar 10, 2015
1 parent 350e47c commit 23142a4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
28 changes: 28 additions & 0 deletions base.asm
Expand Up @@ -18,6 +18,34 @@ equal:
setz al
movzx eax, al
ret

less_than:
mov rax,[rsp+8*2]
cmp rax,[rsp+8*1]
setb al
movzx eax, al
ret
greater_than:
mov rax,[rsp+8*2]
cmp rax,[rsp+8*1]
seta al
movzx eax, al
ret
less_than_equal:
mov rax,[rsp+8*2]
cmp rax,[rsp+8*1]
setbe al
movzx eax, al
ret
greater_than_equal:
mov rax,[rsp+8*2]
cmp rax,[rsp+8*1]
setae al
movzx eax, al
ret
plus:
mov rax,[rsp+8*2]
Expand Down
4 changes: 4 additions & 0 deletions lily/compile.scm
Expand Up @@ -85,6 +85,10 @@
(define (mangle-name f)
(case f
((=) 'equal)
((<) 'less_than)
((>) 'greater_than)
((<=) 'less_than_equal)
((>=) 'greater_than_equal)
((-) 'minus)
((+) 'plus)
(else (mangle-symbol f))))
4 changes: 4 additions & 0 deletions lily/recognize.scm
Expand Up @@ -9,6 +9,10 @@

(define (parse-program program)
(let ((names (append '((= . 2)
(< . 2)
(> . 2)
(<= . 2)
(>= . 2)
(+ . 2)
(- . 2)
(* . 2)
Expand Down

0 comments on commit 23142a4

Please sign in to comment.