fantasm
The Fantastic (dis-/re-)Assembly tools for 6502 code.
fantasm is a Python library and CLI for working with annotated 6502
disassemblies. It consumes the JSON / ASM / driver-script artefacts a
disassembly run produces — typically from
dasmos or
py8dis, but fantasm only
sees the output and stays disassembler-agnostic — and exposes them
through a coherent set of sub-commands: round-trip verification,
annotation linting, basic-block and call-graph analysis,
cross-version annotation diffing, opcode-level address mapping
between versions, and propagation of annotations along a project’s
version DAG.
It is the consolidation of the per-project disasm_tools/ packages
that used to live in acorn-nfs, acorn-adfs, acorn-econet-bridge
and acorn-6502-tube-client; the four siblings now depend on
fantasm and the duplication is gone.
Where to start
Brand new to fantasm? Read Getting started. It walks through the first hour: install,
fantasm project init, dropping in a disassembly driver script, running the firstdisassemble/verify/lintcycle.Disassembling a disc-loaded program, or adopting a project with its own layout? See Disassembling a disc-loaded program.
Setting up a new project’s
fantasm.toml? See fantasm.toml reference for the full schema, then The version graph for the multi-version pieces ([[versions.entry]],parents,reloc_blocks).Asking “how do I X?” Check Workflows — recipe-style pages keyed on common questions (find missing comments, port annotations between versions, locate shared code with another ROM, …).
Reaching for the CLI reference? CLI reference is an exhaustive command-by-command listing, generated from the same Click definitions the binary uses, so it never goes stale.
Calling fantasm from your own Python code? The API reference is the importable surface — every public symbol from
fantasm.api.*.
Tutorial
- Getting started
- Disassembling a disc-loaded program
fantasm.tomlreference- Discovery and project context
- Top-level structure
- Targets
[verify]— the round-trip assembler- The driver’s environment
[memory]— non-ROM addresses where code and labels can live[[versions.entry]]— the version graph[comments.suggest]— label hints forfantasm comments suggest- Per-module summary
- Example: a complete config
- The version graph
- Workflows
- I want to verify my disassembly is byte-correct
- I want to validate annotation addresses
- I want to find missing or wrong comments
- I want to understand a subroutine’s role
- I want to find the gaps in my annotation work
- I want a global comment-coverage snapshot
- I want to review my data declarations
- I want to know what’s in this byte run
- I want to find missing print-inline hooks
- I want to bring annotations from a known version to a new one
- I want to know which addresses moved between versions
- I want to find a specific byte sequence in a ROM
- I want to find duplicated code within a ROM
- I want to find code shared with another ROM
- I want to promote auto-generated labels to entry points
- I want to extract a slice of the assembly listing
- I want to add a new subroutine declaration to a driver
- Checking the project / CLI
Reference
- CLI reference
- API reference
- Top-level package
- 6502 / 65C02 opcodes and mnemonics
- Project paths and version directory layout
- Targets: resolving a target’s files
- Acorn
.infsidecar files - Round-trip verification
- Subroutine audit and memory regions
- Comment-vs-code consistency checks
- Comment suggestions
- Lint
- Call graph and basic blocks
- Graphviz and GraphML rendering
- Code context (depth, sub-context, uncommented gaps)
- Auto-label classification and rename application
- Cross-reference field accessors
- Subroutine-declaration insertion
- Promotion candidates
- ROM comparison
- Cross-version address mapping
- Fingerprinting (block-level deduplication)
- Byte-signature search (literal + wildcard patterns)
- Data-declaration review and heuristic classification
- Print-inline hook discovery
- Cross-ROM shared-code matching
- Annotation backfill across versions
- Driver-script annotation parsing
- Driver-script address sorting
- Version graph (DAG) and chain composition
- Assembly-source extraction
- Project bootstrap (
fantasm project init/add/list)
- Testing strategy