mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 12:18:07 +11:00
forth: inline "strcmp"
This commit is contained in:
parent
031bfc6d72
commit
ce6e31dda1
Binary file not shown.
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user