1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 15:38:05 +11:00

pcat: make find compare strings

find is the biggest chunk of logic of the boot code. The 8086 version
is significantly terser than the z80 one. REP/CMPS helps...
This commit is contained in:
Virgil Dupras 2020-06-15 06:23:19 -04:00
parent 8c452f5add
commit d8d2e05eb2
7 changed files with 33 additions and 23 deletions

View File

@ -5,7 +5,7 @@ JMPn, 0 A,, ( 00, main ) JMPn, 0 A,, ( 03, find )
0 A, ( 0a, unused ) JMPn, 0 A,, ( 0b, cellWord ) 0 A, ( 0a, unused ) JMPn, 0 A,, ( 0b, cellWord )
JMPn, 0 A,, ( 0e compiledWord ) JMPn, 0 A,, ( 11, pushRS ) JMPn, 0 A,, ( 0e compiledWord ) JMPn, 0 A,, ( 11, pushRS )
JMPn, 0 A,, ( 14, popRS ) JMPn, 0 A,, ( 14, popRS )
BX JMPr, ( 17, nativeWord ) 0 A, DI JMPr, ( 17, nativeWord ) 0 A,
JMPn, 0 A,, ( 1a, next ) JMPn, 0 A,, ( 1d, unused ) JMPn, 0 A,, ( 1a, next ) JMPn, 0 A,, ( 1d, unused )
0 A, 0 A, ( 20, numberWord ) 0 A, 0 A, ( 22, litWord ) 0 A, 0 A, ( 20, numberWord ) 0 A, 0 A, ( 22, litWord )
0 A, 0 A, ( 24, addrWord ) 0 A, 0 A, ( 26, unused ) 0 A, 0 A, ( 24, addrWord ) 0 A, 0 A, ( 26, unused )

View File

@ -9,5 +9,5 @@ H@ XCURRENT ! ( set current tip of dict, 0x42 )
;CODE ;CODE
CODE FOO CODE FOO
AH 0x0e MOVri, ( print char ) AL 'X' MOVri, 0x10 INT, AH 0x0e MOVri, ( print char ) AL 'X' MOVri, 0x10 INT,
L2 BSET JMPs, L2 @ RPCs, BEGIN, JMPs, AGAIN,
;CODE ;CODE

View File

@ -1,5 +1,5 @@
L1 BSET PC 3 - ORG @ 0x34 + ! ( execute -- BX -> wordref ) L1 BSET PC 3 - ORG @ 0x34 + ! ( execute -- DI -> wordref )
AH AH XORrr, AH AH XORrr,
AL [BX] MOVr[], AL [DI] MOVr[],
BX INCx, ( PFA ) DI INCx, ( PFA )
AX JMPr, AX JMPr,

24
blk/815
View File

@ -1,14 +1,16 @@
L4 BSET PC 3 - ORG @ 4 + ! ( find ) L4 BSET PC 3 - ORG @ 4 + ! ( find )
( find word the same name as str in SI starting from tip in ( find word the same name as str in SI starting from tip in
BX. Returns wordref in BX. Z if found, NZ if not. ) DI. Returns wordref in BX. Z if found, NZ if not. )
CH CH XORrr, CL [SI] MOVr[], ( CX -> strlen ) CH CH XORrr, CL [SI] MOVr[], ( CX -> strlen )
SI INCx, SI INCx, ( first char ) AX AX XORxx, ( initial prev )
AX AX XORxx, ( initial prev ) BEGIN, ( loop )
BEGIN, ( inner ) DI AX SUBxx, ( jump to prev wordref )
BX AX SUBxx, ( jump to prev wordref ) DI DECx, AL [DI] MOVr[], ( strlen )
BX DECx, AL [BX] MOVr[], ( strlen ) CL AL CMPrr, IFZ, ( same len )
CL AL CMPrr, IFZ, BX INCx, RETn, THEN, SI PUSHx, DI PUSHx, CX PUSHx, ( --> lvl 3 )
BX DECx, BX DECx, AX [BX] MOVx[], ( prev ) 2 ADDALi, ( prev ) AH AH XORrr, DI AX SUBxx,
AX AX ORxx, REPZ, CMPSB,
JNZ, AGAIN, CX POPx, DI POPx, SI POPx, ( <-- lvl 3 )
BEGIN, JMPs, AGAIN, IFZ, DI INCx, AL AL XORrr, ( Z ) RETn, THEN,
THEN,
( cont. )

12
blk/816
View File

@ -1,6 +1,6 @@
L3 BSET 3 A, 'F' A, 'O' A, 'O' A, ( find cont. )
PC 3 - ORG @ 1+ ! ( main ) DI DECx, DI DECx, AX [DI] MOVx[], ( prev )
BX 0x08 MOVxm, ( LATEST ) AX AX ORxx,
SI L3 @ MOVxi, JNZ, AGAIN, ( loop )
CALLn, L4 @ RPCn, ( find ) AX INCx, ( NZ ) RETn,
JMPs, L1 @ RPCs, ( execute )

8
blk/817 Normal file
View File

@ -0,0 +1,8 @@
L3 BSET 3 A, 'F' A, 'O' A, 'O' A,
PC 3 - ORG @ 1+ ! ( main )
DI 0x08 MOVxm, ( LATEST )
SI L3 @ MOVxi,
CALLn, L4 @ RPCn, ( find )
IFZ, JMPs, L1 @ RPCs, ( execute ) THEN,
AH 0x0e MOVri, ( print char ) AL '!' MOVri, 0x10 INT,
BEGIN, JMPs, AGAIN,

View File

@ -1,7 +1,7 @@
750 LOAD ( 8086 asm ) 750 LOAD ( 8086 asm )
262 LOAD ( xcomp ) 262 LOAD ( xcomp )
270 LOAD ( xcomp overrides ) 270 LOAD ( xcomp overrides )
812 816 LOADR 812 817 LOADR
(entry) _ (entry) _
( Update LATEST ) ( Update LATEST )
PC ORG @ 8 + ! PC ORG @ 8 + !