DTC and SCI improvements
This commit is contained in:
32
README.md
32
README.md
@@ -12,6 +12,12 @@ If you are using the repo-local venv:
|
||||
.\.venv\Scripts\python.exe h8536_decompiler.py --out build\rom_decompiled.asm --json build\rom_decompiled.json --cycles --callgraph-dot build\callgraph.dot
|
||||
```
|
||||
|
||||
To turn the structured decompile output into conservative C-like pseudocode:
|
||||
|
||||
```powershell
|
||||
.\.venv\Scripts\python.exe h8536_pseudocode.py build\rom_decompiled.json --out build\rom_pseudocode.c --cycles
|
||||
```
|
||||
|
||||
## What It Does
|
||||
|
||||
- Decodes the H8/500 instruction set used by the H8/536.
|
||||
@@ -21,12 +27,17 @@ If you are using the repo-local venv:
|
||||
- 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.
|
||||
- Annotates interrupt priority registers and DTC enable routing registers.
|
||||
- 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.
|
||||
- Parses the DTC vector table described by the manual and decodes DTC register-information blocks.
|
||||
- Tracks SCI setup writes and can infer baud rates from SMR/BRR when `--clock-hz` is supplied.
|
||||
- Flags/manual-annotates TEMP-register access ordering for FRT and A/D 16-bit peripheral registers.
|
||||
- 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.
|
||||
- Adds Appendix A cycle estimates to JSON and can append them to ASM comments.
|
||||
- Summarizes straight-line block timing and backward-branch loop timing when requested.
|
||||
- Handles the E-clock transfer instructions `MOVFPE` and `MOVTPE`.
|
||||
- Generates a separate C-like pseudocode view from the JSON, preserving labels, calls, branches, register names, comments, and optional cycle notes.
|
||||
|
||||
The generated listing is written to:
|
||||
|
||||
@@ -51,9 +62,22 @@ 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.
|
||||
- `--clock-hz 16000000`: infer SCI baud rates from manual BRR formulas.
|
||||
- `--cycles`: append Appendix A cycle estimates to assembly comments.
|
||||
- `--timing`: include straight-line block and backward-branch loop timing summaries.
|
||||
- `--callgraph-dot build\callgraph.dot`: write a Graphviz DOT call graph.
|
||||
|
||||
For pseudocode:
|
||||
|
||||
```powershell
|
||||
python h8536_pseudocode.py --help
|
||||
```
|
||||
|
||||
- `--no-asm`: omit original assembly text from pseudocode line comments.
|
||||
- `--no-addresses`: omit instruction addresses from pseudocode line comments.
|
||||
- `--cycles`: include cycle estimates from the JSON.
|
||||
- `--max-functions N`: emit only the first `N` functions for focused review.
|
||||
|
||||
## Code Layout
|
||||
|
||||
- `h8536_decompiler.py`: compatibility wrapper for the CLI.
|
||||
@@ -61,9 +85,15 @@ python h8536_decompiler.py --help
|
||||
- `h8536/decoder.py`: instruction and effective-address decoding.
|
||||
- `h8536/tables.py`: manual-derived opcode/vector/register tables.
|
||||
- `h8536/vectors.py`: exception and DTC vector parsing.
|
||||
- `h8536/dtc.py`: DTC register-information block decoding.
|
||||
- `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/cycles.py`: Appendix A cycle estimate tables.
|
||||
- `h8536/timing.py`: block and loop cycle summaries.
|
||||
- `h8536/sci.py`: SCI setup tracking and baud inference.
|
||||
- `h8536/peripheral_access.py`: FRT/A-D TEMP-register access analysis.
|
||||
- `h8536/pseudocode.py`: JSON-to-C-like pseudocode generation.
|
||||
- `h8536/render.py`: assembly and JSON output.
|
||||
- `h8536/model.py`, `h8536/rom.py`, `h8536/formatting.py`: shared data structures and helpers.
|
||||
- `h8536_pseudocode.py`: pseudocode CLI wrapper.
|
||||
|
||||
Reference in New Issue
Block a user