Posts

Showing posts with the label Apple II

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...

Baker's COMFY for the PIC?

I encountered Henry G. Baker's COMFY compiler a couple years ago. ( Baker's site contains a text article , a TeX format article, and an Emacs Lisp implementation . The ACM published the two articles COMFY theory and COMFY-65 ) COMFY is not a very high-level language, in the conventional sense, but is an attempt to provide a clean but simple set of control structures on top of conventional machine code. Baker calls it 'medium-level.' The resulting compiler is very small; its main task in life is to automate the generation of branch instructions, which is one of the tedious parts of tightly optimizing assembly programs. Yet it allows as well for arbitrary Lisp-style macros. I found the concept intriguing, but I found the article and the compiler code itself rather obscure. Part of the obscurity is the unconventional names for the 6502 operations, unconventional notation for the addressing modes, and decimal numbers for opcodes (because Emacs Lisp does not accept o...

Apple II Disk Transfer

It seems that others have also had the desire to upgrade the ADT (Apple Disk Transfer) tool to work with disks other than the Disk II 5-1/4 inch floppy format under DOS 3.3. ADTPro is a ProDOS-based version of ADT. It should presumably work with all block devices recognized by ProDOS. I e-mailed some code to David Schmidt which allowed ADT to work with the ordinary IIgs serial ports; direct access to the Z8530 chip might allow for faster transfers; that's a potential project.

What is this about

This blog is a simple experiment for now, to understand what is available for a "scratchpad on the Web." I have a picture which is something more like a lab notebook for my various hacking projects. The requirements are roughly access from various places where hacking might happen; an idea for a project can happen at work, but I don't want my personal laptop with me at all times. some kind of permanence, as suits a lab notebook. Various things this might mean: version control with timestamping no revisions allowed at all (this seems extreme: one wants to separate a polished presentation view from the underlying archival lab notebook. One can revise slides for a talk without altering the historical record of the lab notebook) ability to archive into a big .tgz for burning to disk as necessary flexible project documentation easy way to archive associated files; diffs, error messages, screen shots, sketches, links, data sheets downloaded for the web. perhaps I...