diff --git a/asm/forth-dictionary.s b/asm/forth-dictionary.s index 9e460f4..6f2b935 100644 --- a/asm/forth-dictionary.s +++ b/asm/forth-dictionary.s @@ -4746,16 +4746,14 @@ eword ; ( c-addr u wid -- xt ) Search wordlist wid for word. hword dWLSEARCH,"$WLSEARCH" - jsr _popwr + jsr _popwr ; wid -> WR ldy #$02 - lda [WR],y - sta YR+2 - dey - dey - lda [WR],y + lda [WR],y ; LAST of wordlist at wid, high word + sta YR+2 ; to YR + lda [WR] ; now low word sta YR - jsr _popxr - jsr _popwr + jsr _popxr ; u -> XR + jsr _popwr ; c-addr -> WR jsr _search_unsmudged PUSHNEXT eword @@ -4767,14 +4765,14 @@ dword SEARCH_WORDLIST,"SEARCH-WORDLIST" hword SEARCH_WORDLIST,"SEARCH-WORDLIST" .endif ENTER - .dword dWLSEARCH - .dword DUP - .dword _IF - .dword notfound - .dword IMMEDQ - ONLIT 1 - .dword LOR - .dword NEGATE + .dword dWLSEARCH ; ( c-addr u wid -- 0 | xt ) + .dword DUP ; ( 0 | xt -- 0 0 | xt xt ) + .dword _IF ; ( 0 0 | xt xt - 0 | xt ) + .dword notfound ; ( 0 ) if taken + .dword IMMEDQ ; ( xt -- xt f ) + .dword ONE ; ( xt f -- xt f 1 ) + .dword LOR ; ( ... xt 1/-1 ) + .dword NEGATE ; ( ... xt -1/1 ) notfound: EXIT eword @@ -6575,22 +6573,22 @@ dword BACKSLASH,"\",F_IMMED .dword SOURCEID .dword _IF .dword term ; faster - ONLIT 0 ; something to drop... + .dword ZERO lp: .dword DROP .dword INQ .dword _IF - .dword done + .dword done ; whole enchilada has been eaten .dword GETCH .dword DUP ONLIT c_cr .dword EQUAL .dword _IFFALSE - .dword ddone ; if true (= CR) + .dword ddone ; taken if = CR .dword DUP ONLIT c_lf .dword EQUAL .dword _IF - .dword lp ; if false (<> LF) + .dword lp ; taken if <> LF ddone: .dword DROP done: EXIT term: .dword NIN @@ -6831,7 +6829,7 @@ eword dword EVALUATE,"EVALUATE" ENTER .dword SAVEINPUT - .dword XNPtoR ; throw it all on the return stack + .dword XNPtoR ; throw it all on the return stack .dword PtoR ; along with the count ONLIT -1 .dword dSOURCEID ; standard requires source-id to be -1 during EVALUATE diff --git a/asm/interpreter.s b/asm/interpreter.s index d3b4230..0c70e6c 100644 --- a/asm/interpreter.s +++ b/asm/interpreter.s @@ -915,17 +915,16 @@ good: sec rts .endproc - ; search dictionary for word at WR, length in XR, start of search (header) at YR ; if found, AY=XT and carry set, otherwise ; AY=0 and carry clear -; preserves WR, XR, and YR +; preserves WR, XR; YR points at the header of the last word considered .proc _search olp: lda YR ora YR+2 beq notfnd ldy #$04 ; offset of length - lda [YR],y ; get name length + lda [YR],y ; get name length (we pull in two bytes) and #$7F ; mask in significant bits cmp XR ; compare to supplied bne snext ; not the right word @@ -939,12 +938,14 @@ olp: lda YR .a8 ldx XR ; get length to match ldy #$05 ; offset of name -clp: lda [WR] - jsr _cupper8 ; upper case - cmp [YR],y ; compare char +clp: lda [WR] ; char in the word we are searching for + jsr _cupper8 ; upper case it + cmp [YR],y ; compare to char in definition bne xsnext ; no match - iny ; move to next char - jsr _incwr + iny ; move to next char of name in def + rep #SHORT_A + jsr _incwr ; move to next char of word we are searching for + sep #SHORT_A dex ; if X hit zero, matched it all bne clp ; if it didn't, keep going rep #SHORT_A ; match! @@ -963,6 +964,7 @@ clp: lda [WR] sec rts xsnext: rep #SHORT_A + .a16 ; good habit plx pla sta WR