Re-root site.
23
site/.gcloudignore
Normal file
@ -0,0 +1,23 @@
|
||||
# This file specifies files that are *not* uploaded to Google Cloud Platform
|
||||
# using gcloud. It follows the same syntax as .gitignore, with the addition of
|
||||
# "#!include" directives (which insert the entries of the given .gitignore-style
|
||||
# file at that point).
|
||||
#
|
||||
# For more information, run:
|
||||
# $ gcloud topic gcloudignore
|
||||
#
|
||||
.gcloudignore
|
||||
# If you would like to upload your .git directory, .gitignore file or files
|
||||
# from your .gitignore file, remove the corresponding line
|
||||
# below:
|
||||
.git
|
||||
.gitignore
|
||||
|
||||
# Binaries for programs and plugins
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
1037
site/ESP32forth.html
Normal file
46
site/app.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
# Copyright 2021 Bradley D. Nelson
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
runtime: go115
|
||||
|
||||
default_expiration: "1m"
|
||||
|
||||
handlers:
|
||||
- url: /robots.txt
|
||||
static_files: static/robots.txt
|
||||
upload: static/robots.txt
|
||||
secure: always
|
||||
|
||||
- url: /favicon(.*)
|
||||
static_files: static/favicon\1
|
||||
upload: static/favicon.*
|
||||
secure: always
|
||||
|
||||
- url: /
|
||||
static_files: index.html
|
||||
upload: index.html
|
||||
secure: always
|
||||
|
||||
- url: /(.*).html
|
||||
static_files: \1.html
|
||||
upload: (.*).html
|
||||
secure: always
|
||||
|
||||
- url: /static
|
||||
static_dir: static
|
||||
secure: always
|
||||
|
||||
- url: /.*
|
||||
script: auto
|
||||
secure: always
|
||||
73
site/classic.html
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2021 Bradley D. Nelson
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Classic EForth</title>
|
||||
<link rel="stylesheet" href="static/eforth.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Classic EForth</h1>
|
||||
|
||||
{{MENU}}
|
||||
|
||||
<p>
|
||||
EForth is a delightfully minimalist approach to Forth originated by Bill Muench and Dr. C. H. Ting.
|
||||
</p>
|
||||
|
||||
<h2>Classic ESP32forth</h2>
|
||||
|
||||
<p>
|
||||
ESP32forth - Version 6.3 for NodeMCU ESP32S - Tweaked for the Web
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="https://eforth.storage.googleapis.com/releases/ESP32forth-6.3.0.ino">ESP32forth-6.3.0.ino</a>
|
||||
- This has Dr. Ting's v6.3 version with WebUI added in
|
||||
</p>
|
||||
|
||||
<h3>Classic EForth Quirks</h3>
|
||||
|
||||
<p>
|
||||
EForth exclusively uses <code>FOR..NEXT</code> in favor of <code>DO..LOOP</code>.
|
||||
<a href="https://github.com/TG9541/stm8ef/wiki/eForth-FOR-..-NEXT">Details</a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This construct has the odd property that it iterates one "extra" time for zero.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
: FOO 10 FOR R@ . NEXT ; FOO
|
||||
10 9 8 7 6 5 4 3 2 1 0 ok
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
To permit a more ordinary loop the <code>AFT</code> word is used in the sequence
|
||||
<code>FOR..AFT..THEN..NEXT</code>.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
: FOO 10 FOR ( 1st time only ) AFT R@ . THEN NEXT ; FOO
|
||||
9 8 7 6 5 4 3 2 1 0 ok
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The even more enigmatic <code>FOR..WHILE..NEXT..ELSE..THEN</code>
|
||||
is used in place of <code>DO..LEAVE..LOOP</code>.
|
||||
It allows a while condition to early out of a counted loop.
|
||||
</p>
|
||||
279
site/common.html
Normal file
@ -0,0 +1,279 @@
|
||||
<!--
|
||||
Copyright 2021 Bradley D. Nelson
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<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
|
||||
REMAINING ( -- n ) Bytes remaining in Forth heap.
|
||||
</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
|
||||
PREVIOUS ( -- ) Drop 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>
|
||||
|
||||
<h5>Floating-Point</h5>
|
||||
<p><b>(Requires v7.0.6.5+)</b></p>
|
||||
<p>
|
||||
Single precision floating-point support is available as a work in progress.
|
||||
While initially left out in the name of minimalism,
|
||||
hardware support for floating-point argues some advantages to limited support.
|
||||
</p>
|
||||
<p>
|
||||
Floating point is kept on a separate stack.
|
||||
</p>
|
||||
<p>
|
||||
<b>NOTE: Tasks currently don't correctly support floating point.</b>
|
||||
A single floating point stack is shared by all tasks.
|
||||
</p>
|
||||
<pre>
|
||||
FLOAT OPCODES
|
||||
-------------
|
||||
DOFLIT ( --- ) Puts a float from the next cell onto float stack.
|
||||
FP@ ( -- a )
|
||||
FP! ( a -- )
|
||||
SF@ ( a -- r ) Single precision load
|
||||
SF! ( r a -- ) Single precision store
|
||||
FDUP ( r -- r r )
|
||||
FNIP ( ra rb -- rb )
|
||||
FDROP ( r -- )
|
||||
FOVER ( ra rb -- ra rb ra )
|
||||
FSWAP ( ra rb -- rb ra )
|
||||
F0< ( r -- f )
|
||||
F0= ( r -- f )
|
||||
F+ ( r r -- r )
|
||||
F- ( r r -- r )
|
||||
F* ( r r -- r )
|
||||
F/ ( r r -- r )
|
||||
1/F ( r -- r )
|
||||
S>F ( n -- r )
|
||||
F>S ( r -- n )
|
||||
|
||||
HIGH LEVEL
|
||||
----------
|
||||
F= ( r r -- f )
|
||||
F< ( r r -- f )
|
||||
F> ( r r -- f )
|
||||
F<= ( r r -- f )
|
||||
F>= ( r r -- f )
|
||||
F<> ( r r -- f )
|
||||
|
||||
SFLOAT ( -- 4 )
|
||||
SFLOATS ( n -- n*4 )
|
||||
SFLOAT+ ( a -- a+4 )
|
||||
SF, ( r -- )
|
||||
|
||||
AFLITERAL ( r -- )
|
||||
FLITERAL ( r -- ) IMMEDIATE
|
||||
|
||||
FCONSTANT ( r "name" )
|
||||
FVARIABLE ( "name" )
|
||||
|
||||
PI ( -- r )
|
||||
|
||||
FSQRT ( r r -- r )
|
||||
|
||||
F.S ( -- ) Print float stack.
|
||||
</pre>
|
||||
|
||||
<h5>Locals</h5>
|
||||
|
||||
<p>
|
||||
Locals allow named word local parameters and values.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
Syntax:
|
||||
{ local1 local2 .. -- comment }
|
||||
or
|
||||
{ local1 local2 .. }
|
||||
|
||||
Locals are ordered to match the stack, examples:
|
||||
: 2OVER { a b c d } a b c d a b ;
|
||||
: MAX { a b -- biggest } a b < IF b ELSE a THEN ;
|
||||
|
||||
( Equivalent with DO and FOR )
|
||||
: POW2 { n } 1 { s } n FOR AFT s 2* to s THEN NEXT s ;
|
||||
: POW2 { n } 1 { s } n 0 DO s 2* to s LOOP s ;
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Capabilities and limitations:
|
||||
<ul>
|
||||
<li>Support for locals referenced inside DO and FOR loops - OK</li>
|
||||
<li>Support for multiple {} uses in one definition - OK</li>
|
||||
<li>Support for TO and +TO to modify a local</li>
|
||||
<li>Locals mixed with raw return stack operations (<code>>R R></code>) - NOT OK</li>
|
||||
<li>Locals defined inside a DO or FOR loop - NOT OK</li>
|
||||
<li>The low level ANSForth word <code>(LOCAL)</code> is also supported.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<h5 id="dictimages">Dictionary Images and Startup</h5>
|
||||
|
||||
<p>
|
||||
<b>WARNING: Danger ahead.</b><br/>
|
||||
Snapshotting the dictionary may not be stable across reinstallations of the C build of Forth.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A collection of non-standard words is provided that allow snapshotting
|
||||
the dictionary and restoring it at startup, with a start word.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
SAVE ( "name" -- ) Saves a snapshot of the current dictionary to a file.
|
||||
RESTORE ( "name" -- ) Restore a snapshot from a file.
|
||||
REMEMBER ( -- ) Save a snapshot to the default file
|
||||
(./myforth or /spiffs/myforth on ESP32).
|
||||
STARTUP: ( "name" -- ) Save a snapshot to the default file arranging for
|
||||
"name" to be run on startup.
|
||||
REVIVE ( -- ) Restore the default filename.
|
||||
RESET ( -- ) Delete the default filename.
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Here's an example usage:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
: welcome ." Hello!" cr 100 0 do i . loop cr ;
|
||||
startup: welcome
|
||||
bye
|
||||
|
||||
( Next boot will run a custom startup message )
|
||||
|
||||
reset
|
||||
|
||||
( Reset removes the custom message )
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
The <code>INTERNALS</code> vocabulary has some additional words
|
||||
for more control.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
SAVE-NAME ( a n -- ) Save a snapshot if the current vocabulary to a file.
|
||||
RESTORE-NAME ( a n -- ) Restore a snapshot from a file.
|
||||
'COLD ( -- a ) Address of the word that will be run on startup.
|
||||
REMEMBER-FILENAME ( -- a n ) Deferred word specifying the platform specific
|
||||
default snapshot filename.
|
||||
</pre>
|
||||
43
site/desktop_common.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!--
|
||||
Copyright 2021 Bradley D. Nelson
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<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/common/calling.h">calling.h</a>.
|
||||
</p>
|
||||
44
site/eforth.go
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright 2021 Bradley D. Nelson
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/test", indexHandler)
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8080"
|
||||
log.Printf("Defaulting to port %s", port)
|
||||
}
|
||||
log.Printf("Listening on port %s", port)
|
||||
if err := http.ListenAndServe(":"+port, nil); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/test" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
fmt.Fprint(w, "Hello")
|
||||
}
|
||||
33
site/index.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2021 Bradley D. Nelson
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>EForth</title>
|
||||
<link rel="stylesheet" href="static/eforth.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>EForth</h1>
|
||||
<script>
|
||||
window.location.replace('./ESP32forth.html');
|
||||
</script>
|
||||
|
||||
{{MENU}}
|
||||
|
||||
<p>
|
||||
Choose you platform above.
|
||||
</p>
|
||||
109
site/internals.html
Normal file
@ -0,0 +1,109 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2021 Bradley D. Nelson
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>µEforth Internals</title>
|
||||
<link rel="stylesheet" href="static/eforth.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>µEforth Internals</h1>
|
||||
|
||||
{{MENU}}
|
||||
|
||||
<p>
|
||||
µEforth (micro-Eforth) simplifies EForth even futher, by building just enough
|
||||
of the core of the system in C to allow the rest to be be built in proper Forth.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A handful of "tricky" words that involve internal loops or many steps are built in their own
|
||||
functions:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
FIND ( a n -- xt | 0 )
|
||||
PARSE ( ch -- a n )
|
||||
S>NUMBER? ( a n -- n f | 0 )
|
||||
CREATE ( "name" -- )
|
||||
EVALUATE1 ( -- )
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
This includes <code>EVALUATE1</code> which parses a single word and
|
||||
interprets or compiles it (reusing <code>PARSE</code>,
|
||||
<code>FIND</code>, and <code>S>NUMBER?</code>).
|
||||
</p>
|
||||
|
||||
<p>
|
||||
See <a href="https://github.com/flagxor/eforth/blob/main/common/core.h">core.h</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A few global variables connect parsing and compilation state between
|
||||
C and Forth (by way of a memory region accessed via <code>'SYS</code>):
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
'TIB --- Pointer to the Translation Input Buffer
|
||||
#TIB --- Length of the Translation Input Buffer
|
||||
>IN --- Number of characters consumed from TIB
|
||||
|
||||
BASE --- Numeric base for printing and parsing
|
||||
|
||||
STATE --- State of compiling, -1 for compiling, 0 for interpreting
|
||||
CURRENT --- Pointer to pointer to last word of current vocabulary
|
||||
CONTEXT --- Pointer to pointer to last word of context vocabulary
|
||||
|
||||
'NOTFOUND --- Execution token of a handler to call on word not found
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Error handling is routed via a deferred callback in <code>'NOTFOUND</code>
|
||||
used when a word is absent from the dictionary.
|
||||
This is eventually directed to an error routing that prints
|
||||
a proper error, once I/O and exceptions are available.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="https://en.wikipedia.org/wiki/X_Macro">X-Macros</a>
|
||||
are then used to build up a small set of core opcodes defined in 1-3 lines each:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
0= 0< + U/MOD */MOD AND OR XOR
|
||||
LSHIFT RSHIFT DUP SWAP OVER DROP
|
||||
@ SL@ SW@ C@ ! L! W! C! SP@ SP! RP@ RP!
|
||||
>R R> R@ : ; EXIT
|
||||
EXECUTE BRANCH 0BRANCH DONEXT DOLIT
|
||||
ALITERAL CELL DOES> IMMEDIATE 'SYS
|
||||
</pre>
|
||||
|
||||
<p><b>NOTE: Later to reduce the use of the RAM heap and improve performance,
|
||||
additional non-essential extra opcodes were added in place of high-level
|
||||
words.</b></p>
|
||||
|
||||
<p>
|
||||
See <a href="https://github.com/flagxor/eforth/blob/main/common/opcodes.h">opcodes.h</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
I/O and access to systems outside Forth are connected via a few per platform words.
|
||||
Typically this set of words should be minimal, while still allowing relevant parts
|
||||
of the host system to be available to Forth.
|
||||
</p>
|
||||
|
||||
96
site/linux.html
Normal file
@ -0,0 +1,96 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2021 Bradley D. Nelson
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>µEforth for Linux</title>
|
||||
<link rel="stylesheet" href="static/eforth.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>µEforth for Linux</h1>
|
||||
|
||||
{{MENU}}
|
||||
|
||||
<h2>Download</h2>
|
||||
|
||||
<h3>STABLE RELEASE</h3>
|
||||
<p>
|
||||
<a href="https://eforth.storage.googleapis.com/releases/ueforth-{{STABLE_VERSION}}.linux">ueforth-{{STABLE_VERSION}}.linux</a>
|
||||
- Linux 64-bit Executable µEforth<br/>
|
||||
<i>Version: {{STABLE_VERSION}}</i>
|
||||
</p>
|
||||
|
||||
<h3>Beta Release</h3>
|
||||
<p>
|
||||
<a href="https://eforth.storage.googleapis.com/releases/ueforth-{{VERSION}}.linux">ueforth-{{VERSION}}.linux</a>
|
||||
- Linux 64-bit Executable µEforth<br/>
|
||||
<i>Version: {{VERSION}}</i>
|
||||
</p>
|
||||
|
||||
<hr/>
|
||||
|
||||
<p>
|
||||
<a href="https://eforth.storage.googleapis.com/releases/archive.html" target="_blank">Release Archive</a>
|
||||
- Prior Releases
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://github.com/flagxor/eforth" target="_blank">http://github.com/flagxor/eforth</a>
|
||||
- Complete Unprocessed Source Code
|
||||
</p>
|
||||
|
||||
<h2>µEforth</h2>
|
||||
|
||||
<h3>µEforth Specific Words</h3>
|
||||
|
||||
{{COMMON}}
|
||||
{{POSIX_COMMON}}
|
||||
|
||||
<h3>Linux</h3>
|
||||
|
||||
<h4>Linux Opcodes</h4>
|
||||
|
||||
<p>
|
||||
Linux libraries and the operating system can be accessed via the use
|
||||
of the <code>DLSYM</code> word. Functions can be requested by name from
|
||||
particular modules. As the dynamic linking module is already loaded initially,
|
||||
a 0 for the module allows the library loading function (<code>dlopen</code>)
|
||||
to be loaded from Forth.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
DLSYM ( module name-z -- fn )
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
See <a href="https://github.com/flagxor/eforth/blob/main/posix/posix_main.c">posix_main.c</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Native functions all called with CALL(n) (see Windows & Linux Calling below).
|
||||
</p>
|
||||
|
||||
<h4>Linux Imports</h4>
|
||||
|
||||
<p>
|
||||
Various Linux calls including Xlib are imported in
|
||||
<a href="https://github.com/flagxor/eforth/blob/main/posix/posix.fs">posix.fs</a> and
|
||||
<a href="https://github.com/flagxor/eforth/blob/main/posix/xlib.fs">xlib.fs</a>.
|
||||
In addition, <code>TYPE</code> and <code>KEY</code> are connected to
|
||||
<code>stdin</code> and <code>stdout</code>.
|
||||
</p>
|
||||
|
||||
{{DESKTOP_COMMON}}
|
||||
50
site/menu.html
Normal file
@ -0,0 +1,50 @@
|
||||
<!--
|
||||
Copyright 2021 Bradley D. Nelson
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<div class="menu">
|
||||
<span><a href="https://esp32forth.appspot.com/ESP32forth.html">ESP32forth</a></span>
|
||||
<span><a href="https://eforth.appspot.com/linux.html">Linux</a></span>
|
||||
<span><a href="https://eforth.appspot.com/windows.html">Windows</a></span>
|
||||
<span><a href="https://eforth.appspot.com/internals.html">Internals</a></span>
|
||||
<span><a href="https://eforth.appspot.com/classic.html">Classic</a></span>
|
||||
</div>
|
||||
<script>
|
||||
(function() {
|
||||
function Behead(full, link) {
|
||||
if (full) {
|
||||
link = link.replace('https://eforth.appspot.com/', './');
|
||||
link = link.replace('https://esp32forth.appspot.com/', './');
|
||||
}
|
||||
return link.split('?')[0];
|
||||
}
|
||||
var anchors = document.getElementsByTagName('a');
|
||||
if (window.location.href.indexOf('file://') == 0) {
|
||||
for (var i = 0; i < anchors.length; ++i) {
|
||||
anchors[i].href = Behead(true, anchors[i].href);
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < anchors.length; ++i) {
|
||||
if (Behead(true, anchors[i].href) == Behead(true, window.location.href)) {
|
||||
if (Behead(false, anchors[i].href) == Behead(false, window.location.href)) {
|
||||
anchors[i].parentElement.classList.add('picked');
|
||||
} else {
|
||||
// Redirect if on the wrong host.
|
||||
window.location.replace(anchors[i].href);
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
39
site/posix_common.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!--
|
||||
Copyright 2021 Bradley D. Nelson
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<h5>Web Interface</h5>
|
||||
These words are inside the <code>web-interface</code> vocabulary.
|
||||
<pre>
|
||||
server ( port -- ) Start web UI on port (used to implement webui).
|
||||
</pre>
|
||||
|
||||
<h5>HTTP Daemon</h5>
|
||||
<p><b>Requires v7.0.6+</b></p>
|
||||
These words are inside the <code>httpd</code> vocabulary.
|
||||
<pre>
|
||||
server ( port -- ) Start an httpd on port.
|
||||
handleClient ( -- ) Get next request.
|
||||
path ( -- a n ) Request path, e.g. /foo
|
||||
method ( -- a n ) Request method, e.g. GET
|
||||
header ( a n -- a n ) Contents of header (or empty string).
|
||||
body ( -- a n ) Rquest body.
|
||||
</pre>
|
||||
|
||||
<h5>Telnet Daemon</h5>
|
||||
These words are inside the <code>web-interface</code> vocabulary.
|
||||
<pre>
|
||||
server ( port -- ) Start telnet daemon on port.
|
||||
</pre>
|
||||
103
site/static/eforth.css
Normal file
@ -0,0 +1,103 @@
|
||||
// Copyright 2021 Bradley D. Nelson
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
body {
|
||||
max-width: 800px;
|
||||
margin-top: 0px;
|
||||
}
|
||||
h1 {
|
||||
border-top: 3px solid #777;
|
||||
background-color: #111;
|
||||
color: #eee;
|
||||
padding: 10px;
|
||||
margin: 0px;
|
||||
}
|
||||
h2 {
|
||||
border-top: 2px solid #777;
|
||||
background-color: #ccc;
|
||||
padding: 10px;
|
||||
}
|
||||
h3 {
|
||||
border-top: 1px solid #777;
|
||||
background-color: #eee;
|
||||
padding: 10px;
|
||||
}
|
||||
h4 {
|
||||
border-bottom: 2px solid #777;
|
||||
width: 30%;
|
||||
}
|
||||
h5 {
|
||||
border-bottom: 2px solid #777;
|
||||
margin: 2px;
|
||||
width: 30%;
|
||||
}
|
||||
a:link {
|
||||
color: #00c;
|
||||
}
|
||||
a:visited {
|
||||
color: #00c;
|
||||
}
|
||||
a:active {
|
||||
color: #0f0;
|
||||
}
|
||||
a:hover {
|
||||
color: #0f0;
|
||||
}
|
||||
.menu {
|
||||
background-color: #333;
|
||||
border-top: 3px solid #777;
|
||||
padding: 10px;
|
||||
}
|
||||
.menu span {
|
||||
margin: 0px;
|
||||
padding: 10px;
|
||||
}
|
||||
.menu a:link {
|
||||
color: #fff;
|
||||
}
|
||||
.menu a:visited {
|
||||
color: #fff;
|
||||
}
|
||||
.menu a:active {
|
||||
color: #0f0;
|
||||
}
|
||||
.menu a:hover {
|
||||
color: #0f0;
|
||||
}
|
||||
.menu .picked {
|
||||
background-color: #070;
|
||||
}
|
||||
.menu .picked a:active {
|
||||
color: #fff;
|
||||
}
|
||||
.menu .picked a:hover {
|
||||
color: #fff;
|
||||
}
|
||||
table {
|
||||
border: 1px solid black;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
th {
|
||||
border: 1px solid black;
|
||||
padding: 3px;
|
||||
color: #fff;
|
||||
background-color: #444;
|
||||
}
|
||||
td {
|
||||
border: 1px solid black;
|
||||
padding: 5px;
|
||||
}
|
||||
.hilit {
|
||||
background-color: yellow;
|
||||
}
|
||||
BIN
site/static/esp-cam-back.jpg
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
site/static/esp-cam-front.jpg
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
site/static/esp-cam-wiring.jpg
Normal file
|
After Width: | Height: | Size: 140 KiB |
BIN
site/static/esp32-c3-mini-1.jpg
Normal file
|
After Width: | Height: | Size: 60 KiB |
BIN
site/static/esp32-c3-wroom-02.jpg
Normal file
|
After Width: | Height: | Size: 63 KiB |
BIN
site/static/esp32-mini-1.jpg
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
site/static/esp32-s2-wroom.jpg
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
site/static/esp32-s2-wrover.jpg
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
site/static/esp32-wroom.jpg
Normal file
|
After Width: | Height: | Size: 73 KiB |
2
site/static/robots.txt
Normal file
@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow: /terminal
|
||||
BIN
site/static/serial_bridge.jpg
Normal file
|
After Width: | Height: | Size: 80 KiB |
103
site/windows.html
Normal file
@ -0,0 +1,103 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Copyright 2021 Bradley D. Nelson
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>µEforth for Windows</title>
|
||||
<link rel="stylesheet" href="static/eforth.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>µEforth for Windows</h1>
|
||||
|
||||
{{MENU}}
|
||||
|
||||
<h2>Download</h2>
|
||||
|
||||
<h3>STABLE RELEASE</h3>
|
||||
<p>
|
||||
<a href="https://eforth.storage.googleapis.com/releases/uEf32-{{STABLE_VERSION}}.exe">uEf32-{{STABLE_VERSION}}.exe</a>
|
||||
- Window 32-bit EXE µEforth<br/>
|
||||
<a href="https://eforth.storage.googleapis.com/releases/uEf64-{{STABLE_VERSION}}.exe">uEf64-{{STABLE_VERSION}}.exe</a>
|
||||
- Window 64-bit EXE µEforth<br/>
|
||||
<i>Version: {{STABLE_VERSION}} (Stable)</i>
|
||||
</p>
|
||||
|
||||
<h3>Beta Release</h3>
|
||||
<p>
|
||||
<a href="https://eforth.storage.googleapis.com/releases/uEf32-{{VERSION}}.exe">uEf32-{{VERSION}}.exe</a>
|
||||
- Window 32-bit EXE µEforth<br/>
|
||||
<a href="https://eforth.storage.googleapis.com/releases/uEf64-{{VERSION}}.exe">uEf64-{{VERSION}}.exe</a>
|
||||
- Window 64-bit EXE µEforth<br/>
|
||||
<i>Version: {{VERSION}}</i>
|
||||
</p>
|
||||
|
||||
<hr/>
|
||||
|
||||
<p>
|
||||
<a href="https://eforth.storage.googleapis.com/releases/archive.html" target="_blank">Release Archive</a>
|
||||
- Prior Releases
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://github.com/flagxor/eforth" target="_blank">http://github.com/flagxor/eforth</a>
|
||||
- Complete Unprocessed Source Code
|
||||
</p>
|
||||
|
||||
<h2>µEforth</h2>
|
||||
|
||||
<h3>µEforth Specific Words</h3>
|
||||
|
||||
{{COMMON}}
|
||||
|
||||
<h3>Windows</h3>
|
||||
|
||||
<h4>Windows Opcodes</h4>
|
||||
|
||||
<p>
|
||||
The wealth of Windows .DLL and system functionality can be
|
||||
accessed via the dynamic loading interface.
|
||||
A handle to a library is obtained with <code>LOADLIBRARYA</code>,
|
||||
and then individual symbols are accessed with <code>GETPROCADDRESS</code>.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
LOADLIBRARYA ( dllname-z -- module )
|
||||
GETPROCADDRESS ( module name-z -- fn )
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
And assembly version of <code>*/MOD</code> is provided to allow the EXE to build without
|
||||
including MSVCRT.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
See <a href="https://github.com/flagxor/eforth/blob/main/windows/windows_main.c">windows_main.c</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Native functions all called with CALL(n) (see Windows & Linux Calling below).
|
||||
</p>
|
||||
|
||||
<h4>Windows Imports</h4>
|
||||
|
||||
<p>
|
||||
Various Win32 calls are imported in
|
||||
<a href="https://github.com/flagxor/eforth/blob/main/windows/windows.fs">windows.fs</a>.
|
||||
In addition, a terminal that responds to ANSI escape codes is created and connected to
|
||||
<code>TYPE</code> and <code>KEY</code>.
|
||||
</p>
|
||||
|
||||
{{DESKTOP_COMMON}}
|
||||