1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 09:58:06 +11:00

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 ( Native words )
( Find the entry corresponding to word name where (HL) points H@ 4 + XCURRENT ! ( make next CODE have 0 prev field )
to in dictionary having its tip at DE and sets DE to point CODE _find ( cur w -- a f )
to that entry. Z if found, NZ if not. ) HL POP, ( w ) DE POP, ( cur ) chkPS,
HL PUSH, HL PUSH, ( --> lvl 1 )
( First, figure out string len ) ( First, figure out string len )
A (HL) LDrr, A ORr, A (HL) LDrr, A ORr,
( special case. zero len? we never find anything. ) ( 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*. ( Let's do something weird: We'll hold HL by the *tail*.
Because of our dict structure and because we know our Because of our dict structure and because we know our
lengths, it's easier to compare starting from the end. ) 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? ) ( DE is a wordref, first step, do our len correspond? )
HL PUSH, ( --> lvl 1 ) HL PUSH, ( --> lvl 2 )
DE PUSH, ( --> lvl 2 ) DE PUSH, ( --> lvl 3 )
DE DECd, DE DECd,
LDA(DE), LDA(DE),
0x7f ANDi, ( remove IMMEDIATE flag ) 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, ( At this point, Z is set if we have a match. In all cases,
we want to pop HL and DE ) we want to pop HL and DE )
DE POP, ( <-- lvl 2 ) DE POP, ( <-- lvl 3 )
HL POP, ( <-- lvl 1 ) IFZ, ( match, we're done! )
JRZ, L2 FWR ( end-B296, match? we're done! ) HL POP, HL POP, ( <-- lvl 1-2 ) DE PUSH, PUSH1,
JPNEXT,
THEN,
( no match, go to prev and continue ) ( no match, go to prev and continue )
HL PUSH, ( --> lvl 1 )
DE DECd, DE DECd, DE DECd, ( prev field ) DE DECd, DE DECd, DE DECd, ( prev field )
DE PUSH, ( --> lvl 2 ) DE PUSH, ( --> lvl 3 )
EXDEHL, EXDEHL,
LDDE(HL), LDDE(HL),
( cont. ) ( cont. )

17
blk/295
View File

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

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