使用说明补充 --disasm 反汇编用法。
This commit is contained in:
@@ -16,16 +16,44 @@ ctest --test-dir build/gcc-debug # 测试(当前 9 个用例)
|
||||
|
||||
```text
|
||||
STCompiler <project.toml> [-o <name>.stb]
|
||||
STCompiler <name>.stb --disasm
|
||||
```
|
||||
|
||||
| 参数 | 作用 |
|
||||
|---|---|
|
||||
| `<project.toml>` | 工程文件(必填) |
|
||||
| `-o <name>.stb` | 编译并写出映像文件;**缺省时只打印文件集合与工程哈希**(12.3 阶段行为) |
|
||||
| `<name>.stb --disasm` | **反汇编一个已编译的映像**(不重新编译,见下) |
|
||||
| `--help` | 打印帮助 |
|
||||
|
||||
退出码:`0` 成功;`1` 编译失败(错误信息打到 stderr)。
|
||||
|
||||
## 反汇编(--disasm)
|
||||
|
||||
对已编译的 `.stb` 逐段查看:段摘要、函数表逐条指令(文件绝对偏移)、常量表、数据段 hex。
|
||||
|
||||
```bash
|
||||
$ STCompiler line1.stb --disasm
|
||||
image: line1.stb (184 bytes, 2 functions, 4 globals, entry fn 1)
|
||||
dt_ms=10 cycle_limit=100000 hash=0xc3fe4ae74ad45900
|
||||
functions:
|
||||
fn 0: nregs=8, offset=0, len=1
|
||||
0x0060 RET
|
||||
fn 1: nregs=13, offset=4, len=17
|
||||
0x0064 LOAD_I r8, 1
|
||||
0x0068 STORE_GLOBAL r8, 8
|
||||
0x006c LOAD_GLOBAL r9, 2
|
||||
...
|
||||
data (16 bytes):
|
||||
0x0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
```
|
||||
|
||||
说明:
|
||||
|
||||
- 指令偏移是**文件绝对字节偏移**,可直接对照 `xxd line1.stb`
|
||||
- 映像里**没有符号名**(函数表只有 fn_id,数据段无名字映射),因此按 `fn 0` / `fn 1`、槽号显示
|
||||
- 文件损坏或打不开 → `error: ...` 退出码 1
|
||||
|
||||
## 示例(line1)
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user