feat(v4): 2! 2@ 2, store a double as FORTH-83 says -- the high cell at the lower address (#189)
Captain Bob, 2026-11-14: "Yes, FORTH-83's layout". FORTH83.TXT, "number": "The address of the least significant 16 bits is two greater than the address of the most significant 16 bits." v4 stored the low cell first, as v3. dict.f18 (2,) and words.f18 (2@ 2!); test_host_dict.c and test_host_quit.c to the new layout. POST 539/539; v4 test-64/32 dict and quit pass. Not pushed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -89,7 +89,7 @@ set HDR-NFA here ", C, #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
drop a DP b! @b -1 + jump C!
|
||||
FULL: drop ;
|
||||
set HDR-NFA here ", 2, #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: 2, ( lo hi -- ) SWAP , , ; \ the low cell first, as v3
|
||||
: 2, ( lo hi -- ) , , ; \ the high cell first: FORTH-83's layout (#189, 2026-11-14)
|
||||
|
||||
set HDR-NFA here ", LATEST #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: LATEST ( -- xt ) CURRENT a! @ a! @ ; \ the newest entry of the CURRENT vocabulary
|
||||
|
||||
@@ -27,9 +27,9 @@ set HDR-NFA here ", INVERT #id, #, 8 #, HDR-NFA #, HDR-LINK set HDR-LINK h
|
||||
|
||||
\ ---- memory ----
|
||||
set HDR-NFA here ", 2@ #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: 2@ ( addr -- lo hi ) a! @+ @ ;
|
||||
: 2@ ( addr -- lo hi ) a! @+ @ SWAP ; \ the high cell at addr: FORTH-83 (#189, 2026-11-14)
|
||||
set HDR-NFA here ", 2! #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: 2! ( lo hi addr -- ) a! SWAP !+ ! ;
|
||||
: 2! ( lo hi addr -- ) a! !+ ! ; \ the high cell at addr, the low after: FORTH-83
|
||||
set HDR-NFA here ", -! #id, #, 0 #, HDR-NFA #, HDR-LINK set HDR-LINK here
|
||||
: -! ( n addr -- ) a! NEGATE @ + ! ;
|
||||
|
||||
|
||||
@@ -233,8 +233,8 @@ int main(void)
|
||||
CHECK(run("C,", 1, 'f', 0) && clean() && run("ALIGN", 0, 0, 0) && clean() && n.mem[DP] == (DICT_W + 6) * 4, "ALIGN rounds up to a cell");
|
||||
CHECK(run("ALIGN", 0, 0, 0) && clean() && n.mem[DP] == (DICT_W + 6) * 4, "ALIGN when aligned does nothing");
|
||||
|
||||
/* 2, : the low cell first, as v3 (HERE 1 2 2, : the first cell holds 1) */
|
||||
CHECK(run("2,", 2, 1, 2) && clean() && n.mem[DICT_W + 6] == 1 && n.mem[DICT_W + 7] == 2 && get("HERE", 0, 0) == DICT_W + 8, "v3: 2, stores the low cell first");
|
||||
/* 2, : the high cell first, FORTH-83's layout (#189, Captain Bob 2026-11-14): 1 2 2, -- the first cell holds 2 */
|
||||
CHECK(run("2,", 2, 1, 2) && clean() && n.mem[DICT_W + 6] == 2 && n.mem[DICT_W + 7] == 1 && get("HERE", 0, 0) == DICT_W + 8, "2, stores the high cell first, as FORTH-83");
|
||||
|
||||
/* ALLOT counts cells */
|
||||
CHECK(run("ALLOT", 1, 5, 0) && clean() && !err() && get("HERE", 0, 0) == DICT_W + 13, "5 ALLOT reserves five cells");
|
||||
|
||||
@@ -801,7 +801,7 @@ static const transcript script[] = {
|
||||
{ "1 2 3 4 5 6 2ROT . . . . . .\n", "2 1 6 5 4 3 ok\nok> ", 1 },
|
||||
{ ": T 1 2 2>R 2R@ 2R> . . . . ; T\n", "2 1 2 1 ok\nok> ", 1 },
|
||||
{ "TRUE . FALSE . 5 INVERT . NOP\n", "-1 0 -6 ok\nok> ", 1 },
|
||||
{ "VARIABLE X 0 , 11 22 X 2! X 2@ . . X @ .\n", "22 11 11 ok\nok> ", 1 },
|
||||
{ "VARIABLE X 0 , 11 22 X 2! X 2@ . . X @ .\n", "22 11 22 ok\nok> ", 1 }, /* the high cell at X: FORTH-83 */
|
||||
{ "VARIABLE Y 10 Y ! 3 Y -! Y @ .\n", "7 ok\nok> ", 1 },
|
||||
{ "0 0<> . 5 0<> . -5 0<> .\n", "0 -1 -1 ok\nok> ", 1 },
|
||||
{ "0 0> . 5 0> . -5 0> .\n", "0 -1 0 ok\nok> ", 1 },
|
||||
|
||||
Reference in New Issue
Block a user