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:
co-authored by
Claude Opus 5.5
parent
32753f5479
commit
0f82d8c22a
@@ -0,0 +1,47 @@
|
||||
/* mkmap.c -- the memory map, as constants the ROM is assembled with.
|
||||
*
|
||||
* mkmap > rom-map-<width>.f18
|
||||
*
|
||||
* Runs on the build machine, built for the host node (HOST_WORDS and the
|
||||
* 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).
|
||||
* The map has one source, host_map.h; this is how the ROM reads it.
|
||||
*/
|
||||
#include "../tests/host_map.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static void constant(const char *name, long value)
|
||||
{
|
||||
printf("constant %s %ld\n", name, value);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
(void)host_load; /* host_map.h's loader is not this tool's */
|
||||
(void)host_branch_slots;
|
||||
printf("\\ Generated by v4/tools/mkmap.c from v4/tests/host_map.h -- do not edit.\n");
|
||||
constant("CONSOLE-RX", (long)CONSOLE_RX);
|
||||
constant("CONSOLE-STATUS", (long)CONSOLE_ST);
|
||||
constant("(TOK)", (long)ROM_TOK);
|
||||
constant("(TOKN)", (long)ROM_TOKN);
|
||||
constant("(PEEK)", (long)ROM_PEEK);
|
||||
constant("(LINE)", (long)ROM_LINE);
|
||||
constant("(EOF)", (long)ROM_EOF);
|
||||
constant("(FAILED)", (long)ROM_FAILED);
|
||||
constant("(ERRLINE)", (long)ROM_ERRLINE);
|
||||
constant("(NBASE)", (long)ROM_NBASE);
|
||||
constant("(NNEG)", (long)ROM_NNEG);
|
||||
constant("(NI)", (long)ROM_NI);
|
||||
constant("(NU)", (long)ROM_NU);
|
||||
constant("(NBIG)", (long)ROM_NBIG);
|
||||
/* the cell width's constants (NUMBER) needs, written as signed cells */
|
||||
constant("MSB", (long)(v4_cell)V4_MSB);
|
||||
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));
|
||||
constant("ERR-TOO-LONG", (long)ROM_ERR_TOO_LONG);
|
||||
constant("ERR-COMMENT", (long)ROM_ERR_COMMENT);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user