fix(v4): the final review's six minors in the ROM boot

- Text after start is refused, as text.c refuses it: before it jumps, the
  ROM reads on to the end of the source; blanks, comments and the ends of
  blobs may follow, a token is ERR-AFTER (26), "text after start".
- A token too long where a name, a target or a value is wanted is "name
  too long", as text.c says: (MISSING) reports "missing" only when no error
  came first.  `", keeps "missing", which is text.c's word for both.
- text.c's "address out of range" names the address, not the value.
- The system's source files are one list, v4/sys_files.h: boot.c, the
  harness and the nucleus test are made from it.
- The ROM's error codes and words are one list, v4/rom_errors.h: boot.c's
  messages, host_map.h's ROM_ERR_* and mkmap's ERR-* are made from it.
- node.h says what v4_node_store does with a ROM address (nothing, as for
  any address outside RAM, D-14); test_host_rom_range pins it.

ROM: 2095 words, rom_hash 0x06d0dcb7a0cb41a1.  dict_hash unchanged,
0xe5a57f3eb72ff94a.  make -C v4 test test-32 hosted-check pass.  QEMU:
amd64, aarch64, riscv64 to ok>, POST 538/538, POST: PASSED.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-15 17:10:45 -04:00
co-authored by Claude Opus 5.5
parent ff75e69e91
commit a28b5f2230
18 changed files with 646 additions and 89 deletions
+3 -1
View File
@@ -60,7 +60,9 @@
/* THE ROM (docs/v4.0.0/MACHINE.md section 2, DATASHEET-F18.md section 5).
* A read-only range of V4_ROM_WORDS words at V4_ROM_BASE, just above RAM.
* An instruction fetch, an @p literal and a data fetch there read the ROM; a
* running programme's store there is an address fault. In the model it is
* running programme's store there is an address fault. C code's
* v4_node_store there does nothing and counts no fault, as for any address
* outside RAM (D-14, at v4_node_store below). In the model it is
* attached, as every device is, and v4_node_reset detaches it: the owner
* attaches it again after a reset. The range's size is a build parameter,
* as RAM's is; 0 (the default) is a machine with no ROM. */
+43
View File
@@ -0,0 +1,43 @@
/* rom_errors.h -- the ROM's error codes and what they mean.
*
* The ROM (capsules/v4/rom) stops at (ROM-FAILED) with one of these codes in
* (FAILED); the loader, which owns the console, prints its words
* (v4/system/boot.c). This is the one list: the map's constants ERR-* the
* ROM is assembled with (v4/tools/mkmap.c, through v4/tests/host_map.h's
* ROM_ERR_*) and the boot's messages are both made from it. The codes run
* 1, 2, 3 ... in order; a new one goes at the end.
*
* X(NAME, CODE, WORDS)
*/
#ifndef V4_ROM_ERRORS_H
#define V4_ROM_ERRORS_H
#define V4_ROM_ERRORS(X) \
X(TOO_LONG, 1, "name too long") /* a token longer than 63 characters */ \
X(COMMENT, 2, "comment not closed") /* a ( with no ) before the end of its blob */ \
X(BAD_NAME, 3, "cannot be used as a name") /* an opcode, a reserved word, a label, a number or &... */ \
X(DEFINED, 4, "already defined") \
X(NAMES, 5, "too many names") /* the symbol table is full */ \
X(FIT, 6, "does not fit: memory is full, or a branch cannot reach") \
X(OPCODE, 7, "not an opcode the packer takes there") \
X(IN_MACRO, 8, "not allowed in a macro") \
X(MACRO, 9, "macro without endmacro, or endmacro without macro") \
X(LABEL_DUP, 10, "label already defined in this word") \
X(LABELS, 11, "too many labels in one word") \
X(FOR, 12, "FOR nested too deep, NEXT or UNEXT without FOR, or FOR without NEXT") \
X(UNEXT, 13, "FOR ... UNEXT must fit one instruction word and hold no literal") \
X(TARGET, 14, "not something to branch to") \
X(UNDEFINED, 15, "never defined") \
X(BIG, 16, "number does not fit a cell") \
X(AMP, 17, "& needs a word that is already defined") \
X(FETCH_P, 18, "write the number, not @p") \
X(MISSING, 19, "a name, a target, a value or a string is missing") \
X(DEEP, 20, "macros nested too deep") \
X(REFS, 21, "too many unresolved branches") \
X(VALUE, 22, "not a value") \
X(NO_START, 23, "the source ended with no start") \
X(START, 24, "start of something not a word") \
X(RANGE, 25, "address out of range") /* store outside RAM */ \
X(AFTER, 26, "text after start")
#endif
+17
View File
@@ -0,0 +1,17 @@
/* sys_files.h -- the system's source, in the order the ROM reads it.
*
* capsules/v4/sys: the memory map (map-<cell bits>.f18) first, then these,
* then end.f18 -- the state the system is switched on in, and `start`. The
* one list: the boot feeds these blobs (v4/system/boot.c), and the tests
* that build the system read these files (v4/tests/rom_harness.h).
*
* X(FILE): capsules/v4/sys/FILE.f18
*/
#ifndef V4_SYS_FILES_H
#define V4_SYS_FILES_H
#define V4_SYS_FILES(X) \
X(core) X(input) X(dict) X(codegen) X(compile) X(quit) X(forth) \
X(numout) X(words) X(system) X(qmath) X(blocks) X(log) X(acl)
#endif