Posts

Showing posts with the label 6502

COMFY-6502: hosting at github

Mostly to support my own development on multiple computers, I've moved my Common Lisp port of COMFY-6502 to github. I chose the name cl-comfy-6502 for the repository, although the "cl" prefix is a bit ugly. The current snapshot of COMFY-6502 .

COMFY-6502: snapshot

Even though it is hardly a finished product, I've posted a snapshot of my current CL conversion of COMFY-6502 Not that I expect a huge pent-up demand for the code, but it might be slightly more interesting than the output examples. Thanks to Henry Baker for allowing the release. The page also contains a link to the TODO file describing my next steps. (Most immediately, my attempt to include JMP elision was messy enough to convince me I need a different class to represent opcodes+arguments as a unit.)

COMFY-6502: a slight correction

After all the work to write a post showing off COMFY-6502's ability to reproduce the Red Book tone routine, I made a slight mistake in translation. The code I presented differed ever-so-slightly from the Red Book routine in the case where the Y-register reached zero.

COMFY-6502: work in progress

As I've mentioned before, I've become intrigued by Baker's COMFY assembler, and have been working on porting it to Common Lisp, and making it a bit more powerful in the link stage. One metric to judge the success of this kind of "medium-level" language is how well it compiles compared to hand-written assembler code. For the 6502, there are a few examples of code created by wizards like Steve Wozniak, which you can find copies of around the web, the largest being the Apple II monitor, the Integer Basic interpreter, and some medium-sized ones like the Apple II 6502 step/trace, the mini-assembler, the floating-point "Wozpack," and the Sweet-16 virtual machine. This kind of code has a lot of quirks that make it hard to straight-forwardly translate: lots of shared "tail code", branches known by the programmer to always be taken (to save a precious extra byte consumed by an unconditional JMP), and the classic "fake RTS trick", pushing a...

Another interesting mid-level assembler

While I'm still digesting COMFY in my "ample spare time," a post on comp.sys.apple2 mentioned some assemblers from "Ron" having a similar flavor : SPL for the 6502 and PIC0 for PIC 10F2xx microcontrollers . They are apparently implemented in Python, and inspired by Forth. They emit assembler.

Baker's COMFY: a few notes

I've been working a bit with Baker's COMFY-6502 code; a few notes of what I have learned so far. First, a couple of tiny bugs in the genbrc ; the code miscounts the size of the branch instructions, meaning that (- l 2) should be a (+ l 2) and so on. I found it handy to enumerate each clause of the cond. Each clause handles a particular case, such as when the "lose" continuation can be reached by a short branch instruction, while the "win" continuation is far enough away to require an absolute jump. Second, genbrc , genbr , and compile all provide the address of the resulting "continuation" as the return value. This is perhaps clear when one traces out all the recursion, but it isn't explicitly mentioned. One interesting case is genbrc when the "win" and "lose" branch destinations are the same: one could simply emit an unconditional branch to that destination, and return the address of that branch but actually returning t...