Geometry defaults: 11 bit cells on a 259 cell tape

Both knobs already existed (--mem / --cell, rot8_config_apply).  This only moves
the defaults off the historical 256 x 8, which is the interesting case: a tape
written for byte cells now means something else, and nothing crashes.

    rot8_test --dump tapes/and.rot8                     # 512 1536 512
    rot8_test --mem 256 --cell 8 --dump tapes/and.rot8  # 13 7 5, as before

What follows the width without being touched:

* ROR rotates inside the cell, so a single set bit walks 11 places instead of 8
  (the wave tape's view shows 001 010 .. 400 over 11 columns).
* FLB, BIZ and RNZ only look at the low bit, so they need no change at all.
* INP masks to the width and config validation covers 1..32.

What the view does with it: ceil(11/4) = 3 hex digits per cell, 11 columns a
row, and 259 cells is 24 rows, so the grid is a window around the pointer with
its range on the last line.

--mem 256 --cell 8 reproduces every earlier number byte for byte, so the
machinery is unchanged; only the default moved.
This commit is contained in:
dsh committed 2026-11-07 10:56:15 +08:00
1 parent 5a23ffd64d
commit dde545d0d5
2 files changed
+11 -10

No files matched your search

+6 -5
View File
@@ -35,7 +35,7 @@ ROT-8 ([rəʊˈteɪt]) 提供了一套简洁的指令集,使利用无ALU的各
## 可视化内存
虚拟机可以一边执行 tape,一边把整条纸带(默认 256 个 Cell x 8 bit,`--mem` / `--cell` 可改)
虚拟机可以一边执行 tape,一边把整条纸带(默认 259 个 Cell x 11 bit,`--mem` / `--cell` 可改)
画成一张实时视图:
```sh
@@ -97,8 +97,8 @@ ROT-8 ([rəʊˈteɪt]) 提供了一套简洁的指令集,使利用无ALU的各
| `-k`, `--compact` / `--full` | 强制精简画面/完整画面 |
| `-c`, `--color` / `--no-color` | 强制开/关 ANSI 颜色(默认跟随终端) |
| `-i`, `--input <v...>` | 预先喂给 `INP` 的值(空格或逗号分隔) |
| `-m`, `--mem <n>` | 纸带长度(单位 Cell),任意值,默认 256,范围 1..1048576 |
| `-b`, `--cell <bits>` | Cell 位宽,任意值,默认 8,范围 1..32 |
| `-m`, `--mem <n>` | 纸带长度(单位 Cell),任意值,默认 259,范围 1..1048576 |
| `-b`, `--cell <bits>` | Cell 位宽,任意值,默认 11,范围 1..32 |
| `-h`, `--help` | 帮助 |
不加 `--live` 与 `--dump` 时行为与以前完全一致:直接跑完,只留下 `OUT` 的输出.\
@@ -143,13 +143,14 @@ ROT-8 ([rəʊˈteɪt]) 提供了一套简洁的指令集,使利用无ALU的各
```c
rot8_config cfg = {1000, 12}; /* 纸带长度, Cell 位宽 */
rot8_config_apply(&cfg); /* 之后创建的机器都用这个几何 */
rot8_config_default(&cfg); /* 恢复 256 x 8 */
rot8_config_default(&cfg); /* 恢复默认 259 x 11 */
size_t cells = rot8_mem_cells(iter);
unsigned bits = rot8_cell_width(iter);
```
`rot8_config_apply` 只在越界(0 格 / 位宽 0 或 >32 / 长度 >1048576)时返回 `false` 并且什么都不改.
默认几何(256 x 8)下的行为与以前逐字节一致:`--dump` 的画面、`OUT` 的输出都没有变.
把默认几何显式写出来(`--mem 256 --cell 8`)时,行为与改默认值之前逐字节一致:`--dump` 的
画面、`OUT` 的输出都没有变 —— 所以拿旧基准对比时记得把这两个参数带上.
## 输入
+5 -5
View File
@@ -6,11 +6,11 @@
#include <stdint.h>
/* Geometry. A tape is mem_size cells and a cell is cell_bits wide; the
* defaults are the historical 256 x 8. Both are picked at run time
* (rot8_config_apply), so one binary can watch a 256 x 8 tape and a 4096 x 32
* one. rot8_data is always wide enough for the largest cell. */
#define ROT8_DEFAULT_MEM_SIZE 256
#define ROT8_DEFAULT_CELL_BITS 8
* defaults are 259 x 11 (they were the historical 256 x 8). Both are picked
* at run time (rot8_config_apply), so one binary can watch a 259 x 11 tape and
* a 4096 x 32 one. rot8_data is always wide enough for the largest cell. */
#define ROT8_DEFAULT_MEM_SIZE 259
#define ROT8_DEFAULT_CELL_BITS 11
#define ROT8_MAX_CELL_BITS 32
#define ROT8_MAX_MEM_SIZE (1u << 20)
#define INS_SIZE 65536