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

forth: inline "strcmp"

This commit is contained in:
Virgil Dupras 2020-03-31 08:02:40 -04:00
parent 031bfc6d72
commit ce6e31dda1
3 changed files with 12 additions and 29 deletions

Binary file not shown.

View File

@ -68,8 +68,8 @@
.dw INITIAL_SP .dw INITIAL_SP
.dw WORDBUF .dw WORDBUF
jp flagsToBC jp flagsToBC
; 43 nop \ nop \ nop ; unused
jp strcmp ; 46
.dw RS_ADDR .dw RS_ADDR
.dw CINPTR .dw CINPTR
.dw SYSVNXT .dw SYSVNXT
@ -186,30 +186,6 @@ forthMain:
.bootName: .bootName:
.db "BOOT", 0 .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. ; Parse string at (HL) as a decimal value and return value in DE.
; Reads as many digits as it can and stop when: ; Reads as many digits as it can and stop when:
; 1 - A non-digit character is read ; 1 - A non-digit character is read
@ -527,7 +503,7 @@ litWord:
ld (IP), hl ld (IP), hl
jp next jp next
.fill 6 .fill 20
; *** Dict hook *** ; *** Dict hook ***
; This dummy dictionary entry serves two purposes: ; This dummy dictionary entry serves two purposes:
; 1. Allow binary grafting. Because each binary dict always end with a dummy ; 1. Allow binary grafting. Because each binary dict always end with a dummy

View File

@ -342,8 +342,15 @@ CODE SCMP
DE POPqq, DE POPqq,
HL POPqq, HL POPqq,
chkPS, chkPS,
( 43 == strcmp ) ( loop )
43 CALLnn, 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 == flagsToBC )
40 CALLnn, 40 CALLnn,
BC PUSHqq, BC PUSHqq,