added WORDS
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Tue, 18 May 2021 08:22:07 +0000 (18:22 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Tue, 18 May 2021 08:22:07 +0000 (18:22 +1000)
wordlists.asm

index 9790a288b4e945363da6f548427f6c3fcae73a8f..ae3062bedc82e6a2240b2cda0d729bb9f467d40d 100644 (file)
@@ -1,9 +1,40 @@
 ;;; This file contains words dealing with word lists (vocabularies)
-;;;
-       WORD p_wordlists,'WORDLIST',dovariable
+
+       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
@@ -30,7 +61,7 @@ p_strncmp_end:
        WORD p_find,'FIND'
        ;; ( chars length -- [ chars 0 | cfa 1 )
        ;; Search the current wordlists for the given pname
-       mov rcx,[p_wordlists_DFA]
+       mov rcx,[p_wordlist_DFA]
 p_find_loop:
        cmp rcx,0
        je p_find_done