To me, this post is in the finest spirit of HN's reason for being. It is delightful to to see the endless colliding of important primitive and historic objects written well and become accessible to many. My mind reels with all these fantastic permutations of what is possible and made accessible, and I must constantly refresh and resort the "I want to know this one too" queue.
As a long time fellow traveler in the land of Literate Programming, I must ask how you created the document---by hand or with tools and if tools, which ones?
Basically, you write markdown comments in the code and there is a Makefile that uses awk and sed to grab them out, cat some things together and pass it to an awesome LaTeX stylesheet written by Pete Kazmier. See: https://github.com/redline6561/cl-6502/tree/master/src/doc and the Makefile in the parent directory.
Shameless plug: My Rust 6502 emulator used macros for opcode decoding as well. CPU emulation is an ideal use case for Lispy macros: the addressing mode and opcode combinations have a lot of closely related code that's amenable to macro factoring, and having the interpreter, JIT (if present), and disassembler share code is a nice application as well.
Hi, Patrick! Sprocketnes has been helpful reading as I've worked on my own emulator. Ian Piumarta's lib6502 uses plain C macros. It's even almost as short as cl-6502...though I don't think it's quite as readable. ;)
Keep up the great work on Rust, been waiting on the gc/scheduler stuff to shake out a little bit. Looking forward to 0.8!
"All programs have been written, and that program is Lisp. With perfection already attained, implementation is left to the ignorant who do not already know the truth of this."
and, of course,
"Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp".
Robert Morris's addendum: "Including Common Lisp."
... except if you use a well-written Lisp interpreter library :) - Scheme
This is interesting because its exactly the kind of code that I thought would be easier in C than Lisp, due to easy bit manipulation, memory access, etc.
Me too! Common Lisp actually was intended for system programming historically, back from when Lisp Machines had a shot at ruling the world. Consequently, there is quite nice support for low-level programming.
That is nicely written! Even though I had the serial number 71 Apple II, and dipped into 6502 assembler way back, I am not much interested at all in the 6502 any more, but the author's literate programming/writing style is very nice - good read for those of us who still are into Common Lisp.
My old vic-20 had a 6502, and c-64 had a 6510. 6510 was backwards compatible with 6502. the most obvious diffrence was the 6510 had more instructions. has any of you had a c-64 with a 6502?