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>
55 lines
2.2 KiB
Plaintext
55 lines
2.2 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. Entries 0-5 are the shared math, the same in a mesh node's
|
|
\ ROM (mesh.f18, MACHINE.md 2.2). DATASHEET-F18.md lists each routine's
|
|
\ stack effect.
|
|
|
|
: (ENTRIES)
|
|
(MATH-ENTRIES) \ 0-5 the shared math (math.f18; v4/rom_entries.h)
|
|
jump (KEY) \ 6 ( -- c )
|
|
jump (TOKEN) \ 7 ( -- len )
|
|
jump (NUMBER) \ 8 ( -- n flag )
|
|
jump (FIND) \ 9 ( -- rec | 0 )
|
|
jump (DEFINE) \ 10 ( value kind -- )
|
|
jump (OPCODE) \ 11 ( -- op | -1 )
|
|
jump (OP) \ 12 ( op -- )
|
|
jump (LIT) \ 13 ( v -- )
|
|
jump (BRANCH) \ 14 ( op target -- )
|
|
jump (BRANCH>) \ 15 ( op -- ref )
|
|
jump (RESOLVE) \ 16 ( ref target -- )
|
|
jump (LABEL) \ 17 ( -- addr )
|
|
jump (ROM) \ 18 the ROM itself: where the machine starts (V4_ROM_START)
|
|
|
|
\ ( -- ) 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
|
|
|