feat(v4): mkrom -- the ROM built off the node; it reads tokens

The ROM's source is F18 code in capsules/v4/rom, assembled off the node by
v4/tools/mkrom.c with the memory map's constants from v4/tools/mkmap.c
(MACHINE.md 2).  main.f18 is the entry table payloads call through (2.1);
in.f18 reads the console and splits it into tokens exactly as text.c does,
the token held packed as a counted string.  The ROM's state is a reserved
area of the map (host_map.h ROM_*).  text.c gains the constant directive,
so the off-node assembler and the ROM speak one language.  The map also
names (NUMBER)'s state, for the next task.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-15 11:49:05 -04:00
co-authored by Claude Opus 5.5
parent 32753f5479
commit 0f82d8c22a
11 changed files with 560 additions and 7 deletions
+10
View File
@@ -489,6 +489,16 @@ int main(void)
CHECK(v4_text_word(&tx, "FAR") > (v4_cell)(V4_NODE_WORDS - 200u), "FAR is far: %ld", (long)v4_text_word(&tx, "FAR"));
}
/* ---- `constant NAME VALUE`, the directive form of v4_text_constant (MACHINE.md, the ROM's language) ---- */
CHECK(ok("constant SEVEN 7 constant MINUS -2 constant BIG $7F : T SEVEN MINUS + BIG + ;") && result("T", 0, 0, 0) == 132,
"constant defines a literal: %s", v4_text_error(&tx));
CHECK(ok("constant K 3 : T K+2 ;") && result("T", 0, 0, 0) == 5, "CONST+N works with a directive constant");
CHECK(refused("constant K 3 constant K 4", "already defined", 1), "a constant twice is refused");
CHECK(refused("constant dup 3", "cannot be used as a name", 1), "an opcode is not a constant's name");
CHECK(refused("constant K", "constant without a value", 1), "constant needs a value");
CHECK(refused("constant K x", "not a number", 1), "a constant's value is a number");
CHECK(refused(": constant ;", "cannot be used as a name", 1), "constant is reserved");
CHECK(v4_node_guards_intact(&na) && v4_node_guards_intact(&nb), "guards intact");
printf(" %d checks, %d failures\n", checks, failures);