fix(v4): the final review's four defects in the ROM boot
- 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>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a73580e949
commit
ff75e69e91
@@ -90,12 +90,17 @@
|
||||
D: drop ;
|
||||
MISS: drop ERR-MISSING jump (FAIL)
|
||||
|
||||
\ store ADDR VALUE: ADDR must be in RAM, as text.c requires
|
||||
: (H-STORE)
|
||||
(IN-MACRO?) if OK drop ;
|
||||
OK: drop
|
||||
(NEXT-VALUE) if BADV drop (T1) a! !
|
||||
(NEXT-VALUE) if BADV drop
|
||||
(T1) a! @ b! !b ;
|
||||
(T1) a! @ -if LO
|
||||
drop drop ERR-RANGE jump (FAIL)
|
||||
LO: RAM-WORDS inv 1 + + -if HI
|
||||
drop (T1) a! @ b! !b ;
|
||||
HI: drop drop ERR-RANGE jump (FAIL)
|
||||
BADV: drop drop ;
|
||||
|
||||
\ ( -- ) clear the tables the ROM uses only while it assembles: the symbol
|
||||
|
||||
+11
-4
@@ -1,8 +1,10 @@
|
||||
\ in.f18 -- the ROM's input: characters from the console, and tokens.
|
||||
\
|
||||
\ The text the ROM assembles arrives at the console's receive registers,
|
||||
\ a character at a time. The end of it is EOT (4), which the loader sends
|
||||
\ after the last blob. A token is what v4/src/text.c's next_token makes
|
||||
\ a character at a time. Each blob of it ends with a new line and FS (28,
|
||||
\ V4_ROM_BLOB_END), where a file ends for text.c: a comment still open there
|
||||
\ is an error, and (TOKEN) gives 0 there as at the end. The end of all of
|
||||
\ it is EOT (4), which the loader sends after the last blob. A token is what v4/src/text.c's next_token makes
|
||||
\ of the same text: blanks are space, tab, CR and LF; a token is at most 63
|
||||
\ characters; `\` as a whole token skips to the end of the line, and `(` as a
|
||||
\ whole token to the next `)`.
|
||||
@@ -56,13 +58,14 @@
|
||||
S: if SD -1 + pop 2/ 2/ 2/ 2/ 2/ 2/ 2/ 2/ push jump S
|
||||
SD: drop pop 255 and ;
|
||||
|
||||
\ ( -- len ) the next token into (TOK), its length into (TOKN). 0: the end,
|
||||
\ or an error, which is in (FAILED).
|
||||
\ ( -- len ) the next token into (TOK), its length into (TOKN). 0: the end
|
||||
\ of a blob, the end of all ((EOF) set), or an error, which is in (FAILED).
|
||||
: (TOKEN)
|
||||
(EOF) a! @ if GO drop 0 ;
|
||||
GO: drop
|
||||
SKIP: (GETC)
|
||||
dup 4 xor if END
|
||||
drop dup 28 xor if BLOB
|
||||
drop dup 10 xor if NL
|
||||
drop dup 32 xor if SP
|
||||
drop dup 9 xor if SP
|
||||
@@ -72,6 +75,7 @@
|
||||
READ: (TOKN) a! @ 63 xor if LONG
|
||||
drop (PUT) (GETC)
|
||||
dup 4 xor if TEND
|
||||
drop dup 28 xor if TEND
|
||||
drop dup 10 xor if TEND
|
||||
drop dup 32 xor if TEND
|
||||
drop dup 9 xor if TEND
|
||||
@@ -90,6 +94,7 @@
|
||||
BSL: drop drop
|
||||
B1: (GETC)
|
||||
dup 10 xor if BEND
|
||||
drop dup 28 xor if BEND
|
||||
drop dup 4 xor if BEND
|
||||
drop drop jump B1
|
||||
BEND: drop (BACK) jump SKIP
|
||||
@@ -97,12 +102,14 @@
|
||||
P1: (GETC)
|
||||
dup 41 xor if PCLOSE
|
||||
drop dup 10 xor if PNL
|
||||
drop dup 28 xor if PEOF
|
||||
drop dup 4 xor if PEOF
|
||||
drop drop jump P1
|
||||
PNL: drop drop (LF+) jump P1
|
||||
PCLOSE: drop drop jump SKIP
|
||||
PEOF: drop drop ERR-COMMENT (FAIL) 0 ;
|
||||
END: drop drop 1 (EOF) a! ! 0 ;
|
||||
BLOB: drop drop 0 ;
|
||||
NL: drop drop (LF+) jump SKIP
|
||||
SP: drop drop jump SKIP
|
||||
LONG: drop drop ERR-TOO-LONG (FAIL) 0 ;
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
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 until its start
|
||||
\ runs it; on an error, stop at (ROM-FAILED) with the error's code in
|
||||
\ 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)
|
||||
@@ -40,7 +40,11 @@
|
||||
L0: drop jump L
|
||||
END: drop
|
||||
(FAILED) a! @ if NS drop jump (ROM-FAILED)
|
||||
NS: drop ERR-NO-START (FAIL) 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
|
||||
|
||||
Reference in New Issue
Block a user