v4 text.c: the address record (ADR step 3, task 1)
Build / Image RASPI (push) Successful in 4m13s
Build / Image PC (push) Successful in 3m51s
Build / Image MILKV (push) Successful in 4m30s
Build / v4 tests (32- and 64-bit cells) (push) Successful in 17m32s

Every cell laid down that holds an address of the assembly is recorded,
with its branch slot or 7 for the whole cell, as ARTIFACT.md's
relocations need. Test first: test_text 13 checks failed before.
test_host_rom_nucleus runs with the record on: 1825 branches, 664 whole
cells, the ROM still equal word for word. v4 test, test-32 and
ASan+UBSan pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-19 17:51:54 +00:00
parent 29b99f90e6
commit 4d64e677f5
11 changed files with 1898 additions and 14 deletions
@@ -145,3 +145,36 @@ accepted before the next:
3. `mkf18a` and `make -C v4 artifacts` (test 3).
4. The small train, placed at a base other than 0 (test 5).
5. The nucleus renamed to name order (3a), designed first: it changes the boot, so the protocol runs.
## 8. Task 1 built (2026-11-19): `text.c`'s address record
**What changed:**
- `text.h` and `text.c`: `v4_text_record(t, buf, cap)` turns the record on, and `v4_text_addresses(t)` says
how many were recorded. Each entry is a cell and its slot, 0–3 for a branch field or 7
(`V4_TEXT_WHOLE_CELL`) for the whole cell. What is recorded:
- every branch, to a word or a label, back or forward, including `NEXT`'s;
- an `&NAME` literal in code, and `#, &NAME`;
- `here`, and a `set` variable that holds an address, wherever it is laid down (code, `#,`, `store`);
- a header's name cell, and its link when there is an entry before it.
The map's constants and plain numbers are not recorded. A full record is an error. With the record off,
nothing changes.
- **Found while building:** the nucleus lays its headers down with `set HDR-NFA here ... #, HDR-LINK`, not
with `header`. So a `set` variable carries whether it holds an address, or those links would be missed.
**Test first** (`logs/20261119-text-record/`):
- `test_text`: 15 new checks. Before the change, 13 failed: every one that expects an address recorded.
The two that expect nothing passed, as they should. Two errors in the tests themselves were fixed before
the change: `source` needs its `N-1` constant, and the notation is `FOR ... NEXT`, upper case.
- `test_host_rom_nucleus`, with the record on (test 4). On the system's source it records 1825 branches
and 664 whole cells. Every whole cell holds an address of the assembly, and the ROM's assembly is still
equal to it word for word, at both widths. This check could not be seen to fail before: the record did
not exist. It guards that the record changes no cell.
**Verified:**
- `make -C v4 test` passes: all tests at both widths, and the three mesh boots with POST 990/990.
- `make -C v4 test-32` passes.
- ASan+UBSan passes for every test at both widths, and for the mesh boot (POST 990/990). The run hit my
one-hour background limit at the 64-bit `test_host_mesh`, so the rest was run again from there.
`v4-gates.txt` and `v4-sanitize-rest.txt` hold the two parts.
- The boot does not use the record, so the kernel and the protocol are unchanged.