AGENTS.md: the naming rules come from SPEC.md, not from habit
The old text said "a macro that exposes cells as parameters must have raw in its
name". SPEC.md (r8asm_rev-fork/SPEC.md, identical in r8asm_rev) says something
else:
clb clobber destroys its input (usually clears it)
bit bit works on the LSB of a cell
raw raw unwrapped; the caller passes the scratch cell
So raw_add is called raw because you hand it the Co and tmp cells, not because
it takes cells at all, and bit means every CellBit parameter is a low bit -- the
same fact as biz/rnz testing & 1, which is what went wrong last round.
Record the three prefixes, apply them to the existing library, note the two
macros that predate the rule (bit_copy and copy take a buffer without raw in the
name), and point at the two documents that actually define the language: SPEC.md
and the instruction table in ROT-8-viz/README.md. %synth is not in the spec --
it is this repository's own extension, documented only in README.md.
This commit is contained in:
1 parent
afd56e7a8c
commit
417b428cea
1 file changed
+37
-4
@@ -160,7 +160,41 @@ void rot8_rnz(rot8_iter *iter) { if ((*(iter->mem_now) & 1) == 1) { ... } }
|
||||
只有 6 cell 的 `bit_raw_add`(有草稿 cell)能做到。
|
||||
* 字节级(2^16 项真值表)交给 `%synth`:搜索空间不可行。
|
||||
|
||||
## 命名与注释格式(`asm/lib.r8asm` 的约定)
|
||||
## 命名与注释格式(照 `SPEC.md`,别自己发明)
|
||||
|
||||
R8ASM 的语言规格不在这个仓库里:
|
||||
|
||||
* **`SPEC.md`**:`C:\Users\peng0\git\r8asm_rev-fork\SPEC.md`(`r8asm_rev` 里那份一模一样)。
|
||||
语言、内建指令、运算符优先级、作用域、标准宏前缀都在里面。**`%synth` 不在里面** ——
|
||||
那是 R8Forge 自己的扩展,只有本仓库的 README 有文档。
|
||||
* **ROT-8 指令集规格**:`C:\Users\peng0\git\ROT-8-viz\README.md`("1-Bit Brainfuck 变体",
|
||||
指令表里写明 `BIZ`/`RNZ` 判 **LSB**)。
|
||||
|
||||
SPEC 第 136-150 行的标准宏前缀:
|
||||
|
||||
| 前缀 | 全称 | 含义 |
|
||||
|---|---|---|
|
||||
| `clb` | clobber | 破坏性宏,会破坏原始输入(多数情况是清零) |
|
||||
| `bit` | bit | 对 cell 的 **LSB** 操作的宏 |
|
||||
| `raw` | raw | 未经封装的宏,**通常要手动传入 tmp cell 作为实参** |
|
||||
|
||||
**`raw` 不是"暴露 cell 作为参数"**(这条以前写错过):`raw_add` 之所以叫 raw,
|
||||
是因为它要你自己给 `Co` 和 `tmp` 那两个草稿 cell。`bit` 则说明所有 `CellBit` 形参
|
||||
指的都是最低位 —— 这跟 `biz`/`rnz` 判 `& 1` 是同一件事:整套语言是围绕"1 位"设计的。
|
||||
|
||||
既有宏对号入座:
|
||||
|
||||
| 宏 | 为什么这么叫 |
|
||||
|---|---|
|
||||
| `raw_add` / `raw_and` / `raw_or` / `raw_xor` / `raw_inc` | 字节级,且草稿 cell 由调用者传 |
|
||||
| `bit_raw_add`(6 cell)/ `bit_raw_add_nc`(4 cell) | 位级,且草稿 cell 由调用者传 |
|
||||
| `clb_bit_mov` | 位级搬运,并且把源吃掉 |
|
||||
| `bit_copy` / `copy` | 位级/字节级拷贝,缓冲由调用者传(历史命名,少了 `raw`) |
|
||||
| `set_0` / `set_1` / `erase` / `rol` / `step` / `back` / `output` | 基础操作,不带前缀 |
|
||||
|
||||
`%synth` 块名 = `<宏名>_synth`,包装的 `%macro` 用不带 `_synth` 的名字。
|
||||
|
||||
宏里的注释:
|
||||
|
||||
```asm
|
||||
; Macro bit_raw_add_nc
|
||||
@@ -168,6 +202,5 @@ void rot8_rnz(rot8_iter *iter) { if ((*(iter->mem_now) & 1) == 1) { ... } }
|
||||
; %2: CellBit B
|
||||
```
|
||||
|
||||
* 暴露 cell 作为参数的宏,名字里要有 `raw`;块级别的宏(`Cell` 参数)不带。
|
||||
* `%synth` 块名 = `<宏名>_synth`,包装的 `%macro` 用不带 `_synth` 的名字。
|
||||
* 宏里的注释沿用上面那种 `; Macro` / `; %N: <类型> <名字>`。
|
||||
* `%this` 表示"dp 当前所指的 cell"(`set_0`、`clb_bit_mov` 都这么写)。
|
||||
* 新宏先按上表选前缀。套不上的(块级、自己管草稿 cell 的)就在注释里写清吃什么、留下什么。
|
||||
Reference in new issue
Block a user