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
+31
View File
@@ -0,0 +1,31 @@
/* rom_entries.h -- the ROMs' shared entries (docs/v4.0.0/MACHINE.md 2.2).
*
* Both ROMs, the host node's and a mesh node's, begin with these entries, in
* this order: entry i is at V4_ROM_BASE + i, a jump to the routine. A
* payload calls an entry, never an address inside the ROM. This is the one
* list: tools/mkmap.c makes of it the (MATH-ENTRIES) macro both ROMs' entry
* tables begin with (capsules/v4/rom/main.f18, mesh.f18) and the constants
* ROM-UM* ... the system's source calls them by (tests/host_map.h).
*
* X(INDEX, ROUTINE, FORTH, EFFECT): ROUTINE is the ROM's name for the code
* (capsules/v4/rom/math.f18), FORTH the system's word that calls it, EFFECT
* its stack effect. An entry is added only at the end.
*/
#ifndef V4_ROM_ENTRIES_H
#define V4_ROM_ENTRIES_H
#define V4_ROM_MATH_ENTRIES(X) \
X(0, "(UM*)", "UM*", "( u1 u2 -- ulo uhi )") \
X(1, "(UM/MOD)", "UM/MOD", "( ulo uhi ud -- urem uquot )") \
X(2, "(D+)", "D+", "( d1 d2 -- d3 )") \
X(3, "(DNEGATE)", "DNEGATE", "( d -- -d )") \
X(4, "(Q.*)", "Q.*", "( a b -- c )") \
X(5, "(Q./)", "Q./", "( a b -- q )")
#define V4_ROM_MATH_COUNT 6u
/* The host ROM's own entries follow: the assembler's twelve routines, then
* (ROM), where the host machine starts (capsules/v4/rom/main.f18). */
#define V4_ROM_START (V4_ROM_MATH_COUNT + 12u)
#endif