Made site more templatized.
This commit is contained in:
@ -278,28 +278,36 @@ $(ARDUINO)/ESP32forth.zip: $(ARDUINO)/ESP32forth/ESP32forth.ino
|
|||||||
$(DEPLOY):
|
$(DEPLOY):
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
|
REPLACE = common/replace.js \
|
||||||
|
COMMON=@site/common.html \
|
||||||
|
DESKTOP_COMMON=@site/desktop_common.html \
|
||||||
|
MENU=@site/menu.html \
|
||||||
|
VERSION=${VERSION} \
|
||||||
|
REVISION=${REVISION}
|
||||||
|
UE_REPLACE = $(REPLACE) FORTH=uEForth
|
||||||
|
ESP_REPLACE = $(REPLACE) FORTH=ESP32forth
|
||||||
|
|
||||||
$(DEPLOY)/app.yaml: $(ARDUINO)/ESP32forth.zip \
|
$(DEPLOY)/app.yaml: $(ARDUINO)/ESP32forth.zip \
|
||||||
$(wildcard site/*.html) \
|
$(wildcard site/*.html) \
|
||||||
site/app.yaml \
|
site/app.yaml \
|
||||||
site/eforth.go \
|
site/eforth.go \
|
||||||
$(TARGETS) | $(DEPLOY)
|
$(TARGETS) | $(DEPLOY)
|
||||||
cp -r site/* $(DEPLOY)/
|
mkdir -p $(DEPLOY)
|
||||||
mkdir -p $(DEPLOY)/downloads
|
cp -r site/static $(DEPLOY)/static
|
||||||
|
cp -r site/downloads $(DEPLOY)/downloads
|
||||||
|
cp site/*.go $(DEPLOY)/
|
||||||
|
cp site/*.yaml $(DEPLOY)/
|
||||||
cp -r $(ARDUINO)/ESP32forth.zip $(DEPLOY)/downloads
|
cp -r $(ARDUINO)/ESP32forth.zip $(DEPLOY)/downloads
|
||||||
cp -r $(POSIX)/ueforth $(DEPLOY)/downloads/ueforth.linux
|
cp -r $(POSIX)/ueforth $(DEPLOY)/downloads/ueforth.linux
|
||||||
cp -r $(WINDOWS)/uEf32.exe $(DEPLOY)/downloads/uEf32.exe
|
cp -r $(WINDOWS)/uEf32.exe $(DEPLOY)/downloads/uEf32.exe
|
||||||
cp -r $(WINDOWS)/uEf64.exe $(DEPLOY)/downloads/uEf64.exe
|
cp -r $(WINDOWS)/uEf64.exe $(DEPLOY)/downloads/uEf64.exe
|
||||||
cp -r $(RES)/eforth.ico $(DEPLOY)/downloads/favicon.ico
|
cp -r $(RES)/eforth.ico $(DEPLOY)/downloads/favicon.ico
|
||||||
cp site/.gcloudignore $(DEPLOY)
|
cp site/.gcloudignore $(DEPLOY)
|
||||||
cat site/ESP32forth.html | \
|
cat site/index.html | $(ESP_REPLACE) >$(DEPLOY)/index.html
|
||||||
sed "s/{{VERSION}}/${VERSION}/g" | \
|
cat site/ESP32forth.html | $(ESP_REPLACE) >$(DEPLOY)/ESP32forth.html
|
||||||
sed "s/{{REVISION}}/${REVISION}/g" > $(DEPLOY)/ESP32forth.html
|
cat site/linux.html | $(UE_REPLACE) >$(DEPLOY)/linux.html
|
||||||
cat site/windows.html | \
|
cat site/windows.html | $(UE_REPLACE) >$(DEPLOY)/windows.html
|
||||||
sed "s/{{VERSION}}/${VERSION}/g" | \
|
cat site/classic.html | $(UE_REPLACE) >$(DEPLOY)/classic.html
|
||||||
sed "s/{{REVISION}}/${REVISION}/g" > $(DEPLOY)/windows.html
|
|
||||||
cat site/linux.html | \
|
|
||||||
sed "s/{{VERSION}}/${VERSION}/g" | \
|
|
||||||
sed "s/{{REVISION}}/${REVISION}/g" > $(DEPLOY)/linux.html
|
|
||||||
|
|
||||||
deploy: clean all
|
deploy: clean all
|
||||||
cd out/deploy && gcloud app deploy -q --project esp32forth *.yaml
|
cd out/deploy && gcloud app deploy -q --project esp32forth *.yaml
|
||||||
|
|||||||
36
ueforth/common/replace.js
Normal file
36
ueforth/common/replace.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#! /usr/bin/env nodejs
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var source = fs.readFileSync(process.stdin.fd).toString();
|
||||||
|
var replacements = [];
|
||||||
|
for (var i = 2; i < process.argv.length; ++i) {
|
||||||
|
var item = process.argv[i];
|
||||||
|
var m = item.match(/^([^=]+)=@(.+)$/);
|
||||||
|
if (m) {
|
||||||
|
replacements.push([m[1], fs.readFileSync(m[2]).toString()]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var m = item.match(/^([^=]+)=(.+)$/);
|
||||||
|
if (m) {
|
||||||
|
replacements.push([m[1], m[2]]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
throw 'Bad replacement ' + item;
|
||||||
|
}
|
||||||
|
|
||||||
|
var version = process.argv[3];
|
||||||
|
var revision = process.argv[4];
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
var old_source = source;
|
||||||
|
for (var i = 0; i < replacements.length; ++i) {
|
||||||
|
source = source.replace('{{' + replacements[i][0] + '}}',
|
||||||
|
replacements[i][1]);
|
||||||
|
}
|
||||||
|
if (old_source == source) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
process.stdout.write(source);
|
||||||
@ -8,13 +8,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<h1>ESP32forth</h1>
|
<h1>ESP32forth</h1>
|
||||||
|
|
||||||
<div class="menu">
|
{{MENU}}
|
||||||
<span class="picked"><a href="ESP32forth.html">ESP32forth</a></span>
|
|
||||||
<span><a href="linux.html">Linux</a></span>
|
|
||||||
<span><a href="windows.html">Windows</a></span>
|
|
||||||
<span><a href="internals.html">Internals</a></span>
|
|
||||||
<span><a href="classic.html">Classic</a></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2>Download</h2>
|
<h2>Download</h2>
|
||||||
|
|
||||||
@ -83,117 +77,9 @@ On boot, ESP32forth configures PIN 2 (typically an LED) to be an output and brin
|
|||||||
|
|
||||||
<h3>ESP32forth Specific Words</h3>
|
<h3>ESP32forth Specific Words</h3>
|
||||||
|
|
||||||
<h5>Null Terminated Strings</h5>
|
{{COMMON}}
|
||||||
<p>
|
|
||||||
As null terminated strings are used throughout C interfaces,
|
|
||||||
their use is supported in Forth by way of several non-standard
|
|
||||||
words with the convention of using Z/z to refer to such strings
|
|
||||||
in names and stack comments.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
Z" ( "string" -- z ) Creates a null terminated string on the heap
|
|
||||||
Z>S ( z -- a n ) Convert a null terminated string to a counted string
|
|
||||||
S>Z ( a n -- z ) Conver a counted string string to null terminated (copies string to heap)
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Raw Strings</h5>
|
<h3>ESP32forth Bindings</h3>
|
||||||
<p>
|
|
||||||
Raw strings are provided better support using a string
|
|
||||||
for the duration of the current command, without consuming heap memory.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
R" ( "string" -- a n ) Creates a temporary counted string
|
|
||||||
R| ( string| -- a n ) Creates a temporary counted string ending with |
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Utilities</h5>
|
|
||||||
<pre>
|
|
||||||
DUMP ( a n -- ) Dump a memory region
|
|
||||||
SEE ( "name" -- ) Attempt to decompile a word
|
|
||||||
VARIABLE ECHO -- Determines if commands are echoed
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Vocabularies</h5>
|
|
||||||
<p>
|
|
||||||
ESP32forth uses a hybrid of Forth-79 and Forth-83 style vocabularies.
|
|
||||||
By default vocabularies chain to the vocabulary in which they were defined,
|
|
||||||
as in Forth-79. However, like Forth-83, <code>ALSO</code>
|
|
||||||
can be used to add vocabularies to a vocabulary stack of which
|
|
||||||
<code>CONTEXT @</code> is the first item.
|
|
||||||
The word <code>ONLY</code> clears the vocabulary stack, but as there is
|
|
||||||
no separate ONLY vocabulary, it also sets <code>CONTEXT</code>
|
|
||||||
to the <code>FORTH</code> vocabulary.
|
|
||||||
The word <code>SEALED</code> modifies the most recently defined vocabulary
|
|
||||||
such that it does not chain. Note, this must be done before words are added to it.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
VOCABULARY ( "name" ) Create a vocabulary with the current vocabulary as parent
|
|
||||||
FORTH ( -- ) Make the FORTH vocabulary the context vocabulary
|
|
||||||
DEFINITIONS ( -- ) Make the context vocabulary the current vocabulary
|
|
||||||
VLIST ( -- ) List the words in the context vocabulary (not chains)
|
|
||||||
WORDS ( -- ) List the words in the context vocabulary (including chains)
|
|
||||||
TRANSFER ( "name" ) Move a word from its current dictionary to the current vocabulary
|
|
||||||
Useful for "hiding" built-in words
|
|
||||||
TRANSFER{ ..words.. }TRANSFER ( -- ) Transfer multiple words to the current vocabulary
|
|
||||||
ALSO ( -- ) Duplicate the vocabulary at the top of the vocabulary stack
|
|
||||||
ONLY ( -- ) Reset context stack to one item, the FORTH dictionary
|
|
||||||
Non-standard, as there's no distinct ONLY vocabulary
|
|
||||||
ORDER ( -- ) Print the vocabulary search order
|
|
||||||
SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Interpret Time Conditions</h5>
|
|
||||||
<p>
|
|
||||||
<code>[I]F</code>, <code>[ELSE]</code>, and <code>[THEN]</code> can be used
|
|
||||||
to selectively compile. Used in tandem with <code>DEFINED?</code> they can
|
|
||||||
be used to handle the absence of modules gracefully.
|
|
||||||
Nesting is supported.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
DEFINED? ( "name" -- xt|0 ) Check if a word exists (works at compile time too).
|
|
||||||
[IF] ( f -- ) Conditionally interpret the text the follows.
|
|
||||||
[ELSE] ( -- ) Interpret time ELSE.
|
|
||||||
[THEN] ( -- ) Interpret time THEN.
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Blocks</h5>
|
|
||||||
<pre>
|
|
||||||
USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo
|
|
||||||
OPEN-BLOCKS ( a n -- ) Open a file as the block file
|
|
||||||
LOAD ( n -- ) Evaluate a block
|
|
||||||
THRU ( a b -- ) Load blocks a thru b
|
|
||||||
LIST ( n -- ) List a block
|
|
||||||
BLOCK ( n -- a ) Get a 1024 byte block
|
|
||||||
BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents
|
|
||||||
UPDATE ( -- ) Mark the last block modified
|
|
||||||
FLUSH ( -- ) Save and empty all buffers
|
|
||||||
EMPTY-BUFFERS ( -- ) Empty all buffers
|
|
||||||
SAVE-BUFFERS ( -- ) Save all buffers
|
|
||||||
SCR ( -- a ) Pointer to last listed block
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Block Editor</h5>
|
|
||||||
These words are available inside the <code>EDITOR</code> vocabulary.
|
|
||||||
Note the block editor places newlines in the 63rd column of each line
|
|
||||||
to make the block file readable in a text editor.
|
|
||||||
<pre>
|
|
||||||
WIPE ( -- ) Blank out the current block
|
|
||||||
L ( -- ) List the current block
|
|
||||||
D ( n -- ) Delete a line in the current block
|
|
||||||
E ( n -- ) Clear a line in the current block
|
|
||||||
R ( n "text" -- ) Replace a line in the current block
|
|
||||||
A ( n "text" -- ) Add (insert) a line in the current block
|
|
||||||
P ( -- ) Move to the previous block
|
|
||||||
N ( -- ) Move to the next block
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Utilities</h5>
|
|
||||||
<pre>
|
|
||||||
SEE ( "name" -- ) Attempt to decompile a word
|
|
||||||
ECHO ( -- a ) -- Address of flag that determines if commands are echoed
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h3>ESP32forth Opcodes</h3>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Because Arduino builds a statically linked image for flashing into ESP32 devices,
|
Because Arduino builds a statically linked image for flashing into ESP32 devices,
|
||||||
|
|||||||
@ -7,13 +7,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>Classic EForth</h1>
|
<h1>Classic EForth</h1>
|
||||||
|
|
||||||
<div class="menu">
|
{{MENU}}
|
||||||
<span><a href="ESP32forth.html">ESP32forth</a></span>
|
|
||||||
<span><a href="linux.html">Linux</a></span>
|
|
||||||
<span><a href="windows.html">Windows</a></span>
|
|
||||||
<span><a href="internals.html">Internals</a></span>
|
|
||||||
<span class="picked"><a href="classic.html">Classic</a></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
EForth is a delightfully minimalist approach to Forth originated by Bill Muench and Dr. C. H. Ting.
|
EForth is a delightfully minimalist approach to Forth originated by Bill Muench and Dr. C. H. Ting.
|
||||||
|
|||||||
109
ueforth/site/common.html
Normal file
109
ueforth/site/common.html
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
<h5>Null Terminated Strings</h5>
|
||||||
|
<p>
|
||||||
|
As null terminated strings are used throughout C interfaces,
|
||||||
|
their use is supported in Forth by way of several non-standard
|
||||||
|
words with the convention of using Z/z to refer to such strings
|
||||||
|
in names and stack comments.
|
||||||
|
</p>
|
||||||
|
<pre>
|
||||||
|
Z" ( "string" -- z ) Creates a null terminated string on the heap
|
||||||
|
Z>S ( z -- a n ) Convert a null terminated string to a counted string
|
||||||
|
S>Z ( a n -- z ) Conver a counted string string to null terminated (copies string to heap)
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h5>Raw Strings</h5>
|
||||||
|
<p>
|
||||||
|
Raw strings are provided better support using a string
|
||||||
|
for the duration of the current command, without consuming heap memory.
|
||||||
|
</p>
|
||||||
|
<pre>
|
||||||
|
R" ( "string" -- a n ) Creates a temporary counted string
|
||||||
|
R| ( string| -- a n ) Creates a temporary counted string ending with |
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h5>Utilities</h5>
|
||||||
|
<pre>
|
||||||
|
DUMP ( a n -- ) Dump a memory region
|
||||||
|
SEE ( "name" -- ) Attempt to decompile a word
|
||||||
|
VARIABLE ECHO -- Determines if commands are echoed
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h5>Vocabularies</h5>
|
||||||
|
<p>
|
||||||
|
{{FORTH}} uses a hybrid of Forth-79 and Forth-83 style vocabularies.
|
||||||
|
By default vocabularies chain to the vocabulary in which they were defined,
|
||||||
|
as in Forth-79. However, like Forth-83, <code>ALSO</code>
|
||||||
|
can be used to add vocabularies to a vocabulary stack of which
|
||||||
|
<code>CONTEXT @</code> is the first item.
|
||||||
|
The word <code>ONLY</code> clears the vocabulary stack, but as there is
|
||||||
|
no separate ONLY vocabulary, it also sets <code>CONTEXT</code>
|
||||||
|
to the <code>FORTH</code> vocabulary.
|
||||||
|
The word <code>SEALED</code> modifies the most recently defined vocabulary
|
||||||
|
such that it does not chain. Note, this must be done before words are added to it.
|
||||||
|
</p>
|
||||||
|
<pre>
|
||||||
|
VOCABULARY ( "name" ) Create a vocabulary with the current vocabulary as parent
|
||||||
|
FORTH ( -- ) Make the FORTH vocabulary the context vocabulary
|
||||||
|
DEFINITIONS ( -- ) Make the context vocabulary the current vocabulary
|
||||||
|
VLIST ( -- ) List the words in the context vocabulary (not chains)
|
||||||
|
WORDS ( -- ) List the words in the context vocabulary (including chains)
|
||||||
|
TRANSFER ( "name" ) Move a word from its current dictionary to the current vocabulary
|
||||||
|
Useful for "hiding" built-in words
|
||||||
|
TRANSFER{ ..words.. }TRANSFER ( -- ) Transfer multiple words to the current vocabulary
|
||||||
|
ALSO ( -- ) Duplicate the vocabulary at the top of the vocabulary stack
|
||||||
|
ONLY ( -- ) Reset context stack to one item, the FORTH dictionary
|
||||||
|
Non-standard, as there's no distinct ONLY vocabulary
|
||||||
|
ORDER ( -- ) Print the vocabulary search order
|
||||||
|
SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h5>Interpret Time Conditions</h5>
|
||||||
|
<p>
|
||||||
|
<code>[I]F</code>, <code>[ELSE]</code>, and <code>[THEN]</code> can be used
|
||||||
|
to selectively compile. Used in tandem with <code>DEFINED?</code> they can
|
||||||
|
be used to handle the absence of modules gracefully.
|
||||||
|
Nesting is supported.
|
||||||
|
</p>
|
||||||
|
<pre>
|
||||||
|
DEFINED? ( "name" -- xt|0 ) Check if a word exists (works at compile time too).
|
||||||
|
[IF] ( f -- ) Conditionally interpret the text the follows.
|
||||||
|
[ELSE] ( -- ) Interpret time ELSE.
|
||||||
|
[THEN] ( -- ) Interpret time THEN.
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h5>Blocks</h5>
|
||||||
|
<pre>
|
||||||
|
USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo
|
||||||
|
OPEN-BLOCKS ( a n -- ) Open a file as the block file
|
||||||
|
LOAD ( n -- ) Evaluate a block
|
||||||
|
THRU ( a b -- ) Load blocks a thru b
|
||||||
|
LIST ( n -- ) List a block
|
||||||
|
BLOCK ( n -- a ) Get a 1024 byte block
|
||||||
|
BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents
|
||||||
|
UPDATE ( -- ) Mark the last block modified
|
||||||
|
FLUSH ( -- ) Save and empty all buffers
|
||||||
|
EMPTY-BUFFERS ( -- ) Empty all buffers
|
||||||
|
SAVE-BUFFERS ( -- ) Save all buffers
|
||||||
|
SCR ( -- a ) Pointer to last listed block
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h5>Block Editor</h5>
|
||||||
|
These words are available inside the <code>EDITOR</code> vocabulary.
|
||||||
|
Note the block editor places newlines in the 63rd column of each line
|
||||||
|
to make the block file readable in a text editor.
|
||||||
|
<pre>
|
||||||
|
WIPE ( -- ) Blank out the current block
|
||||||
|
L ( -- ) List the current block
|
||||||
|
D ( n -- ) Delete a line in the current block
|
||||||
|
E ( n -- ) Clear a line in the current block
|
||||||
|
R ( n "text" -- ) Replace a line in the current block
|
||||||
|
A ( n "text" -- ) Add (insert) a line in the current block
|
||||||
|
P ( -- ) Move to the previous block
|
||||||
|
N ( -- ) Move to the next block
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h5>Utilities</h5>
|
||||||
|
<pre>
|
||||||
|
SEE ( "name" -- ) Attempt to decompile a word
|
||||||
|
ECHO ( -- a ) -- Address of flag that determines if commands are echoed
|
||||||
|
</pre>
|
||||||
28
ueforth/site/desktop_common.html
Normal file
28
ueforth/site/desktop_common.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
<h3>Windows & Linux Calling</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
As unfortunately both Windows and Linux have system and library calls with
|
||||||
|
as many as 10 parameters (for example <code>XCreateImage</code>),
|
||||||
|
a collection of calling thunks is required.
|
||||||
|
A single varidic thunk would be ideal, but is hard to do without per platform
|
||||||
|
assembly language.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
CALL0 ( fn -- n )
|
||||||
|
CALL1 ( n fn -- n )
|
||||||
|
CALL2 ( n n fn -- n )
|
||||||
|
CALL3 ( n n n fn -- n )
|
||||||
|
CALL4 ( n n n n fn -- n )
|
||||||
|
CALL5 ( n n n n n fn -- n )
|
||||||
|
CALL6 ( n n n n n n fn -- n )
|
||||||
|
CALL7 ( n n n n n n n fn -- n )
|
||||||
|
CALL7 ( n n n n n n n n fn -- n )
|
||||||
|
CALL9 ( n n n n n n n n n fn -- n )
|
||||||
|
CALL10 ( n n n n n n n n n n fn -- n )
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
See <a href="https://github.com/flagxor/eforth/blob/main/ueforth/common/calling.h">calling.h</a>.
|
||||||
|
</p>
|
||||||
@ -7,13 +7,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>µEforth Internals</h1>
|
<h1>µEforth Internals</h1>
|
||||||
|
|
||||||
<div class="menu">
|
{{MENU}}
|
||||||
<span><a href="ESP32forth.html">ESP32forth</a></span>
|
|
||||||
<span><a href="linux.html">Linux</a></span>
|
|
||||||
<span><a href="windows.html">Windows</a></span>
|
|
||||||
<span class="picked"><a href="internals.html">Internals</a></span>
|
|
||||||
<span><a href="classic.html">Classic</a></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
µEforth (micro-Eforth) simplifies EForth even futher, by building just enough
|
µEforth (micro-Eforth) simplifies EForth even futher, by building just enough
|
||||||
|
|||||||
@ -7,13 +7,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>µEforth for Linux</h1>
|
<h1>µEforth for Linux</h1>
|
||||||
|
|
||||||
<div class="menu">
|
{{MENU}}
|
||||||
<span><a href="ESP32forth.html">ESP32forth</a></span>
|
|
||||||
<span class="picked"><a href="linux.html">Linux</a></span>
|
|
||||||
<span><a href="windows.html">Windows</a></span>
|
|
||||||
<span><a href="internals.html">Internals</a></span>
|
|
||||||
<span><a href="classic.html">Classic</a></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2>Download</h2>
|
<h2>Download</h2>
|
||||||
|
|
||||||
@ -32,115 +26,7 @@
|
|||||||
|
|
||||||
<h3>µEforth Specific Words</h3>
|
<h3>µEforth Specific Words</h3>
|
||||||
|
|
||||||
<h5>Null Terminated Strings</h5>
|
{{COMMON}}
|
||||||
<p>
|
|
||||||
As null terminated strings are used by virtually all platforms,
|
|
||||||
their use is supported in Forth by way of several non-standard
|
|
||||||
words with the convention of using Z/z to refer to such strings
|
|
||||||
in names and stack comments.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
Z" ( "string" -- z ) Creates a null terminated string on the heap
|
|
||||||
Z>S ( z -- a n ) Convert a null terminated string to a counted string
|
|
||||||
S>Z ( a n -- z ) Conver a counted string string to null terminated (copies string to heap)
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Raw Strings</h5>
|
|
||||||
<p>
|
|
||||||
Raw strings are provided better support using a string
|
|
||||||
for the duration of the current command, without consuming heap memory.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
R" ( "string" -- a n ) Creates a temporary counted string
|
|
||||||
R| ( string| -- a n ) Creates a temporary counted string ending with |
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Utilities</h5>
|
|
||||||
<pre>
|
|
||||||
DUMP ( a n -- ) Dump a memory region
|
|
||||||
SEE ( "name" -- ) Attempt to decompile a word
|
|
||||||
VARIABLE ECHO -- Determines if commands are echoed
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Vocabularies</h5>
|
|
||||||
<p>
|
|
||||||
µEforth uses a hybrid of Forth-79 and Forth-83 style vocabularies.
|
|
||||||
By default vocabularies chain to the vocabulary in which they were defined,
|
|
||||||
as in Forth-79. However, like Forth-83, <code>ALSO</code>
|
|
||||||
can be used to add vocabularies to a vocabulary stack of which
|
|
||||||
<code>CONTEXT @</code> is the first item.
|
|
||||||
The word <code>ONLY</code> clears the vocabulary stack, but as there is
|
|
||||||
no separate ONLY vocabulary, it also sets <code>CONTEXT</code>
|
|
||||||
to the <code>FORTH</code> vocabulary.
|
|
||||||
The word <code>SEALED</code> modifies the most recently defined vocabulary
|
|
||||||
such that it does not chain. Note, this must be done before words are added to it.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
VOCABULARY ( "name" ) Create a vocabulary with the current vocabulary as parent
|
|
||||||
FORTH ( -- ) Make the FORTH vocabulary the context vocabulary
|
|
||||||
DEFINITIONS ( -- ) Make the context vocabulary the current vocabulary
|
|
||||||
VLIST ( -- ) List the words in the context vocabulary (not chains)
|
|
||||||
WORDS ( -- ) List the words in the context vocabulary (including chains)
|
|
||||||
TRANSFER ( "name" ) Move a word from its current dictionary to the current vocabulary
|
|
||||||
Useful for "hiding" built-in words
|
|
||||||
TRANSFER{ ..words.. }TRANSFER ( -- ) Transfer multiple words to the current vocabulary
|
|
||||||
ALSO ( -- ) Duplicate the vocabulary at the top of the vocabulary stack
|
|
||||||
ONLY ( -- ) Reset context stack to one item, the FORTH dictionary
|
|
||||||
Non-standard, as there's no distinct ONLY vocabulary
|
|
||||||
ORDER ( -- ) Print the vocabulary search order
|
|
||||||
SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Interpret Time Conditions</h5>
|
|
||||||
<p>
|
|
||||||
<code>[I]F</code>, <code>[ELSE]</code>, and <code>[THEN]</code> can be used
|
|
||||||
to selectively compile. Used in tandem with <code>DEFINED?</code> they can
|
|
||||||
be used to handle the absence of modules gracefully.
|
|
||||||
Nesting is supported.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
DEFINED? ( "name" -- xt|0 ) Check if a word exists (works at compile time too).
|
|
||||||
[IF] ( f -- ) Conditionally interpret the text the follows.
|
|
||||||
[ELSE] ( -- ) Interpret time ELSE.
|
|
||||||
[THEN] ( -- ) Interpret time THEN.
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Blocks</h5>
|
|
||||||
<pre>
|
|
||||||
USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo
|
|
||||||
OPEN-BLOCKS ( a n -- ) Open a file as the block file
|
|
||||||
LOAD ( n -- ) Evaluate a block
|
|
||||||
THRU ( a b -- ) Load blocks a thru b
|
|
||||||
LIST ( n -- ) List a block
|
|
||||||
BLOCK ( n -- a ) Get a 1024 byte block
|
|
||||||
BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents
|
|
||||||
UPDATE ( -- ) Mark the last block modified
|
|
||||||
FLUSH ( -- ) Save and empty all buffers
|
|
||||||
EMPTY-BUFFERS ( -- ) Empty all buffers
|
|
||||||
SAVE-BUFFERS ( -- ) Save all buffers
|
|
||||||
SCR ( -- a ) Pointer to last listed block
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Block Editor</h5>
|
|
||||||
These words are available inside the <code>EDITOR</code> vocabulary.
|
|
||||||
Note the block editor places newlines in the 63rd column of each line
|
|
||||||
to make the block file readable in a text editor.
|
|
||||||
<pre>
|
|
||||||
WIPE ( -- ) Blank out the current block
|
|
||||||
L ( -- ) List the current block
|
|
||||||
D ( n -- ) Delete a line in the current block
|
|
||||||
E ( n -- ) Clear a line in the current block
|
|
||||||
R ( n "text" -- ) Replace a line in the current block
|
|
||||||
A ( n "text" -- ) Add (insert) a line in the current block
|
|
||||||
P ( -- ) Move to the previous block
|
|
||||||
N ( -- ) Move to the next block
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Utilities</h5>
|
|
||||||
<pre>
|
|
||||||
SEE ( "name" -- ) Attempt to decompile a word
|
|
||||||
ECHO ( -- a ) -- Address of flag that determines if commands are echoed
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h3>Linux</h3>
|
<h3>Linux</h3>
|
||||||
|
|
||||||
@ -176,30 +62,4 @@ In addition, <code>TYPE</code> and <code>KEY</code> are connected to
|
|||||||
<code>stdin</code> and <code>stdout</code>.
|
<code>stdin</code> and <code>stdout</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>Windows & Linux Calling</h3>
|
{{DESKTOP_COMMON}}
|
||||||
|
|
||||||
<p>
|
|
||||||
As unfortunately both Windows and Linux have system and library calls with
|
|
||||||
as many as 10 parameters (for example <code>XCreateImage</code>),
|
|
||||||
a collection of calling thunks is required.
|
|
||||||
A single varidic thunk would be ideal, but is hard to do without per platform
|
|
||||||
assembly language.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
CALL0 ( fn -- n )
|
|
||||||
CALL1 ( n fn -- n )
|
|
||||||
CALL2 ( n n fn -- n )
|
|
||||||
CALL3 ( n n n fn -- n )
|
|
||||||
CALL4 ( n n n n fn -- n )
|
|
||||||
CALL5 ( n n n n n fn -- n )
|
|
||||||
CALL6 ( n n n n n n fn -- n )
|
|
||||||
CALL7 ( n n n n n n n fn -- n )
|
|
||||||
CALL7 ( n n n n n n n n fn -- n )
|
|
||||||
CALL9 ( n n n n n n n n n fn -- n )
|
|
||||||
CALL10 ( n n n n n n n n n n fn -- n )
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
See <a href="https://github.com/flagxor/eforth/blob/main/ueforth/common/calling.h">calling.h</a>.
|
|
||||||
</p>
|
|
||||||
|
|||||||
@ -7,13 +7,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>µEforth for Windows</h1>
|
<h1>µEforth for Windows</h1>
|
||||||
|
|
||||||
<div class="menu">
|
{{MENU}}
|
||||||
<span><a href="ESP32forth.html">ESP32forth</a></span>
|
|
||||||
<span><a href="linux.html">Linux</a></span>
|
|
||||||
<span class="picked"><a href="windows.html">Windows</a></span>
|
|
||||||
<span><a href="internals.html">Internals</a></span>
|
|
||||||
<span><a href="classic.html">Classic</a></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h2>Download</h2>
|
<h2>Download</h2>
|
||||||
|
|
||||||
@ -38,115 +32,7 @@
|
|||||||
|
|
||||||
<h3>µEforth Specific Words</h3>
|
<h3>µEforth Specific Words</h3>
|
||||||
|
|
||||||
<h5>Null Terminated Strings</h5>
|
{{COMMON}}
|
||||||
<p>
|
|
||||||
As null terminated strings are used by virtually all platforms,
|
|
||||||
their use is supported in Forth by way of several non-standard
|
|
||||||
words with the convention of using Z/z to refer to such strings
|
|
||||||
in names and stack comments.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
Z" ( "string" -- z ) Creates a null terminated string on the heap
|
|
||||||
Z>S ( z -- a n ) Convert a null terminated string to a counted string
|
|
||||||
S>Z ( a n -- z ) Conver a counted string string to null terminated (copies string to heap)
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Raw Strings</h5>
|
|
||||||
<p>
|
|
||||||
Raw strings are provided better support using a string
|
|
||||||
for the duration of the current command, without consuming heap memory.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
R" ( "string" -- a n ) Creates a temporary counted string
|
|
||||||
R| ( string| -- a n ) Creates a temporary counted string ending with |
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Utilities</h5>
|
|
||||||
<pre>
|
|
||||||
DUMP ( a n -- ) Dump a memory region
|
|
||||||
SEE ( "name" -- ) Attempt to decompile a word
|
|
||||||
VARIABLE ECHO -- Determines if commands are echoed
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Vocabularies</h5>
|
|
||||||
<p>
|
|
||||||
µEforth uses a hybrid of Forth-79 and Forth-83 style vocabularies.
|
|
||||||
By default vocabularies chain to the vocabulary in which they were defined,
|
|
||||||
as in Forth-79. However, like Forth-83, <code>ALSO</code>
|
|
||||||
can be used to add vocabularies to a vocabulary stack of which
|
|
||||||
<code>CONTEXT @</code> is the first item.
|
|
||||||
The word <code>ONLY</code> clears the vocabulary stack, but as there is
|
|
||||||
no separate ONLY vocabulary, it also sets <code>CONTEXT</code>
|
|
||||||
to the <code>FORTH</code> vocabulary.
|
|
||||||
The word <code>SEALED</code> modifies the most recently defined vocabulary
|
|
||||||
such that it does not chain. Note, this must be done before words are added to it.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
VOCABULARY ( "name" ) Create a vocabulary with the current vocabulary as parent
|
|
||||||
FORTH ( -- ) Make the FORTH vocabulary the context vocabulary
|
|
||||||
DEFINITIONS ( -- ) Make the context vocabulary the current vocabulary
|
|
||||||
VLIST ( -- ) List the words in the context vocabulary (not chains)
|
|
||||||
WORDS ( -- ) List the words in the context vocabulary (including chains)
|
|
||||||
TRANSFER ( "name" ) Move a word from its current dictionary to the current vocabulary
|
|
||||||
Useful for "hiding" built-in words
|
|
||||||
TRANSFER{ ..words.. }TRANSFER ( -- ) Transfer multiple words to the current vocabulary
|
|
||||||
ALSO ( -- ) Duplicate the vocabulary at the top of the vocabulary stack
|
|
||||||
ONLY ( -- ) Reset context stack to one item, the FORTH dictionary
|
|
||||||
Non-standard, as there's no distinct ONLY vocabulary
|
|
||||||
ORDER ( -- ) Print the vocabulary search order
|
|
||||||
SEALED ( -- ) Alter the last vocabulary defined so it doesn't chain
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Interpret Time Conditions</h5>
|
|
||||||
<p>
|
|
||||||
<code>[I]F</code>, <code>[ELSE]</code>, and <code>[THEN]</code> can be used
|
|
||||||
to selectively compile. Used in tandem with <code>DEFINED?</code> they can
|
|
||||||
be used to handle the absence of modules gracefully.
|
|
||||||
Nesting is supported.
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
DEFINED? ( "name" -- xt|0 ) Check if a word exists (works at compile time too).
|
|
||||||
[IF] ( f -- ) Conditionally interpret the text the follows.
|
|
||||||
[ELSE] ( -- ) Interpret time ELSE.
|
|
||||||
[THEN] ( -- ) Interpret time THEN.
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Blocks</h5>
|
|
||||||
<pre>
|
|
||||||
USE ( "name" -- ) Use "name" as the blockfile, e.g. USE /spiffs/foo
|
|
||||||
OPEN-BLOCKS ( a n -- ) Open a file as the block file
|
|
||||||
LOAD ( n -- ) Evaluate a block
|
|
||||||
THRU ( a b -- ) Load blocks a thru b
|
|
||||||
LIST ( n -- ) List a block
|
|
||||||
BLOCK ( n -- a ) Get a 1024 byte block
|
|
||||||
BUFFER ( n -- a ) Get a 1024 byte block without regard to old contents
|
|
||||||
UPDATE ( -- ) Mark the last block modified
|
|
||||||
FLUSH ( -- ) Save and empty all buffers
|
|
||||||
EMPTY-BUFFERS ( -- ) Empty all buffers
|
|
||||||
SAVE-BUFFERS ( -- ) Save all buffers
|
|
||||||
SCR ( -- a ) Pointer to last listed block
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Block Editor</h5>
|
|
||||||
These words are available inside the <code>EDITOR</code> vocabulary.
|
|
||||||
Note the block editor places newlines in the 63rd column of each line
|
|
||||||
to make the block file readable in a text editor.
|
|
||||||
<pre>
|
|
||||||
WIPE ( -- ) Blank out the current block
|
|
||||||
L ( -- ) List the current block
|
|
||||||
D ( n -- ) Delete a line in the current block
|
|
||||||
E ( n -- ) Clear a line in the current block
|
|
||||||
R ( n "text" -- ) Replace a line in the current block
|
|
||||||
A ( n "text" -- ) Add (insert) a line in the current block
|
|
||||||
P ( -- ) Move to the previous block
|
|
||||||
N ( -- ) Move to the next block
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h5>Utilities</h5>
|
|
||||||
<pre>
|
|
||||||
SEE ( "name" -- ) Attempt to decompile a word
|
|
||||||
ECHO ( -- a ) -- Address of flag that determines if commands are echoed
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h3>Windows</h3>
|
<h3>Windows</h3>
|
||||||
|
|
||||||
@ -186,31 +72,4 @@ In addition, a terminal that responds to ANSI escape codes is created and connec
|
|||||||
<code>TYPE</code> and <code>KEY</code>.
|
<code>TYPE</code> and <code>KEY</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>Windows & Linux Calling</h3>
|
{{DESKTOP_COMMON}}
|
||||||
|
|
||||||
<p>
|
|
||||||
As unfortunately both Windows and Linux have system and library calls with
|
|
||||||
as many as 10 parameters (for example <code>XCreateImage</code>),
|
|
||||||
a collection of calling thunks is required.
|
|
||||||
A single varidic thunk would be ideal, but is hard to do without per platform
|
|
||||||
assembly language.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
CALL0 ( fn -- n )
|
|
||||||
CALL1 ( n fn -- n )
|
|
||||||
CALL2 ( n n fn -- n )
|
|
||||||
CALL3 ( n n n fn -- n )
|
|
||||||
CALL4 ( n n n n fn -- n )
|
|
||||||
CALL5 ( n n n n n fn -- n )
|
|
||||||
CALL6 ( n n n n n n fn -- n )
|
|
||||||
CALL7 ( n n n n n n n fn -- n )
|
|
||||||
CALL7 ( n n n n n n n n fn -- n )
|
|
||||||
CALL9 ( n n n n n n n n n fn -- n )
|
|
||||||
CALL10 ( n n n n n n n n n n fn -- n )
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
See <a href="https://github.com/flagxor/eforth/blob/main/ueforth/common/calling.h">calling.h</a>.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user