summaryrefslogtreecommitdiff
path: root/assembly.lisp
diff options
context:
space:
mode:
authormRnea <akannemre@gmail.com>2024-07-27 16:42:24 +0300
committermRnea <akannemre@gmail.com>2024-07-27 16:42:24 +0300
commitd1481f2770f363aa436db853a7c4f7616de80e50 (patch)
tree33eb9616d2d96f08aaff329be9a8f9aee65e939b /assembly.lisp
parent2d94db09901c346d1ac7f5787f89609b6ecf38dd (diff)
added memory manipulation and syscalls
Diffstat (limited to 'assembly.lisp')
-rw-r--r--assembly.lisp24
1 files changed, 24 insertions, 0 deletions
diff --git a/assembly.lisp b/assembly.lisp
index 1522643..e2b62f1 100644
--- a/assembly.lisp
+++ b/assembly.lisp
@@ -116,6 +116,30 @@
"cmovg rcx, rdx"
"push rcx")
+(defop bel ()
+ "push bel")
+
+(defop oku ()
+ "pop rax"
+ "xor rbx, rbx"
+ "mov bl, [rax]"
+ "push rbx")
+
+(defop yaz ()
+ "pop rbx"
+ "pop rax"
+ "mov [rax], bl")
+
+(defop (syscall num) ()
+ (iter (with call-regs = #("rdi" "rsi" "rdx" "r10" "r8" "r9"))
+ (initially (:write "pop rax"))
+ (for i from (- num 1) downto 0)
+ (:write ("pop ~a" (aref call-regs i)))
+ (finally (:write "syscall"))))
+
+(defun gen-header (op str)
+ (format str " ;; -- ~s --~%" op))
+
(defun gen-code (op str)
(let ((op-fn (gethash (car op) *operations*)))
(if (null op-fn)