mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 23:08:06 +11:00
Make literal word routines into regular native words
This commit is contained in:
parent
ea9833d4ff
commit
2be2f74a43
13
blk/086
13
blk/086
@ -1,4 +1,3 @@
|
|||||||
(cont.)
|
|
||||||
0x2b: doesWord. This word is created by "DOES>" and is followed
|
0x2b: doesWord. This word is created by "DOES>" and is followed
|
||||||
by a 2-byte value as well as the address where "DOES>" was
|
by a 2-byte value as well as the address where "DOES>" was
|
||||||
compiled. At that address is an atom list exactly like in a
|
compiled. At that address is an atom list exactly like in a
|
||||||
@ -6,11 +5,7 @@ compiled word. Upon execution, after having pushed its cell
|
|||||||
addr to PSP, it execute its reference exactly like a
|
addr to PSP, it execute its reference exactly like a
|
||||||
compiledWord.
|
compiledWord.
|
||||||
|
|
||||||
0x20: numberWord. No word is actually compiled with this
|
Also note that word routines references in wordrefs are 1b.
|
||||||
routine, but atoms are. Atoms with a reference to the number
|
This means that all word routine reference must live below
|
||||||
words routine are followed, *in the atom list*, of a 2-byte
|
0x100 in boot binary. This is why numberWord and addrWord are
|
||||||
number. Upon execution, that number is fetched and IP is
|
squeezed where they are.
|
||||||
avdanced by an extra 2 bytes.
|
|
||||||
|
|
||||||
0x24: addrWord. Exactly like a numberWord, except that it is
|
|
||||||
treated differently by meta-tools. (cont.)
|
|
||||||
|
16
blk/087
16
blk/087
@ -1,16 +0,0 @@
|
|||||||
(cont.)
|
|
||||||
0x22: litWord. Similar to a number word, except that instead of
|
|
||||||
being followed by a 2 byte number, it is followed by a
|
|
||||||
null-terminated string. Upon execution, the address of that
|
|
||||||
null-terminated string is pushed on the PSP and IP is advanced
|
|
||||||
to the address following the null.
|
|
||||||
|
|
||||||
Also note that word routines references in wordrefs are 1b.
|
|
||||||
This means that all word routine reference must live below
|
|
||||||
0x100 in boot binary. This is why numberWord and addrWord are
|
|
||||||
squeezed where they are.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
blk/283
2
blk/283
@ -7,7 +7,7 @@ NOP, ( 0a, unused )
|
|||||||
0 JPnn, ( 14, popRS )
|
0 JPnn, ( 14, popRS )
|
||||||
EXDEHL, JP(HL), NOP, ( 17, nativeWord )
|
EXDEHL, JP(HL), NOP, ( 17, nativeWord )
|
||||||
0 JPnn, ( 1a, next ) 0 JPnn, ( unused )
|
0 JPnn, ( 1a, next ) 0 JPnn, ( unused )
|
||||||
NOP, NOP, ( 20, numberWord ) NOP, NOP, ( 22, litWord )
|
NOP, NOP, NOP, NOP, ( 20, unused )
|
||||||
NOP, NOP, NOP, NOP, ( 24, unused )
|
NOP, NOP, NOP, NOP, ( 24, unused )
|
||||||
0 JPnn, ( RST 28 )
|
0 JPnn, ( RST 28 )
|
||||||
0 JPnn, ( 2b, doesWord ) NOP, NOP, ( 2e, unused )
|
0 JPnn, ( 2b, doesWord ) NOP, NOP, ( 2e, unused )
|
||||||
|
22
blk/286
22
blk/286
@ -1,16 +1,14 @@
|
|||||||
CODE 2>R ( 0xa9 )
|
CODE 2>R ( 0xa9 )
|
||||||
DE POPqq, HL POPqq,
|
DE POPqq, HL POPqq,
|
||||||
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
|
17 BCALL, ( 17 == pushRS ) EXDEHL, 17 BCALL,
|
||||||
;CODE ( END OF STABLE ABI )
|
;CODE NOP, NOP, NOP,
|
||||||
CODE >R
|
CODE (n) ( 0xbf, number literal )
|
||||||
HL POPqq,
|
( PF means nothing and the actual number is placed next to
|
||||||
17 BCALL, ( 17 == pushRS )
|
the (n) reference in the compiled word list. What we need
|
||||||
;CODE
|
to do to fetch that number is to play with the IP. )
|
||||||
CODE R>
|
E 0 IY+ LDrIXY,
|
||||||
20 BCALL, ( 20 == popRS )
|
D 1 IY+ LDrIXY,
|
||||||
HL PUSHqq,
|
IY INCss,
|
||||||
;CODE
|
IY INCss,
|
||||||
CODE 2R>
|
DE PUSHqq,
|
||||||
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
|
|
||||||
HL PUSHqq, DE PUSHqq,
|
|
||||||
;CODE
|
;CODE
|
||||||
|
26
blk/287
26
blk/287
@ -1,15 +1,11 @@
|
|||||||
( See B85 for word routine impl notes )
|
CODE (s) ( 0xd4, string literal )
|
||||||
PC ORG @ 0x20 + ! ( numberWord )
|
( Like (n) but instead of being followed by a 2 bytes
|
||||||
( This is not a word, but a number literal. This works a bit
|
number, it's followed by a null-terminated string. When
|
||||||
differently than others: PF means nothing and the actual
|
called, puts the string's address on PS )
|
||||||
number is placed next to the numberWord reference in the
|
IY PUSHqq, HL POPqq, ( <-- IP )
|
||||||
compiled word list. What we need to do to fetch that number
|
E (HL) LDrr, D 0 LDrn,
|
||||||
is to play with the IP. )
|
DE INCss,
|
||||||
E 0 IY+ LDrIXY,
|
DE ADDIYss,
|
||||||
D 1 IY+ LDrIXY,
|
HL PUSHqq,
|
||||||
IY INCss,
|
;CODE
|
||||||
IY INCss,
|
( END OF STABLE ABI )
|
||||||
DE PUSHqq,
|
|
||||||
JPNEXT,
|
|
||||||
|
|
||||||
|
|
||||||
|
22
blk/288
22
blk/288
@ -1,15 +1,15 @@
|
|||||||
PC ORG @ 0x22 + ! ( litWord, 0xf7, tight on the 0x100 limit )
|
CODE >R
|
||||||
( Like numberWord, but instead of being followed by a 2 bytes
|
HL POPqq,
|
||||||
number, it's followed by a null-terminated string. When
|
17 BCALL, ( 17 == pushRS )
|
||||||
called, puts the string's address on PS )
|
;CODE
|
||||||
IY PUSHqq, HL POPqq, ( <-- IP )
|
CODE R>
|
||||||
E (HL) LDrr, D 0 LDrn,
|
20 BCALL, ( 20 == popRS )
|
||||||
DE INCss,
|
|
||||||
DE ADDIYss,
|
|
||||||
HL PUSHqq,
|
HL PUSHqq,
|
||||||
JPNEXT,
|
;CODE
|
||||||
|
CODE 2R>
|
||||||
|
20 BCALL, ( 20 == popRS ) EXDEHL, 20 BCALL,
|
||||||
|
HL PUSHqq, DE PUSHqq,
|
||||||
|
;CODE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2
blk/382
2
blk/382
@ -3,7 +3,7 @@
|
|||||||
C< DUP 34 ( ASCII " ) = IF DROP EXIT THEN C,
|
C< DUP 34 ( ASCII " ) = IF DROP EXIT THEN C,
|
||||||
AGAIN ;
|
AGAIN ;
|
||||||
: LIT"
|
: LIT"
|
||||||
34 , ( litWord ) H@ 0 C, ,"
|
COMPILE (s) H@ 0 C, ,"
|
||||||
DUP H@ -^ 1- ( a len ) SWAP C!
|
DUP H@ -^ 1- ( a len ) SWAP C!
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
: ." [COMPILE] LIT" COMPILE (print) ; IMMEDIATE
|
: ." [COMPILE] LIT" COMPILE (print) ; IMMEDIATE
|
||||||
|
2
blk/397
2
blk/397
@ -3,7 +3,7 @@
|
|||||||
: DO COMPILE 2>R H@ ; IMMEDIATE
|
: DO COMPILE 2>R H@ ; IMMEDIATE
|
||||||
: LOOP COMPILE (loop) H@ - _bchk , ; IMMEDIATE
|
: LOOP COMPILE (loop) H@ - _bchk , ; IMMEDIATE
|
||||||
( LEAVE is implemented in low xcomp )
|
( LEAVE is implemented in low xcomp )
|
||||||
: LITN 32 , , ( 32 == NUMBER ) ;
|
: LITN COMPILE (n) , ;
|
||||||
( gets its name at the very end. can't comment afterwards )
|
( gets its name at the very end. can't comment afterwards )
|
||||||
: _ BEGIN LIT< ) WORD S= UNTIL ; IMMEDIATE
|
: _ BEGIN LIT< ) WORD S= UNTIL ; IMMEDIATE
|
||||||
: _ ( : will get its name almost at the very end )
|
: _ ( : will get its name almost at the very end )
|
||||||
|
2
blk/399
2
blk/399
@ -1,4 +1,4 @@
|
|||||||
: LIT< WORD 34 , DUP C@ 1+ MOVE, ; IMMEDIATE
|
: LIT< COMPILE (s) WORD DUP C@ 1+ MOVE, ; IMMEDIATE
|
||||||
: BEGIN H@ ; IMMEDIATE
|
: BEGIN H@ ; IMMEDIATE
|
||||||
: AGAIN COMPILE (br) H@ - _bchk , ; IMMEDIATE
|
: AGAIN COMPILE (br) H@ - _bchk , ; IMMEDIATE
|
||||||
: UNTIL COMPILE (?br) H@ - _bchk , ; IMMEDIATE
|
: UNTIL COMPILE (?br) H@ - _bchk , ; IMMEDIATE
|
||||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user