From ce6e31dda1565fc07d582b8305042b1c6e5885f6 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 31 Mar 2020 08:02:40 -0400 Subject: [PATCH] forth: inline "strcmp" --- emul/forth/z80c.bin | Bin 1549 -> 1555 bytes forth/forth.asm | 30 +++--------------------------- forth/z80c.fs | 11 +++++++++-- 3 files changed, 12 insertions(+), 29 deletions(-) diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index 2190a1db3602403b87ce76eaf653b1f5b85230e2..6b8849c00ed7f1cf42729c171d2b037a50d86cc9 100644 GIT binary patch delta 447 zcmX|-y-NaN9LK*t&pmfV$2HhsYS(2&TC=!B(u>d`re1=IQ;1MY9M%#I4NVR~aDPFI zP!I$T*Hl9!5d_%MDfHM%%#s#26!?}4J-SH)!n1Wl28-^J-NvK zL`pPEgo;f{eYqCrC0fIUEIL|!$^Q`I7}d~|W6Xw+AND}RROc1?RRJStIw_{Fh_ITR zg%B<;M|gHZUquMXM6sWw0ku8EbAsD^w2lJLu1xlvOBNhkP`Ev6;+*r!CY2`FsiWg` G*wioB4Q=}X delta 484 zcmYLFze_@46g_^wUWC1dejo**R-m=i&{Pl^LJuqR2V^)%JRDl$VKp>GG#OOG8`~WO zA#jkE2qK6;TAFHdi-IWp1MGe;qvhj%_ndpqy~p*R`LC+XY)+#Y!TsF`me)20>o?5s z6>74wS8_KMMd7$*AU9CsiPP`Y2* z+1-y0>3)iR@D$USLXBBCa3{nRkEwv05~Jf!@`1l{{RZJff~p3$u$fsL1ve2y2;c67 z7?!6h#jf3|7~6VQC#=zBdtK$=vr}V1m~Z4<+}$r7MyIv2R&A?{{8P`<9$MdFdC##$ zc%GMWsWhYIhUCCeTg^%b0dn?1=TM;vUX?=+Zi!bx4lf-Gv1Bqk17RZk7lRkmEe%n} zUWn3HU+pJCBEIE;LHOUg@Px)4($snaHnR;2t8QHeRze2df--)08Kwl!#Xqx5{NC;+ X@5b*g^K&@XX<0N?6gH(?=!fqIG%Rzy diff --git a/forth/forth.asm b/forth/forth.asm index 394d729..19e45fc 100644 --- a/forth/forth.asm +++ b/forth/forth.asm @@ -68,8 +68,8 @@ .dw INITIAL_SP .dw WORDBUF jp flagsToBC -; 43 - jp strcmp + nop \ nop \ nop ; unused +; 46 .dw RS_ADDR .dw CINPTR .dw SYSVNXT @@ -186,30 +186,6 @@ forthMain: .bootName: .db "BOOT", 0 -; Compares strings pointed to by HL and DE until one of them hits its null char. -; If equal, Z is set. If not equal, Z is reset. C is set if HL > DE -strcmp: - push hl - push de - -.loop: - ld a, (de) - cp (hl) - jr nz, .end ; not equal? break early. NZ is carried out - ; to the caller - or a ; If our chars are null, stop the cmp - inc hl - inc de - jr nz, .loop ; Z is carried through - -.end: - pop de - pop hl - ; Because we don't call anything else than CP that modify the Z flag, - ; our Z value will be that of the last cp (reset if we broke the loop - ; early, set otherwise) - ret - ; Parse string at (HL) as a decimal value and return value in DE. ; Reads as many digits as it can and stop when: ; 1 - A non-digit character is read @@ -527,7 +503,7 @@ litWord: ld (IP), hl jp next -.fill 6 +.fill 20 ; *** Dict hook *** ; This dummy dictionary entry serves two purposes: ; 1. Allow binary grafting. Because each binary dict always end with a dummy diff --git a/forth/z80c.fs b/forth/z80c.fs index a673dd9..eac27ad 100644 --- a/forth/z80c.fs +++ b/forth/z80c.fs @@ -342,8 +342,15 @@ CODE SCMP DE POPqq, HL POPqq, chkPS, - ( 43 == strcmp ) - 43 CALLnn, +( loop ) + LDA(DE), + (HL) CPr, + 7 JRNZe, ( not equal? break early to "end". NZ is set. ) + A ORr, ( if our char is null, stop ) + HL INCss, + DE INCss, + -7 JRNZe, ( loop ) +( end ) ( 40 == flagsToBC ) 40 CALLnn, BC PUSHqq,