Amiga M68k Reverse Engineering System — terminal-native, keyboard-first disassembler, static call-graph analyzer, trace-seeded chipset analyzer, music module ripper, and interactive TUI (pure Go, zero CGo).
- Workspace + Module namespacing (
-p <root>+-m <module>): Automatically deduces<module>from binary filenames (work/<module>/,src/<module>/hunk*.asm,disasm/<module>.asm, sharedsrc/equates.i) with--forceoverwrite protection so multiple binaries in the same workspace never collide - Unified 3-stage M68000 disassembler for both multi-hunk AmigaOS executables (
HUNK_CODE,HUNK_DATA,HUNK_BSS,CHIP/FAST) and flat ROM/disk binaries - Trace-seeded M68000 + Amiga OCS/ECS chipset analysis (
analyze --trace): Built-in sandboxed M68000 interpreter (m68kemu) + deterministic Agnus/Denise/Paula/Blitter/Copper/8520-CIA state machine that resolves indirect dispatch, self-installed interrupt/trap handlers, and base-register hardware accesses by observation - Shared SQLite database (
work/<module>/project.db) and unified virtual address space across all segments of a module (powered by pure-Gomodernc.org/sqlite) - Relocation-exact symbol resolution (
HUNK_RELOC32/HUNK_DREL32), automatic cross-hunkXDEFexports, and collision-freeLAB_<hunk>_<offset>auto-labels (LAB_5_24BE8) - Source-linkable
; XREF:comments (; XREF: hunk5:LAB_5_24E84 (jsr 498(a5))), automatic cross-hunk / jump-vector target hints (; -> hunk3:LAB_3_26432), and Amiga custom register bitfield auto-comments (DMACON,INTENA,INTREQ,ADKCON,BPLCON0,BLTCON0/BLTCON1,BLTSIZEdecoded into persistent auto-comments that surviveemit) - Static Call Graph CLI (
hunks -m <module> cg) with automaticd16(a5)jump-vector resolution, self & inclusive (+callees) MC68000 cycle bounds (+loop,+ind), bottom-up--readyworklists,--leaves,--anchors(strings &$DFFxxxhardware),--suspectaudits, and--codecaller/callee inspection - Standalone Amiga music module scanner (
hunks rip <file>, experimental) with 26 ExoticRipper recognizers (including sandboxed self-executing M68000 driver probes for David Whittaker and Final Music System) - Interactive TUI (
hunks -m <module> tui) with full-width Sub-Row Code View, inline 16-bytedc.bhex/ASCII grid, 3-tier EOL comment priority, exact MC68000 single-instruction, block-selection (v), and subroutine (V) self + inclusive ([incl: ... cyc]) cycle & R/W bus timing, interactive Amiga Bitplane Image Viewer & Ripper (B) (Kitty/iTerm2/Sixel/Half-Block pixel graphics,BPLCON01–7 planes, EHB/HAM6, Copper/$0RGBpalette extraction, PNG &FORM ILBMexport), experimental TUI Music Ripper (M) (scan, jump, rip, & carve), virtual segmentincbincarves (v+Kin editor,Kin asset viewers with metadata block comments and round-trip onB), configurable truecolor themes (~/.config/hunks/theme.json), vertical scrollbar, floating modal overlays, byte-exact cursor splitting, cross-hunkEnternavigation,xXREFs modal,fFunctions filter, and struct/alias editors - 100% bit-for-bit reassembly verified with
vasmm68k_mot
go install ./cmd/hunks
# 1. Initialize 13-hunk module ('frontier' deduced -> work/frontier/), analyze, and emit modular assembly
hunks init --hunk-file assets/frontier
hunks -m frontier analyze
hunks -m frontier emit --amiga
# 2. Explore the call graph (leaves, hardware/string anchors, and function neighborhoods)
hunks -m frontier cg --anchors --unrenamed -n 20
hunks -m frontier cg hunk3:LAB_3_2649E --code
# 3. Assemble with vasmm68k_mot & verify load-image parity
vasmm68k_mot -Fhunkexe -kick1hunks -nosym -no-opt -I . -I src -o build/frontier disasm/frontier.asm
python3 scripts/verify_parity.py build/frontier assets/frontier# 1. Initialize module at fixed load address ('disk_1' deduced -> work/disk_1/)
hunks init --binary assets/disk.1 --base 0x3B800
# 2. Add entry point, analyze, and emit disasm/disk_1.asm
hunks -m disk_1 entry 0x63EC8 --name main
hunks -m disk_1 analyze
hunks -m disk_1 emit
# 3. Verify 100% bit-for-bit parity
vasmm68k_mot -m68000 -no-opt -Fbin -o build/disk_1.bin disasm/disk_1.asm
cmp -l assets/disk.1 build/disk_1.bin # 0 differences
# 4. Launch interactive TUI
hunks -m disk_1 tui- MANUAL.md — Complete user manual with CLI/TUI reference and end-to-end walkthroughs
- ARCHITECTURE.md — System internals: package map, data model (
project.json+project.dbschema), analyzer pipeline, emitter, and call graph - TESTING.md — Verification and regression test procedures
- AGENTS.md — Development guidelines, invariants, and coding standards
- CODE_OF_CONDUCT.md — Community code of conduct
- Go 1.27+ (pure Go build; zero CGo dependencies)
vasmm68k_mot(optional, required only when running end-to-end reassembly parity checks against local binaries)
# Build all packages and the CLI binary
go build ./...
go build -o hunks ./cmd/hunks
# Run static analysis (must report 0 warnings)
go vet ./...
# Run the self-contained synthetic unit test suite (no external assets required)
go test -v ./...
# Install the `hunks` binary to $GOPATH/bin
go install ./cmd/hunksAny change that touches the analyzer (internal/analyzer) or emitter (internal/emitter) must preserve 100% load-image parity on reference targets:
# Multi-hunk AmigaOS executable (compares hunk table, payloads, and order-independent RELOC32 sets)
hunks init --hunk-file assets/<target> --force
hunks -m <target> analyze
hunks -m <target> emit --amiga --force
vasmm68k_mot -Fhunkexe -kick1hunks -nosym -no-opt -I . -I src -o build/<target> disasm/<target>.asm
python3 scripts/verify_parity.py build/<target> assets/<target>
# Flat binary (compares raw assembled bytes 1:1)
vasmm68k_mot -m68000 -no-opt -Fbin -o build/<flat>.bin disasm/<flat>.asm
cmp -l assets/<flat> build/<flat>.binContributions are welcome! Before opening a pull request, please review AGENTS.md and ARCHITECTURE.md and ensure your changes follow the project's core invariants:
- Branching & Commits: Never commit directly to
main/master. Create a focused feature or bugfix branch (feat/...,fix/...,refactor/...,docs/...) and use clear conventional commit messages explaining the rationale. - 100% Load-Image Parity: Disassembly or emission changes must never break byte-for-byte reassembly (
vasmm68k_mot+scripts/verify_parity.py/cmp -l). - Self-Contained Synthetic Tests: All unit tests in
*_test.gomust use synthetic byte slices and in-memory SQLite (:memory:). Never commit or reference copyrighted Amiga game binaries, ROMs, or music modules (assets/,work/, andtestdata/*are gitignored). - Architecture Boundaries:
- Keep all SQL queries encapsulated inside typed methods on
db.Controller(internal/db/). - Keep domain kind strings (
CellType,EdgeKind,XrefKind,LabelKind) strictly insideinternal/db/types.go. - Preserve the one-way
emitcontract (never overwrite existing.asmfiles without--force).
- Keep all SQL queries encapsulated inside typed methods on
- Clean Verification: Run
go build ./...,go vet ./..., andgo test ./...with zero warnings or failures, and update MANUAL.md if CLI flags, TUI keys, or capabilities changed.
646,740-byte AmigaOS executable with 13 hunks (10 CODE, 1 DATA,CHIP, 2 BSS) and 2,882 relocations. Emits 159,000+ lines across src/frontier/hunk0.asm .. src/frontier/hunk12.asm and reassembles with 100% hunk payload and relocation parity.
180 KB flat binary loaded at $3B800, entry at $63EC8. Reassembles with 0 byte differences (cmp -l).
284 KB WHDLoad game binary loaded at $2E0, entry at $304.
Licensed under the MIT License. Copyright (c) 2026 Mikolas Hämäläinen.
