mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 08:58:06 +11:00
Make word routine refs 1b instead of 2
Saves quite a bit of binary space. More than 300 bytes in forth1.bin
This commit is contained in:
parent
e40c059c26
commit
d8de8a058a
2
blk/077
2
blk/077
@ -6,7 +6,7 @@ A dictionary entry has this structure:
|
||||
bigger than input buffer, of course). not null-terminated
|
||||
- 2b prev offset
|
||||
- 1b size + IMMEDIATE flag
|
||||
- 2b code pointer
|
||||
- 1b code pointer (always jumps in the <0x100 range)
|
||||
- Parameter field (PF)
|
||||
|
||||
The prev offset is the number of bytes between the prev field
|
||||
|
4
blk/078
4
blk/078
@ -1,7 +1,9 @@
|
||||
(cont.) The code pointer point to "word routines". These
|
||||
routines expect to be called with IY pointing to the PF. They
|
||||
themselves are expected to end by jumping to the address at
|
||||
(IP). They will usually do so with "jp next".
|
||||
(IP). They will usually do so with "jp next". They are 1b
|
||||
because all those routines live in the first 0x100 bytes of
|
||||
the boot binary. The 0 MSB is assumed.
|
||||
|
||||
That's for "regular" words (words that are part of the dict
|
||||
chain). There are also "special words", for example NUMBER,
|
||||
|
Binary file not shown.
@ -315,7 +315,6 @@ PC ORG @ 0x34 + ! ( execute )
|
||||
H 0 LDrn,
|
||||
( HL points to code pointer )
|
||||
IY INCss,
|
||||
IY INCss,
|
||||
( IY points to PFA )
|
||||
JP(HL),
|
||||
|
||||
@ -338,7 +337,7 @@ PC ORG @ 0x0f + ! ( compiledWord )
|
||||
0x33 JPnn, ( 33 == execute )
|
||||
|
||||
PC ORG @ 0x0c + ! ( cellWord )
|
||||
( Pushes the PFA directly )
|
||||
( Pushes PFA directly )
|
||||
IY PUSHqq,
|
||||
JPNEXT,
|
||||
|
||||
|
@ -58,7 +58,7 @@
|
||||
: CREATE
|
||||
(entry) ( empty header with name )
|
||||
11 ( 11 == cellWord )
|
||||
, ( write it )
|
||||
C, ( write it )
|
||||
;
|
||||
|
||||
( We run this when we're in an entry creation context. Many
|
||||
@ -71,11 +71,11 @@
|
||||
: DOES>
|
||||
( Overwrite cellWord in CURRENT )
|
||||
( 43 == doesWord )
|
||||
43 CURRENT @ !
|
||||
43 CURRENT @ C!
|
||||
( When we have a DOES>, we forcefully place HERE to 4
|
||||
bytes after CURRENT. This allows a DOES word to use ","
|
||||
and "C," without messing everything up. )
|
||||
CURRENT @ 4 + HERE !
|
||||
CURRENT @ 3 + HERE !
|
||||
( HERE points to where we should write R> )
|
||||
R> ,
|
||||
( We're done. Because we've popped RS, we'll exit parent
|
||||
|
@ -237,7 +237,7 @@ XCURRENT @ ( to PSP )
|
||||
( We cannot use LITN as IMMEDIATE because of bootstrapping
|
||||
issues. Same thing for ",".
|
||||
32 == NUMBER 14 == compiledWord )
|
||||
[ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] ,
|
||||
[ 32 H@ ! 2 ALLOT 14 H@ ! 2 ALLOT ] C,
|
||||
BEGIN
|
||||
WORD
|
||||
(find)
|
||||
|
@ -82,7 +82,7 @@
|
||||
)
|
||||
( ol o a1 a2 -- )
|
||||
: RLWORD
|
||||
SWAP DUP @ ( ol o a2 a1 n )
|
||||
SWAP DUP C@ ( ol o a2 a1 n )
|
||||
( 0e == compiledWord, 2b == doesWord )
|
||||
DUP <>{ 0x0e &= 0x2b |= <>} NOT IF
|
||||
( unwind all args )
|
||||
@ -95,7 +95,7 @@
|
||||
( ol o a2 a1 n )
|
||||
0x2b = IF 2 + THEN
|
||||
( ol o a2 a1 )
|
||||
2 + ( ol o a2 a1+2 )
|
||||
1 + ( ol o a2 a1+1 )
|
||||
BEGIN ( ol o a2 a1 )
|
||||
2OVER ( ol o a2 a1 ol o )
|
||||
SWAP ( ol o a2 a1 o ol )
|
||||
|
@ -34,7 +34,7 @@ VARIABLE XOFF
|
||||
: X:
|
||||
(xentry)
|
||||
( 0e == compiledWord )
|
||||
[ 0x0e LITN ] ,
|
||||
[ 0x0e LITN ] C,
|
||||
BEGIN
|
||||
WORD
|
||||
( cross compile CURRENT )
|
||||
|
@ -324,7 +324,7 @@
|
||||
( same as CREATE, but with native word )
|
||||
(entry)
|
||||
( 23 == nativeWord )
|
||||
23 ,
|
||||
23 C,
|
||||
;
|
||||
|
||||
: ;CODE JPNEXT, ;
|
||||
|
Loading…
Reference in New Issue
Block a user