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
-
+
@@ -1655,6 +1658,27 @@ _______________________________________________________
_______________________________________________________
+
+
+
+
Word: DEFINITIONS
+
+
+
Data stack: ( wordlist -- )
+
+
"DEFINITIONS" is a function word that installs the given wordlist as
+the CURRENT-WORDLIST one.
+
+
+_______________________________________________________
+
@@ -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
+
+
"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.