From d7958ae7b474ef357864237fc40412139e43b117 Mon Sep 17 00:00:00 2001 From: Ralph Ronnquist Date: Sun, 6 Jun 2021 23:22:09 +1000 Subject: [PATCH] some new words --- adoc/p_definitions.adoc | 19 ++++++++++++ adoc/p_exit.adoc | 8 ++--- adoc/p_return.adoc | 13 ++++++++ adoc/p_use.adoc | 15 +++++++++ compile.asm | 20 ++++++------ reference.adoc | 6 ++++ reference.html | 67 +++++++++++++++++++++++++++++++++++----- rrqforth | Bin 2150703 -> 2151053 bytes rrqforth.asm | 7 ++++- stdio.asm | 10 +++--- temp.asm | 2 +- wordindex.adoc | 3 ++ wordlists.asm | 24 ++++++++++++++ 13 files changed, 165 insertions(+), 29 deletions(-) create mode 100644 adoc/p_definitions.adoc create mode 100644 adoc/p_return.adoc create mode 100644 adoc/p_use.adoc diff --git a/adoc/p_definitions.adoc b/adoc/p_definitions.adoc new file mode 100644 index 0000000..37f2180 --- /dev/null +++ b/adoc/p_definitions.adoc @@ -0,0 +1,19 @@ +// stack.asm: WORD p_definitions, 'DEFINITIONS',fasm + +anchor:p_definitions[] + +=== Word: DEFINITIONS + +.... +Data stack: ( wordlist -- ) +.... + +"DEFINITIONS" is a function word that installs the given wordlist as +the <> one. + +==== +.Definition concept for DEFINITIONS +**** +: DEFINITIONS CURRENT-WORDLIST ! ; +**** +==== diff --git a/adoc/p_exit.adoc b/adoc/p_exit.adoc index 1d9d78a..f0db678 100644 --- a/adoc/p_exit.adoc +++ b/adoc/p_exit.adoc @@ -5,10 +5,8 @@ anchor:p_exit[] === Word: EXIT .... -Data stack: ( -- ) +Data stack: ( v -- ) .... -"EXIT" is a function word that implements the ending of a FORTH -definition and its threading to the subsequent step of the calling -definition. - +"EXIT" is a function word that terminates the +rrqforth+ process +immediately with the given exit code. diff --git a/adoc/p_return.adoc b/adoc/p_return.adoc new file mode 100644 index 0000000..9fb33a2 --- /dev/null +++ b/adoc/p_return.adoc @@ -0,0 +1,13 @@ +// rrqforth.asm: WORD p_return, 'RETURN',fasm + +anchor:p_return[] + +=== Word: RETURN + +.... +Data stack: ( -- ) +.... + +"RETURN" is a function word that implements the ending of a FORTH +definition and make execution return to the next step in the calling +definition. diff --git a/adoc/p_use.adoc b/adoc/p_use.adoc new file mode 100644 index 0000000..4dc5168 --- /dev/null +++ b/adoc/p_use.adoc @@ -0,0 +1,15 @@ +// rrqforth.asm: WORD p_use,'USE',dovariable + +anchor:p_use[] + +=== Word: USE + +.... +Data value: ( wordlist -- ) Input stream: word +.... + +"USE" is a function word that looks up next word given the wordlist. +It reads next word on <> via <>, +then temporarily changes <> to +<> the word via the given wordlist, and returns the TFA +of that word, or just 0 if the word coudn't be found. diff --git a/compile.asm b/compile.asm index defb1ac..fc9d3f5 100644 --- a/compile.asm +++ b/compile.asm @@ -41,7 +41,7 @@ p_create_COPY: WORD p_allot,'ALLOT' ;; ( n -- ) ;; Allocate n bytes on the heap - dq p_here, p_put_plus, p_exit + dq p_here, p_put_plus, p_return WORD p_quote,"'" ;; ( "word" -- cfa ) @@ -50,22 +50,22 @@ p_create_COPY: BRANCH 0,p_quote_end dq p_tfa2cfa p_quote_end: - dq p_exit + dq p_return WORD p_bracketed_quote,"[']",doforth,IMMEDIATE ;; Compilation ( "word" -- cfa ) ;; Compile down " LIT value " - dq p_literal, p_literal, p_comma,p_quote, p_comma, p_exit + dq p_literal, p_literal, p_comma,p_quote, p_comma, p_return WORD p_comma,',' ;; ( v -- ) ;; Put cell value onto the heap and advance "HERE" - dq p_here, p_literal, 8, p_get_n_increment, p_put, p_exit + dq p_here, p_literal, 8, p_get_n_increment, p_put, p_return WORD p_Ccomma,'C,' ;; ( c -- ) ;; Put byte value onto the heap and advance "HERE" - dq p_here, p_Cput, p_literal, 1, p_here, p_put_plus, p_exit + dq p_here, p_Cput, p_literal, 1, p_here, p_put_plus, p_return WORD p_does,"DOES>",fasm,IMMEDIATE ;; ( -- ) @@ -286,7 +286,7 @@ p_evaluate_stream_END: dq p_literal, 1 p_evaluate_stream_BAD: dq p_Rgt, p_input, p_put ; restore previous stream - dq p_exit + dq p_return WORD p_colon,':' ;; ( -- ) @@ -299,12 +299,12 @@ p_evaluate_stream_BAD: dq p_tfa2cfa dq p_put dq p_right_bracket - dq p_exit + dq p_return WORD p_semicolon,';',,IMMEDIATE ;; ( -- ) - ;; Lay out p_exit, and set interpreting mode - dq p_literal, p_exit, p_comma, p_left_bracket, p_exit + ;; Lay out p_return, and set interpreting mode + dq p_literal, p_return, p_comma, p_left_bracket, p_return WORD p_immediate,'IMMEDIATE',fasm,IMMEDIATE ;; ( -- ) @@ -346,4 +346,4 @@ p_load_file_badfile: dq p_tell, p_dot, p_nl, p_emit dq p_literal,1 p_load_file_exit: - dq p_exit + dq p_return diff --git a/reference.adoc b/reference.adoc index 7720490..e9e369f 100644 --- a/reference.adoc +++ b/reference.adoc @@ -79,6 +79,8 @@ include::adoc/data_stack.adoc[] include::separator.adoc[] include::adoc/p_decimal.adoc[] include::separator.adoc[] +include::adoc/p_definitions.adoc[] +include::separator.adoc[] include::adoc/p_depth.adoc[] include::separator.adoc[] include::adoc/p_dfa2tfa.adoc[] @@ -229,6 +231,8 @@ include::adoc/p_read_word.adoc[] include::separator.adoc[] include::adoc/p_realloc.adoc[] include::separator.adoc[] +include::adoc/p_return.adoc[] +include::separator.adoc[] include::adoc/p_right_bracket.adoc[] include::separator.adoc[] include::adoc/p_roll.adoc[] @@ -289,6 +293,8 @@ include::adoc/p_unequal.adoc[] include::separator.adoc[] include::adoc/p_unstream.adoc[] include::separator.adoc[] +include::adoc/p_use.adoc[] +include::separator.adoc[] include::adoc/p_verboseQ.adoc[] include::separator.adoc[] include::adoc/p_within.adoc[] diff --git a/reference.html b/reference.html index a1de89c..988e551 100644 --- a/reference.html +++ b/reference.html @@ -806,6 +806,7 @@ asciidoc.install(); CREATE   CURRENT-WORDLIST  

DECIMAL   +DEFINITIONS   DEPTH   DIGITS   /MOD   @@ -858,6 +859,7 @@ asciidoc.install();

@@ -882,7 +884,8 @@ asciidoc.install(); THIS-WORD   TRUE   TUCK  

- +

UNSTREAM   +USE  

@@ -1655,6 +1658,27 @@ _______________________________________________________
_______________________________________________________
+

+ +
+

Word: DEFINITIONS

+
+
+
Data stack: ( wordlist -- )
+
+

"DEFINITIONS" is a function word that installs the given wordlist as +the CURRENT-WORDLIST one.

+
+
+
+
+
Definition concept for DEFINITIONS
+

: DEFINITIONS CURRENT-WORDLIST ! ;

+
+
+
+_______________________________________________________ +

@@ -2133,11 +2157,10 @@ _______________________________________________________

Word: EXIT

-
Data stack: ( -- )
+
Data stack: ( v -- )
-

"EXIT" is a function word that implements the ending of a FORTH -definition and its threading to the subsequent step of the calling -definition.

+

"EXIT" is a function word that terminates the rrqforth process +immediately with the given exit code.

_______________________________________________________
@@ -2966,6 +2989,20 @@ kernel, and the granularity is in pages, i.e. a multiple of 4 kb.

_______________________________________________________
+

+ +
+

Word: RETURN

+
+
+
Data stack: ( -- )
+
+

"RETURN" is a function word that implements the ending of a FORTH +definition and make execution return to the next step in the calling +definition.

+
+_______________________________________________________ +

compile.asm: WORD p_right_bracket,],fasm

@@ -3483,10 +3520,26 @@ at (stream* + 16) is its size.

_______________________________________________________
-

+

+

Word: USE

+
+
+
Data value: ( wordlist -- )  Input stream: word
+
+

"USE" is a function word that looks up next word given the wordlist. +It reads next word on INPUT via READ-WORD, +then temporarily changes CURRENT-WORDLIST to +FIND the word via the given wordlist, and returns the TFA +of that word, or just 0 if the word coudn’t be found.

+
+_______________________________________________________ +
+

+
+

Word: VERBOSE?

@@ -3575,7 +3628,7 @@ is deepest.

diff --git a/rrqforth b/rrqforth index 81b5b6ce79bada6af919d3e84198aa42d8d1e884..6634bcbd47cdaff0d58c3409f43008f338536276 100755 GIT binary patch delta 11384 zcmZ`<2V7Lg)}OfoE}*-x$g)&t1w~XMU?hnm0QA$dR6_6JU}lw{xIsa;^kiMOW#NA!_xOFWxL(O`_P1-ng>F3BTq#h^luj zhmY`M*BV%Z^W19T@A$S`Ib4nt-K`xBHUtK{bJ6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z5zwzSf{tjLUYZ=E$zH<<(q7_UgZKg*Vvwa&vmlrA9jru zn48zh(RtW4=2F`=wqZ}wMkkJniHna0mDlLX>TmuvA&ghYi{r`f9IE}}nc_+=HsQJ? zCRX1-mIAoWW^o&DloKZRAhSV#Dx#NG`Xp10b8*KRr^t_4OC(09CE&;RomQeo1MUJ_gEOP9@b!Kep4YB$r8YZZ3i2H7$2ut-1_PpZ; zEqrc5{f$4ofT-t<18%Z#By^K-^!$@&V=5Qx2J&f$|}jys{v_xt5P3pRnRWO77rpa-M-?G5j~xa+qr&ztha< zK_0Gpe(y^TqeK5mW|QV}m)4*q;CT`Epf_AKM0{VxcPpyJqpuNvo1i3J14<#duY8WdaE#vqJR zd7L8dN^Z*(iPaq19>?4NY^kA(D7~igfu;EtL?3kU2XfZR)k_vAY{{e;Xm<;jzR7OJ k^E2d?ASbN6fLQYdM1C%>VRFJ+$_=kPmj>?vA|>+w0R9SlV*mgE diff --git a/rrqforth.asm b/rrqforth.asm index 894e4b4..5187c90 100644 --- a/rrqforth.asm +++ b/rrqforth.asm @@ -133,7 +133,12 @@ previous_word = 0 pop rax jmp qword [rax] ; goto code of that FORTH word (64 bit jump) - WORD p_exit, 'EXIT',fasm + WORD p_sysexit, 'EXIT', + ;; ( v -- ) + ;; Terminate RRQFORTH with error code + dq sys_exit + + WORD p_return, 'RETURN',fasm ;; ( -- ) ( R: addr -- ) ;; Returns execution to the calling definition as per the ;; return stack. diff --git a/stdio.asm b/stdio.asm index 467952b..e07e809 100644 --- a/stdio.asm +++ b/stdio.asm @@ -288,22 +288,22 @@ p_double_quote_endstream: WORD p_fdtell,'FDTELL', ;; ( chars* n fd -- ) ;; Write n bytes from chars* to fd - dq p_rot, p_rot, sys_write, p_drop, p_exit + dq p_rot, p_rot, sys_write, p_drop, p_return WORD p_tell,'TELL' ;; ( chars* n -- ) ;; Write n bytes from chars* to stdout - dq p_literal,1,p_fdtell, p_exit + dq p_literal,1,p_fdtell, p_return WORD p_fdemit,'FDEMIT' ;; ( c fd -- ) ;; Write byte to fd - dq p_literal,1, p_dsp, p_literal,1, sys_write, p_2drop, p_exit + dq p_literal,1, p_dsp, p_literal,1, sys_write, p_2drop, p_return WORD p_emit,'EMIT' ;; ( c -- ) ;; Write byte to stdout - dq p_literal,1, p_fdemit, p_exit + dq p_literal,1, p_fdemit, p_return WORD p_nl,'NL',dovalue ;; ( -- c ) @@ -360,4 +360,4 @@ p_dot_remainder: WORD p_dot,'.' ;; ( v -- ) ;; Print value to stdout - dq p_dot_temp, p_literal,1, p_fdtell, p_exit + dq p_dot_temp, p_literal,1, p_fdtell, p_return diff --git a/temp.asm b/temp.asm index f85cb33..46a1358 100644 --- a/temp.asm +++ b/temp.asm @@ -48,4 +48,4 @@ p_objecthole_from_tail: dq p_dup, p_gtR ; ( -- char* n addr+8 ) [ n addr+8 ] dq p_swap, p_strncpy ; ( -- ) [ n addr+8 ] dq p_Rgt, p_Rgt ; ( -- addr+8 n ) [ ] - dq p_exit + dq p_return diff --git a/wordindex.adoc b/wordindex.adoc index a64f84b..66d0ae8 100644 --- a/wordindex.adoc +++ b/wordindex.adoc @@ -74,6 +74,7 @@ xref:p_create[CREATE] {nbsp} xref:p_current_wordlist[CURRENT-WORDLIST] {nbsp} xref:p_decimal[DECIMAL] {nbsp} +xref:p_definitions[DEFINITIONS] {nbsp} xref:p_depth[DEPTH] {nbsp} xref:p_digits[DIGITS] {nbsp} xref:p_divmod[/MOD] {nbsp} @@ -137,6 +138,7 @@ xref:p_quit[QUIT] {nbsp} xref:p_read_stream_char[READ-STREAM-CHAR] {nbsp} xref:p_read_word[READ-WORD] {nbsp} xref:p_realloc[REALLOC] {nbsp} +xref:p_return[RETURN] {nbsp} xref:p_roll[ROLL] {nbsp} xref:p_rot[ROT] {nbsp} xref:p_rbp[RSP] {nbsp} @@ -165,6 +167,7 @@ xref:p_true[TRUE] {nbsp} xref:p_tuck[TUCK] {nbsp} xref:p_unstream[UNSTREAM] {nbsp} +xref:p_use[USE] {nbsp} xref:p_verboseQ[VERBOSE?] {nbsp} diff --git a/wordlists.asm b/wordlists.asm index 7daa428..0ee7aec 100644 --- a/wordlists.asm +++ b/wordlists.asm @@ -14,6 +14,30 @@ ;; CURRENT-WORDLIST points to dfa of the currently active wordlist. dq p_forth_DFA ; compilation word list + WORD p_definitions,'DEFINITIONS',fasm + ;; ( wordlist -- ) + ;; Change CURRENT-WORDLIST to use the given word list + pop qword [p_wordlist_DFA] + next + + WORD p_use,'USE',fasm + ;; ( wordlist "name" -- cfa ) + ;; Read next word using the given wordlist + pushr rsi + mov rax,qword [p_wordlist_DFA] + pushr rax + pop qword [p_wordlist_DFA] + DOFORTH p_input, p_get, p_read_word, p_find + popr rax + mov qword [p_wordlist_DFA],rax + cmp qword [rsp],0 + jne p_use_done + add rsp,16 + mov qword [rsp],0 +p_use_done: + popr rsi + next + WORD p_words,'WORDS',fasm ;; ( w -- ) ;; Dump all words of the word list w (the dfa of a word list) -- 2.39.2