- The boot left the source's last new line in the console input, and the first KEY after the boot read it. What the ROM has not read when it starts the system is taken back (boot.c, rom_harness.h). hosted-check: KEY after the boot reads the key typed. - A comment or macro left open at the end of a blob ran on into the next, and the ROM accepted source text.c refuses. The loader ends each blob with FS (V4_ROM_BLOB_END) after its new line; the ROM ends a blob there as text.c ends a file: an open comment or macro is an error, and the word being assembled ends. test_host_rom_asm: seven blob pairs against text.c. - store to an address outside RAM faulted the ROM with no message. It is now refused, as text.c refuses it: ERR-RANGE, "address out of range". - The kernel build did not regenerate capsules/v4/sys/map-<w>.f18 before packing the capsule directory; it now does. ROM: 2084 words, rom_hash 0x4c458c6e48b35456. 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>
52 lines
2.0 KiB
Plaintext
52 lines
2.0 KiB
Plaintext
\ main.f18 -- the ROM's entry table.
|
|
\
|
|
\ docs/v4.0.0/MACHINE.md 2.1. The ROM is shared code: a payload calls its
|
|
\ routines through this table and never to an address inside the ROM, so a
|
|
\ rebuilt ROM breaks no payload. It is at the ROM's base, one jump a word,
|
|
\ in a fixed order that only ever grows at its end. Entry i is at the ROM's
|
|
\ base plus i. DATASHEET-F18.md lists each routine's stack effect.
|
|
|
|
: (ENTRIES)
|
|
jump (KEY) \ 0 ( -- c )
|
|
jump (TOKEN) \ 1 ( -- len )
|
|
jump (NUMBER) \ 2 ( -- n flag )
|
|
jump (FIND) \ 3 ( -- rec | 0 )
|
|
jump (DEFINE) \ 4 ( value kind -- )
|
|
jump (OPCODE) \ 5 ( -- op | -1 )
|
|
jump (OP) \ 6 ( op -- )
|
|
jump (LIT) \ 7 ( v -- )
|
|
jump (BRANCH) \ 8 ( op target -- )
|
|
jump (BRANCH>) \ 9 ( op -- ref )
|
|
jump (RESOLVE) \ 10 ( ref target -- )
|
|
jump (LABEL) \ 11 ( -- addr )
|
|
jump (ROM) \ 12 the ROM itself: where the machine starts
|
|
|
|
\ ( -- ) the state the ROM begins from: code goes to ORIGIN, nothing read,
|
|
\ nothing defined
|
|
: (INIT)
|
|
(CLEAR)
|
|
ORIGIN (HERE) a! ! 0 (CUR) a! ! 0 (SLOT) a! ! 0 (NLIT) a! !
|
|
0 (FAILED) a! ! 0 (ERRLINE) a! ! 0 (LINE) a! ! 0 (EOF) a! !
|
|
0 (PEEK) a! ! 0 (RAW) a! ! ;
|
|
|
|
\ the ROM: assemble the system's source from the console, blob by blob,
|
|
\ until its start runs it; on an error, stop at (ROM-FAILED) with the error's code in
|
|
\ (FAILED) and its line in (ERRLINE), for the loader to report
|
|
: (ROM)
|
|
(INIT)
|
|
L: (NEXT-TOKEN) if END drop
|
|
(ONE)
|
|
(FAILED) a! @ if L0 drop jump (ROM-FAILED)
|
|
L0: drop jump L
|
|
END: drop
|
|
(FAILED) a! @ if NS drop jump (ROM-FAILED)
|
|
NS: drop (EOF) a! @ if BLOB drop ERR-NO-START (FAIL) jump (ROM-FAILED)
|
|
\ the end of a blob: the word being assembled ends, as at the end of a
|
|
\ file for text.c
|
|
BLOB: drop (END-WORD)
|
|
(FAILED) a! @ if L0 drop jump (ROM-FAILED)
|
|
|
|
: (ROM-FAILED)
|
|
H: jump H
|
|
|