K65, the Atari 2600 Coders' High-Level Assembler, Gets an Atari 8-bit Playground
In October 2020 zbyti opened an AtariAge thread for K65, a 6502 compiler by KK/Altair that Atari 2600 programmers already knew well. He used it to write a growing set of Atari 8-bit examples. Over the next year and a half he added documentation, editor support and new targets, which made K65 a real option for Atari computer coders too.
What K65 is
K65 sits between an assembler and a high-level language. Each instruction is written as a data flow rather than a mnemonic: COLPF2=a=VCOUNT loads VCOUNT into the accumulator and stores it in COLPF2. Loops and conditions are blocks in braces, closed by a test on the processor flags (} always, } !=, } >=0). Data tables can be generated at compile time with expressions (for x=0..255 eval [ rnd() & 255 ]) and kept within one page using align or nocross. The complete "rainbow" example is three lines long:
main {
{ COLPF2=a=VCOUNT WSYNC=a } always
}
A project is built with k65 @program.conf. The configuration file lists the source files and the target system.
What zbyti added
- Documentation: a rewritten manual at zbyti.github.io/k65-mkdocs. At first it left out the Atari 2600 tutorials and the undocumented opcodes, and later updates covered labels, raw data and
else. - A "K65 Language Support" extension for Visual Studio Code with syntax highlighting.
- An Atari playground repository of examples: a DLI colour bar, a missile starfield, Find the Differences, a random mountain landscape taken from ilmenit's 256-byte intro Quatari, a picture slideshow, a tank demo, and Interstate, a translation of superogue's 128-byte intro that won its category at Lovebyte 2022. It later became k65-playground, with examples for other platforms too.
- A 16 KB cartridge target for the XL/XE, posted as a system script in the thread, which maps the program at $8000–$BFFF and writes the cartridge trailer.
Limits and praise
Zbyti was open about the drawbacks compared with MADS. K65 has no macros like ADW and no procedures with parameters. There are no ready-made libraries such as relocatable music players or depackers. Brace blocks don't turn into long jumps when a branch goes out of range. Version 0.2.1 also reports syntax errors very poorly. None of that stopped him from writing all his 8-bit code in K65. He pointed out that new targets are easy to add, and that KK/Altair had used K65 for winning Atari 2600 demos and for the Atari 8-bit production Druidarium, which placed second at Copy Party. Another user built the tools on macOS and had an emulator launch automatically after each make.
Getting it
The compiler source is at github.com/Krzysiek-K/k65, and zbyti attached an older Windows build of the compiler in the thread. Zbyti's documentation and examples are linked from the same thread. Every example comes as source, .conf file and ready-to-run .xex.
Credits
- AtariAge — K65 — AtariAge forum members
- GitHub — Krzysiek-K/k65 — GitHub project authors
- K65 documentation (zbyti) — zbyti.github.io
