feat(v4): the shared math in both ROMs, and a mesh node's ROM

MACHINE.md 2.2.  UM*, UM/MOD, D+, DNEGATE, Q.* and Q./ are entries 0-5
of the host ROM and of a mesh node's ROM, from one source (rom/math.f18)
and one entry list (v4/rom_entries.h).  The host ROM starts at entry 18.
The mesh ROM is 277 words; the host ROM 2372.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-15 19:46:00 -04:00
co-authored by Claude Opus 5.5
parent 473e105a69
commit 11b5d402b1
11 changed files with 426 additions and 43 deletions
+5 -5
View File
@@ -6,6 +6,7 @@
* which only a whole system has.
*/
#include "v4/post.h"
#include "v4/rom_entries.h"
#include "v4/blocks.h"
#include "v4/boot.h"
#include "v4/rom_errors.h"
@@ -413,9 +414,9 @@ static int load_capsule(const v4_boot *b, const char *name)
/* The ROM (docs/v4.0.0/MACHINE.md section 2): the machine's one binary,
* built by v4/tools/mkrom.c for this cell width. The machine starts at its
* entry 12, (ROM) (capsules/v4/rom/main.f18), which reads the system's
* source from the console, assembles it into RAM and, at the source's
* `start`, runs it. */
* entry V4_ROM_START (v4/rom_entries.h), (ROM) (capsules/v4/rom/main.f18),
* which reads the system's source from the console, assembles it into RAM
* and, at the source's `start`, runs it. */
#if V4_CELL_BITS == 64
extern const v4_cell v4_rom_64[];
extern const unsigned v4_rom_64_words;
@@ -427,7 +428,6 @@ extern const unsigned v4_rom_32_words;
#define BOOT_ROM v4_rom_32
#define BOOT_ROM_WORDS v4_rom_32_words
#endif
#define ROM_START 12u /* the entry where the machine starts */
#define ROM_STEP_LIMIT 400000000ULL /* instruction words the ROM may take: it takes about 16 million */
#define EOT 4 /* the end of the source: the ROM's (KEY) sees no more */
@@ -502,7 +502,7 @@ static int load_system(const v4_boot *b)
}
v4_node_rom_attach(n, BOOT_ROM, BOOT_ROM_WORDS);
n->p = V4_ROM_BASE + (v4_cell)ROM_START;
n->p = V4_ROM_BASE + (v4_cell)V4_ROM_START;
while (n->p >= V4_ROM_BASE) {
/* the console is given more of the source whenever it has taken
* all it had */