"Not done yet" was scattered: AGENTS had a five item candidate list, docs/divmod.md had a "no optimisation we skipped" section, README pointed at neither, and the tree carried one genuine code marker nobody had noticed -- src/r8asm.cc:154 still says "TODO: FILL THE BLANK" above the ROT8_NODE macro (inherited from upstream, so it is recorded rather than changed). TODO.md now holds all of it, each item with why it matters and where to start: interaction the desk calculator (input plumbing is already in place) tools --opt peephole + tape diff, --profile, %synth --verify, CI text/picture clb_puts + mini printf, 259 cells as a frame buffer skipped opts clb_divmod's ~D precompute, clb_digits layout, the 495 char copy not TODOs SPEC 12 "we already proved this cannot work" stays out of it AGENTS' candidate section shrinks to a pointer, README gains a row in both of its index tables, and docs/divmod.md 6 is linked from the optimisation entry instead of being rewritten.
3.0 KiB
3.0 KiB
TODO
"还没做"的事都收在这一个文件里,别散在 README/AGENTS/docs 中。每条写清楚为什么值得做和
从哪开始;做完就删掉(历史在 git log 里)。SPEC.md §12 那张"已经确认走不通"的表是
结论,不是待办,别混进来。
交互式计算
- 桌上计算器(
examples/calc.r8asm):输入12+34=输出46,支持+ - * /。 条件已经齐了:inp在三个 VM 里都有实现、tape_run/derive能用-i脚本化喂输入、 例程头部能声明; in ...;数字用clb_undigits攒、回打用clb_digits、 四则用clb_add_nc/clb_mul/clb_divmod(都穷举验证过)。 要设计的是字符分派:'0'..'9'(0x30..0x39)bit4 是 1,'*' '+' '-' '/'(0x2A..0x2F)bit4 是 0 —— 一次ror+biz就能分开;运算符再按t = C - 0x2A的小整数链式比较。先写drv/calc_lex.r8asm单点验证分派,再拼整机。
工具
r8forge --opt:纸带级窥孔优化(收益面最大):><、<>、--、11 个++、 重复清位…… 要能重算跳转偏移。配套r8forge_tape_diff(比较两条纸带的 OUT 流和步数) 证明等价 —— 一次改动全库受益。--profile:统计每段宏/每个 cell 的步数占比和.tp行走距离,用数据决定下一步优化谁 (现在".tp行走占七成"还是估的)。%synth --verify:把.r8forge_cache/里每条结果按对应表的所有输入重跑一遍, 给"缓存已入库"兜底 —— 一条坏条目会让每次构建静默用错块。- CI:
enable_testing()+ 六条add_test,再接一个 workflow,push 即跑全套(现在 46 万组 验证只能靠人记得敲命令)。ROT-8-viz 那边更值得先做:它目前零测试,串行默认 /-n/ 几何 / 7E1 全靠手测,而它又是权威虚拟机。 src/r8asm.cc:154有个上游留下的// TODO: FILL THE BLANK(ROT8_NODE宏的 children 是空的)。那是继承来的实现,先记着,别顺手改。
文本与画面
clb_puts+ 迷你printf:现在只能一个 cell 一个字符地打,缺"把一段 cell 当字符串 打出来"和%d/%c/%s的格式化,例程就能打印整句话而不是光秃秃的数字。- 把 259 格当帧缓冲:串行下
\r(0x0D)能原地重绘,1 bit/cell 的 16×16 位图或 8×8 生命游戏都能塞进纸带,rot8_test --live里直接看它动。
想清楚但没做的优化
clb_divmod预计算~D:单轮 2019 → 973 步,估计 28.6k → 17.6k 步,纸带净 −76; 没换是因为当时指名用raw_sub。细节和注意事项见docs/divmod.md第 6 节。clb_digits的布局:13 格草稿跨得很开,.tp行走占了纸带的大头;重排草稿格应该能 明显缩短(未实测)。clb_divmod里那个 495 字符的提交copy:还是全展开的,可以想压缩的办法。