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
+17 -1
View File
@@ -8,10 +8,12 @@
* host stack sizes) at one cell width. It writes, as `constant` lines in
* the text assembler's notation, the addresses and codes of
* v4/tests/host_map.h that the ROM's source (capsules/v4/rom) uses: the
* console's receive registers and the ROM's state area (MACHINE.md 2.1).
* console's receive registers, the ROM's state area (MACHINE.md 2.1), the
* math's constants and its shared entries (MACHINE.md 2.2).
* The map has one source, host_map.h; this is how the ROM reads it.
*/
#include "../tests/host_map.h"
#include "../include/v4/rom_entries.h"
#include <stdio.h>
static void constant(const char *name, long value)
@@ -147,5 +149,19 @@ int main(int argc, char **argv)
constant("DEC-LIMIT", (long)(v4_cell)(~(v4_ucell)0 / 10u));
constant("DEC-NLAST", -(long)(~(v4_ucell)0 % 10u) - 1);
constant("HEX-HIGH", (long)(v4_cell)~(~(v4_ucell)0 >> 4));
/* the math's constants (capsules/v4/rom/math.f18) */
constant("N-1", (long)(V4_CELL_BITS - 1));
constant("NODE-ERROR", (long)NODE_ERROR);
constant("(Q/)", (long)QBASE);
constant("MAXHI", (long)(v4_cell)(V4_MSB - 1u));
constant("2N+15", (long)(2 * V4_CELL_BITS + 15));
constant("N-18", (long)(V4_CELL_BITS - 18));
constant("N-17", (long)(V4_CELL_BITS - 17));
/* the shared entries, the start of both ROMs' tables (v4/rom_entries.h) */
printf("macro (MATH-ENTRIES)");
#define MATH_ENTRY_JUMP(i, routine, forth, effect) printf(" jump %s", routine);
V4_ROM_MATH_ENTRIES(MATH_ENTRY_JUMP)
#undef MATH_ENTRY_JUMP
printf(" endmacro\n");
return 0;
}