diff --git a/emul/forth/z80c.bin b/emul/forth/z80c.bin index 2190a1d..6b8849c 100644 Binary files a/emul/forth/z80c.bin and b/emul/forth/z80c.bin differ 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,