From ef2e2e05df192742bc4e0c2f69dcd4233548b672 Mon Sep 17 00:00:00 2001 From: crc <> Date: Mon, 22 Aug 2022 09:52:09 +0000 Subject: [PATCH] add more glossary entries for mem: words FossilOrigin-Name: 1a777b619a5109735110d4ab35fa2a60f7de41d38fa118a8bb292689cfa81aac --- doc/Glossary-Concise.txt | 15 ++++++++ doc/Glossary-Names-and-Stack.txt | 5 +++ doc/Glossary.html | 43 ++++++++++++++++++++-- doc/Glossary.txt | 63 ++++++++++++++++++++++++++++++-- doc/words.tsv | 13 +++++-- 5 files changed, 127 insertions(+), 12 deletions(-) diff --git a/doc/Glossary-Concise.txt b/doc/Glossary-Concise.txt index f4ce1dc..2cef4dd 100644 --- a/doc/Glossary-Concise.txt +++ b/doc/Glossary-Concise.txt @@ -652,6 +652,9 @@ Fetch the double cell values stored in the double cell variable at a. double:store D: nna- A: - F: - Store the double cell values on the stack in the double cell variable at a. +double:swap D: nnmm-mmnn A: - F: - +Swap double cell value on stack. + double:var D: nns- A: - F: - Create a variable for holding the specified double cell value. @@ -1075,12 +1078,24 @@ Compare n1 and n2. Return `TRUE` if n1 is less than n2, or `FALSE` otherwise. lteq? D: nn-f A: - F: - Compare n1 and n2. Return `TRUE` if n1 is less than or equal to n2, or `FALSE` otherwise. +mem:alloc D: n-nn A: - F: - +Use malloc to allocate memory. Returns a double cell pointer to this memory. + mem:cell+ D: nnn-n A: - F: - Return address of next cell. Uses a double cell pointer on the stack. +mem:fetch D: nn-n A: - F: - +Fetch value from malloc'd memory region. Address is a double cell value. + mem:fetch-double D: nn-n A: - F: - Fetch a double cell value from a malloc memory region. +mem:free D: nn- A: - F: - +Fre a malloc'd region of memory. Pass a double cell pointer to the memory to free. + +mem:store D: xnn- A: - F: - +Store a value into a malloc'd memory region. Uses a double cell pointer for the address. + mod D: nm-o A: - F: - Divide `n` by `m` and return the remainder. diff --git a/doc/Glossary-Names-and-Stack.txt b/doc/Glossary-Names-and-Stack.txt index 0b71f5a..e1a4937 100644 --- a/doc/Glossary-Names-and-Stack.txt +++ b/doc/Glossary-Names-and-Stack.txt @@ -216,6 +216,7 @@ does D: q- A: - F: - double:const D: nns- A: - F: - double:fetch D: a-n A: - F: - double:store D: nna- A: - F: - +double:swap D: nnmm-mmnn A: - F: - double:var D: nns- A: - F: - drop D: n- A: - F: - drop-pair D: nn- A: - F: - @@ -357,8 +358,12 @@ io:unix-syscall D: ...n- A: - F: - listen D: - A: - F: - lt? D: nn-f A: - F: - lteq? D: nn-f A: - F: - +mem:alloc D: n-nn A: - F: - mem:cell+ D: nnn-n A: - F: - +mem:fetch D: nn-n A: - F: - mem:fetch-double D: nn-n A: - F: - +mem:free D: nn- A: - F: - +mem:store D: xnn- A: - F: - mod D: nm-o A: - F: - n:-zero? D: n-f A: - F: - n:MAX D: -n A: - F: - diff --git a/doc/Glossary.html b/doc/Glossary.html index 77c9380..95db3b0 100644 --- a/doc/Glossary.html +++ b/doc/Glossary.html @@ -1592,28 +1592,35 @@ Float: -
Create a constant returning the specified double cell value.
-Class: | class:word |
Namespace: | double |
Interface Layer: | all |
Class: | class:word |
Namespace: | double |
Interface Layer: | rre |
Data: a-n
Addr: -
Float: -
Fetch the double cell values stored in the double cell variable at a.
-Class: | class:word |
Namespace: | double |
Interface Layer: | all |
Class: | class:word |
Namespace: | double |
Interface Layer: | rre |
Data: nna-
Addr: -
Float: -
Store the double cell values on the stack in the double cell variable at a.
-Class: | class:word |
Namespace: | double |
Interface Layer: | all |
Class: | class:word |
Namespace: | double |
Interface Layer: | rre |
Data: nnmm-mmnn
+Addr: -
+Float: -
Swap double cell value on stack.
+Class: | class:word |
Namespace: | double |
Interface Layer: | rre |
Data: nns-
Addr: -
Float: -
Create a variable for holding the specified double cell value.
-Class: | class:word |
Namespace: | double |
Interface Layer: | all |
Class: | class:word |
Namespace: | double |
Interface Layer: | rre |
Data: n-
Addr: -
@@ -2677,6 +2684,13 @@
Compare n1 and n2. Return `TRUE` if n1 is less than or equal to n2, or `FALSE` otherwise.
Class: | class:word |
Namespace: | global |
Interface Layer: | all |
Data: n-nn
+Addr: -
+Float: -
Use malloc to allocate memory. Returns a double cell pointer to this memory.
+Class: | class:word |
Namespace: | mem |
Interface Layer: | rre |
Data: nnn-n
Addr: -
@@ -2684,6 +2698,13 @@
Return address of next cell. Uses a double cell pointer on the stack.
Class: | class:word |
Namespace: | mem |
Interface Layer: | rre |
Data: nn-n
+Addr: -
+Float: -
Fetch value from malloc'd memory region. Address is a double cell value.
+Class: | class:word |
Namespace: | mem |
Interface Layer: | rre |
Data: nn-n
Addr: -
@@ -2691,6 +2712,20 @@
Fetch a double cell value from a malloc memory region.
Class: | class:word |
Namespace: | mem |
Interface Layer: | rre |
Data: nn-
+Addr: -
+Float: -
Fre a malloc'd region of memory. Pass a double cell pointer to the memory to free.
+Class: | class:word |
Namespace: | mem |
Interface Layer: | rre |
Data: xnn-
+Addr: -
+Float: -
Store a value into a malloc'd memory region. Uses a double cell pointer for the address.
+Class: | class:word |
Namespace: | mem |
Interface Layer: | rre |
Data: nm-o
Addr: -
diff --git a/doc/Glossary.txt b/doc/Glossary.txt
index 9620dc3..17779e6 100644
--- a/doc/Glossary.txt
+++ b/doc/Glossary.txt
@@ -2468,7 +2468,7 @@ double:const
Create a constant returning the specified double cell value.
-Class: class:word | Namespace: double | Interface Layer: all
+Class: class:word | Namespace: double | Interface Layer: rre
------------------------------------------------------------------------
double:fetch
@@ -2479,7 +2479,7 @@ double:fetch
Fetch the double cell values stored in the double cell variable at a.
-Class: class:word | Namespace: double | Interface Layer: all
+Class: class:word | Namespace: double | Interface Layer: rre
------------------------------------------------------------------------
double:store
@@ -2490,7 +2490,18 @@ double:store
Store the double cell values on the stack in the double cell variable at a.
-Class: class:word | Namespace: double | Interface Layer: all
+Class: class:word | Namespace: double | Interface Layer: rre
+------------------------------------------------------------------------
+
+double:swap
+
+ Data: nnmm-mmnn
+ Addr: -
+ Float: -
+
+Swap double cell value on stack.
+
+Class: class:word | Namespace: double | Interface Layer: rre
------------------------------------------------------------------------
double:var
@@ -2501,7 +2512,7 @@ double:var
Create a variable for holding the specified double cell value.
-Class: class:word | Namespace: double | Interface Layer: all
+Class: class:word | Namespace: double | Interface Layer: rre
------------------------------------------------------------------------
drop
@@ -4146,6 +4157,17 @@ Compare n1 and n2. Return `TRUE` if n1 is less than or equal to n2, or `FALSE` o
Class: class:word | Namespace: global | Interface Layer: all
------------------------------------------------------------------------
+mem:alloc
+
+ Data: n-nn
+ Addr: -
+ Float: -
+
+Use malloc to allocate memory. Returns a double cell pointer to this memory.
+
+Class: class:word | Namespace: mem | Interface Layer: rre
+------------------------------------------------------------------------
+
mem:cell+
Data: nnn-n
@@ -4157,6 +4179,17 @@ Return address of next cell. Uses a double cell pointer on the stack.
Class: class:word | Namespace: mem | Interface Layer: rre
------------------------------------------------------------------------
+mem:fetch
+
+ Data: nn-n
+ Addr: -
+ Float: -
+
+Fetch value from malloc'd memory region. Address is a double cell value.
+
+Class: class:word | Namespace: mem | Interface Layer: rre
+------------------------------------------------------------------------
+
mem:fetch-double
Data: nn-n
@@ -4168,6 +4201,28 @@ Fetch a double cell value from a malloc memory region.
Class: class:word | Namespace: mem | Interface Layer: rre
------------------------------------------------------------------------
+mem:free
+
+ Data: nn-
+ Addr: -
+ Float: -
+
+Fre a malloc'd region of memory. Pass a double cell pointer to the memory to free.
+
+Class: class:word | Namespace: mem | Interface Layer: rre
+------------------------------------------------------------------------
+
+mem:store
+
+ Data: xnn-
+ Addr: -
+ Float: -
+
+Store a value into a malloc'd memory region. Uses a double cell pointer for the address.
+
+Class: class:word | Namespace: mem | Interface Layer: rre
+------------------------------------------------------------------------
+
mod
Data: nm-o
diff --git a/doc/words.tsv b/doc/words.tsv
index 994817d..ae656bd 100644
--- a/doc/words.tsv
+++ b/doc/words.tsv
@@ -213,10 +213,11 @@ decimal - - - Set `Base` to decimal. class:word {n/a} {n/a} a all
depth -n - - Return the number of items on the stack. class:word {n/a} {n/a} global all
dip nq-n - - Temporarily remove n from the stack, execute the quotation, and then restore n to the stack. class:word {n/a} {n/a} global all
does q- - - Attach an action to the most recently created word. This is used in a manner similar to CREATE/DOES> in traditional Forth. class:word {n/a} {n/a} global all
-double:const nns- - - Create a constant returning the specified double cell value. class:word {n/a} {n/a} double all
-double:fetch a-n - - Fetch the double cell values stored in the double cell variable at a. class:word {n/a} {n/a} double all
-double:store nna- - - Store the double cell values on the stack in the double cell variable at a. class:word {n/a} {n/a} double all
-double:var nns- - - Create a variable for holding the specified double cell value. class:word {n/a} {n/a} double all
+double:const nns- - - Create a constant returning the specified double cell value. class:word {n/a} {n/a} double rre
+double:fetch a-n - - Fetch the double cell values stored in the double cell variable at a. class:word {n/a} {n/a} double rre
+double:store nna- - - Store the double cell values on the stack in the double cell variable at a. class:word {n/a} {n/a} double rre
+double:swap nnmm-mmnn - - Swap double cell value on stack. class:word {n/a} {n/a} double rre
+double:var nns- - - Create a variable for holding the specified double cell value. class:word {n/a} {n/a} double rre
drop n- - - Discard the top value on the stack. class:primitive {n/a} {n/a} global all
drop-pair nn- - - Remove top two items on the stack. class:word {n/a} {n/a} global all
dump-stack - - - Display the items on the data stack. class:word {n/a} {n/a} global all
@@ -357,8 +358,12 @@ io:unix-syscall ...n- - - Trigger a Unix system call. This is not intended to be
listen - - - "Run interactive ""listener"" (a REPL)." class:word {n/a} {n/a} global rre
lt? nn-f - - Compare n1 and n2. Return `TRUE` if n1 is less than n2, or `FALSE` otherwise. class:primitive {n/a} {n/a} global all
lteq? nn-f - - Compare n1 and n2. Return `TRUE` if n1 is less than or equal to n2, or `FALSE` otherwise. class:word {n/a} {n/a} global all
+mem:alloc n-nn - - Use malloc to allocate memory. Returns a double cell pointer to this memory. class:word {n/a} {n/a} mem rre
mem:cell+ nnn-n - - Return address of next cell. Uses a double cell pointer on the stack. class:word {n/a} {n/a} mem rre
+mem:fetch nn-n - - Fetch value from malloc'd memory region. Address is a double cell value. class:word {n/a} {n/a} mem rre
mem:fetch-double nn-n - - Fetch a double cell value from a malloc memory region. class:word {n/a} {n/a} mem rre
+mem:free nn- - - Fre a malloc'd region of memory. Pass a double cell pointer to the memory to free. class:word {n/a} {n/a} mem rre
+mem:store xnn- - - Store a value into a malloc'd memory region. Uses a double cell pointer for the address. class:word {n/a} {n/a} mem rre
mod nm-o - - Divide `n` by `m` and return the remainder. class:word {n/a} {n/a} global all
n:-zero? n-f - - Return `TRUE` if number is not zero, or `FALSE` otherwise. class:word {n/a} {n/a} n all
n:MAX -n - - Return the maximum value that will fit in a cell. class:word {n/a} {n/a} n all