added a few operations and expanded standard library

This commit is contained in:
2024-08-18 17:10:32 +03:00
parent 30e2c565fb
commit 86dbe8eb0a
3 changed files with 51 additions and 3 deletions

View File

@@ -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:"