Files
LithosAnanake/v4/tools/mkmap.c
T
rajamesandClaude Opus 5.5 c233cb6536 feat(v4): the ROM's slot packer, word for word with asm.c
(OP) (LIT) (BRANCH) (BRANCH>) (RESOLVE) (LABEL), entries 6-11: the code
generator of any language built on the machine (MACHINE.md 2.1).  asm.c's
layout rules with text.c's branch placement; 400 random sequences agree
word for word with asm.c at both widths, memory-full and out-of-reach are
refused on both sides, and a ref with no branch is refused, not looped on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 11:58:47 -04:00

73 lines
2.9 KiB
C

/* 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);
constant("(RECN)", (long)ROM_RECN);
constant("(POOLN)", (long)ROM_POOLN);
constant("(REC)", (long)ROM_REC);
constant("(CNT)", (long)ROM_CNT);
constant("(PTR)", (long)ROM_PTR);
constant("(I)", (long)ROM_I);
constant("(WI)", (long)ROM_WI);
constant("(SYMH)", (long)ROM_SYMH);
constant("SYMREC", (long)ROM_SYMREC);
constant("POOLTOP", (long)ROM_POOLTOP);
constant("ERR-BAD-NAME", (long)ROM_ERR_BAD_NAME);
constant("ERR-DEFINED", (long)ROM_ERR_DEFINED);
constant("ERR-NAMES", (long)ROM_ERR_NAMES);
constant("(HERE)", (long)ROM_HERE);
constant("(CUR)", (long)ROM_CUR);
constant("(SLOT)", (long)ROM_SLOT);
constant("(NLIT)", (long)ROM_NLIT);
constant("(LITS)", (long)ROM_LITS);
constant("(PI)", (long)ROM_PI);
constant("(RS)", (long)ROM_RS);
constant("(RN)", (long)ROM_RN);
constant("RAM-WORDS", (long)V4_NODE_WORDS);
constant("ADDR-TOP", (long)ROM_ADDR_TOP);
constant("ERR-FIT", (long)ROM_ERR_FIT);
constant("ERR-OPCODE", (long)ROM_ERR_OPCODE);
/* 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;
}