fix(v4): the final review's six minors in the ROM boot
- Text after start is refused, as text.c refuses it: before it jumps, the ROM reads on to the end of the source; blanks, comments and the ends of blobs may follow, a token is ERR-AFTER (26), "text after start". - A token too long where a name, a target or a value is wanted is "name too long", as text.c says: (MISSING) reports "missing" only when no error came first. `", keeps "missing", which is text.c's word for both. - text.c's "address out of range" names the address, not the value. - The system's source files are one list, v4/sys_files.h: boot.c, the harness and the nucleus test are made from it. - The ROM's error codes and words are one list, v4/rom_errors.h: boot.c's messages, host_map.h's ROM_ERR_* and mkmap's ERR-* are made from it. - node.h says what v4_node_store does with a ROM address (nothing, as for any address outside RAM, D-14); test_host_rom_range pins it. ROM: 2095 words, rom_hash 0x06d0dcb7a0cb41a1. dict_hash unchanged, 0xe5a57f3eb72ff94a. make -C v4 test test-32 hosted-check pass. QEMU: amd64, aarch64, riscv64 to ok>, POST 538/538, POST: PASSED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ff75e69e91
commit
a28b5f2230
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "v4/testcode.h"
|
||||
#include "host_map.h"
|
||||
#include "v4/sys_files.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -105,13 +106,15 @@ static void rom_boot(v4_node *n)
|
||||
}
|
||||
|
||||
/* THE SYSTEM, AS THE MACHINE BUILDS IT (MACHINE.md section 6, step 1). The
|
||||
* system's source, capsules/v4/sys (V4_SYS_DIR): the map, the fourteen and
|
||||
* system's source, capsules/v4/sys (V4_SYS_DIR): the map, v4/sys_files.h and
|
||||
* the end, each followed by a new line and V4_ROM_BLOB_END, then EOT -- what v4/system/boot.c
|
||||
* feeds the console. rom_system_text gives it whole, *len its length;
|
||||
* rom_build_system has `n`, booted with its ROM, assemble it, and runs it to
|
||||
* its start: 1 if it started, with *words the instruction words it took. */
|
||||
static const char *const rom_system_files[] = { "core", "input", "dict", "codegen", "compile", "quit", "forth",
|
||||
"numout", "words", "system", "qmath", "blocks", "log", "acl" };
|
||||
#define ROM_SYS_FILE(file) #file,
|
||||
static const char *const rom_system_files[] = { V4_SYS_FILES(ROM_SYS_FILE) };
|
||||
#undef ROM_SYS_FILE
|
||||
#define ROM_SYS_FILES ((unsigned)(sizeof rom_system_files / sizeof rom_system_files[0]))
|
||||
|
||||
static char *rom_system_text(size_t *len)
|
||||
{
|
||||
@@ -119,12 +122,12 @@ static char *rom_system_text(size_t *len)
|
||||
char *text = malloc(cap);
|
||||
unsigned i;
|
||||
if (!text) return NULL;
|
||||
for (i = 0; i < 16; i++) {
|
||||
for (i = 0; i < ROM_SYS_FILES + 2u; i++) {
|
||||
char path[512];
|
||||
FILE *f;
|
||||
long n;
|
||||
if (i == 0) snprintf(path, sizeof path, "%s/map-%d.f18", V4_SYS_DIR, V4_CELL_BITS);
|
||||
else if (i <= 14) snprintf(path, sizeof path, "%s/%s.f18", V4_SYS_DIR, rom_system_files[i - 1]);
|
||||
else if (i <= ROM_SYS_FILES) snprintf(path, sizeof path, "%s/%s.f18", V4_SYS_DIR, rom_system_files[i - 1]);
|
||||
else snprintf(path, sizeof path, "%s/end.f18", V4_SYS_DIR);
|
||||
f = fopen(path, "rb");
|
||||
if (!f) { printf(" cannot read %s\n", path); free(text); return NULL; }
|
||||
|
||||
Reference in New Issue
Block a user