A simple WDC 65C816 / 6502 assembler written in Rust.
Canonical syntax: ca65 (source of truth) https://cc65.github.io/doc/ca65.html
- Assemble 65C816 and 6502 source code into a raw
.binoutput. - Stay close to ca65 syntax while accepting a practical subset of common 6502/65816 conventions.
- Provide clear, source-spanned error messages.
- Keep assembly readable by supporting a canonical, formatter-friendly style.
Non-goals (v1):
- No optimization.
- No object files or linking (raw
.binonly).
Requires a recent Rust toolchain.
git clone <repo-url>
cd asm816
cargo build --release -p asm816_cliAssemble to a raw binary:
cargo run --release -p asm816_cli -- assemble path/to/main.s -o out.binAdd include directories:
cargo run --release -p asm816_cli -- assemble path/to/main.s -o out.bin -I include -I vendorUse module imports instead of .include:
; main.asm
import libs::constants
.org $8000
LDA #libs::constants::ONE; libs/constants.asm
pub ONE = 1Notes:
- module files map from roots as
foo/bar.asm->foo::bar pubcontrols cross-module visibility- selective imports are supported:
use foo::bar::{ONE, TWO as T} - inner modules are supported:
mod util { ... }-><current>::util - public macros are supported and expand at call site:
- define:
pub macro emit { LDA #ONE } - invoke:
foo::macros::emitor viause ...::{emit}thenemit - macro-local labels:
%%loop
- define:
.includeis deprecated and now reported as an error
Set default 65816 register widths (used to size immediate operands):
cargo run --release -p asm816_cli -- assemble path/to/main.s -o out.bin --a16 --i16Validate input without writing output:
cargo run --release -p asm816_cli -- check path/to/main.sFormat to canonical style (if available in your build):
cargo run --release -p asm816_cli -- fmt path/to/main.s0on success- non-zero if any errors were reported