MADS (Mad-Assembler)
- Publisher
- Open source (GitHub: tebe6502/Mad-Assembler)
- Type
- Development tool
- Category
- 6502/65816 cross-assembler
- Developer
- Tomasz Biela (Tebe/Madteam)
- Language
- Delphi / Free Pascal (runs on Windows, Linux, macOS)
- Requirements
- Any PC that can run Free Pascal builds (Windows, Linux, macOS); output runs on any Atari 8-bit (65816 code needs a 65C816 upgrade)
- Tags
- assembler, cross-assembler, 6502, 65816, mads, tebe, madteam, spartados-x, modern, open-source
- Related
- Mad Pascal, Fast Assembler, WUDSN IDE, BW-DOS, Effectus, SpartaDOS X
Overview
MADS (Mad-Assembler) is the most widely used assembler in today's Atari 8-bit scene. It is a cross-assembler: you write and assemble code on a PC and run the result in an emulator or on real hardware. Tomasz Biela (Tebe/Madteam) wrote it in Delphi, and it now builds with Free Pascal on Windows, Linux and macOS. It targets both the 6502 and the 65816, and it writes standard Atari DOS binaries (.xex/.obx) or relocatable SpartaDOS X executables. MADS is also the back end of the Mad Pascal compiler, and the Effectus Action!-language cross-compiler uses it too, so a large share of modern Atari software passes through it.
History and lineage
Tebe wrote it for people who already used three Polish-scene assemblers. It borrows its syntax from Quick Assembler (QA), some macro commands and conventions from Fox's XASM, and its SpartaDOS X block syntax from Fast Assembler (FA). XASM code usually assembles as-is: MADS keeps the same syntax, exit codes and macro commands. It adds whitespace inside expressions, both () and [] grouping, local and temporary labels, and SDX support. In the other direction, MADS understands Fast Assembler syntax.
MADS was already well established by 2009, when version 1.8.x was in wide use. Tebe released 1.8.8 with a fix for macOS and Linux builds. The English manual covers version 1.9.5 (January 2013). The current release is Mad-Assembler v2.1.8, and its changelog runs to 2026, with recent entries for things like a branch-range checker (-bc), warnings for unreferenced procedures (-xp) and cartridge checksums.
Features
- Pseudo-instructions that expand to common 6502 idioms:
mva/mwa(move a byte/word),adw/sbw,cpw,inw, and conditional-branch macros such asjne. Addressing extras such aslda $2000,x+(load, theninx). - Macros, procedures and structures.
.PROCwith parameters is passed on a software stack. There are also.STRUCT,.ENUM,.ARRAY,.LOCALscopes, nested "C++/Delphi-style" label names, anonymous@+/@-branch labels, and#WHILE/#IFstructured code. - Memory banking: virtual banks and hardware banks for 130XE-style extended memory.
- Relocatable code and linking: a custom relocatable format, public/external symbols, and native SDX relocatable blocks and symbols.
- No practical limits: label and macro counts are bounded only by PC memory, and arithmetic is done in 64-bit integers.
- Output for other tools:
.lstlistings,.lablabel files for emulator debuggers,.hheaders for CC65 (-hc) and.heaheaders for MADS (-hm).
Using it
mads source.asm [switches]
Useful switches: -o:file.xex (output name; the default is source.obx), -l (listing), -t (label table), -i:path (include directory), -d:LABEL=value (define), -x (drop unreferenced procedures, a big space saver with libraries), -c (case-sensitive labels), -u (warn about unused labels). Switches can be combined, for example mads -lptd:label=value.
A minimal program that prints a line through the OS's CIO routine:
ICCOM = $0342
ICBAL = $0344
ICBLL = $0348
CIOV = $E456
org $2000
start ldx #$00 ; IOCB 0 = screen editor
mva #$09 ICCOM ; command: PUT RECORD
mwa #text ICBAL ; buffer address (low/high)
mwa #$ff ICBLL ; maximum length; stops at EOL
jsr CIOV
jmp * ; stay here
text dta c'HELLO FROM MADS',$9b
run start
mads hello.asm -o:hello.xex produces a file that boots straight from any DOS, or from an emulator's "run program" option. The RUN pseudo-command writes the $2E0 run vector for you. INI does the same for $2E2 init blocks, and INS 'file' pulls in binary data such as fonts or graphics.
Ecosystem
Dozens of projects have been built with MADS. They include Lorenz Wiest's documented Star Raiders source and other disassemblies (Turbo-BASIC XL 1.5, APX Logo), a MADS port of BW-DOS, an Infocom Z-machine interpreter, BBC BASIC for the Atari, LK Avalon sources, and many modern games. The WUDSN IDE plug-in for Eclipse, first announced on AtariAge as supporting ATasm, was soon asked to add MADS and now integrates it with syntax highlighting and error navigation. For reference, use the documentation at mads.atari8.info and the MADS knowledge-base topic on AtariAge (topic 179559).
Tips
- Labels start in column 1 and instructions must be indented, unless you pass
-f(mnemonics allowed in the first column). - Single quotes encode ATASCII and double quotes encode screen ("internal") codes in immediate operands (
lda #'A'vslda #"A"). InDTA, use thecanddprefixes. - Mad Pascal programs are built in two steps: the compiler produces an
.a65file, thenmads file.a65 -x -i:<Mad Pascal base dir> -o:file.xex.
Credits
- Picture: This entry's example program, assembled with MADS and running in an emulator. — Tomasz Biela (Tebe/Madteam) (program); screenshot by the site
- Mad-Assembler repository — README, CHANGELOG, mads-usage.txt — GitHub project authors
- MAD-ASSEMBLER 1.9.5 instructions (English translation by Phaeron) — JAC; mads.atari8.info
- AtariAge forum — Mad Pascal (build workflow with MADS) — AtariAge forum members
- AtariAge forum — WUDSN IDE thread — AtariAge forum members
