From 4072b5ca25e64a4d8e41ad5b1861546db1348971 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 7 Jun 2023 12:04:16 -0400 Subject: [PATCH] Change CALLSZ to DOESSZ The only place CALLSZ was used in was "does'" and became a misnomer under ARM. A call under ARM is 4 bytes, but for "does'" to return the right thing, it had to be 8 because a pushret, comes before "compile (does)". It's simpler to change the meaning of that constant and, while we're at it, include the 4b pointer that follows it. Also, correct outdated iter docs. --- fs/doc/dict.txt | 3 ++- fs/doc/iter.txt | 6 +++--- fs/xcomp/arm/rpi/kernel.fs | 2 +- fs/xcomp/bootlo.fs | 2 +- fs/xcomp/i386/kernel.fs | 2 +- fs/xcomp/rpiboot.fs | 2 +- posix/vm.c | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/doc/dict.txt b/fs/doc/dict.txt index 5426fb08..c6e7c0a5 100644 --- a/fs/doc/dict.txt +++ b/fs/doc/dict.txt @@ -81,7 +81,8 @@ ABORT Address containing the value of "abort". EMIT Address containing the value of "emit". IN< Address containing the value of "in<". CELLSZ Size of a cell: 4 -CALLSZ The size in bytes of a native call. +BRSZ Size in bytes of a "branch," or "branchC," +DOESSZ The size in bytes of a (does) header, after which there's data SPC $20 CR $0d diff --git a/fs/doc/iter.txt b/fs/doc/iter.txt index f8a1525e..50a57f6c 100644 --- a/fs/doc/iter.txt +++ b/fs/doc/iter.txt @@ -112,8 +112,8 @@ for something more... creative. When the iterator is done iterating and is about to exit, it already knows where it's going to exit to: the address following the "yield" call that the iterator made. We already know what's after that call: a backward jump to the loop body. -We already know how many bytes such a jump takes: CALLSZ + CELLSZ. +We already know how many bytes such a jump takes: BRSZ. Therefore, if we want to exit the iterator loop, all we need to do is to add -CALLSZ + CELLSZ to RS+0. That's what "unyield" does. Then, we exit the loop, -execute the loop cleanup code and go on with our lives. +BRSZ to RS+0. That's what "unyield" does. Then, we exit the loop, execute the +loop cleanup code and go on with our lives. diff --git a/fs/xcomp/arm/rpi/kernel.fs b/fs/xcomp/arm/rpi/kernel.fs index 6d8f2735..8758d2df 100644 --- a/fs/xcomp/arm/rpi/kernel.fs +++ b/fs/xcomp/arm/rpi/kernel.fs @@ -52,7 +52,7 @@ forward b) ,) \ coldboot HERESTART xconst herestart PSTOP xconst PSTOP RSTOP xconst RSTOP -4 xconst CALLSZ +12 xconst DOESSZ 4 xconst BRSZ xcode bye 0 b) ,) diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs index 858c43e3..4730ce4c 100644 --- a/fs/xcomp/bootlo.fs +++ b/fs/xcomp/bootlo.fs @@ -155,7 +155,7 @@ create _ 0 , code (does) r> W>A, W) @, W<>A, CELLSZ W+n, branchA, : doer code compile (does) HERE @ _ ! CELLSZ allot ; : does> r> ( exit current definition ) _ @ ! ; -: does' ( w -- 'data ) CALLSZ + CELLSZ + ; +: does' ( w -- 'data ) DOESSZ + ; : _to doer ' , ' , immediate does> toptr ! ; : _!, !, drop, ; :16b 16b) !, drop, ; :8b 8b) !, drop, ; diff --git a/fs/xcomp/i386/kernel.fs b/fs/xcomp/i386/kernel.fs index 4e5bc86d..d27d6979 100644 --- a/fs/xcomp/i386/kernel.fs +++ b/fs/xcomp/i386/kernel.fs @@ -59,7 +59,7 @@ lblidt m) lidt, sti, forward16 jmp, to L1 L2 xconst IDT -5 xconst CALLSZ +9 xconst DOESSZ 5 xconst BRSZ HERESTART xconst herestart diff --git a/fs/xcomp/rpiboot.fs b/fs/xcomp/rpiboot.fs index 7ead30ac..86f5bd06 100644 --- a/fs/xcomp/rpiboot.fs +++ b/fs/xcomp/rpiboot.fs @@ -155,7 +155,7 @@ create _ 0 , code (does) pushret, r> W>A, W) @, W<>A, CELLSZ W+n, branchA, : doer code pushret, compile (does) HERE @ _ ! CELLSZ allot ; : does> r> ( exit current definition ) _ @ ! ; -: does' ( w -- 'data ) CALLSZ + CELLSZ + ; +: does' ( w -- 'data ) DOESSZ + ; : test ( n ) dup 1+ >r >r V1 emit V2 emit 2rdrop ; : test2 doer , does> @ emit ; diff --git a/posix/vm.c b/posix/vm.c index b359fc10..8a83d0ec 100644 --- a/posix/vm.c +++ b/posix/vm.c @@ -960,7 +960,7 @@ static void buildsysdict() { sysconst("NEXTWORD", NEXTWORD); sysconst("HEREMAX", HEREMAX); sysconst("MOD", MOD); - sysconst("CALLSZ", 5); + sysconst("DOESSZ", 9); sysconst("BRSZ", 5); sysconst("PSTOP", PSTOP); sysconst("RSTOP", RSTOP); -- 2.45.2