feat(v4): v3's whole POST, Task 8 round -- the rules, and v4 where the rulings put it (#189)
v3's whole POST on v4 at 983 of 1010 (the table's own count with its drops), from 850.
What remains is capacity ("Dictionary full", the 100-900-deep stacks): next, as ruled.
Found and fixed under the rulings (docs/v4.0.0/POST-PARITY.md):
- IS and DEFER@ refuse a word DEFER did not make, as v3: error 22, "Not deferred".
v4's IS stored into any word -- POST's `42 IS DUP` broke DUP for every case after it.
DEFER marks its word with flag 128 (dict.f18).
- SMUDGE and HIDDEN are compile-only, as v3's table: at the prompt v4's hid the newest word.
- Q./ by zero gives 0 and no error (ruled: v3's table); error 11 retired. The ROM's,
the test's reference and its hand-assembled copy changed alike.
- FENCE is v3's: it protects what is defined so far. The variable is (FENCE).
- The line's length is (#SRC), no longer SPAN: an EXPECT in a line cut the rest of
the line off, and 0 EXPECT could not leave SPAN 0 (FORTH-83).
- POST gains V4_POST_HEAD: the values left and how the output begins -- the form of a
printout whose values are the run's own (TOP-WORDS, WORD-ENTROPY).
post_all_rules.py: the rest of the whole table where it is not taken as v3 ran it --
v4's units for the cases that wrote through HERE as a byte address (CMOVE>, BLANK,
ERASE, FILL wrote into the system's code), the standard's results (COMPARE, SEARCH,
BASE output, THRU, >BODY with FIND's address), v3's descriptions where v3 printed
otherwise, and the cases dropped with their reasons (SP@/SP! by D-2, DABS/DMIN
underflow, CMOVE>.bounds, THRU.negative_end).
make -C v4 test: all v4 tests passed (both widths, mesh-boot, inference).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -11,8 +11,9 @@
|
||||
\ N-18 N-17, and (Q/), Q./'s five scratch cells, fixed in the memory map
|
||||
\ (MACHINE.md 2.1).
|
||||
\
|
||||
\ ERRORS. Q./ by zero leaves the result D-11 gives and stores 11, "Division
|
||||
\ by zero", into NODE-ERROR (D-18).
|
||||
\ Q./ by zero gives 0 and no error: v3's table, "division by zero yields q=0"
|
||||
\ (Captain Bob, 2026-11-14, docs/v4.0.0/POST-PARITY.md; it was D-11's Q max or
|
||||
\ Q min and error 11).
|
||||
|
||||
macro SWAP over push push drop pop pop endmacro
|
||||
macro - push inv pop + inv endmacro \ x y -- x-y
|
||||
@@ -88,8 +89,6 @@ macro OR over inv and xor endmacro
|
||||
SWAP push 0 (D+) pop
|
||||
push over pop SWAP (Q>INT) push (Q>INT) pop SWAP ;
|
||||
|
||||
: (QERR11) NODE-ERROR b! 11 !b ;
|
||||
|
||||
: (D2*C) ( lo hi cin -- lo' hi' cout )
|
||||
a! dup -if L1 drop 1 jump L2 L1: drop 0 L2: push
|
||||
over -if L3 drop 1 jump L4 L3: drop 0 L4:
|
||||
@@ -137,7 +136,4 @@ macro OR over inv and xor endmacro
|
||||
OV: drop drop drop pop pop drop drop
|
||||
(Q/)+4 b! @b -if OVP drop 0 MSB ; OVP: drop -1 MAXHI ;
|
||||
DIV: (UQ/) (Q/)+4 b! @b -if L3 drop (DNEGATE) ; L3: drop ;
|
||||
ZERO: drop drop drop
|
||||
over over OR if Z0 drop -if ZP drop drop 0 MSB jump (QERR11)
|
||||
ZP: drop drop -1 MAXHI jump (QERR11)
|
||||
Z0: drop jump (QERR11)
|
||||
ZERO: drop drop drop drop drop 0 0 ; \ by zero: 0, as v3's table (ruled 2026-11-14)
|
||||
|
||||
@@ -88,7 +88,7 @@ set HDR-NFA here ", LIST #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK her
|
||||
DONE: drop jump CR
|
||||
|
||||
\ ---- LOAD ----------------------------------------------------------------------
|
||||
\ The text being interpreted is at (SRC), SPAN characters of it, >IN the
|
||||
\ The text being interpreted is at (SRC), (#SRC) characters of it, >IN the
|
||||
\ place in it. LOAD saves those and BLK on the return stack, points them at
|
||||
\ the block, interprets it, and puts them back; so a block may LOAD another,
|
||||
\ and the rest of the line LOAD was on is interpreted afterwards. (v3's
|
||||
@@ -105,11 +105,11 @@ set HDR-NFA here ", LOAD #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK her
|
||||
: LOAD
|
||||
-if POS jump BAD
|
||||
POS: if BAD
|
||||
BLK a! @ push >IN a! @ push SPAN a! @ push (SRC) a! @ push
|
||||
BLK a! ! 0 >IN a! ! 1024 SPAN a! !
|
||||
BLK a! @ push >IN a! @ push (#SRC) a! @ push (SRC) a! @ push
|
||||
BLK a! ! 0 >IN a! ! 1024 (#SRC) a! !
|
||||
&(BLK-SRC) (SRC-HOOK) a! !
|
||||
INTERPRET
|
||||
pop (SRC) a! ! pop SPAN a! ! pop >IN a! ! pop BLK a! ! ;
|
||||
pop (SRC) a! ! pop (#SRC) a! ! pop >IN a! ! pop BLK a! ! ;
|
||||
BAD: drop NODE-ERROR b! 13 !b ;
|
||||
|
||||
\ ( -- ) go on with the next block. Only in a block being loaded: at the
|
||||
|
||||
@@ -59,7 +59,7 @@ macro ROT push SWAP pop SWAP endmacro
|
||||
(C)+9 a! !
|
||||
0 STATE a! ! (CG-RESET)
|
||||
CFBASE (CFP) a! !
|
||||
SPAN a! @ >IN a! !
|
||||
(#SRC) a! @ >IN a! !
|
||||
(C)+9 a! @ NODE-ERROR b! !b ;
|
||||
: (ABANDON) -1 jump (ABANDON-AS)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ set HDR-LINK 0 \ the newest dictionary entry: none yet
|
||||
\ 15 Deferred word not set 16 Not a word
|
||||
\ 17 Storage refused 18 No one on that port
|
||||
\ 19 Message refused 20 Node gone
|
||||
\ 21 Interrupted
|
||||
\ 21 Interrupted 22 Not deferred
|
||||
\ -1 the word has printed its own message
|
||||
|
||||
macro SWAP over push push drop pop pop endmacro
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
\ (ENGINE.md 3b; #189 Phase 2, Captain Bob 2026-11-13: "ID field in
|
||||
\ the header"). The next is in (NEXT-ID); FORGET gives back the
|
||||
\ IDs of what it removes, which are always the newest
|
||||
\ xt - 3 flags: 1 immediate, 2 hidden, 4 data
|
||||
\ xt - 3 flags: 1 immediate, 2 hidden, 4 data, 128 deferred (system.f18)
|
||||
\ xt - 2 the word address of the name
|
||||
\ xt - 1 the link: the xt of the entry before this one, 0 for the first
|
||||
\ xt the code
|
||||
@@ -124,9 +124,9 @@ set HDR-NFA here ", TRAVERSE #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK
|
||||
NN: if ZERO drop dup C@ 31 and + 1 + ;
|
||||
ZERO: drop ;
|
||||
|
||||
set HDR-NFA here ", SMUDGE #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
set HDR-NFA here ", SMUDGE #id, #, 16 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: SMUDGE ( -- ) LATEST if NONE (FLAGS) a! @ 2 xor ! ; NONE: drop ;
|
||||
set HDR-NFA here ", HIDDEN #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
set HDR-NFA here ", HIDDEN #id, #, 16 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: HIDDEN ( -- ) LATEST if NONE (FLAGS) a! @ 2 OR ! ; NONE: drop ;
|
||||
|
||||
\ ---- telling the kernel (docs/v4.0.0/ENGINE.md 3b) ------------------------------
|
||||
|
||||
@@ -25,7 +25,7 @@ store (BOOT)+1 HDR-LINK
|
||||
\ the word IDs: the system's are 0 .. #ids - 1, numbered as assembled (#189, Phase 2)
|
||||
store (NEXT-ID) #ids
|
||||
store (BOOT-ID) #ids
|
||||
store FENCE DICT-W
|
||||
store (FENCE) DICT-W
|
||||
\ nothing has ended badly; nothing has been printed
|
||||
store (LINE-STATUS) 1
|
||||
store (OUT^) (OUT)
|
||||
|
||||
+14
-10
@@ -10,12 +10,15 @@
|
||||
\ TIB byte address of the text input buffer; QUERY fills at most 81 bytes
|
||||
\ >IN word address of the variable: offset in TIB of the next character
|
||||
\ SPAN word address of the variable: how many characters the last
|
||||
\ EXPECT or QUERY read
|
||||
\ EXPECT or QUERY read (FORTH-83), and nothing else
|
||||
\ (#SRC) word address of the variable: the length of the text being
|
||||
\ interpreted (until 2026-11-14 that was SPAN, so an EXPECT in a
|
||||
\ line cut the rest of the line off)
|
||||
\ WBUF byte address of WORD's buffer, 257 bytes
|
||||
\ (P) word address of eight cells of scratch for this file
|
||||
\ (SRC) word address of the variable: the byte address of the text being
|
||||
\ interpreted. QUERY makes it TIB; LOAD (blocks.f18) makes it a
|
||||
\ block buffer. >IN is an offset from it and SPAN its length.
|
||||
\ block buffer. >IN is an offset from it and (#SRC) its length.
|
||||
\ (SRC-HOOK) word address of a variable: 0, or the address of a word
|
||||
\ that WORD calls before it looks at the text, to make sure (SRC)
|
||||
\ is right. LOAD puts one there: a block buffer can be given to
|
||||
@@ -28,13 +31,14 @@ macro BL 32 endmacro
|
||||
|
||||
\ ( -- baddr u ) the input buffer and how much of it is in use
|
||||
set HDR-NFA here ", SOURCE #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: SOURCE (SRC) a! @ SPAN a! @ -if P drop 0 P: ;
|
||||
: SOURCE (SRC) a! @ (#SRC) a! @ -if P drop 0 P: ;
|
||||
|
||||
\ ( baddr n -- ) FORTH-79: characters from the terminal are stored from
|
||||
\ baddr upward until a new-line or until n have been received; the new-line
|
||||
\ is taken but not stored. A zero is added after the text, so the buffer
|
||||
\ must hold n + 1 bytes. No action for n <= 0. SPAN is how many characters
|
||||
\ were stored (SPAN is not FORTH-79; v3 has it). A line longer than n leaves
|
||||
\ must hold n + 1 bytes. For n <= 0 nothing is read and SPAN is 0
|
||||
\ (FORTH-83). SPAN is how many characters were stored (SPAN is not FORTH-79;
|
||||
\ FORTH-83 and v3 have it). A line longer than n leaves
|
||||
\ the rest, its new-line included, to be read next.
|
||||
\ It is what the prompt reads every line with, with whatever the user has left
|
||||
\ on the stack beneath it, so it works in (P) -- (P)+0 where the next
|
||||
@@ -42,7 +46,7 @@ set HDR-NFA here ", SOURCE #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK h
|
||||
\ and has at most three cells of its own on the data stack (D-2).
|
||||
set HDR-NFA here ", EXPECT #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: EXPECT
|
||||
-if NN drop drop ; \ n < 0
|
||||
-if NN drop drop 0 SPAN a! ! ; \ n < 0
|
||||
NN: if ZERO
|
||||
(P)+1 a! ! dup (P)+2 a! ! (P) a! !
|
||||
L: (P)+1 a! @ if END drop
|
||||
@@ -54,11 +58,11 @@ set HDR-NFA here ", EXPECT #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK h
|
||||
END: drop
|
||||
FIN: 0 (P) a! @ C!
|
||||
(P) a! @ (P)+2 a! @ - SPAN a! ! ;
|
||||
ZERO: drop drop ;
|
||||
ZERO: drop drop 0 SPAN a! ! ;
|
||||
|
||||
\ ( -- ) FORTH-79: up to 80 characters, or a line, into TIB; >IN to 0.
|
||||
set HDR-NFA here ", QUERY #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: QUERY TIB (SRC) a! ! TIB 80 EXPECT 0 >IN a! ! ;
|
||||
: QUERY TIB (SRC) a! ! TIB 80 EXPECT SPAN a! @ (#SRC) a! ! 0 >IN a! ! ;
|
||||
|
||||
\ ---- WORD ------------------------------------------------------------------
|
||||
\ WORD is called from deep inside the interpreter and compiler, with whatever
|
||||
@@ -99,7 +103,7 @@ macro (STEP) (P)+6 a! @ 1 + ! endmacro
|
||||
jump HOOKED
|
||||
NONE: drop
|
||||
HOOKED:
|
||||
SPAN a! @ -if A drop 0 A: (P)+1 a! !
|
||||
(#SRC) a! @ -if A drop 0 A: (P)+1 a! !
|
||||
>IN a! @ -if B drop 0 B: (P)+6 a! ! ;
|
||||
|
||||
: (WORD-TAKE) ( -- baddr )
|
||||
@@ -214,4 +218,4 @@ set HDR-NFA here ", \ #id, #, 1 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
|
||||
: BACKSLASH
|
||||
BLK a! @ if TERM drop >IN a! @ -64 and 64 + ! ;
|
||||
TERM: drop SPAN a! @ >IN a! ! ;
|
||||
TERM: drop (#SRC) a! @ >IN a! ! ;
|
||||
|
||||
@@ -37,6 +37,7 @@ constant (ACL-HOOK) 14671
|
||||
constant SCR 15707
|
||||
constant BLK 15708
|
||||
constant (SRC) 15709
|
||||
constant (#SRC) 15706
|
||||
constant (SRC-HOOK) 15710
|
||||
constant (LINE-STATUS) 14668
|
||||
constant (PORT) 14537
|
||||
@@ -108,7 +109,7 @@ constant N-18 14
|
||||
constant N-17 15
|
||||
constant MAX-INT 2147483647
|
||||
constant HLD 16359
|
||||
constant FENCE 16358
|
||||
constant (FENCE) 16358
|
||||
constant CONTEXT 16320
|
||||
constant CURRENT 16321
|
||||
constant VOC-LINK 16334
|
||||
|
||||
@@ -37,6 +37,7 @@ constant (ACL-HOOK) 14671
|
||||
constant SCR 15707
|
||||
constant BLK 15708
|
||||
constant (SRC) 15709
|
||||
constant (#SRC) 15706
|
||||
constant (SRC-HOOK) 15710
|
||||
constant (LINE-STATUS) 14668
|
||||
constant (PORT) 14537
|
||||
@@ -108,7 +109,7 @@ constant N-18 46
|
||||
constant N-17 47
|
||||
constant MAX-INT 9223372036854775807
|
||||
constant HLD 16359
|
||||
constant FENCE 16358
|
||||
constant (FENCE) 16358
|
||||
constant CONTEXT 16320
|
||||
constant CURRENT 16321
|
||||
constant VOC-LINK 16334
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
\ the host node's vocabulary. Rests on core.f18, forth.f18, numout.f18 and
|
||||
\ words.f18.
|
||||
\
|
||||
\ ERRORS. Q./ by zero, and Q.SQRT and Q.LOG outside their domain, leave the
|
||||
\ result D-11 and D-12 give and then raise an error (D-18): codes 11,
|
||||
\ "Division by zero", and 12, "Argument out of range".
|
||||
\ ERRORS. Q.SQRT and Q.LOG outside their domain leave the result D-12 gives
|
||||
\ and then raise an error (D-18): code 12, "Argument out of range". Q./ by
|
||||
\ zero gives 0 and raises none, as v3's table (ruled 2026-11-14).
|
||||
\
|
||||
\ Constants the loader supplies:
|
||||
\ MSB MAXHI the high cells of Q min and Q max
|
||||
|
||||
@@ -173,7 +173,7 @@ macro R-CLEAR RSTACK-DEPTH b! a !b endmacro
|
||||
if TAKEN drop (UNTAKEN) jump M \ not taken: the wire was cut since it was looked at
|
||||
TAKEN: drop
|
||||
0 (MSG)+6 a! @ TIB + C! \ a zero after the text
|
||||
(MSG)+6 a! @ SPAN a! !
|
||||
(MSG)+6 a! @ (#SRC) a! !
|
||||
(DONE-PORT) a! @ (KEEP) a! ! \ the room for its answer is kept from here
|
||||
(CONSOLE) a! @ if P0 jump P1 \ where what it prints goes: the console,
|
||||
P0: drop (MSG)+1 a! @ \ or whoever sent it;
|
||||
@@ -183,7 +183,7 @@ macro R-CLEAR RSTACK-DEPTH b! a !b endmacro
|
||||
jump (LINE)
|
||||
|
||||
\ ( -- ) THE TEXT, INTERPRETED. It is in TIB with a zero after it and its
|
||||
\ length in SPAN, and the return stack is empty. It is interpreted with one
|
||||
\ length in (#SRC), and the return stack is empty. It is interpreted with one
|
||||
\ return entry under it, this word's call of INTERPRET; whatever is on the
|
||||
\ data stack stays there.
|
||||
: (LINE)
|
||||
@@ -400,12 +400,12 @@ set HDR-NFA here ", PORT! #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK he
|
||||
|
||||
\ ( -- ) WHAT IS IN THE DICTIONARY NOW IS THE SYSTEM: COLD comes back to
|
||||
\ it and FORGET will not go below it. Whoever has loaded a node's capsules
|
||||
\ has it do this (system.f18, (BOOT) and FENCE).
|
||||
\ has it do this (system.f18, (BOOT) and (FENCE)).
|
||||
set HDR-NFA here ", (SEAL) #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: (SEAL)
|
||||
DP a! @ (BOOT) a! !
|
||||
(LATEST) a! @ (BOOT)+1 a! !
|
||||
DP a! @ 3 + 2/ 2/ FENCE a! !
|
||||
DP a! @ 3 + 2/ 2/ (FENCE) a! !
|
||||
(NEXT-ID) a! @ (BOOT-ID) a! ! ;
|
||||
|
||||
\ FORTH-79: clear the return stack, set execution mode, return control to
|
||||
@@ -475,7 +475,7 @@ set HDR-NFA here ", ABORT #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK he
|
||||
-1 + if M5 -1 + if M6 -1 + if M7 -1 + if M8 -1 + if M9
|
||||
-1 + if M10 -1 + if M11 -1 + if M12 -1 + if M13 -1 + if M14
|
||||
-1 + if M15 -1 + if M16 -1 + if M17 -1 + if M18
|
||||
-1 + if M19 -1 + if M20 -1 + if M21
|
||||
-1 + if M19 -1 + if M20 -1 + if M21 -1 + if M22
|
||||
drop 2 jump (DONE)
|
||||
M1: drop $6167654E (EMIT4) $65766974 (EMIT4) $756F6320 (EMIT4) $746E (EMIT4) CR 2 jump (DONE)
|
||||
M2: drop $20746F4E (EMIT4) $756E2061 (EMIT4) $7265626D (EMIT4) CR 2 jump (DONE)
|
||||
@@ -499,6 +499,7 @@ set HDR-NFA here ", ABORT #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK he
|
||||
M19: drop $7373654D (EMIT4) $20656761 (EMIT4) $75666572 (EMIT4) $646573 (EMIT4) CR 2 jump (DONE)
|
||||
M20: drop $65646F4E (EMIT4) $6E6F6720 (EMIT4) $65 (EMIT4) CR 2 jump (DONE)
|
||||
M21: drop $65746E49 (EMIT4) $70757272 (EMIT4) $646574 (EMIT4) CR 2 jump (DONE)
|
||||
M22: drop $20746F4E (EMIT4) $65666564 (EMIT4) $64657272 (EMIT4) CR 2 jump (DONE)
|
||||
|
||||
\ The table the loader gives the node: six words, one for each kind of
|
||||
\ fault in the node's order, each a jump. A jump fills its word, so they
|
||||
|
||||
@@ -4,14 +4,17 @@
|
||||
\ dict.f18, quit.f18 and forth.f18.
|
||||
\
|
||||
\ Constants the loader supplies:
|
||||
\ FENCE word address of the variable: FORGET will not remove an entry
|
||||
\ (FENCE) word address of the variable: FORGET will not remove an entry
|
||||
\ that starts below the address it holds
|
||||
\ VOC-LINK word address of the variable: the newest vocabulary, or 0
|
||||
\ (BOOT) word address of two cells: DP and (LATEST) as the loader left them
|
||||
\ HEAT-OP ANTICLOCK word addresses of HEAT-OP[0] and ANTICLOCK, the heat
|
||||
\ registers (DECOMPOSITION.md section 7): read-only
|
||||
|
||||
set HDR-NFA here ", FENCE #id, #, 8 #, HDR-NFA #, HDR-LINK set HDR-LINK here : FENCE' FENCE ;
|
||||
\ ( -- ) as v3: what is defined now FORGET will not remove -- the fence is
|
||||
\ raised to HERE (v3's table; no standard defines FENCE, ruled 2026-11-14).
|
||||
set HDR-NFA here ", FENCE #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: FENCE DP a! @ 3 + 2/ 2/ (FENCE) a! ! ;
|
||||
|
||||
\ ---- the heat registers (DECOMPOSITION.md section 7; #189) -----------------------
|
||||
\ Captain Bob, 2026-11-12: "Add HEAT-OP". The node counts every instruction it
|
||||
@@ -95,13 +98,13 @@ set HDR-NFA here ", VLIST #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK he
|
||||
\ FORGET xxx FORTH-79: remove xxx and every word defined after it, in
|
||||
\ whatever vocabulary; the space they took is free again. A vocabulary that
|
||||
\ goes is no longer CONTEXT or CURRENT: FORTH is. A word that is not there
|
||||
\ is an error, and so is one below FENCE, which is where the capsule's own
|
||||
\ is an error, and so is one below the fence, which is where the capsule's own
|
||||
\ words are (code 10, "Protected word").
|
||||
set HDR-NFA here ", FORGET #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: FORGET
|
||||
32 WORD (LOOKUP) if MISSING
|
||||
-2 + a! @ \ where its name starts
|
||||
dup FENCE a! @ inv + 1 + -if OK \ name - fence
|
||||
dup (FENCE) a! @ inv + 1 + -if OK \ name - fence
|
||||
drop drop NODE-ERROR b! 10 !b ;
|
||||
OK: drop
|
||||
dup (Q) a! ! 4* DP a! ! \ the space from its name on
|
||||
@@ -153,7 +156,7 @@ set HDR-NFA here ", COLD #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK her
|
||||
: COLD
|
||||
(BOOT) a! @ DP a! !
|
||||
(BOOT)+1 a! @ (LATEST) a! !
|
||||
(BOOT) a! @ 2/ 2/ FENCE a! !
|
||||
(BOOT) a! @ 2/ 2/ (FENCE) a! !
|
||||
(BOOT-ID) a! @ (NEXT-ID) a! !
|
||||
(LATEST) CONTEXT a! ! (LATEST) CURRENT a! ! 0 VOC-LINK a! !
|
||||
10 BASE a! ! 0 SCR a! ! 2 (LOG-LEVEL) a! ! 0 (ACL-HOOK) a! ! EMPTY-BUFFERS
|
||||
@@ -165,20 +168,28 @@ set HDR-NFA here ", COLD #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK her
|
||||
\ ---- deferred words (as v3) -------------------------------------------------------
|
||||
\ DEFER xxx makes xxx, which does whatever word it has been given:
|
||||
\ ' yyy IS xxx gives it one; DEFER@ xxx leaves the one it has. A deferred
|
||||
\ word with none is an error (code 15, "Deferred word not set").
|
||||
\ word with none is an error (code 15, "Deferred word not set"). DEFER marks
|
||||
\ its word with flag 128 (dict.f18); IS and DEFER@ refuse any other word, as v3
|
||||
\ does ("was not created by DEFER"): error 22, "Not deferred".
|
||||
: (DODEFER)
|
||||
pop a! @ if UNSET push ; \ go to it: it returns to xxx's caller
|
||||
UNSET: drop NODE-ERROR b! 15 !b ;
|
||||
set HDR-NFA here ", DEFER #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: DEFER &(DODEFER) (C)+3 a! ! (DATA) (C)+8 a! @ if NONE drop 0 jump , NONE: drop ;
|
||||
: DEFER &(DODEFER) (C)+3 a! ! (DATA) (C)+8 a! @ if NONE drop LATEST (FLAGS) a! @ 128 OR ! 0 jump , NONE: drop ;
|
||||
: (is!) a! ! ;
|
||||
\ ( "name" -- addr ) the data address of the deferred word named next
|
||||
: (DEFERRED)
|
||||
32 WORD (LOOKUP) if MISSING
|
||||
dup (FLAGS) a! @ 128 and if NOTDEF drop jump PFA
|
||||
NOTDEF: drop drop NODE-ERROR b! 22 !b ;
|
||||
MISSING: drop jump (UNKNOWN)
|
||||
: (defer@) a! @ ;
|
||||
set HDR-NFA here ", IS #id, #, 1 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: IS
|
||||
(') STATE a! @ if NOW drop (LIT,) &(is!) jump (CALL,)
|
||||
(DEFERRED) STATE a! @ if NOW drop (LIT,) &(is!) jump (CALL,)
|
||||
NOW: drop jump (is!)
|
||||
set HDR-NFA here ", DEFER@ #id, #, 1 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: DEFER@
|
||||
(') STATE a! @ if NOW drop (LIT,) &(defer@) jump (CALL,)
|
||||
(DEFERRED) STATE a! @ if NOW drop (LIT,) &(defer@) jump (CALL,)
|
||||
NOW: drop jump (defer@)
|
||||
|
||||
|
||||
@@ -175,11 +175,11 @@ EXECUTE ( xt -- ) Run the word whose execution token is xt.
|
||||
EXIT ( -- ) Compile-only: return from the definition at this point.
|
||||
EXPECT ( baddr n -- ) Read up to n characters, or a line, from the terminal into baddr; SPAN holds how many.
|
||||
FALSE ( -- 0 ) Constant: the false flag, zero.
|
||||
FENCE ( -- addr ) Variable: FORGET will not remove anything below the address it holds.
|
||||
FENCE ( -- ) As v3: FORGET will not remove anything defined so far (the fence is raised to HERE).
|
||||
FILL ( baddr u c -- ) Fill u bytes from baddr with the byte c.
|
||||
FIND ( -- xt | 0 ) FIND xxx: the execution token of xxx, from the input stream, or 0 if it is not found.
|
||||
FLUSH ( -- ) Write every changed block (SAVE-BUFFERS).
|
||||
FORGET ( -- ) FORGET xxx: remove xxx and every word defined after it, never below FENCE.
|
||||
FORGET ( -- ) FORGET xxx: remove xxx and every word defined after it, never below the fence (FENCE).
|
||||
FORTH ( -- ) Make FORTH, the primary vocabulary, the CONTEXT vocabulary.
|
||||
FREEZE-WORD ( baddr u -- ) The word named stops decaying (its record frozen, in the kernel). Nothing if there is no such word.
|
||||
FROZEN? ( baddr u -- flag ) True if the word named is frozen; false for one that is not, or is not there.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 11 and column 3.
|
@@ -115,3 +115,28 @@ v3's behaviour -- or its table, where v3 contradicts it -- only for v3's own ext
|
||||
least significant 16 bits is two greater than the address of the most significant 16 bits." FORTH-79 says
|
||||
only "as for a double number" (`2!`). v4's `2!` `2@` `2,` stored the low cell first, "as v3": changed to the
|
||||
high cell at the lower address.
|
||||
|
||||
**Ruled (Captain Bob, 2026-11-14), on four questions from the whole table at 969 of 1018:**
|
||||
- **Capacity: "Enlarge v4 to fit".** Four stress cases push 100 to 900 values (v4's prompt node: 32); 21
|
||||
cases late in the run meet "Dictionary full" (1018 cases defining words in one dictionary; Hera's run-time
|
||||
space about 5.5K cells). The standards ask less (FORTH-79 6.2: a 64-byte data stack, 2000 bytes of
|
||||
dictionary; ANS: 32 cells), but v4 is grown until v3's cases fit.
|
||||
- **`Q./` by zero: "v3's table: q = 0".** No standard defines the Q48 words; v3's table says division by
|
||||
zero yields 0. v4's error 11 ("Division by zero (Q./)") goes.
|
||||
- **`SP@` `SP!`: D-2 stands; `FENCE`: v3's** ("D-2 for SP@; v3 for FENCE"). The six `SP@`/`SP!` cases are
|
||||
dropped: no stack pointer is visible to code (DECOMPOSITION.md D-2). `FENCE` becomes v3's word -- it
|
||||
protects what is defined so far from FORGET -- and the variable FORGET and COLD read is `(FENCE)`.
|
||||
- **SPAN: "Fix it in Phase 7".** v4's interpreter took the line's length from SPAN, so an `EXPECT` in a
|
||||
line cut the rest of the line off, and `0 EXPECT` could not leave SPAN 0 (FORTH-83: SPAN is the count the
|
||||
last EXPECT stored). The line's length gets its own variable.
|
||||
|
||||
Settled under the rulings above, without a question:
|
||||
- `IS` and `DEFER@` refuse a word `DEFER` did not make, as v3 ("was not created by DEFER"): error 22, "Not
|
||||
deferred". v4's IS stored into any word -- `42 IS DUP` broke `DUP` for every case after it.
|
||||
- `SMUDGE` and `HIDDEN` at the prompt are errors, as v3's table (no standard defines them): v4 marks them
|
||||
compile-only. v4's hid the newest word.
|
||||
- `DABS` and `DMIN` given too few values: ANS (8.6.1.1160, 8.6.1.1220) makes stack underflow an ambiguous
|
||||
condition, so there is no error to expect: dropped.
|
||||
- `CMOVE>.bounds` and `THRU.negative_end` dropped (no standard asks for the error); the cases that write
|
||||
through `HERE` as a byte address -- `CMOVE>`, `BLANK`, `ERASE`, `FILL` -- in v4's units (they wrote into
|
||||
the system's code).
|
||||
|
||||
@@ -58,7 +58,7 @@ typedef struct {
|
||||
|
||||
/* What COLD returns the system to and FORGET will not go below: two
|
||||
* cells, DP and LATEST as they were when the system was complete, and
|
||||
* the variable FENCE. The system's source sets them; a system that
|
||||
* the variable (FENCE). The system's source sets them; a system that
|
||||
* loads capsules when it boots sets them again when it has
|
||||
* (v4_image_seal). */
|
||||
v4_cell boot_cells, fence;
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#define V4_POST_DEPTH 1 /* only how many values it leaves; what it prints is not compared */
|
||||
#define V4_POST_DEPTH_OUTPUT 2 /* how many values it leaves, and what it prints */
|
||||
#define V4_POST_ERROR 3 /* it must end in an error; nothing else is compared */
|
||||
#define V4_POST_HEAD 4 /* how many values it leaves, and how what it prints begins: the form of a
|
||||
printout whose values are the run's own (TOP-WORDS; #189, 2026-11-14) */
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
|
||||
+4
-1
@@ -89,7 +89,10 @@ int v4_post_run(const v4_post_host *h, const v4_post_case *cases, unsigned count
|
||||
if (depth > SHOWN_STACK) ok = 0;
|
||||
for (k = 0; ok && k < depth; k++) ok = left[k] == (v4_cell)c->stack[depth - 1u - k];
|
||||
}
|
||||
if (ok && c->expect != V4_POST_DEPTH) {
|
||||
if (ok && c->expect == V4_POST_HEAD) {
|
||||
ok = c->output_len <= kept;
|
||||
for (k = 0; ok && k < c->output_len; k++) ok = out[k] == c->output[k];
|
||||
} else if (ok && c->expect != V4_POST_DEPTH) {
|
||||
ok = total == c->output_len && total <= V4_POST_OUT;
|
||||
for (k = 0; ok && k < total; k++) ok = out[k] == c->output[k];
|
||||
}
|
||||
|
||||
+4
-2
@@ -66,7 +66,8 @@
|
||||
#define HOTVARS (XVARS - 35) /* (HOT): the hot-words cache (#189 Phase 7): its count, the kernel's next slot to take when it is full, the lookup's index, then 32 xts */
|
||||
#define HOT_SIZE 32
|
||||
#define QBASE (HOTVARS - 40) /* the Q words' and DUMP's scratch cells, 39 in all */
|
||||
#define BVARS (QBASE - 16) /* blocks.f18: 6 cells not used now, then SCR BLK (SRC) (SRC-HOOK) */
|
||||
#define BVARS (QBASE - 16) /* blocks.f18: 5 cells not used now, then (#SRC) SCR BLK (SRC) (SRC-HOOK) */
|
||||
#define SRC_LEN (BVARS + 5) /* (#SRC): the length of the text being interpreted (SPAN is EXPECT's count, FORTH-83) */
|
||||
#define SCR (BVARS + 6)
|
||||
#define BLK (BVARS + 7)
|
||||
#define SRC (BVARS + 8)
|
||||
@@ -299,6 +300,7 @@ static unsigned host_branch_slots(void)
|
||||
X("SCR", SCR) \
|
||||
X("BLK", BLK) \
|
||||
X("(SRC)", SRC) \
|
||||
X("(#SRC)", SRC_LEN) \
|
||||
X("(SRC-HOOK)", SRC_HOOK) \
|
||||
X("(LINE-STATUS)", LINE_STATUS) \
|
||||
X("(PORT)", PORT) \
|
||||
@@ -370,7 +372,7 @@ static unsigned host_branch_slots(void)
|
||||
X("N-17", V4_CELL_BITS - 17) \
|
||||
X("MAX-INT", (v4_cell)(V4_MSB - 1u)) \
|
||||
X("HLD", HLD) \
|
||||
X("FENCE", FENCE) \
|
||||
X("(FENCE)", FENCE) \
|
||||
X("CONTEXT", CONTEXT) \
|
||||
X("CURRENT", CURRENT) \
|
||||
X("VOC-LINK", VOC_LINK) \
|
||||
|
||||
@@ -805,16 +805,14 @@ static void build(void)
|
||||
* OV: drop drop drop pop pop drop drop
|
||||
* QS 4 + b! @b -if OVP drop 0 MSB ; OVP: drop -1 MAXHI ;
|
||||
* DIV: (UQ/) QS 4 + b! @b -if L3 drop DNEGATE ; L3: drop ;
|
||||
* ZERO: drop drop drop NODE-ERROR b! -1 !b
|
||||
* over over OR if Z0 drop -if ZP drop drop 0 MSB ;
|
||||
* ZP: drop drop -1 MAXHI ; Z0: drop ;
|
||||
* ZERO: drop drop drop drop drop 0 0 ; by zero: 0 (ruled 2026-11-14)
|
||||
* MSB and MAXHI are the high cells of Q min and Q max. Clobbers A and B. */
|
||||
#define SWAP_INLINE() do { O(OVER); O(PUSH); O(PUSH); O(DROP); O(RPOP); O(RPOP); } while (0)
|
||||
#define SUB_INLINE() do { O(PUSH); O(INV); O(RPOP); O(ADD); O(INV); } while (0)
|
||||
#define FWD(op) v4_asm_branch_fwd(&as, V4_OP_##op)
|
||||
#define HERE_(r) v4_asm_resolve(&as, (r), v4_asm_label(&as))
|
||||
{
|
||||
v4_asm_ref zero, l1, l2, chk, chk2, same, noov1, ov1, ov2, ovp, l3, z0, zp;
|
||||
v4_asm_ref zero, l1, l2, chk, chk2, same, noov1, ov1, ov2, ovp, l3;
|
||||
v4_asm_ref d1, d2, d3;
|
||||
v4_cell l_div, l_noov, l_ov;
|
||||
|
||||
@@ -853,14 +851,8 @@ static void build(void)
|
||||
CALL(w_uqdiv); LIT(QS + 4); O(BANG_B); O(FETCH_B); l3 = FWD(MINUS_IF);
|
||||
O(DROP); CALL(w_dnegate); O(SEMI);
|
||||
HERE_(l3); O(DROP); O(SEMI);
|
||||
HERE_(zero);
|
||||
O(DROP); O(DROP); O(DROP);
|
||||
LIT(NODE_ERROR); O(BANG_B); LIT(-1); O(STORE_B);
|
||||
O(OVER); O(OVER); CALL(w_or); z0 = FWD(IF);
|
||||
O(DROP); zp = FWD(MINUS_IF);
|
||||
O(DROP); O(DROP); LIT(0); LIT((v4_cell)V4_MSB); O(SEMI);
|
||||
HERE_(zp); O(DROP); O(DROP); LIT(-1); LIT((v4_cell)(MAXU >> 1)); O(SEMI);
|
||||
HERE_(z0); O(DROP); O(SEMI);
|
||||
HERE_(zero); /* by zero: 0, no error (v3's table, ruled 2026-11-14) */
|
||||
O(DROP); O(DROP); O(DROP); O(DROP); O(DROP); LIT(0); LIT(0); O(SEMI);
|
||||
|
||||
v4_asm_resolve(&as, d1, l_div);
|
||||
v4_asm_resolve(&as, d2, l_div);
|
||||
@@ -1867,8 +1859,8 @@ static uint64_t v3_q48_mul(uint64_t a, uint64_t b)
|
||||
/* Reference Q./ (D-11), by a different method from the FORTH: magnitudes
|
||||
* in 16-bit limbs, |a| * 2^16 divided by |b| one bit at a time, then the
|
||||
* sign applied (rounding toward zero) and the result saturated to Q max or
|
||||
* Q min. Division by zero gives Q max / Q min by the dividend's sign, 0 for
|
||||
* 0 / 0, and *err = 1. */
|
||||
* Q min. Division by zero gives 0 and no error (v3's table, ruled
|
||||
* 2026-11-14). */
|
||||
static void qdiv_ref(v4_ucell al, v4_ucell ah, v4_ucell bl, v4_ucell bh,
|
||||
v4_ucell *rl, v4_ucell *rh, int *err)
|
||||
{
|
||||
@@ -1877,11 +1869,8 @@ static void qdiv_ref(v4_ucell al, v4_ucell ah, v4_ucell bl, v4_ucell bh,
|
||||
unsigned i, k;
|
||||
|
||||
*err = 0;
|
||||
if (bl == 0 && bh == 0) {
|
||||
*err = 1;
|
||||
if (al == 0 && ah == 0) { *rl = 0; *rh = 0; }
|
||||
else if (ah & V4_MSB) { *rl = 0; *rh = V4_MSB; }
|
||||
else { *rl = MAXU; *rh = MAXU >> 1; }
|
||||
if (bl == 0 && bh == 0) { /* 0, no error: v3's table (ruled 2026-11-14) */
|
||||
*rl = 0; *rh = 0;
|
||||
return;
|
||||
}
|
||||
q_to_limbs(al, ah, a, &an);
|
||||
|
||||
@@ -103,6 +103,7 @@ static int interpret_with(const char *line, unsigned depth, unsigned rdepth)
|
||||
unsigned len = (unsigned)strlen(line), i;
|
||||
put_bytes(TIB, line, len + 1u);
|
||||
n.mem[SPAN] = (v4_cell)len;
|
||||
n.mem[SRC_LEN] = (v4_cell)len;
|
||||
n.mem[TO_IN] = 0;
|
||||
n.mem[NODE_ERROR] = 0;
|
||||
v4_dstack_reset(&n.ds);
|
||||
@@ -132,7 +133,7 @@ static v4_cell one(const char *line)
|
||||
/* the line is abandoned: NODE-ERROR set, not compiling, the rest of it skipped */
|
||||
static int abandoned(const char *line)
|
||||
{
|
||||
return interpret(line) && err() && n.mem[STATE] == 0 && n.mem[TO_IN] == n.mem[SPAN];
|
||||
return interpret(line) && err() && n.mem[STATE] == 0 && n.mem[TO_IN] == n.mem[SRC_LEN];
|
||||
}
|
||||
|
||||
typedef struct { const char *defs, *expr; unsigned nres; v4_cell want[4]; int v3; } programme;
|
||||
|
||||
@@ -66,6 +66,7 @@ static void set_line(const char *s)
|
||||
unsigned len = (unsigned)strlen(s);
|
||||
put_bytes(TIB, s, len + 1u);
|
||||
n.mem[SPAN] = (v4_cell)len;
|
||||
n.mem[SRC_LEN] = (v4_cell)len;
|
||||
n.mem[TO_IN] = 0;
|
||||
}
|
||||
static v4_cell W(const char *name)
|
||||
|
||||
@@ -74,6 +74,7 @@ static void set_line(const char *s)
|
||||
unsigned len = (unsigned)strlen(s);
|
||||
put_bytes(TIB, s, len + 1u);
|
||||
n.mem[SPAN] = (v4_cell)len;
|
||||
n.mem[SRC_LEN] = (v4_cell)len;
|
||||
n.mem[TO_IN] = 0;
|
||||
}
|
||||
|
||||
@@ -316,7 +317,7 @@ int main(void)
|
||||
k = n.input_len - n.input_pos;
|
||||
CHECK(k == (i < t ? 0u : i + 1u - t), "EXPECT leaves %u unread [%u,%u]", k, t, i);
|
||||
}
|
||||
/* no action for n <= 0: nothing read, nothing stored, SPAN as it was, no error */
|
||||
/* for n <= 0 nothing is read or stored, no error, and SPAN is 0: FORTH-83, the count received (ruled 2026-11-14) */
|
||||
{
|
||||
static const v4_cell none[] = { 0, -1, -100, (v4_cell)V4_MSB };
|
||||
for (i = 0; i < 4; i++) {
|
||||
@@ -324,8 +325,8 @@ int main(void)
|
||||
v4_node_console_input_attach(&n, CONSOLE_RX, CONSOLE_ST);
|
||||
(void)v4_node_console_feed(&n, "abc\n", 4);
|
||||
n.mem[SPAN] = 5;
|
||||
CHECK(run("EXPECT", 2, SBUF, none[i], 0) && clean() && !err() && n.mem[SPAN] == 5
|
||||
&& n.input_len - n.input_pos == 4 && byte_at(SBUF) == 0x2A, "EXPECT takes no action for n <= 0 [%u]", i);
|
||||
CHECK(run("EXPECT", 2, SBUF, none[i], 0) && clean() && !err() && n.mem[SPAN] == 0
|
||||
&& n.input_len - n.input_pos == 4 && byte_at(SBUF) == 0x2A, "EXPECT reads nothing for n <= 0, and SPAN is 0 [%u]", i);
|
||||
}
|
||||
v4_node_console_input_attach(&n, CONSOLE_RX, CONSOLE_ST);
|
||||
}
|
||||
@@ -335,8 +336,8 @@ int main(void)
|
||||
n.mem[TO_IN] = 77;
|
||||
CHECK(v4_node_console_feed(&n, " 12 34 +\nnext line\n", 20) == 20, "fed");
|
||||
CHECK(run("QUERY", 0, 0, 0, 0) && clean() && !err(), "QUERY returns");
|
||||
CHECK(n.mem[SPAN] == 9 && n.mem[TO_IN] == 0 && bytes_are(TIB, " 12 34 +\0", 10), "QUERY fills TIB, sets SPAN and zeroes >IN");
|
||||
CHECK(run("SOURCE", 0, 0, 0, 0) && pop() == 9 && pop() == TIB && clean(), "SOURCE is TIB and SPAN @");
|
||||
CHECK(n.mem[SPAN] == 9 && n.mem[SRC_LEN] == 9 && n.mem[TO_IN] == 0 && bytes_are(TIB, " 12 34 +\0", 10), "QUERY fills TIB, sets SPAN and the line's length, and zeroes >IN");
|
||||
CHECK(run("SOURCE", 0, 0, 0, 0) && pop() == 9 && pop() == TIB && clean(), "SOURCE is TIB and the line's length");
|
||||
CHECK(run("QUERY", 0, 0, 0, 0) && clean() && n.mem[SPAN] == 9 && bytes_are(TIB, "next line\0", 10), "the next QUERY reads the next line");
|
||||
{
|
||||
static char longline[200];
|
||||
@@ -349,8 +350,8 @@ int main(void)
|
||||
CHECK(run("QUERY", 0, 0, 0, 0) && clean() && n.mem[SPAN] == 70 && bytes_are(TIB, longline + 80, 70), "the rest of the line is the next QUERY's");
|
||||
v4_node_console_input_attach(&n, CONSOLE_RX, CONSOLE_ST);
|
||||
}
|
||||
n.mem[SPAN] = -5;
|
||||
CHECK(run("SOURCE", 0, 0, 0, 0) && pop() == 0 && pop() == TIB && clean(), "SOURCE reads a negative SPAN as 0");
|
||||
n.mem[SRC_LEN] = -5;
|
||||
CHECK(run("SOURCE", 0, 0, 0, 0) && pop() == 0 && pop() == TIB && clean(), "SOURCE reads a negative length as 0");
|
||||
|
||||
/* ---- WORD ---- */
|
||||
|
||||
@@ -417,8 +418,8 @@ int main(void)
|
||||
set_line("abc def");
|
||||
n.mem[TO_IN] = -3;
|
||||
CHECK(run("WORD", 1, 32, 0, 0) && word_is(pop(), "abc", ' ') && clean(), "a negative >IN reads as 0");
|
||||
n.mem[SPAN] = -3; n.mem[TO_IN] = 0;
|
||||
CHECK(run("WORD", 1, 32, 0, 0) && word_is(pop(), "", 0) && clean() && n.mem[TO_IN] == 0, "a negative SPAN reads as an empty line");
|
||||
n.mem[SRC_LEN] = -3; n.mem[TO_IN] = 0;
|
||||
CHECK(run("WORD", 1, 32, 0, 0) && word_is(pop(), "", 0) && clean() && n.mem[TO_IN] == 0, "a negative length reads as an empty line");
|
||||
|
||||
/* ---- the comment words ---- */
|
||||
set_line("skip this ) kept ( and ) too");
|
||||
|
||||
@@ -697,8 +697,8 @@ static const transcript script[] = {
|
||||
{ "1 Q.FROM-INT 2 Q.FROM-INT Q./ Q.LOG Q.PRINT\n", "-0.69314 ok\nok> ", 0 },
|
||||
{ "-1 Q.FROM-INT 3 Q.FROM-INT Q./ -1 Q.FROM-INT 7 Q.FROM-INT Q./ Q.* . .\n", "0 3120 ok\nok> ", 0 },
|
||||
{ "-4 Q.FROM-INT Q.SIN . . 4 Q.FROM-INT Q.COS . .\n", "0 49598 -1 -42838 ok\nok> ", 0 },
|
||||
{ "Q.0 Q.0 Q./ 65 EMIT\nDEPTH .\n", "Division by zero\n ERROR\nok> 2 ok\nok> ", 0 },
|
||||
{ "7 Q.1 Q.0 Q./ 65 EMIT\nDEPTH .\n", "Division by zero\n ERROR\nok> 3 ok\nok> ", 0 },
|
||||
{ "Q.0 Q.0 Q./ 65 EMIT\nDEPTH .\n", "A ok\nok> 2 ok\nok> ", 0 }, /* by zero: 0, no error (v3's table, ruled 2026-11-14) */
|
||||
{ "7 Q.1 Q.0 Q./ 65 EMIT\nDEPTH .\n", "A ok\nok> 3 ok\nok> ", 0 },
|
||||
{ "7 -4 Q.FROM-INT Q.SQRT 65 EMIT\nDEPTH . . . .\n", "Argument out of range\n ERROR\nok> 3 0 0 7 ok\nok> ", 0 },
|
||||
{ "Q.0 Q.LOG 65 EMIT\n-1 Q.FROM-INT Q.LOG\n", "Argument out of range\n ERROR\nok> Argument out of range\n ERROR\nok> ", 0 },
|
||||
{ "7 PAD -1 DUMP 65 EMIT\n.S\n", "Negative count\n ERROR\nok> <1> 7 \n ok\nok> ", 0 },
|
||||
@@ -1320,7 +1320,7 @@ int main(void)
|
||||
v4_cell dp0 = n.mem[DP], latest0 = n.mem[LATEST];
|
||||
CHECK(is(say(": F1 1 ; VARIABLE F2 : F3 F1 F2 ;\n"), " ok\nok> ") && n.mem[DP] > dp0, "three words");
|
||||
CHECK(is(say("FORGET F1\n"), " ok\nok> ") && n.mem[DP] == dp0 && n.mem[LATEST] == latest0, "FORGET of the first puts HERE and LATEST back where they were");
|
||||
CHECK(is(say(": G1 65 EMIT ; : G2 66 EMIT ;\n"), " ok\nok> ") && is(say("HERE FENCE ! : G3 67 EMIT ;\n"), " ok\nok> "), "two words, the fence, and a third");
|
||||
CHECK(is(say(": G1 65 EMIT ; : G2 66 EMIT ;\n"), " ok\nok> ") && is(say("FENCE : G3 67 EMIT ;\n"), " ok\nok> "), "two words, the fence, and a third");
|
||||
CHECK(is(say("FORGET G2\n"), "Protected word\n ERROR\nok> ") && is(say("G1 G2 G3\n"), "ABC ok\nok> "), "a word below the fence cannot be forgotten");
|
||||
CHECK(is(say("FORGET G3 G1 G2\n"), "AB ok\nok> ") && is(say("G3\n"), "UNKNOWN WORD: 'G3'\n ERROR\nok> "), "one above it can");
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ static const math_case cases[] = {
|
||||
{ 4, 4, {1, 0, 1, 0}, 2, {0, 0}, 0 },
|
||||
{ 5, 4, {65536, 0, 196608, 0}, 2, {21845, 0}, 0 },
|
||||
{ 5, 4, {-491520, -1, 131072, 0}, 2, {-245760, -1}, 0 },
|
||||
{ 5, 4, {65536, 0, 0, 0}, 2, {-1, X}, 11 },
|
||||
{ 5, 4, {-65536, -1, 0, 0}, 2, {0, M}, 11 },
|
||||
{ 5, 4, {0, 0, 0, 0}, 2, {0, 0}, 11 },
|
||||
{ 5, 4, {65536, 0, 0, 0}, 2, {0, 0}, 0 }, /* Q./ by zero: 0, no error (v3's table, ruled 2026-11-14) */
|
||||
{ 5, 4, {-65536, -1, 0, 0}, 2, {0, 0}, 0 },
|
||||
{ 5, 4, {0, 0, 0, 0}, 2, {0, 0}, 0 },
|
||||
{ 5, 4, {0, 1, 1, 0}, 2, {0, 65536}, 0 },
|
||||
{ 5, 4, {-1, X, 32768, 0}, 2, {-1, X}, 0 },
|
||||
{ 5, 4, {M, -1, -65536, -1}, 2, {M, 0}, 0 },
|
||||
|
||||
@@ -116,6 +116,10 @@ int main(void)
|
||||
|
||||
/* ---- the boot ---- */
|
||||
CHECK(v4_mesh_boot(&ms) == 1, "the boot: %s", said);
|
||||
{ /* POST's tally, shown: for runs of other tables (mkpost --all) */
|
||||
const char *t = strstr(said, "PARITY:V4_POST ");
|
||||
if (t) printf(" %.*s\n", (int)(strchr(t, '\n') ? strchr(t, '\n') - t : 40), t);
|
||||
}
|
||||
CHECK(strstr(said, "PARITY:V4_ROM ") != 0, "the ROM assembled the nucleus, and said so");
|
||||
CHECK(strstr(said, "PARITY:V4_CAPSULE name=v4:forth79.4th ") && strstr(said, "PARITY:V4_CAPSULE name=v4:centre.4th ")
|
||||
&& strstr(said, "PARITY:V4_CAPSULE name=v4:hera.4th "), "FORTH-79 and the kernel's capsules, each with its parity line");
|
||||
|
||||
+11
-2
@@ -319,13 +319,18 @@ def main():
|
||||
help="every case of v3's whole POST, every module and word, not the Required set alone "
|
||||
"(#189 Phase 7, Task 8: the measure of parity); with --out, and no document written")
|
||||
ap.add_argument("--out", default=None, help="write the table here, not system/post_cases.c")
|
||||
ap.add_argument("--only", default=None, help="with --all: only these modules, comma-separated (to find what a case leaves behind)")
|
||||
args = ap.parse_args()
|
||||
global OUTPUT
|
||||
if args.out:
|
||||
OUTPUT = os.path.abspath(args.out)
|
||||
if args.all: # the whole POST's own rules (post_all_rules.py), beside 79's
|
||||
import post_all_rules
|
||||
rules.STANDARD.update(post_all_rules.STANDARD)
|
||||
rules.DROPPED.update(post_all_rules.DROPPED)
|
||||
|
||||
required, left_out, cases, seen = set(REQUIRED), [], [], {}
|
||||
for module in (MODULES_ALL if args.all else MODULES):
|
||||
for module in ([m for m in MODULES_ALL if not args.only or m in args.only.split(",")] if args.all else MODULES):
|
||||
for word, name, text, should_error in read_module(os.path.join(MODULE_DIR, module)):
|
||||
if word not in required and not args.all:
|
||||
continue
|
||||
@@ -395,7 +400,9 @@ def main():
|
||||
continue
|
||||
lines = pack("T|", atoms(rule.get("text", case["text"])))
|
||||
assert lines, label
|
||||
if "depth" in rule:
|
||||
if "head" in rule: # the form of a printout whose values are the run's own
|
||||
emit(label, lines, {"expect": "V4_POST_HEAD", "stack": [], "depth": rule.get("depth", 0), "out": rule["head"]})
|
||||
elif "depth" in rule:
|
||||
emit(label, lines, {"expect": "V4_POST_DEPTH", "stack": [], "depth": rule["depth"], "out": ""})
|
||||
else:
|
||||
emit(label, lines, expectation(rule.get("error", False), rule.get("stack", []), rule.get("out", "")))
|
||||
@@ -481,6 +488,8 @@ def code(text):
|
||||
def expects(rule):
|
||||
if rule.get("error"):
|
||||
return "an error"
|
||||
if "head" in rule:
|
||||
return "%d value(s) left; prints, to begin with, `%s`" % (rule.get("depth", 0), rule["head"].replace("\n", "\\n"))
|
||||
if "depth" in rule:
|
||||
return "%d value(s) left; output not compared" % rule["depth"]
|
||||
return "stack `%s`, prints %s" % (" ".join(str(v) for v in rule.get("stack", [])) or "empty",
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
# SPDX-License-Identifier: LicenseRef-Starship-1.0
|
||||
# Copyright (c) 2023-2026 Robert A. James
|
||||
"""post_all_rules.py -- v3's whole POST on v4: where a case is not taken as v3 ran it (#189 Phase 7, Task 8).
|
||||
|
||||
mkpost.py --all takes every case of v3's whole POST, v3 the reference, with post79_rules.py's rules for the
|
||||
Required set. These are the rest, in post79_rules.STANDARD's shape: `text` if the line changes, then `error`,
|
||||
or `stack` and `out`, or `depth`; `why` the reason. None drops a case (DROPPED gives why).
|
||||
|
||||
The authority, ruled by Captain Bob 2026-11-14 (docs/v4.0.0/POST-PARITY.md; the texts in
|
||||
docs/reference/standards/): FORTH-79, then FORTH-83, then ANS Forth 1994, then v3 -- held to its own table
|
||||
where v3 does not do what the table says -- only for words no standard defines. Where a case's output names
|
||||
v3's own words, its form is kept with v4's values. Every expectation here is worked from that authority, not
|
||||
taken from what v4 prints.
|
||||
"""
|
||||
|
||||
D1 = "v3's address unit is a byte in 8-byte cells; v4's is a cell (D-1): the case in v4's units, a byte address 4 * a cell's"
|
||||
D83 = "FORTH-83 ('number'): a double is stored with its high cell at the lower address (ruled 2026-11-14)"
|
||||
D79 = "FORTH-79: a double on the stack has its high cell on top; the case's double was written low-cell-last"
|
||||
ANS_MPLUS = "ANS Forth 8.6.1.1830 M+ ( d1 n -- d2 ); v3's results, and its descriptions, are not"
|
||||
ANS_2R = "ANS Forth 6.2.0340 2>R: 'Interpretation semantics for this word are undefined' -- the case run inside a definition"
|
||||
V3TABLE = "v3's own word: v3 raises an error its table says it does not (ruled: v3's table, not v3's bugs)"
|
||||
DAMAGE = "v3's case in v3's units, run in v4's, writes into the system's code (FILL at a cell address taken as a byte address)"
|
||||
DAMAGE_W = "v3's case in v3's units, run in v4's, writes into the system's code (HERE, a cell address, taken as a byte address)"
|
||||
ANS_RF = "ANS Forth 6.1.0580 >R: 'Interpretation semantics for this word are undefined' -- the case run inside a definition"
|
||||
|
||||
V3ADDR = "the case leaves an address on the stack (HERE's, or S\"'s), a different number on each machine: the case without it"
|
||||
ANS_CMP = "ANS Forth 17.6.1.0935 COMPARE and 17.6.1.2191 SEARCH, as their descriptions have them; v3's case compares S\"'s string with HERE taken as a length. In a definition, as ANS 11.6.1.2165 S\" keeps one interpreted string only"
|
||||
V3OWN_DESC = "v3's own word, as its table's description has it; v3's case leaves HERE on the stack"
|
||||
F79BASE = "FORTH-79 BASE: numbers are converted in and out in BASE -- after 16 BASE ! the line's 255 is hexadecimal and is printed 255; v3 printed it in decimal"
|
||||
F83THRU = "FORTH-83 THRU loads n1 through n2: with n2 below n1 there is none to load, and no error"
|
||||
V3INT = "v3's own word: v3 prints a value of its own machine (its DictEntry); the case as its description has it"
|
||||
ANS_BODY = "FORTH-83 >BODY takes a compilation address -- FORTH-79's FIND gives one; FORTH-79's ' gives the parameter field already, so v3's ' xxx >BODY goes one too far. v3 prints an address: the case shows >BODY's field is ''s (and VARIABLE's)"
|
||||
ORDERF = "ANS Forth 16.6.2.1985 ORDER: the form is the system's; v3 names FORTH '(FIND)' -- v4's form with v4's names"
|
||||
V3RUN = "v3 prints a number its table's description does not ask for; the description's value"
|
||||
QD = "Q48.16 on v4 is a double, low cell then high (ruled 2026-11-14): its raw value printed with D."
|
||||
INFHIST = "the value comes of the run's own history, the same on no two runs or machines: the case as its description has it ('no error')"
|
||||
DECAY = "v3's own word: the build's DECAY_RATE_PER_US_Q16, 1 by default (v3/Makefile, Kconfig.physics); the v3 that made the table was built with 0"
|
||||
|
||||
FORM = "v3's own word, its output v3's own words and counts: the form kept, v4's values (ruled 2026-11-14) -- they come of the run's history, so the printout's head is compared"
|
||||
WE_HEAD = "Word Usage Statistics (Execution Heat Counts):\n=============================================\n"
|
||||
def TOPHEAD(n): return "Top %d most frequently used words:\n==================================\n" % n
|
||||
|
||||
STANDARD = {
|
||||
# ---- memory_words ----
|
||||
"C,.basic": {"text": "ALIGN HERE 4 * 65 C, C@ . CR", "stack": [], "out": "65 \n", "why": D1},
|
||||
"C,.zero": {"text": "ALIGN HERE 4 * 0 C, C@ . CR", "stack": [], "out": "0 \n", "why": D1},
|
||||
"2,.roundtrip": {"text": "12345 67890 2, HERE 2 - 2@ . . CR", "stack": [], "out": "67890 12345 \n", "why": D1},
|
||||
"2,.save-and-verify": {"text": "12345 67890 2, HERE 2 - 2@ 67890 = SWAP 12345 = AND . CR",
|
||||
"stack": [], "out": "-1 \n", "why": D1},
|
||||
"-!.basic": {"stack": [], "out": "7 \n", "why": V3TABLE},
|
||||
"-!.by_zero": {"stack": [], "out": "42 \n", "why": V3TABLE},
|
||||
"-!.negative": {"stack": [], "out": "15 \n", "why": V3TABLE},
|
||||
"2!.basic": {"text": "11 22 HERE 2! HERE @ . HERE 1 + @ . CR", "stack": [], "out": "22 11 \n", "why": D1 + "; " + D83},
|
||||
"2!.zeros": {"text": "0 0 HERE 2! HERE @ . HERE 1 + @ . CR", "stack": [], "out": "0 0 \n", "why": D1 + "; " + D83},
|
||||
"2!.negative": {"text": "-1 -2 HERE 2! HERE @ . HERE 1 + @ . CR", "stack": [], "out": "-2 -1 \n", "why": D1 + "; " + D83},
|
||||
"ERASE.basic": {"text": "HERE 4 * 4 65 FILL HERE 4 * 4 ERASE HERE 4 * C@ . HERE 4 * 3 + C@ . CR",
|
||||
"stack": [], "out": "0 0 \n", "why": D1 + "; " + DAMAGE},
|
||||
"ERASE.zero_n": {"text": "HERE 4 * 0 ERASE", "stack": [], "out": "", "why": D1},
|
||||
"FILL.zero_n": {"text": "HERE 4 * 0 88 FILL", "stack": [], "out": "", "why": D1},
|
||||
"MOVE.zero_n": {"text": "HERE HERE 1 + 0 MOVE", "stack": [], "out": "", "why": D1},
|
||||
"HERE.after_comma~2": {"stack": [0], "out": "", "why": "v3 raises an error its table says it does not: HERE moves by 1 CELLS, so the flag is -1 and 0 -1 / is 0 (ruled: v3's table)"},
|
||||
# ---- string_words: the cases that write through HERE, in v4's byte units ----
|
||||
"CMOVE>.basic": {"text": ": PTCM S\" Test\" HERE 4 * 10 + SWAP CMOVE> ; PTCM HERE 4 * 10 + 4 TYPE CR",
|
||||
"stack": [], "out": "Test\n",
|
||||
"why": D1 + "; " + DAMAGE_W + "; " + ANS_RF + " (v3's DUP >R left the count on the return stack)"},
|
||||
"CMOVE>.overlap": {"text": "HERE 4 * DUP 1+ 5 CMOVE>", "stack": [], "out": "", "why": D1 + "; " + DAMAGE_W},
|
||||
"CMOVE>.bounds": None,
|
||||
"SP@.depth_effect": None,
|
||||
"SP@.empty_stack": None,
|
||||
"SP@.multiple_items": None,
|
||||
"SP!.basic_restore": None,
|
||||
"STACK_MGMT.sp_round_trip": None,
|
||||
"STACK_MGMT.depth_preservation": None,
|
||||
"DABS.one_item": None,
|
||||
"DMIN.three_items": None,
|
||||
"BLANK.basic": {"text": "HERE 4 * 5 BLANK HERE 4 * 5 TYPE CR", "stack": [], "out": " \n", "why": D1 + "; " + DAMAGE_W},
|
||||
# ---- string_words: from their descriptions; no address left behind ----
|
||||
"COMPARE.equal": {"text": ': PTC1 S" Test" S" Test" COMPARE . ; PTC1 CR', "stack": [], "out": "0 \n", "why": ANS_CMP},
|
||||
"COMPARE.less": {"text": ': PTC2 S" Test1" S" Test2" COMPARE . ; PTC2 CR', "stack": [], "out": "-1 \n", "why": ANS_CMP},
|
||||
"COMPARE.greater": {"text": ': PTC3 S" Test2" S" Test1" COMPARE . ; PTC3 CR', "stack": [], "out": "1 \n", "why": ANS_CMP},
|
||||
"COMPARE.different_lengths": {"text": ': PTC4 S" Test" S" Testing" COMPARE . ; PTC4 CR', "stack": [], "out": "-1 \n", "why": ANS_CMP},
|
||||
"SEARCH.found": {"text": ': PTS1 S" Testing" S" Test" SEARCH . . DROP ; PTS1 CR', "stack": [], "out": "-1 7 \n", "why": ANS_CMP},
|
||||
"SEARCH.not_found": {"text": ': PTS2 S" Testing" S" Xyz" SEARCH . . DROP ; PTS2 CR', "stack": [], "out": "0 7 \n", "why": ANS_CMP},
|
||||
"SEARCH.empty_pattern": {"text": ': PTS3 S" Test" HERE 4 * 0 SEARCH . . DROP ; PTS3 CR', "stack": [], "out": "-1 4 \n", "why": ANS_CMP + "; " + D1},
|
||||
"SEARCH.empty_string": {"text": ': PTS4 HERE 4 * 0 S" Test" SEARCH . . DROP ; PTS4 CR', "stack": [], "out": "0 0 \n", "why": ANS_CMP + "; " + D1},
|
||||
"SCAN.basic": {"text": 'S" Test,Data" BL SCAN TYPE CR', "stack": [], "out": "\n", "why": V3OWN_DESC},
|
||||
"SCAN.not_found": {"text": 'S" TestData" BL SCAN TYPE CR', "stack": [], "out": "\n", "why": V3OWN_DESC},
|
||||
"SCAN.all_delims": {"text": 'S" " BL SCAN TYPE CR', "stack": [], "out": " \n", "why": V3OWN_DESC},
|
||||
"SKIP.basic": {"text": 'S" Test" BL SKIP TYPE CR', "stack": [], "out": "Test\n", "why": V3OWN_DESC},
|
||||
"SKIP.no_delims": {"text": 'S" Test" BL SKIP TYPE CR', "stack": [], "out": "Test\n", "why": V3OWN_DESC},
|
||||
"SKIP.all_delims": {"text": 'S" " BL SKIP TYPE CR', "stack": [], "out": "\n", "why": V3OWN_DESC},
|
||||
"BL.in_scan": {"text": 'S" a b" BL SCAN SWAP DROP . CR', "stack": [], "out": "2 \n", "why": V3OWN_DESC},
|
||||
'S".interpret_len': {"text": 'S" hello" . DROP CR', "stack": [], "out": "5 \n", "why": V3ADDR},
|
||||
'S".empty': {"text": 'S" " . DROP CR', "stack": [], "out": "0 \n", "why": V3ADDR},
|
||||
# ---- io_words ----
|
||||
"BASE_OUTPUT.hex": {"stack": [], "out": "255 \n", "why": F79BASE},
|
||||
"BASE_OUTPUT.octal": {"stack": [], "out": "64 \n", "why": F79BASE},
|
||||
"BASE_OUTPUT.binary": {"stack": [], "out": "101 \n", "why": F79BASE + " (5 is read before BASE changes)"},
|
||||
"BASE_OUTPUT.base_restore": {"stack": [], "out": "FF \n", "why": F79BASE + " (255 is read in decimal)"},
|
||||
# ---- block_words ----
|
||||
"FLUSH.dirty_blocks": {"text": "1 BLOCK DROP UPDATE FLUSH", "stack": [], "out": "", "why": V3ADDR + " (BLOCK's)"},
|
||||
"THRU.zero_end": {"stack": [], "out": "", "why": F83THRU},
|
||||
"THRU.negative_end": None,
|
||||
# ---- dictionary_words ----
|
||||
"C,.basic~2": {"text": "ALIGN HERE 4 * 65 C, C@ . CR", "stack": [], "out": "65 \n", "why": D1},
|
||||
"C,.zero~2": {"text": "ALIGN HERE 4 * 0 C, C@ . CR", "stack": [], "out": "0 \n", "why": D1},
|
||||
"C,.high_byte": {"text": "ALIGN HERE 4 * 255 C, C@ . CR", "stack": [], "out": "255 \n", "why": D1},
|
||||
"C,.truncation": {"text": "ALIGN HERE 4 * 256 C, C@ . CR", "stack": [], "out": "0 \n", "why": D1},
|
||||
"C,.negative": {"text": "ALIGN HERE 4 * -1 C, C@ . CR", "stack": [], "out": "255 \n", "why": D1},
|
||||
"C,.multiple": {"text": "ALIGN HERE 4 * 65 C, 66 C, DUP C@ . 1+ C@ . CR", "stack": [], "out": "65 66 \n", "why": D1},
|
||||
"LATEST.stability": {"text": "LATEST DUP LATEST = . DROP CR", "stack": [], "out": "-1 \n", "why": V3ADDR + " (LATEST's)"},
|
||||
"COMPILATION.pad_isolation": {"text": "PAD 4 / 999 OVER ! HERE 42 , PAD 4 / @ 999 = . DROP DROP CR",
|
||||
"stack": [], "out": "-1 \n", "why": D1 + " (PAD is a byte address, ! takes a cell's); " + V3ADDR},
|
||||
# ---- dictionary_manipulation_words ----
|
||||
"LATEST.basic~2": {"text": "LATEST 0<> . CR", "stack": [], "out": "-1 \n", "why": V3INT},
|
||||
"LATEST.after_def": {"text": ": test7 46 ; LATEST ' test7 = . CR", "stack": [], "out": "-1 \n", "why": V3INT},
|
||||
"LATEST.after_forget": {"text": "LATEST CREATE test8 FORGET test8 LATEST = . CR", "stack": [], "out": "-1 \n", "why": V3INT},
|
||||
">BODY.basic": {"text": "CREATE test9 FIND test9 >BODY ' test9 = . CR", "stack": [], "out": "-1 \n", "why": ANS_BODY},
|
||||
">BODY.variable": {"text": "VARIABLE var1 FIND var1 >BODY var1 = . CR", "stack": [], "out": "-1 \n", "why": ANS_BODY},
|
||||
# ---- vocabulary_words ----
|
||||
"ORDER.basic": {"stack": [], "out": "Search order: FORTH \nCurrent: FORTH\n", "why": ORDERF},
|
||||
"ORDER.multiple": {"stack": [], "out": "Search order: TEST-VOC9 FORTH\nCurrent: TEST-VOC9\n", "why": ORDERF},
|
||||
"ORDER.after_forth": {"stack": [], "out": "Search order: FORTH \nCurrent: FORTH\n", "why": ORDERF},
|
||||
# ---- physics_freeze_words ----
|
||||
"FREEZE-WORD.basic": {"stack": [], "out": "-1 \n", "why": V3RUN},
|
||||
"UNFREEZE-WORD.basic": {"stack": [], "out": "0 \n", "why": V3RUN},
|
||||
"FROZEN?.not_frozen": {"stack": [], "out": "0 \n", "why": V3RUN},
|
||||
"FROZEN?.not_found": {"stack": [], "out": "0 \n", "why": V3RUN},
|
||||
"HEAT!.basic": {"stack": [], "out": "999 \n", "why": V3RUN},
|
||||
"HEAT@.of_fresh_word": {"stack": [], "out": "0 \n", "why": V3RUN},
|
||||
"DECAY-RATE@.basic": {"stack": [], "out": "1 \n", "why": DECAY},
|
||||
# ---- inference_words ----
|
||||
"Q.VARIANCE.three_cells": {"text": "100 HERE ! 200 HERE 1 + ! 300 HERE 2 + ! HERE 3 Q.VARIANCE Q.TO-INT . CR",
|
||||
"stack": [], "out": "6666 \n", "why": D1},
|
||||
"INFER-DECAY-SLOPE.three_cells": {"text": "300 HERE ! 200 HERE 1 + ! 100 HERE 2 + ! HERE 3 INFER-DECAY-SLOPE Q.TO-INT . CR",
|
||||
"stack": [], "out": "0 \n", "why": D1},
|
||||
"INFER-VARIANCE@.after_run": {"text": "INFER-RUN INFER-VARIANCE@ Q.TO-INT DROP CR", "stack": [], "out": "\n", "why": INFHIST},
|
||||
"INFER-WINDOW@.after_run": {"text": "INFER-RUN INFER-WINDOW@ DROP CR", "stack": [], "out": "\n", "why": INFHIST},
|
||||
"INFER-EARLY-EXIT@.after_run": {"text": "INFER-RUN INFER-EARLY-EXIT@ DUP 0= SWAP 1 = OR . CR", "stack": [], "out": "-1 \n", "why": INFHIST + " (0 or 1)"},
|
||||
# ---- q48_words ----
|
||||
"Q.1.raw_value": {"text": "Q.1 D. CR", "stack": [], "out": "65536 \n", "why": QD},
|
||||
"Q.0.raw_value": {"text": "Q.0 D. CR", "stack": [], "out": "0 \n", "why": QD},
|
||||
"Q.SCALE.raw_value": {"text": "Q.SCALE D. CR", "stack": [], "out": "65536 \n", "why": QD},
|
||||
# ---- stress: >R at the prompt ----
|
||||
"RETURN_STACK.basic_to_r": {"text": ": PTRS1 1 2 3 >R >R >R R> R> R> + + . ; PTRS1 CR", "stack": [], "out": "6 \n", "why": ANS_RF},
|
||||
"RETURN_STACK.r_fetch": {"text": ": PTRS2 42 >R R@ . R> DROP ; PTRS2 CR", "stack": [], "out": "42 \n", "why": ANS_RF},
|
||||
# ---- starforth_words: v3's printouts, their form ----
|
||||
"WORD-ENTROPY.display_all": {"head": WE_HEAD, "why": FORM},
|
||||
"WORD-ENTROPY.after_execution": {"head": WE_HEAD, "why": FORM},
|
||||
"WORD-ENTROPY.stack_preserved": {"head": WE_HEAD, "why": FORM},
|
||||
"TOP-WORDS.display_top5": {"head": TOPHEAD(5), "why": FORM},
|
||||
"TOP-WORDS.display_top10": {"head": TOPHEAD(10), "why": FORM},
|
||||
"TOP-WORDS.after_reset": {"head": TOPHEAD(5), "why": FORM},
|
||||
"TOP-WORDS.single_word": {"head": TOPHEAD(1), "why": FORM},
|
||||
"TOP-WORDS.large_count": {"head": TOPHEAD(100), "why": FORM},
|
||||
# ---- mixed_arithmetic_words: M+ (ANS); M/MOD (v3's own; the double written as FORTH-79 has it) ----
|
||||
"M+.basic": {"stack": [], "out": "100 200 \n", "why": ANS_MPLUS},
|
||||
"M+.overflow": {"stack": [], "out": "2147483647 1 \n", "why": ANS_MPLUS},
|
||||
"M+.negative": {"stack": [], "out": "-100 50 \n", "why": ANS_MPLUS},
|
||||
"M+.both_negative": {"stack": [], "out": "-101 -200 \n", "why": ANS_MPLUS},
|
||||
"M/MOD.basic": {"text": "1000 0 100 M/MOD . . CR", "stack": [], "out": "10 0 \n", "why": D79 + " (1000 / 100)"},
|
||||
"M/MOD.with_remainder": {"text": "1234 0 100 M/MOD . . CR", "stack": [], "out": "12 34 \n", "why": D79 + " (1234 / 100)"},
|
||||
"M/MOD.double_dividend": {"stack": [], "out": "500 1 \n", "why": "its description: 5001 / 10 is 500 remainder 1; v3 prints otherwise"},
|
||||
"M/MOD.by_one": {"text": "42 0 1 M/MOD . . CR", "stack": [], "out": "42 0 \n", "why": D79 + " (42 / 1)"},
|
||||
"M/MOD.negative_dividend": {"text": "-1000 -1 100 M/MOD . . CR", "stack": [], "out": "-10 0 \n", "why": D79 + " (-1000 / 100)"},
|
||||
# ---- double_words: 2>R 2R> 2R@ (ANS, compile-only) ----
|
||||
"2>R.roundtrip": {"text": ": PT2R1 10 20 2>R 2R> . . ; PT2R1 CR", "stack": [], "out": "20 10 \n", "why": ANS_2R},
|
||||
"2>R.depth_after": {"text": ": PT2R2 1 2 2>R DEPTH . 2R> DROP DROP ; PT2R2 CR", "stack": [], "out": "0 \n", "why": ANS_2R},
|
||||
"2R>.roundtrip": {"text": ": PT2R3 5 6 2>R 2R> . . ; PT2R3 CR", "stack": [], "out": "6 5 \n", "why": ANS_2R},
|
||||
"2R>.depth": {"text": ": PT2R4 9 8 2>R 2R> DEPTH . ; PT2R4 CR", "stack": [9, 8], "out": "2 \n", "why": ANS_2R},
|
||||
"2R@.peek": {"text": ": PT2R5 3 4 2>R 2R@ . . 2R> DROP DROP ; PT2R5 CR", "stack": [], "out": "4 3 \n", "why": ANS_2R},
|
||||
"2R@.non_destructive": {"text": ": PT2R6 7 8 2>R 2R@ DROP DROP 2R> . . ; PT2R6 CR", "stack": [], "out": "8 7 \n", "why": ANS_2R},
|
||||
}
|
||||
|
||||
DROPPED = {
|
||||
"SP@.depth_effect": 'SP@ and SP! are no standard\'s; no stack pointer is visible to code (DECOMPOSITION.md D-2), ruled to stand (Captain Bob, 2026-11-14: "D-2 for SP@").',
|
||||
"SP@.empty_stack": 'SP@ and SP! are no standard\'s; no stack pointer is visible to code (DECOMPOSITION.md D-2), ruled to stand (Captain Bob, 2026-11-14: "D-2 for SP@").',
|
||||
"SP@.multiple_items": 'SP@ and SP! are no standard\'s; no stack pointer is visible to code (DECOMPOSITION.md D-2), ruled to stand (Captain Bob, 2026-11-14: "D-2 for SP@").',
|
||||
"SP!.basic_restore": 'SP@ and SP! are no standard\'s; no stack pointer is visible to code (DECOMPOSITION.md D-2), ruled to stand (Captain Bob, 2026-11-14: "D-2 for SP@").',
|
||||
"STACK_MGMT.sp_round_trip": 'SP@ and SP! are no standard\'s; no stack pointer is visible to code (DECOMPOSITION.md D-2), ruled to stand (Captain Bob, 2026-11-14: "D-2 for SP@").',
|
||||
"STACK_MGMT.depth_preservation": 'SP@ and SP! are no standard\'s; no stack pointer is visible to code (DECOMPOSITION.md D-2), ruled to stand (Captain Bob, 2026-11-14: "D-2 for SP@").',
|
||||
"DABS.one_item": 'ANS Forth 8.6.1.1160 DABS / 8.6.1.1220 DMIN: given too few values, stack underflow is an ambiguous condition (ANS 4.1.2); no standard asks for an error.',
|
||||
"DMIN.three_items": 'ANS Forth 8.6.1.1160 DABS / 8.6.1.1220 DMIN: given too few values, stack underflow is an ambiguous condition (ANS 4.1.2); no standard asks for an error.',
|
||||
"THRU.negative_end": "FORTH-83 THRU takes block numbers, unsigned: -3 is not one (ANS 15.6.2.2280: an ambiguous condition); "
|
||||
"v3's error is its own, which no standard asks for.",
|
||||
"CMOVE>.bounds": "ANS Forth 17.6.1.0920 CMOVE> raises no error for a count past a buffer; 1000 bytes at PAD (84 bytes "
|
||||
"or more) is in v4's memory and writes over what the system keeps above PAD. v3's error is v3's own "
|
||||
"bounds check, which no standard asks for; there is nothing to expect.",
|
||||
}
|
||||
Reference in New Issue
Block a user