summaryrefslogtreecommitdiff
path: root/codegen.lisp
diff options
context:
space:
mode:
authormRnea <akannemre@gmail.com>2024-08-18 17:10:32 +0300
committermRnea <akannemre@gmail.com>2024-08-18 17:10:32 +0300
commit86dbe8eb0abe2a2d5f0f687ff190c4e9f547d126 (patch)
tree734e1ef7a4a2fe480a6c6b19e8b75b6f25e8fe1c /codegen.lisp
parent30e2c565fbe48747760b3d32515b756b5bb2a2d7 (diff)
added a few operations and expanded standard library
Diffstat (limited to 'codegen.lisp')
-rw-r--r--codegen.lisp14
1 files changed, 13 insertions, 1 deletions
diff --git a/codegen.lisp b/codegen.lisp
index 1e8c364..c74b4c0 100644
--- a/codegen.lisp
+++ b/codegen.lisp
@@ -313,7 +313,8 @@
;; ( -- a)
(defop (push-int a) (:lex nil :targets :nasm)
- ("push ~d" a))
+ ("mov rax, ~a" a)
+ ("push rax"))
(defop (push-str len addr str) (:lex nil :targets :nasm)
(progn (:write ("push ~d" len)
@@ -359,6 +360,17 @@
(:write ("pop ~a" (aref call-regs i)))
(finally (:write "syscall"))))
+(defop divmod (:targets :nasm)
+ "mov rdx, 0"
+ (rax rcx -- )
+ "div rcx"
+ (-- rax rdx))
+
+(defop * (:targets :nasm)
+ (rbx rax -- )
+ "mul rbx"
+ ( -- rax))
+
(defun gen-dump (str)
(format str "~{~a~%~}"
'("dump:"