minor change to run to make it more generic
This commit is contained in:
@@ -197,10 +197,7 @@
|
|||||||
|
|
||||||
|
|
||||||
;;; COMPILER
|
;;; COMPILER
|
||||||
(defun generate-program (program &key (path "output.asm") (compile nil)
|
(defun write-program (program out &key mem-cap)
|
||||||
(mem-cap 640000))
|
|
||||||
(with-open-file (out path :direction :output
|
|
||||||
:if-exists :supersede)
|
|
||||||
(format out "~a~%" "segment .text")
|
(format out "~a~%" "segment .text")
|
||||||
(gen-dump out)
|
(gen-dump out)
|
||||||
(format out "~{~a~%~}" '("global _start"
|
(format out "~{~a~%~}" '("global _start"
|
||||||
@@ -212,10 +209,17 @@
|
|||||||
(gen-code '(exit 0) out)
|
(gen-code '(exit 0) out)
|
||||||
(format out "~a~%" "segment .bss")
|
(format out "~a~%" "segment .bss")
|
||||||
(format out "~a ~a~%" "bel: resb" mem-cap))
|
(format out "~a ~a~%" "bel: resb" mem-cap))
|
||||||
|
|
||||||
|
(defun generate-program (program &key (path "output.asm") (compile nil)
|
||||||
|
(mem-cap 640000))
|
||||||
|
(with-open-file (out path :direction :output
|
||||||
|
:if-exists :supersede)
|
||||||
|
(write-program program out :mem-cap mem-cap))
|
||||||
(when compile
|
(when compile
|
||||||
(run `("nasm" "-felf64" ,path))
|
(run `("nasm" "-felf64" ,path) :output t)
|
||||||
(let ((name (first (uiop:split-string path :separator '(#\.)))))
|
(let ((name (first (uiop:split-string path :separator '(#\.)))))
|
||||||
(run `("ld" "-o" ,name ,(concatenate 'string name ".o"))))))
|
(run `("ld" "-o" ,name ,(concatenate 'string name ".o"))
|
||||||
|
:output t))))
|
||||||
|
|
||||||
(defun compile-program (path)
|
(defun compile-program (path)
|
||||||
(generate-program (make-program path) :compile t))
|
(generate-program (make-program path) :compile t))
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
(defun example-run ()
|
(defun example-run ()
|
||||||
(example-compile)
|
(example-compile)
|
||||||
(run '("test/output")))
|
(run '("test/output") :output t))
|
||||||
|
|
||||||
(defun start-forth-repl ()
|
(defun start-forth-repl ()
|
||||||
(iter (for line = (progn (format t "~&> ") (read-line)))
|
(iter (for line = (progn (format t "~&> ") (read-line)))
|
||||||
|
|||||||
@@ -20,9 +20,9 @@
|
|||||||
(defun mklist (form)
|
(defun mklist (form)
|
||||||
(if (listp form) form (list form)))
|
(if (listp form) form (list form)))
|
||||||
|
|
||||||
(defun run (args)
|
(defun run (args &rest options)
|
||||||
(format t "~{~a~^ ~}~%" args)
|
(format t "~{~a~^ ~}~%" args)
|
||||||
(uiop:run-program args :output *standard-output*))
|
(apply #'uiop:run-program args options))
|
||||||
|
|
||||||
(defun from-root (path)
|
(defun from-root (path)
|
||||||
(merge-pathnames path (asdf:system-source-directory :cl-forth)))
|
(merge-pathnames path (asdf:system-source-directory :cl-forth)))
|
||||||
|
|||||||
Reference in New Issue
Block a user