;;; This file contains words dealing with word lists (vocabularies) WORD p_wordlist,'WORDLIST',dovariable ;; VARIABLE WORDLIST is the currently active wordlist. dq last_word WORD p_words,'WORDS',fasm ;; ( -- ) ;; Dump all words pushr rsi push qword [p_wordlist_DFA] p_words_LOOP: mov rax,qword [rsp] cmp rax,0 je p_words_END ;; tfa>pfa add rax,9 ;; pfa@ => ( chars* length) xor rbx,rbx mov bl,[rax] inc rax push 1 push rax push rbx DOFORTH sys_write pop rax ; ignore errors push 10 DOFORTH p_emit mov rax,qword [rsp] mov rax,qword [rax] mov qword [rsp],rax jmp p_words_LOOP p_words_END: popr rsi next WORD p_strncmp,'STRNCMP',fasm ;; ( chars1 chars2 n -- flag ) ;; Compare bytes until one is NUL, return <0, =0 or >0 to ;; indicate that chars1 is lesser, they are equal, or chars2 ;; is lesser in ascii ordering respectively. pop rdx pop rbx pop rax xor rcx,rcx ;; rax = chars1, rbx = chars2, cl = byte acc, rdx = length inc rdx p_strncmp_loop: dec rdx je p_strncmp_end mov cl,[rax] inc rax sub cl,[rbx] inc rbx je p_strncmp_loop p_strncmp_end: push rcx next WORD p_find,'FIND' ;; ( chars length -- [ chars 0 | cfa 1 ) ;; Search the current wordlists for the given pname mov rcx,[p_wordlist_DFA] p_find_loop: cmp rcx,0 je p_find_done mov rbx,[rsp] mov rax,[rsp+8] cmp bl,byte [rcx+10] jne p_find_nextword push rcx ;; check word push rax push rcx+11 push rbx DOFORTH p_strncmp pop rax ; return value pop rcx cmp rax,0 je p_find_done p_find_nextword: mov rcx,[rcx] jmp p_find_loop p_find_found: mov qword [rsp+8],rcx ; replace chars with tfa mov rcx,1 p_find_done: push rcx next