1 ;;; Words for adding words
3 WORD p_here,'HERE',dovariable
7 ;; CREATE ( "[ \t\0]*([^ \t\0]+)" -- tfa )
8 ;; Skip leading whitespace and scan following non-whitespace
9 ;; as being a "word" to add into the current vocabulary. Add
10 ;; that word header, which consisits of:
11 WORD p_create,'CREATE',fasm
13 push p_stdin_DFA ; ( -- stream )
14 DOFORTH p_read_word ; ( -- chars* n ) read next word
15 mov rax,qword [p_wordlist_DFA] ; Current word list
16 mov rax,[rax] ; last word of current wordlist
17 mov rbx,qword [p_here_DFA]
18 mov [rbx],rax ; TFA of new word
19 mov qword [rbx+16],0 ; flags field
22 mov qword [rbx+24],rcx ; PFA (length)
23 pop rsi ; chars* (source)
24 lea rdi,[rbx+32] ; (dest)
30 mov byte [rdi],0 ; extra NUL
32 mov qword [rdi],rbx ; pTFA
34 mov qword [rdi],rbx ; OFF
36 mov qword [rbx+8],rdi ; pCFA
38 mov qword [rdi],dovalue ;CFA
40 mov qword [rax],rbx ; Install new word
41 mov qword [p_here_DFA],rdi ; allocate the space
46 WORD p_allot,'ALLOT',fasm
48 ;; Allocate n bytes on the heap
50 add rax,qword [p_here_DFA]
51 mov qword [p_here_DFA],rax
55 ;; Change DOES offset of latest compilation word to current
56 ;; compilation address.
57 ;; LATEST @ TFA>DOES HERE @ OVER - SWAP !
58 WORD p_does,'DOES>',fasm
59 mov rax,qword [p_wordlist_DFA]
60 mov rax,[rax] ; last word of current wordlist
66 mov qword [rax+8],dodoes
69 WORD p_literal,'LIT',IMMEDIATE
75 WORD p_execute,'EXECUTE'