next
WORD p_find,'FIND'
- ;; ( chars length -- [ chars 0 | cfa 1 )
+ ;; ( chars length -- [ 0 ]|[ tfa ] )
;; Search the current wordlists for the given pname
pushr rsi
mov rcx,[p_wordlist_DFA]
mov rax,[rsp+8]
p_find_loop:
cmp rcx,0
- je p_find_done
+ je p_find_notfound
cmp rbx,qword [rcx+16] ; compare lengths
jne p_find_nextword
- push rcx
+ push rcx ; save tfa for later
;; check word
push rax
tfa2pname rcx
push rbx
DOFORTH p_strncmp
pop rax ; return value
- pop rcx
+ pop rcx ; restore tfa
cmp rax,0
- je p_find_done
+ je p_find_found
mov rbx,[rsp]
mov rax,[rsp+8]
p_find_nextword:
mov rcx,[rcx]
jmp p_find_loop
+p_find_notfound:
+ xor rcx,rcx
p_find_found:
- mov qword [rsp+8],rcx ; replace chars with tfa
- mov rcx,1
-p_find_done:
- push rcx
+ add rsp,8
+ mov qword [rsp],rcx ; replace with tfa / 0
popr rsi
next