Skip to content

Cross-development

Everything up to here happens at the machine: you type a line, press Enter, and something happens. That is the best way to learn a computer and a fine way to write a short program.

This half is for when you want more room. Cross-development means writing your program on your own computer — in your own editor, under version control — and building it into something the ACE loads. It is how you write assembly. It is how you write anything longer than a screenful. And it is how you get a program to run and check itself while you are still typing.

What you end up with

6502 run build/countdown.prg

A window opens, the machine boots, and your program runs. Take the window away and the same build runs in your terminal, prints what it printed, and tells you whether it worked:

$ printf '\rRUN\r' | 6502 run --headless --exit-on 'LIFT OFF' --timeout 20s build/countdown.prg

That second form is the interesting one. It turns "does my program work" into a question a script can answer, which is what makes a test suite possible.

The cross-development toolchain, from editor to machine From your editor to the machine Your editor.asm .bas cl65 · bastokassemble, tokenize build/game.prgthe program The emulatorseconds, no cables A CF cardcffs, then carry it The serial portXModem, both ways An EEPROMbin2woz · minipro Your ACEor the emulator’s window The same .prg every time. Only the way it gets there changes.
One program, four ways to the machine. The chapters that follow take them one at a time.

What you need

Three things, and two of them are already on your computer:

A text editorWhichever one you already use
cc65The assembler and linker — installing it has one trap in it
The 6502 commandThe emulator, driven from a terminal

There is no ACE in that list. You can do every chapter here with nothing but a laptop, and move to hardware when you are ready — that is a chapter of its own.

Everything works the same on macOS, Linux and Windows.

The chapters

ChapterWhat you get out of it
Why cross-developWhat the loop looks like, and when to stay at the machine instead
Installing cc65The assembler, and the one version trap in this ecosystem
The tool beltSix tools, what each is for, and how to prove each one works
Starting from a templateClone a working project instead of building one
The MakefileEvery target, and how to add your own
The linker configWhy a program starts at $0800 and a cartridge at $C000
Build, run, repeatThe loop itself, windowed and headless
DebuggingBreakpoints, registers, memory, and stepping through your own labels
Testing your programA suite that boots once and runs every case in a second
Onto real hardwareMemory card, serial cable, Wozmon paste, EEPROM
BASIC from your editorWrite listings as text, keep them in version control
Driving it from an agentThe machine as something a program can operate

If you are here to write assembly, this section is the part that gets your build working. What to write once it does — the 65C02 itself, and the Kernal routines your program calls — is the assembly guide, and it comes next.

Written for BIOS v1.5. Released under the MIT License.