Found a cool idea for DEFOP
This commit is contained in:
@@ -34,15 +34,23 @@
|
|||||||
,(normalize-op-list body))
|
,(normalize-op-list body))
|
||||||
(replace-write out-stream indent (car body))))))))
|
(replace-write out-stream indent (car body))))))))
|
||||||
|
|
||||||
|
;;; TODO: Turn stack operation comments to DEFOP option,
|
||||||
|
;;; which then can be used by the user as a documentation
|
||||||
|
;;; TODO: Better yet, generate the asm code directly from
|
||||||
|
;;; the stack op documentation (this seems easily doable)
|
||||||
|
|
||||||
|
;; ( -- a)
|
||||||
(defop (push a) ()
|
(defop (push a) ()
|
||||||
("push ~d" a))
|
("push ~d" a))
|
||||||
|
|
||||||
|
;; (rbx rax -- (rbx + rax))
|
||||||
(defop + ()
|
(defop + ()
|
||||||
"pop rax"
|
"pop rax"
|
||||||
"pop rbx"
|
"pop rbx"
|
||||||
"add rax, rbx"
|
"add rax, rbx"
|
||||||
"push rax")
|
"push rax")
|
||||||
|
|
||||||
|
;; (rbx rax -- (rbx - rax))
|
||||||
(defop - ()
|
(defop - ()
|
||||||
"pop rax"
|
"pop rax"
|
||||||
"pop rbx"
|
"pop rbx"
|
||||||
@@ -82,11 +90,13 @@
|
|||||||
(:write (" jmp et_~a" döngü-num)
|
(:write (" jmp et_~a" döngü-num)
|
||||||
("et_~a:" label-num))))
|
("et_~a:" label-num))))
|
||||||
|
|
||||||
|
;; (rax -- rax rax)
|
||||||
(defop eş ()
|
(defop eş ()
|
||||||
"pop rax"
|
"pop rax"
|
||||||
"push rax"
|
"push rax"
|
||||||
"push rax")
|
"push rax")
|
||||||
|
|
||||||
|
;; (rax -- )
|
||||||
(defop düş ()
|
(defop düş ()
|
||||||
"pop rax")
|
"pop rax")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user