by sph · 4y ago · 0 comments
My goal is to create the barest-metal Lisp OS (basically Lisp REPL with full ring-0 access, the OS) with an asm reader macro to write low level assembly opcodes you can jmp into.
(defn add1 (x)
(declare x int64)
#asm(
mov rax, %x
add rax, 1
))
(Just thought of this syntax on the spot, I'm a few dozen hours away from that still.)Does it desugar to something like this?
(assemble ‘((mov rax %x) (add rax 1)))
Anyhow I think this is a great project. I hope you share it! I’ve often thought bootstrapping an assembler with lisp macros would be an interesting way to build a compiler from the very ground up. Assembler macros are nothing new, but I’ve never heard of an homoiconic implementation.Got more details/links to study?
Keyword is the line
(dos-eval '(debug < TO.DEB > NUL))
("mapc" and "map" had their parameters in wrong order, which annoys me even today)The goal is being able to replace every single part of the runtime/interpreter if you wish, but the OS itself starts with the fewest functions/features possible. cons, lambda, and the other usual suspects, a way of running actual native machine code, the homoiconicity of LISP, a runtime-editable image, packed into a UEFI binary.
You could build yourself a Scheme or a Common Lisp on top of it if you wish.
No offense, but if it were Common Lisp I would take a look, but I don't have much interest in learning a one off language.
Sounds like you're having so fun, though, so good luck!