z80: inline lblfind's routine into _find word

This commit is contained in:
Virgil Dupras 2020-07-05 22:35:54 -04:00
parent b9fb6a6226
commit 6fab30b164
8 changed files with 24 additions and 51 deletions

View File

@ -1 +1 @@
VARIABLE lblofl VARIABLE lblexec VARIABLE lblfind
VARIABLE lblofl VARIABLE lblexec

12
blk/291
View File

@ -1,12 +1,12 @@
lblfind BSET
( Find the entry corresponding to word name where (HL) points
to in dictionary having its tip at DE and sets DE to point
to that entry. Z if found, NZ if not. )
HL PUSH,
( Native words )
H@ 4 + XCURRENT ! ( make next CODE have 0 prev field )
CODE _find ( cur w -- a f )
HL POP, ( w ) DE POP, ( cur ) chkPS,
HL PUSH, ( --> lvl 1 )
( First, figure out string len )
A (HL) LDrr, A ORr,
( special case. zero len? we never find anything. )
IFNZ, ( fail-B296 )
IFZ, PUSH0, JPNEXT, THEN,
( Let's do something weird: We'll hold HL by the *tail*.
Because of our dict structure and because we know our
lengths, it's easier to compare starting from the end. )

View File

@ -1,7 +1,7 @@
BEGIN, ( inner )
BEGIN, ( loop )
( DE is a wordref, first step, do our len correspond? )
HL PUSH, ( --> lvl 1 )
DE PUSH, ( --> lvl 2 )
HL PUSH, ( --> lvl 2 )
DE PUSH, ( --> lvl 3 )
DE DECd,
LDA(DE),
0x7f ANDi, ( remove IMMEDIATE flag )

13
blk/294
View File

@ -1,16 +1,15 @@
( At this point, Z is set if we have a match. In all cases,
we want to pop HL and DE )
DE POP, ( <-- lvl 2 )
HL POP, ( <-- lvl 1 )
JRZ, L2 FWR ( end-B296, match? we're done! )
DE POP, ( <-- lvl 3 )
IFZ, ( match, we're done! )
HL POP, HL POP, ( <-- lvl 1-2 ) DE PUSH, PUSH1,
JPNEXT,
THEN,
( no match, go to prev and continue )
HL PUSH, ( --> lvl 1 )
DE DECd, DE DECd, DE DECd, ( prev field )
DE PUSH, ( --> lvl 2 )
DE PUSH, ( --> lvl 3 )
EXDEHL,
LDDE(HL),
( cont. )

17
blk/295
View File

@ -1,16 +1,13 @@
( DE contains prev offset )
HL POP, ( <-- lvl 2 )
( HL is prev field's addr. Is offset zero? )
DEZ,
IFNZ,
HL POP, ( <-- lvl 3, prev field )
DEZ, IFNZ, ( offset not zero )
( get absolute addr from offset )
( carry cleared from "or e" )
DE SBCHLd,
EXDEHL, ( result in DE )
THEN,
HL POP, ( <-- lvl 1 )
JRNZ, AGAIN, ( inner-B292, try to match again )
( Z set? end of dict, unset Z )
( cont. )
HL POP, ( <-- lvl 2 )
JRNZ, AGAIN, ( loop-B292, try to match again )
( Z set? end of dict, not found. "w" already on PSP TOS )
PUSH0,
;CODE

View File

@ -1,6 +0,0 @@
THEN, ( zero length check, B291 )
A XORr,
A INCr,
L2 FSET ( end )
HL POP,
RET,

View File

@ -1,6 +1,4 @@
( Native words )
H@ 4 + XCURRENT ! ( make next CODE have 0 prev field )
CODE (br) ( TODO: move with other native words )
CODE (br)
L1 BSET ( used in ?br and loop )
PC ORG @ 0x3d + ! ( stable ABI JP )
E 0 IY+ LDrIXY, D 1 IY+ LDrIXY,

15
blk/330
View File

@ -1,15 +0,0 @@
CODE _find ( cur w -- a f )
HL POP, ( w )
DE POP, ( cur )
chkPS,
lblfind @ CALL,
IFNZ,
( not found )
HL PUSH,
PUSH0,
JPNEXT,
THEN,
( found )
DE PUSH,
PUSH1,
;CODE