commit 4072b5ca25e64a4d8e41ad5b1861546db1348971
parent b780a2c92e0e010e082ec96c292432329a36923e
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Wed, 7 Jun 2023 12:04:16 -0400
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.
Diffstat:
7 files changed, 10 insertions(+), 9 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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);