Add CURRENT* and simplify xcomp

This commit is contained in:
Virgil Dupras 2020-04-09 12:01:08 -04:00
parent f1171c656c
commit e6d3638f4f
7 changed files with 25 additions and 28 deletions

View File

@ -98,6 +98,8 @@ J -- n Copy RS third item to PS
C@ a -- c Set c to byte at address a C@ a -- c Set c to byte at address a
C! c a -- Store byte c in address a C! c a -- Store byte c in address a
CURRENT -- a Set a to wordref of last added entry. CURRENT -- a Set a to wordref of last added entry.
CURRENT* -- a A pointer to active CURRENT*. Useful when we have
multiple active dicts.
HERE -- a Push HERE's address HERE -- a Push HERE's address
H@ -- a HERE @ H@ -- a HERE @
MOVE a1 a2 u -- Copy u bytes from a1 to a2, starting with a1, going MOVE a1 a2 u -- Copy u bytes from a1 to a2, starting with a1, going

View File

@ -4,3 +4,8 @@
CURRENT @ XCURRENT ! CURRENT @ XCURRENT !
H@ ' _bend - 4 + XOFF ! H@ ' _bend - 4 + XOFF !
( dummy entry for dict hook )
(xentry) _
H@ 256 /MOD 2 PC! 2 PC!

Binary file not shown.

View File

@ -35,7 +35,8 @@
: FLAGS 0x08 RAM+ ; : FLAGS 0x08 RAM+ ;
: (parse*) 0x0a RAM+ ; : (parse*) 0x0a RAM+ ;
: HERE 0x04 RAM+ ; : HERE 0x04 RAM+ ;
: CURRENT 0x02 RAM+ ; : CURRENT* 0x51 RAM+ ;
: CURRENT CURRENT* @ ;
( w -- a f ) ( w -- a f )
: (find) CURRENT @ SWAP _find ; : (find) CURRENT @ SWAP _find ;
@ -185,6 +186,7 @@
; ;
: BOOT : BOOT
0x02 RAM+ CURRENT* !
LIT< (parse) (find) DROP (parse*) ! LIT< (parse) (find) DROP (parse*) !
( 60 == SYSTEM SCRATCHPAD ) ( 60 == SYSTEM SCRATCHPAD )
CURRENT @ 0x60 RAM+ ! CURRENT @ 0x60 RAM+ !

View File

@ -24,40 +24,26 @@
VARIABLE XCURRENT VARIABLE XCURRENT
VARIABLE XOFF VARIABLE XOFF
: (xentry) : XCON XCURRENT CURRENT* ! ;
H@ ( h ) : XCOFF CURRENT CURRENT* ! ;
WORD ( h s )
SCPY ( h ) : (xentry) XCON (entry) XCOFF ;
( Adjust HERE -1 because SCPY copies the null )
H@ 1 - ( h h' )
DUP HERE ! ( h h' )
-^ ( sz )
( write prev value )
H@ XCURRENT @ - ,
( write size )
C,
H@ XCURRENT !
;
( Finds in *both* CURRENT and XCURRENT ) ( Finds in *both* CURRENT and XCURRENT )
( w -- a f xa xf ) ( w -- a f xa xf )
: (xfind) : (xfind)
DUP ( w w ) DUP ( w w )
CURRENT @ SWAP ( w cur w ) ( hardcoded system CURRENT )
0x02 RAM+ @ SWAP ( w cur w )
_find ( w a f ) _find ( w a f )
ROT ( a f w ) ROT ( a f w )
XCURRENT @ SWAP ( a f xcur w ) XCURRENT @ SWAP ( a f xcur w )
_find ( a f xa xf ) _find ( a f xa xf )
; ;
: XCODE : XCODE XCON CODE XCOFF ;
(xentry) 23 ,
;
: XIMM : XIMM XCON IMMEDIATE XCOFF ;
XCURRENT @ 1 -
DUP C@ 128 OR SWAP C!
;
: X: : X:
(xentry) (xentry)

View File

@ -22,10 +22,6 @@
This unit expects the same conf as boot.fs. This unit expects the same conf as boot.fs.
) )
( dummy entry for dict hook )
(xentry) _
H@ 256 /MOD 2 PC! 2 PC!
( a b c -- b c a ) ( a b c -- b c a )
CODE ROT CODE ROT
HL POPqq, ( C ) HL POPqq, ( C )

View File

@ -88,7 +88,8 @@ RAMSTART INITIAL_SP
+0e WORDBUF +0e WORDBUF
+2e SYSVNXT +2e SYSVNXT
+4e INTJUMP +4e INTJUMP
+51 RESERVED +51 CURRENTPTR
+53 RESERVED
+60 SYSTEM SCRATCHPAD +60 SYSTEM SCRATCHPAD
+80 RAMEND +80 RAMEND
@ -116,6 +117,11 @@ those slots...) in boot binaries are made to jump to this address. If you use
one of those slots for an interrupt, write a jump to the appropriate offset in one of those slots for an interrupt, write a jump to the appropriate offset in
that RAM location. that RAM location.
CURRENTPTR points to current CURRENT. The Forth CURRENT word doesn't return
RAM+2 directly, but rather the value at this address. Most of the time, it
points to RAM+2, but sometimes, when maintaining alternative dicts (during
cross compilation for example), it can point elsewhere.
SYSTEM SCRATCHPAD is reserved for temporary system storage or can be reserved SYSTEM SCRATCHPAD is reserved for temporary system storage or can be reserved
by low-level drivers. These are the current usages of this space throughout the by low-level drivers. These are the current usages of this space throughout the
project: project: