1
0
This commit is contained in:
Aiden
2026-05-25 13:47:13 +10:00
parent 46ccaf3e39
commit 5ad90ade49
12 changed files with 17974 additions and 883 deletions

View File

@@ -6,10 +6,10 @@ This repo now includes a standalone Python helper for the H8/536 ROM image:
python h8536_decompiler.py ROM\M27C512@DIP28_1.BIN --out build\rom_decompiled.asm --json build\rom_decompiled.json
```
On this machine the Windows `python.exe` entry is a Microsoft Store launcher stub, so validation was run with WSL:
If you are using the repo-local venv:
```powershell
ubuntu.exe run python3 h8536_decompiler.py --out build/rom_decompiled.asm --json build/rom_decompiled.json
.\.venv\Scripts\python.exe h8536_decompiler.py --out build\rom_decompiled.asm --json build\rom_decompiled.json --callgraph-dot build\callgraph.dot
```
## What It Does
@@ -18,7 +18,13 @@ ubuntu.exe run python3 h8536_decompiler.py --out build/rom_decompiled.asm --json
- Reads the H8/536 minimum-mode vector table from the ROM.
- Recursively traces reachable code from reset, interrupt, and trap vectors.
- Emits labels for branch and call targets.
- Annotates H8/536 on-chip register accesses such as `P1DDR`, `SYSCR1`, `WCR`, and timer/SCI/A-D registers.
- Tracks `LDC.B #xx, BR` along traced control flow so later short absolute `@aa:8` operands can resolve automatically.
- Annotates H8/536 register accesses such as `P1DDR`, `SYSCR1`, `WCR`, watchdog, timer/SCI/A-D, and RAM-control registers.
- Decodes register bitfields and selected hardware semantics for setup writes.
- Emits memory-region metadata for vector, DTC, RAM, register-field, and mode-dependent program/external space.
- Parses the DTC vector table described by the manual.
- Scans unreached ROM ranges for ASCII strings and pointer-table candidates.
- Emits function summaries and a direct-call graph in JSON, with optional Graphviz DOT output.
- Handles the E-clock transfer instructions `MOVFPE` and `MOVTPE`.
The generated listing is written to:
@@ -44,6 +50,7 @@ python h8536_decompiler.py --help
- `--linear`: linear-sweep the selected range instead of tracing from vectors.
- `--start H'1000 --end H'D100`: constrain the decode range.
- `--br H'FE`: resolve short absolute `@aa:8` operands through a known base-register value.
- `--callgraph-dot build\callgraph.dot`: write a Graphviz DOT call graph.
## Code Layout
@@ -51,7 +58,9 @@ python h8536_decompiler.py --help
- `h8536/cli.py`: argument parsing and end-to-end orchestration.
- `h8536/decoder.py`: instruction and effective-address decoding.
- `h8536/tables.py`: manual-derived opcode/vector/register tables.
- `h8536/vectors.py`: exception vector parsing.
- `h8536/analysis.py`: recursive tracing, linear sweep, and labels.
- `h8536/vectors.py`: exception and DTC vector parsing.
- `h8536/analysis.py`: recursive tracing, linear sweep, labels, function grouping, and call graph analysis.
- `h8536/data_analysis.py`: unreached string and pointer-table candidate scans.
- `h8536/memory.py`: manual-derived memory-region tagging.
- `h8536/render.py`: assembly and JSON output.
- `h8536/model.py`, `h8536/rom.py`, `h8536/formatting.py`: shared data structures and helpers.