v4 text.c: the address record (ADR step 3, task 1)
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:
@@ -24,13 +24,16 @@ static int failures = 0, checks = 0;
|
||||
static v4_node a, b;
|
||||
static v4_text tx;
|
||||
|
||||
/* node A: text.c assembles the system's source, map first and end last */
|
||||
/* node A: text.c assembles the system's source, map first and end last, with the address record on
|
||||
* (plans/2026-11-19-f18-artifact-build.md §4 test 4): the record must change no cell. */
|
||||
static v4_text_addr rec[1u << 15];
|
||||
static int build_a(void)
|
||||
{
|
||||
char path[512];
|
||||
unsigned i;
|
||||
v4_node_reset(&a);
|
||||
v4_text_begin(&tx, &a, ROM_ORIGIN);
|
||||
v4_text_record(&tx, rec, (unsigned)(sizeof rec / sizeof rec[0]));
|
||||
for (i = 0; i < ROM_SYS_FILES + 2u; i++) {
|
||||
if (i == 0) snprintf(path, sizeof path, "%s/map-%d.f18", V4_SYS_DIR, V4_CELL_BITS);
|
||||
else if (i <= ROM_SYS_FILES) snprintf(path, sizeof path, "%s/%s.f18", V4_SYS_DIR, rom_system_files[i - 1]);
|
||||
@@ -57,6 +60,20 @@ int main(void)
|
||||
CHECK(build_a(), "text.c assembles the system's source to its start: %s", v4_text_error(&tx));
|
||||
idle_a = v4_text_start(&tx);
|
||||
CHECK(idle_a == v4_text_word(&tx, "(IDLE)"), "the system starts at (IDLE)");
|
||||
{
|
||||
unsigned i, branches = 0, whole = 0, bad = 0;
|
||||
v4_cell end = v4_text_here(&tx);
|
||||
for (i = 0; i < v4_text_addresses(&tx); i++) {
|
||||
if (rec[i].slot == V4_TEXT_WHOLE_CELL) {
|
||||
whole++;
|
||||
if (a.mem[rec[i].cell] < (v4_cell)ROM_ORIGIN || a.mem[rec[i].cell] > end) bad++;
|
||||
} else if (rec[i].slot < 4u) branches++;
|
||||
else bad++;
|
||||
}
|
||||
printf(" address record: %u branches, %u whole cells\n", branches, whole);
|
||||
CHECK(branches > 0 && whole > 0, "the address record holds the system's branches and whole-cell addresses");
|
||||
CHECK(bad == 0, "every whole cell recorded holds an address of the assembly, every slot is 0-3 or 7: %u not", bad);
|
||||
}
|
||||
|
||||
t0 = clock();
|
||||
CHECK(rom_build_system(&b, &words), "the ROM started the system: P %ld, failed %ld at line %ld", (long)b.p,
|
||||
|
||||
Reference in New Issue
Block a user