refrences

This commit is contained in:
2026-02-19 16:16:24 -05:00
parent 3ce2977f01
commit 2d43f1711c
90 changed files with 30482 additions and 1 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
references
# references
.env
references/processed_visuals

View File

@@ -0,0 +1,71 @@
"Anchor Text","URL"
"Original Inspiration for these notes","https://x.com/Richard6044392/status/1926097042029363270"
"Substack Article","https://edsabode.substack.com/p/onats-kyra-compiled-forths-a-new"
"Wikipedia Page","https://en.wikipedia.org/wiki/Forth_(programming_language)"
"Homepage","https://colorforth.github.io/index.html"
"Forth- The Early Years","https://colorforth.github.io/HOPL.html"
"C2-Wiki: Chuck Moore","https://wiki.c2.com/?ChuckMoore"
"C2-Wiki: colorFORTH","https://wiki.c2.com/?ColorForth"
"cmFORTH","https://github.com/ForthHub/cmFORTH"
"Archived Website","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/index.html"
"Metaprogramming VAMP in KYRA, a Next-gen Forth-like language --- Onat Türkçüoğlu -- 2025-04-26","https://www.youtube.com/watch?v=J9U_5tjdegY"
"Website - Bit Test Complement","https://onatto.github.io/lang.html"
"Forth Day 2020 - Preview of x64 & ColorForth & SPIR V - Onat","https://www.youtube.com/watch?v=ajZAECYdJvE"
"Jonesforth.git","http://git.annexia.org/?p=jonesforth.git;a=summary"
"jombloforth (x64 Jonesforth)","https://github.com/matematikaadit/jombloforth"
"JonesForth-arm","https://github.com/M2IHP13-admin/JonesForth-arm"
"guitarvydas/forthish","https://github.com/guitarvydas/forthish"
"Smithforth workings","https://youtu.be/9MSJGzYELBA"
"A Forth for x86-64 personal computers","https://dacvs.neocities.org/SF/"
"SmithForth_RISC-V","https://github.com/AndreiDuma/SmithForth_RISC-V"
"2022-08-27 --- NEW LINUX FORTH --- DAVID SMITH","https://youtu.be/a1UWxa2g9Us"
"Starting FORTH","https://www.forth.com/wp-content/uploads/2018/01/Starting-FORTH.pdf"
"THINKING FORTH","https://www.forth.com/wp-content/uploads/2018/11/thinking-forth-color.pdf"
"The Evolution of Forth","https://www.forth.com/resources/forth-programming-language/"
"Website","https://wiki.c2.com"
"c2-for-me","http://marc.tries.fed.wiki/view/c2-for-me/ward.eu.wiki.org/c2-for-me"
"Forth Landing","https://wiki.c2.com/?ForthLanguage"
"Forth Values","https://wiki.c2.com/?ForthValues"
"Website","https://muforth.dev"
"Threaded code","https://muforth.dev/threaded-code/"
"Variations","https://muforth.dev/threaded-code-variations/"
"Literals, ifs, and loops","https://muforth.dev/threaded-code-literals-ifs-and-loops/"
"call versus branch-and-link","https://muforth.dev/call-versus-branch-and-link/"
"Repo","https://github.com/nimblemachines/muforth#under-active-development"
"Bootstrap yourself into conviviality by writing your own Forth","https://vimeo.com/859408"
"Website","https://www.forth.org/svfig/"
"Youtube","https://www.youtube.com/@siliconvalleyforthinterest1736"
"Forth","https://www.taygeta.com/forth.html"
"Website","https://www.ultratechnology.com"
"Building a tiny FORTH for an Arduino UNO in one week","https://www.thanassis.space/miniforth.html"
"J.V. Noble: A Beginners Guide to Forth","https://galileo.phys.virginia.edu/classes/551.jvn.fall01/primer.htm"
"wiki.laptop: Forth Lessons","https://wiki.laptop.org/go/Forth_Lessons"
"Building A Simple Forth Interpreter (in python)","https://peerdh.com/blogs/programming-insights/building-a-simple-forth-interpreter"
"HN post on concatenative language interpreter","https://news.ycombinator.com/item?id=13082825"
"PYCON UK 2017: What I learned building Forth in 64 bit Intel assembly","https://youtu.be/iZ-5rBQS_p4"
"Color","https://github.com/AshleyF/Color/tree/master"
"easyforth","https://github.com/skilldrick/easyforth"
"libforth","https://github.com/howerj/libforth"
"luaforth","https://github.com/vifino/luaforth"
"foth (forth in go)","https://github.com/skx/foth"
"lbForth","https://github.com/larsbrinkhoff/lbForth"
"milliForth","https://github.com/fuzzballcat/milliForth"
"MiniForth","https://github.com/ttsiodras/MiniForth"
"pforth","https://github.com/philburk/pforth"
"StoneKnifeForth","https://github.com/kragen/stoneknifeforth"
"zForth","https://github.com/zevv/zForth"
"Concatenative language","https://concatenative.org/wiki/view/Concatenative%20language"
"A FOUNDATION FOR TYPED CONCATENATIVE LANGUAGES","https://www2.ccs.neu.edu/racket/pubs/dissertation-kleffner.pdf"
"Wikipedia","https://en.wikipedia.org/wiki/Concatenative_programming_language"
"b4 virtual machine","https://github.com/tangentstorm/b4"
"Callisto","https://github.com/callisto-lang/compiler"
"Cognate","https://cognate-lang.github.io"
"deckload","https://github.com/JosephOziel/deckload"
"Factor","https://factorcode.org"
"fiveth","https://github.com/dramforever/fiveth"
"formic","https://formic.id"
"GDForth","https://github.com/yumaikas/GDForth"
"iNet","https://inet.run"
"kcats","https://github.com/skyrod-vactai/kcats"
"kitten","https://kittenlang.org"
"meow5","https://ratfactor.com/meow5/"
1 Anchor Text URL
2 Original Inspiration for these notes https://x.com/Richard6044392/status/1926097042029363270
3 Substack Article https://edsabode.substack.com/p/onats-kyra-compiled-forths-a-new
4 Wikipedia Page https://en.wikipedia.org/wiki/Forth_(programming_language)
5 Homepage https://colorforth.github.io/index.html
6 Forth- The Early Years https://colorforth.github.io/HOPL.html
7 C2-Wiki: Chuck Moore https://wiki.c2.com/?ChuckMoore
8 C2-Wiki: colorFORTH https://wiki.c2.com/?ColorForth
9 cmFORTH https://github.com/ForthHub/cmFORTH
10 Archived Website https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/index.html
11 Metaprogramming VAMP in KYRA, a Next-gen Forth-like language --- Onat Türkçüoğlu -- 2025-04-26 https://www.youtube.com/watch?v=J9U_5tjdegY
12 Website - Bit Test Complement https://onatto.github.io/lang.html
13 Forth Day 2020 - Preview of x64 & ColorForth & SPIR V - Onat https://www.youtube.com/watch?v=ajZAECYdJvE
14 Jonesforth.git http://git.annexia.org/?p=jonesforth.git;a=summary
15 jombloforth (x64 Jonesforth) https://github.com/matematikaadit/jombloforth
16 JonesForth-arm https://github.com/M2IHP13-admin/JonesForth-arm
17 guitarvydas/forthish https://github.com/guitarvydas/forthish
18 Smithforth workings https://youtu.be/9MSJGzYELBA
19 A Forth for x86-64 personal computers https://dacvs.neocities.org/SF/
20 SmithForth_RISC-V https://github.com/AndreiDuma/SmithForth_RISC-V
21 2022-08-27 --- NEW LINUX FORTH --- DAVID SMITH https://youtu.be/a1UWxa2g9Us
22 Starting FORTH https://www.forth.com/wp-content/uploads/2018/01/Starting-FORTH.pdf
23 THINKING FORTH https://www.forth.com/wp-content/uploads/2018/11/thinking-forth-color.pdf
24 The Evolution of Forth https://www.forth.com/resources/forth-programming-language/
25 Website https://wiki.c2.com
26 c2-for-me http://marc.tries.fed.wiki/view/c2-for-me/ward.eu.wiki.org/c2-for-me
27 Forth Landing https://wiki.c2.com/?ForthLanguage
28 Forth Values https://wiki.c2.com/?ForthValues
29 Website https://muforth.dev
30 Threaded code https://muforth.dev/threaded-code/
31 Variations https://muforth.dev/threaded-code-variations/
32 Literals, ifs, and loops https://muforth.dev/threaded-code-literals-ifs-and-loops/
33 call versus branch-and-link https://muforth.dev/call-versus-branch-and-link/
34 Repo https://github.com/nimblemachines/muforth#under-active-development
35 Bootstrap yourself into conviviality by writing your own Forth https://vimeo.com/859408
36 Website https://www.forth.org/svfig/
37 Youtube https://www.youtube.com/@siliconvalleyforthinterest1736
38 Forth https://www.taygeta.com/forth.html
39 Website https://www.ultratechnology.com
40 Building a tiny FORTH for an Arduino UNO in one week https://www.thanassis.space/miniforth.html
41 J.V. Noble: A Beginners Guide to Forth https://galileo.phys.virginia.edu/classes/551.jvn.fall01/primer.htm
42 wiki.laptop: Forth Lessons https://wiki.laptop.org/go/Forth_Lessons
43 Building A Simple Forth Interpreter (in python) https://peerdh.com/blogs/programming-insights/building-a-simple-forth-interpreter
44 HN post on concatenative language interpreter https://news.ycombinator.com/item?id=13082825
45 PYCON UK 2017: What I learned building Forth in 64 bit Intel assembly https://youtu.be/iZ-5rBQS_p4
46 Color https://github.com/AshleyF/Color/tree/master
47 easyforth https://github.com/skilldrick/easyforth
48 libforth https://github.com/howerj/libforth
49 luaforth https://github.com/vifino/luaforth
50 foth (forth in go) https://github.com/skx/foth
51 lbForth https://github.com/larsbrinkhoff/lbForth
52 milliForth https://github.com/fuzzballcat/milliForth
53 MiniForth https://github.com/ttsiodras/MiniForth
54 pforth https://github.com/philburk/pforth
55 StoneKnifeForth https://github.com/kragen/stoneknifeforth
56 zForth https://github.com/zevv/zForth
57 Concatenative language https://concatenative.org/wiki/view/Concatenative%20language
58 A FOUNDATION FOR TYPED CONCATENATIVE LANGUAGES https://www2.ccs.neu.edu/racket/pubs/dissertation-kleffner.pdf
59 Wikipedia https://en.wikipedia.org/wiki/Concatenative_programming_language
60 b4 virtual machine https://github.com/tangentstorm/b4
61 Callisto https://github.com/callisto-lang/compiler
62 Cognate https://cognate-lang.github.io
63 deckload https://github.com/JosephOziel/deckload
64 Factor https://factorcode.org
65 fiveth https://github.com/dramforever/fiveth
66 formic https://formic.id
67 GDForth https://github.com/yumaikas/GDForth
68 iNet https://inet.run
69 kcats https://github.com/skyrod-vactai/kcats
70 kitten https://kittenlang.org
71 meow5 https://ratfactor.com/meow5/

View File

@@ -0,0 +1,484 @@
0:00
you got 10 minutes you're on awesome
0:03
thank you I'll try to share the screen
0:05
from the another account because like on
0:07
that I don't have um I hope you can see
0:10
it can you see the
0:12
screen
0:14
yes okay I I I assume you can see yes
0:17
you can see the screen so um yes uh my
0:22
adventure fors actually started back
0:25
like four years ago and uh I just
0:27
recently understood for them by just I
0:30
mean like around uh like three months or
0:33
something like that like and uh this
0:36
like this iteration of Fort I I've done
0:39
like 10 20 fors by now like uh this is
0:42
like a month old and um yeah this is
0:47
like this is a uh actually like
0:52
Fort defined by like inspired by color
0:55
Fort and uh I first saw it from Timothy
0:59
lattes and like I really liked it and I
1:01
uh implemented and I thought like uh I'm
1:05
I'm very happy with it and um I can like
1:09
maybe showcase something interesting
1:11
about the editor like uh I care a lot
1:14
about like uh programmer comfort so I I
1:18
sort of um did like an editor from
1:21
scratch and c and won and like
1:25
um and like in three like screens uh
1:29
like there's like this uh x64 assembler
1:33
and um yeah this this test on the right
1:38
side that you see it's it's like
1:41
um generating assembly from uh Define
1:45
with in this language basically So like
1:50
um basically some like
1:54
um oops oh yeah I mean I can maybe
1:57
showcase the editor I guess the editor
1:59
is the most interesting part so it it
2:02
has like uh undo and redo and um it can
2:08
also yeah can also like tus words um and
2:14
it doesn't matter if they're like um you
2:18
can hear me right I assume okay yes yeah
2:23
yes uh so I can hear you yes great so um
2:29
I don't know if this is new maybe uh
2:31
some someone can tell me but like the
2:33
way I do this look up is not by search
2:36
but instead when I'm compiling I have
2:39
another four bytes uh per character for
2:42
a block um that gives the source
2:46
location for the currently compiled word
2:49
and like uh like that it's you can just
2:52
search right inside this block for uh
2:56
the next iteration uh I mean the next
2:59
occurrence of of of that value and then
3:01
like it it finds the word perfectly
3:03
which uh I thought would be only
3:05
possible with uh like binary encoded
3:08
fors you know with specific like IDs for
3:11
Words um but yeah I I found that with
3:15
the simple extension uh like four bytes
3:17
per character um it's it actually allows
3:22
to look up that and also go to the
3:23
definition like uh instantly without uh
3:28
like making okay a having to
3:30
about and like um another thing I found
3:34
like uh interesting was that
3:40
um like I added a word called this and
3:44
now it gives me all theur all the
3:46
calling um it traces the word basically
3:50
so you can look up all uh execution of
3:54
this word in order of execution that it
3:58
happen so it's okay first execute here
4:00
and then here and then like goes on like
4:03
this so sort of gives like a um
4:06
intuition about like what happens in the
4:08
program without having to execute it or
4:11
like do like uh print test or whatever
4:14
like um you know this I mean this this
4:17
might seem maybe yeah it's it's too fast
4:21
right uh but uh I hope people get the
4:24
idea like
4:27
um so actually another interesting thing
4:31
is like with Ford I found like because
4:33
it's so free it's uh we can even go one
4:36
level up right what is this word getting
4:41
like where is this word getting called
4:43
in order and where is that like where is
4:46
the word that is getting called from is
4:49
like uh is called right so it gives like
4:53
oh we're compiling like three times in
4:55
this like uh we're executing that verbs
4:57
three times over here one time over here
5:00
and so on like um basically like a
5:04
compile time
5:07
um idea of like what what gets executed
5:11
um without having to do print like
5:15
[Music]
5:17
um I'm really underprepared for this I I
5:21
use this for to uh like to do games and
5:25
Graphics uh at least that's what I will
5:27
use it for um right now I'm compiling
5:30
spr and um like I got some of this stuff
5:36
maybe x64 will be much more interesting
5:39
like the Syntax for the x64 looks like
5:42
this actually um so there's this like
5:46
Direction register I'm just going to
5:48
turn off the examples and I'm going to
5:50
turn off uh
5:53
oops turn off spe also so
5:58
yeah all right
6:01
so um yeah basically
6:04
like with with this assem you can just
6:07
change the direction and like
6:11
um uh it's it's it was it reads as uh
6:16
from Ax to BX register let's move uh and
6:20
unsign which I Define as 32 bits you can
6:23
change this to Long which makes it like
6:25
RBX to
6:27
uh oh wait
6:30
what okay this is this is somehow broken
6:34
I'm
6:35
sorry oh no
6:37
it's yes yes yes of course not of course
6:40
yeah it's it's it's exactly I mean you
6:44
could instead like reading I mean
6:46
writing from uh RX
6:49
to register RBX you could uh write to
6:52
memory RB RBX or uh maybe like have like
6:57
an offset here uh
7:00
um or you could even do like s bites
7:05
like um like S 4 c one c 2 uh C
7:11
8 uh Al or C with
7:15
offset so um all of that works and again
7:19
like with this um like Direction uh like
7:24
so yeah basically um we can have
7:28
variables like
7:30
oh sorry do we have questions or
7:33
comments Tomatoes I don't know so
7:39
um yeah or we could do like an add you
7:43
like unsign ad like long at or bat
7:46
without having to change like um the
7:50
registers as we usually do in the
7:52
assembly so I yeah I um
8:00
and what
8:01
else I mean
8:04
uh yeah there's also jumps and uh what
8:08
not like um over here that looks like
8:12
this like labels um I mean this is the
8:15
x64 assembler um then I also use this to
8:21
compile like where is it oh
8:26
sorry Compass per V which is is the um
8:30
intermediate representation for um
8:32
shaders in welcome and like um actually
8:37
I I was expecting x64 to be a lot like
8:41
um a lot
8:43
more complicated but turned out
8:46
to be actually uh a bit more complicated
8:50
because um I'm also doing things like
8:54
having like type checked um variables
8:57
and whatnot in this language it's it's
8:59
still work can you can you complete that
9:02
sentence it's not complicated because
9:04
it's less complicated
9:06
because oh
9:08
x64 uh is less complicated because like
9:13
um x64 is a machine language right uh
9:16
machine languages are in my opinion
9:19
easier to compile than like standards
9:21
which like I can't there has to be like
9:24
you know a specific order to these like
9:28
um like definitions inside the standard
9:30
right like the capability has the
9:32
capability Ops have to come first and
9:34
then the type of operations and then uh
9:37
the uh function deficients and whatnot
9:39
so instead of just compiling right I had
9:42
to introduce the concept of like um okay
9:45
where is that sections yeah there it is
9:48
uh the concept of sections uh to compile
9:53
into like a binary with uh multiple
9:55
sections and then I had to assemble that
9:57
versus on x64 it's it was like
10:02
um yeah a lot less complicated when like
10:06
um I
10:09
mean yeah apart from a few things
10:15
um like can you say it in
10:19
words with like without showing us just
10:21
your general
10:23
impression uh general impression
10:26
regarding what sorry regarding this
10:29
less complex to use x I'm gonna have to
10:33
ask you to to wrap it up in the next
10:35
minute or two and uh perhaps back next
10:40
month and give us a more uh
10:45
expanded uh yeah version of this but
10:48
thank you I appreciate your willingness
10:51
to
10:52
present uh I want to encourage you to to
10:55
uh work something up in a more orderly
10:59
organized presentation yes yes yes yes
11:02
this is like completely impris right now
11:05
and I'm not doing like a good job of it
11:07
I hope
11:08
like this looks like St folks would be
11:11
interested in and uh thank you
11:16
uh so you want to take another minute or
11:19
you you done um I I like thanks for
11:24
listening to this like very um you know
11:28
okay un share your
11:30
and we'll move on
11:37
yes oh maybe one thing one last thing I
11:39
could showcas is like I just
11:42
added
11:55
yes okay
12:02
hey
12:03
Masa hi who are you where are you from
12:08
where are you and uh say something about
12:11
Force okay
12:13
well uh I I'm actually joining the
12:17
meeting from
12:18
Sunnyville and um I'm pting things uh C4
12:23
uh version 2.3 to uh LPC
12:27
2148 uh board so uh once I'm success
12:30
successful I'm going to probably present
12:32
that the my
12:35
experience that's
12:37
it that sounds great so uh I noticed
12:42
that somebody I did not
12:45
uh Poll for the
12:48
introductions is this guy uh
12:55
Moore and
12:57
uh I was was thinking I would run a
13:00
YouTube video of the uh Fireside so
13:03
you're just going to have to uh
13:06
imagine a YouTube video of a Fireside
13:09
running for 30 seconds uh while I
13:12
blather uh because uh I feel that if I
13:16
try to do that it'll it'll
13:19
uh it'll cause me it'll kick me off the
13:22
air again so uh Chuck boore needs to
13:25
unmute and deliver his fireside chat at
13:28
this time
13:32
you

View File

@@ -0,0 +1,322 @@
# A Forth for x86-64 personal computers
**Source:** https://dacvs.neocities.org/SF/
SmithForth
# A Forth for x86-64 personal computers
```
David Smith 2022 david.a.c.v.smith@gmail.com
```
***New:*** Check out **[Andrei Duma's explanation of SmithForth](https://github.com/AndreiDuma/SmithForth_RISC-V)!** He has implemented in **RISC-V** the machine-code part of SmithForth and more!
* SmithForth runs on Linux x86-64 systems.
* I believe some other Unix x86-64 systems can run Linux ELF binaries. SmithForth should run on these.
* SmithForth should run on your Windows system if you have installed the Windows Subsystem for Linux. I haven't tried it.
## SmithForth design
SmithForth is an implementation of the Forth programming language for x86-64 desktop computers.
SmithForth is a text interpreter that runs in a Linux text console.
You can use SmithForth as you would use any other standard Forth system.
SmithForth follows the [the Forth standard of 2012](https://forth-standard.org/).
The Forth standard describes some optional word sets concerning features like floating-point arithmetic and dynamic memory allocation that most programmers today would regard as standard, but the Forth community considers optional, perhaps because Forth runs on modest machines like microcontrollers.
SmithForth does not yet have floating-point arithmetic, local variables, or file access.
When I consider using a programming environment, I expect it to work on my hardware, and I expect it to be concrete and simple as possible.
Good luck finding tools that meet this standard.
So I wrote SmithForth.
Please take a look at the source code and the comments.
SmithForth is implemented in the subroutine-threaded style, which I think is the most straightforward way.
The [Intel manual](https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html) is our source of information on the x86 architecture.
We use none of the usual tools from the world of C, not even an assembler.
SmithForth is implemented in two source files:
1. **[SForth.dmp](SForth220711dmp.txt)** contains a primitive Forth system in 1000 hand-written bytes of annotated machine code.
2. **[system.fs](system220711fs.txt)** contains 1000 lines of system Forth to complete a standard Forth system.
## How to run SmithForth
1. ### Combine SForth.dmp and system.fs into one binary file.
Machine code is converted from a human-readable format "DMP" to binary by `xxd`
(hex dump) `-r` (reverse).
```
$ cut -d'#' -f1 SForth.dmp | xxd -p -r > SForth
$ cat system.fs >> SForth
```
The Forth source text is grafted onto the binary.
2. ### Turn the binary file into a proper executable.
Grant permission to execute the file on the Linux system.
```
$ chmod +x SForth
```
You should now have a working executable (if your system is similar enough to mine).
(*Optional:*)
Advanced users might edit the kernel or system.fs.
You must ensure that the ELF segment header entry `p_filesz` contains the number of bytes of the segment that appear in binary file `SForth`.
In my design, that's the whole file, including ELF header, machine code, and system Forth.
We prefer not to count those bytes by hand.
An easy solution is:
1. Make the binary as above. Don't run the binary yet.
2. Ask the system for the size of the binary file.
3. Write the result into field `p_filesz` of `dmqc.dmp`.
4. Remake the binary. The binary is ready to run.
My script [make.sh](make220711sh.txt) does these steps automatically:
```
$ ./make.sh # if and only if you modified SForth.dmp or system.fs
```
3. ### Run the SmithForth executable.
You can use SmithForth interactively, or you can feed your program into the standard input stream.
```
$ ./SForth
$ ./SForth < YourProgram.fs
$ cat YourProgram.fs - | ./SForth
```
The last command allows you to use SmithForth interactively after your programs.
---
## Numbers in machines
If you aren't an experienced programmer, here are some things to know before you read the DMP source file.
### Hexadecimal
Numbers in machine-code listings are often written in hexadecimal,
the base-sixteen number system with numerals 0123456789ABCDEF. In
hexadecimal, the nonnegative integers are:
> 0, 1, 2, ..., 9, A, B, C, D, E, F, 10, 11, ..., 1F, 20, ..., FF, 100, 101, ...
### Bytes
A byte is eight bits. The eight bits of a byte have 28 different states,
but our alphabet has fewer symbols. Instead we write these
states in base sixteen (=24) using a pair of hexadecimal numerals. The
states of a byte are:
> 00, 01, 02, ..., FE, FF.
### Binary
Sometimes we need to convert hexadecimal numbers to and from binary (base 2).
Conveniently, one base is the fourth power of the other, and the conversion
can be done in one-to-four fashion, repeatedly, independently. For example:
> 3E hexadecimal = 0011 1110 binary,
as 3 = 0011 and E = 1110.
You may see bits of a binary number grouped in various ways. For example,
x86 instruction "sub r/m32, r32" has a ModR/M byte written:
> 11 111 000.
Bits 11 select an access mode for argument r/m32, and bits 000 select
register EAX for that argument. The middle three bits 111 select
register EDI. To convert this into hexadecimal, we regroup the eight bits:
> 1111 1000 binary = F8 hexadecimal (as 1111 = F and 1000 = 8).
### Endianness
In hexadecimal, and in our usual decimal system, numbers with more than one
numeral are written with more significant numerals first:
* Decimal has hundreds before tens before ones.
* Hexadecimal has two hundred fifty-sixes before sixteens before ones.
Such systems are *big-endian*. *Little-endian* is the reverse order, with
less significant numerals first.
### The little-endian x86
The x86 architecture is **little-endian in bytes** (that is, little-endian in base 28) ...
> When an integer is moved from a CPU register into memory, for example, the
> least significant byte appears first in memory.
... but each byte is written as a **big-endian pair** of hexadecimal numerals.
This custom is observed:
* in Intel's manuals,
* in the output of tools (like xxd) that convert binary files to text, and
* in the input of tools that convert text (like our DMP file) to binary files.
For example,
* hexadecimal 12 is eighteen,
* hexadecimal 12 00 is eighteen (= 0012 big-endian), and
* hexadecimal 12 00 00 00 is eighteen (= 00000012 big-endian).
### Machine arithmetic is modular
There are infinitely many integers, but digital machines have finitely many states.
Integers processed by the Arithmetic Logic Unit (ALU) of the machine are more aptly
called congruence classes, as the ALU performs modular arithmetic for addition,
subtraction, and multiplication, where the modulus of the congruence relation is a
power of 2, like 28. However, some operations involve a particular representative
of a congruence class.
Two rules are commonly used to select a representative. They are:
1. **unsigned**, where the representatives are
> 0, 1, 2, ..., modulus - 1, and
2. **signed**, where the representatives are
> 0, 1, ..., modulus/2 - 1, (*nonnegative*) and
> -1, -2, ..., modulus/2 (*negative*);
but the machine has no "minus sign," so instead we use
> modulus - 1, modulus - 2, ..., modulus/2 (*negative*).
For example, if the modulus is 28, the signed representatives are
> 00, 01, ..., 7F, (nonnegative)
> FF, FE, ..., 80 (negative).
We can tell negative from nonnegative by the most significant bit.
* Nonnegatives have most significant bit 0.
* Negatives have most significant bit 1.
Watch for "unsigned" and "signed" in the Intel manual.
## Implementing Forth
If you aren't an experienced Forth programmer, here are some things to know before you read the Forth system file.
### Conditionals
Compiling in Forth is simple. The compiler sees a word W, looks it up in the dictionary,
and appends to the body of the current dictionary entry a CALL instruction. The target of
the CALL is the address of the body of the dictionary entry of word W.
CALL facilitates the use of subroutines, which normally return control to the point in the instruction
stream where CALL occurred. There are other forms of flow control, mainly conditionals
and loops.
```
: X ... flag IF ... ( do this if flag is nonzero ) ... THEN ... ;
\ /
-->-- ( skip to THEN if flag is zero ) ---->---
```
Forth has words IF and THEN for conditional execution. They are used in compilation mode.
Normally IF is paired with an instance of THEN later in a word definition.
When the interpreter reaches IF at run time, it examines the number at the top of the stack.
If the number is nonzero, execution continues past IF.
If the number is zero, execution jumps past THEN.
The microprocessor has flow-control features including jumps and conditional jumps.
The Forth compiler, when it sees IF, might emit a conditional jump.
A likely instruction of this kind in x86 is JZ, jump if zero. JZ has a parameter that
indicates where to jump to, *past THEN* in this case. However, when the compiler
first sees IF, it has not yet seen any THEN. So the plan is:
1. Upon IF, reserve space in the compiler's output for instruction JZ and produce (push) a reference.
2. Continue compiling as usual.
3. Upon THEN, consume (pop) a reference and finish formulating instruction JZ.
In the Forth standard, this is *resolving a forward reference*.
Forth implements this plan by using the data stack during compilation:
* IF ( flag -- ) Compilation: ( -- orig ) ... ;
* THEN ( -- ) Compilation: ( orig -- ) ... ;
Stack-effect comments like ( bef -- aft ) describe the end of the stack before and after the word is executed.
The LIFO property of the stack allows IF-THEN statements to be nested.
### Loops
Forth offers several ways to write loops.
One is BEGIN-WHILE-REPEAT.
```
--------------------------------<---------------------------
/ \
: X ... BEGIN ... flag WHILE ... ( do this if flag is nonzero ) ... REPEAT ... ;
\ /
--->-- ( skip to REPEAT if flag is zero ) ---->----
```
* BEGIN ( -- ) Compilation: ( -- dest ) ... ;
* WHILE ( flag -- ) Compilation: ( dest -- orig dest ) ... ;
* REPEAT ( -- ) Compilation: ( orig dest -- )
BEGIN-WHILE-REPEAT is versatile, allowing to exit from the middle of a loop body.
BEGIN-WHILE-REPEAT can emulate other control structures:
IF-THEN:
: flag BEGIN WHILE ... 0 REPEAT
IF-ELSE-THEN:
: flag DUP BEGIN WHILE DROP ... 1 0 REPEAT 0= BEGIN WHILE ... 0 REPEAT
BEGIN-UNTIL:
: BEGIN ... flag 0= WHILE REPEAT
---
## Simpler software
Here are my opinions and motivations for this project.
**Forth** is a simple programming language that achieved some fame back when personal computers were young.
What else would run on such modest computers?
Nowadays computers and languages are fancy and complex.
I say Forth is still a good choice. Forth is simple enough that we may reason about it and understand it.
Forth provides:
* features found in most programming languages:
+ conditionals (if-else)
+ loops
+ variables
+ user-defined functions
* and more:
+ CREATE
+ DOES>
A good system helps us to solve our problems quickly.
Some systems try to be comprehensive.
Others keep it simple.
SmithForth is small and flat enough that a programmer can understand it all.
SmithForth has only a couple files.
We use none of the usual tools from the world of C.
You might argue that C makes programming simpler by insulating us from the workings of the machine.
I might agree if:
* in our daily work, we are allowed to focus on a small number of layers, and
* each layer is well documented,
but this has not been my experience.
C is intentionally vague about the dimensions of machines -- *an irritation the programmer* -- so that programs are portable -- *a feature I never use*.
There is always one kind of machine available, usually x86.
The Intel architecture is fairly well documented, and although the Intel manual is huge, we can find the few parts we need.
For an introduction to x86 machine-language programming (without Forth), please see
[my video series](https://www.youtube.com/playlist?list=PLZCIHSjpQ12woLj0sjsnqDH8yVuXwTy3p) on that topic.
I can imagine a system that contains its own documentation and C source code and tailors these to the computer on which it is installed in such a way that the user can study them and be unconcerned with other computers. No one does this, as far as I know.
Forth has been implemented many times.
Some Forths have a small kernel so that the system can be ported easily to other architectures (by implementing only a small number of kernel words in machine code).
But if you want the system to run well, you have to write more machine code anyway, don't you?
My goal with SmithForth is not to stop writing machine code early, but to start writing Forth early.
In SmithForth, our early Forth contains a lot of machine code.
I believe SmithForth is a good first Forth to learn and a good first programming environment.
The shortened presentation may appeal to mathematicians.
If you want to know my ideas for the direction of this project, I would like to write extensions so that SmithForth becomes
fast and suitable for scientific computing;
and to add enough features of Lisp, Python, Awk, and Tcl that I wouldn't think to use those languages.
I would like to adapt it to other machines and make it usable without an underlying operating system like Linux.

View File

@@ -0,0 +1,380 @@
# Archived Website
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/index.html
```
\\\\\\` \\\\\\\\\\`\\\`\\\\\\\\\`\\\\\\\\\` \```\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\\\\\ `\\` ``\`\\\\` `\ \ \\`` `\\\` ``\` ``\`\\\\`\\
`, , o `, ` `
. .oo.. . . o ... ' .o
OO. ...ooOO..... o . ooOOoooo.. . O o . .
OOOo..OOOOOOOo... ....OOo.... .o..... oOOOOOOOOoooo.... Oo. oO
OOOOOOOOOOOOOOO .Ooo. OOOOo......oo. ..ooOO..OOOOOOOOOO......oo.OOo... ..OOO
OOOOO.OOOOOOo.. oOOOOoo. .OO..OOOOOOOOOOOo.......OOO......OOOOOOOOOOoo.OOOOOO
OOOOOo.OOOOOOOoOOOOOOOOOOO.OOOOOOO|OOOOOOOOOO...||||oo.OOOOOOOOOOOoOOOOOooOOO
||oooOOOOOOOOOOOOOOOOOOO|||||ooOOOO|OOOOO|||||oooOOOOOO|OOO|OOOOOOOOOOOOOOOOO
. OOO''||''OOOOOOOOOOOO|||||''||''OO|||o|||||||''||OOOOOO''OOO''OOO|||ooooOO|OO .
O OOO ||..||OO||||||||||OOo || ||||||||||||| ||||OO|| |o| ||||||||OO||OOO O
' o| |''|' '' '|' '| | '| | |||| |' '| | |' '|' 'OO '
||| || | . . | . || || . | | ||/| | . || |oO || ' | |||||
/|| || | | | | | || || | | | |//| | | || ||| || ...||.. '||
//| || | | | | ' || || | | ' |//| | ' || ||| || '''|''' |/
///..//../../../..//.../....//../../... ////..//...///..///..///....//...///
/////////////../////////////.//////////..///////////././///////./////////////
////.//.//. ..//...././/. ///////..//////.///.//.... ././//...//..////////
//.... . ./ /////. ...//. ./////... . ... .. ././/
.. .. . .// . ...
/
```
# 20161121 - Index - [RSS](index.rss)
*TimothyLottes.github.io - Welcome to this Online Blog and Archive.*
[![](20161114-D.bmp)](20161114-D.bmp)
**Recently Changed**
[20161121 - Moving Beyond Rendering With Triangles](20161121.html)
[20161117 - Mechanics of Vulkan SPIR-V Specialization](20161117.html)
[20161114 - Believing in an Image](20161114.html)
[20161113 - Vintage Programming 2](20161113.html)
**Updates**
RSS feed is done manually, so only the minimal note that a page was added.
Switched over to using [protonmail.com](https://protonmail.com/) for my email.
To contact me, email TimothyLottes at that domain.
Using [duckduckgo.com](https://duckduckgo.com/) for search personally,
*added the duckduckgo widget to this site for direct site search, but the site is too new to get picked up yet*.
Slowly migrating everything else to this site,
and attempting to restore what I can from prior lost images.
* 190 pages left to sort through on blogger* 60 docs left to sort through on drive
**2016**
[20161121 - Moving Beyond Rendering With Triangles](20161121.html)
[20161117 - Mechanics of Vulkan SPIR-V Specialization](20161117.html)
[20161114 - Believing in an Image](20161114.html)
[20161113 - Vintage Programming 2](20161113.html)
[20161112 - Plasma Displays](20161112.html)
[20161109 - CreamTracker](20161109.html)
[20161108 - Linux Link Farm](20161108.html)
[20161105 - Owlboy via CRT](20161105.html)
[20161104 - Is OpenVR Actually Open?](20161104.html)
[20161103 - Game List](20161103.html)
[20161102 - Frequent Web Travels](20161102.html)
[20161101 - Linear Dithering Before Transfer Function](20161101.html)
[20161031 - FPGA Links](20161031.html)
[20161030 - Demo Tube Mega List](20161030.html)
[20161029 - Program Per Clock](20161029.html)
[20161028 - Rotated View Vs Rotated Sample Grid In Pixel](20161028.html)
[20161027 - FXAA Pixel Width Contrast Reduction](20161027.html)
[20161023 - Sphere Tracing AA](20161023.html)
[20161022 - Variation on Branching Design - Return Only](20161022.html)
[20161018 - Fixed Point Rounding](20161018.html)
[20161017 - Notes from Attempting to Understand FPGA Timing Limits](20161017.html)
[20161016 - Instruction Fetch Optimization](20161016.html)
[20161015 - Atomic Scatter-Only Gather-Free Machines](20161015.html)
[20161014 - Possible Directional Routing Hoplite Variant?](20161014.html)
[20161013 - SymbOS - 8-bit OS Awesome Sause](20161013.html)
[20161012 - Technical Evaluation of Traditional vs New "HDR" Encoding Crossed With Display Capability](20161012.html)
[20161011 - Forth Hardware Thoughts](20161011.html)
[20161005 - Epiphany-V Taped Out](20161005.html)
[20161004 - T4K Try 3](20161004.html)
[20161003 - T4K Try 2](20161003.html)
[20161001 - T4K Try 1](20161001.html)
[20160921 - Parallel Noise Generation](20160921.html)
[20160912 - The Great MacOS 9](20160912.html)
[20160909 - Thinking "Clearly" About 4K](20160909.html)
[20160908 - Transistor Count Thoughts](20160908.html)
[20160905 - GPU Parking Lot](20160905.html)
[20160806 - Uber Shader Unrolling](20160806.html)
[20160731 - Vulkan From Scratch Part 2](20160731.html)
[20160728 - Blink Mechanic for Fast View Switch for VR](20160728.html)
[20160727 - Vulkan - How to Deal With the Layouts of Presentable Images](20160727.html)
[20160726 - On Killing WIN32?](20160726.html)
[20160724 - Simplified Vulkan Rapid Prototyping](20160724.html)
[20160723 - Why Motion Blur Trivially Breaks Tone-Mapping - Part 2](20160723.html)
[20160721 - Why Motion Blur Trivially Breaks Tone-Mapping - Part 1](20160721.html)
[20160720 - Re Twitter: Thoughts on Vulkan Command Buffers](20160720.html)
[20160715 - LED Displays](20160715.html)
[20160706 - Low Cost Branching to Factoring Out Loop Exit Check](20160706.html)
[20160705 - CPU Threading to Hide Pipelining](20160705.html)
[20160704 - Relative Addressing With XOR - Removing an Adder](20160704.html)
[20160331 - Instant Soft-Reboot to Prior Machine Snapshot](20160331.html)
[20160127 - Temporal AA Neighborhood Clamp](20160127.html)
[20160126 - Local/Global Dimming, Blooming, Contrast Ratios - CRT/LCD/Plasma/OLED](20160126.html)
**2015**
[20151222 - Random Holiday 2015](20151222.html)
[20151123 - Cross-Invocation Data Sharing Portability](20151123.html)
[20151122 - CRT Inventory](20151122.html)
[20151121 - ISA Toolbox](20151121.html)
[20151116 - Mixing Temporal AA and Transparency](20151116.html)
[20151113 - Rethinking the Symbolic Dictionary](20151113.html)
[20151025 - Finer Points of Living in the Raleigh North Carolina Area](20151025.html)
[20151021 - Thoughts on Minimal Filesystem Design](20151021.html)
[20150930 - Tonemapping and Slot Mask Simulation](20150930.html)
[20150915 - Bacon Wrapped Sour Cream](20150915.html)
[20150914 - Tearaway Unfolded PS4 on Wega CRT HDTV](20150914.html)
[20150913 - Minimal Operand CPU ISA For IPC](20150913.html)
[20150912 - Self-Correcting Part 2 or Rather a Rant on Why Extreme DoD](20150912.html)
[20150911 - Self-Correcting CPU Pipelines](20150911.html)
[20150910 - September Trip to Iceland](20150910.html)
[20150829 - Ketogenic Diet Working on Year 2](20150829.html)
[20150828 - Atari Shock Reloaded?](20150828.html)
[20150814 - The Written Word](20150814.html)
[20150810 - 1536-5 : Keys](20150810.html)
[20150809 - 1536-4 : Coloring](20150809.html)
[20150722 - 1536-3 : Simplify, Repeat](20150722.html)
[20150719 - CRT Shadow Masks vs LCD](20150719.html)
[20150718 - Stochastic 1 Sample/Pixel Lit Fog stills](20150718.html)
[20150715 - 1536-2 : Assembling From the Nothing](20150715.html)
[20150714 - 1536-1 : The Programmer Addiction = Feedback](20150714.html)
[20150713 - Great Tube: Old computers did it better!](20150713.html)
[20150712 - Oh How Programming Has Changed](20150712.html)
[20150710 - Inspiration Reboot](20150710.html)
[20150709 - GPU Unchained ASCII Notes](20150709.html)
[20150630 - Sugar Free Peppermint Chocolate Chip Custard Ice Cream](20150630.html)
[20150624 - AMD Fury X (aka Fiji) is a Beast of a GPU Compute Platform](20150624.html)
[20150623 - BenQ XL2730Z Blur Reduction vs CRT](20150623.html)
[20150604 - Panasonic CT-34WX59 = Piece of Junk](20150604.html)
[20150525 - OS Project : 7 - PS/2 and Misc](20150525.html)
[20150522 - The Other Project Cleaned Up](20150522.html)
[20150509 - OS Project : 6 - Hashing](20150509.html)
[20150430 - The Other Project Getting Wired](20150430.html)
[20150426 - Source-Less Programming : 5](20150426.html)
[20150424 - Source-Less Programming : 4](20150424.html)
[20150423 - Source-Less Programming : 3](20150423.html)
[20150422 - Source-Less Programming : 2](20150422.html)
[20150421 - Look No Triangles : Scatter vs Gather](20150421.html)
[20150420 - From Scratch Bug 2 : Source-Less Programming](20150420.html)
[20150416 - Pixel Art and Slot Mask Pitch](20150416.html)
[20150415 - Indie vs Real Slug Fest](20150415.html)
[20150414 - From Scratch Bug](20150414.html)
[20150406 - End of an Era](20150406.html)
[20150403 - Why I'm Using Fedex From Now On](20150403.html)
[20150328 - Stills From My Talk](20150328.html)
[20150309 - Quick Thoughts on Strobbed LCD Displays for VR Perf Proxy](20150309.html)
[20150327 - Other CRT Options](20150327.html)
[20150308 - CRTs](20150308.html)
[20150221 - Great Example of Horrible API Interface Design](20150221.html)
[20150220 - The Order 1886!](20150220.html)
[20150111 - Leaving Something for the Imagination](20150111.html)
**2014**
[20141231 - Continued Notes on Custom Language](20141231.html)
[20141223 - Transparency/OIT Thoughts](20141223.html)
[20141211 - AMD64 Assembly Porting Between Linux and Windows](20141211.html)
[20141010 - The Source of the Strange "Win7" Color Distortion?](20141010.html)
[20141006 - Driving NTSC TV from GTX 880M](20141006.html)
[20140926 - Post Depth Coverage](20140926.html)
[20140921 - Using GDB Without Source and With Runtime Changing of Code](20140921.html)
[20140920 - Interlacing at High Frame Rates and Low Persistence?](20140920.html)
[20140830 - HDFury Nano GX: Part 2](20140830.html)
[20140828 - HDFury Nano GX: HDMI to VGA](20140828.html)
[20140826 - Scifi Reading Suggestion List From Twitters](20140826.html)
[20140823 - MinWM](20140823.html)
[20140819 - Scanlines](20140819.html)
[20140816 - Vintage Programming](20140816.html)
[20140814 - HRAA And Coverage and Related Topics](20140814.html)
[20140810 - Front Buffer Rendering](20140810.html)
[20140809 - Strict Aliasing](20140809.html)
[20140730 - Scanlines and Vintage TVs](20140730.html)
[20140723 - Body Hacking Running on Oil](20140723.html)
[20140717 - Bad Industry Humor: Computer Engineering Hall of Shame](20140717.html)
[20140715 - Infinte Projection Matrix Notes](20140715.html)
[20140712 - VR Topics : Racing Scan-Out + Filtering/Noise](20140712.html)
[20140627 - CG Anti-Aliasing in 1984](20140627.html)
[20140621 - Filtering and Reconstruction : Points and Filtered Raster Without MSAA](20140621.html)
[20140606 - Easy Understanding of Natural Draw Rate Limiters and The Route To Zero Overhead](20140606.html)
[20140506 - The Other Project](20140506.html)
[20140413 - Minimal Single Symbol ELF For Using GL](20140413.html)
[20140328 - Related to Filtering for VR](20140328.html)
[20140110 - Portable Read-Only Thumb Linux](20140110.html)
[20140104 - GL Idea Listing](20140104.html)
[20140103 - Killzone Shadow Fall Multiplayer After 50 Hours](20140103.html)
**2013**
[20131126 - Random Next Generation Notes](20131126.html)
[20130825 - Modern Memory Mapping](20130825.html)
[20130808 - Runtime Recompile Reloaded](20130808.html)
[20130707 - Slab Hash](20130707.html)
[20130524 - AMD GCN GPU Scaling : Tablet To Desktop](20130524.html)
[20130325 - Understanding WIN32 GetRawInputBuffer()](20130325.html)
[20130226 - Shader Aliasing and Small Triangles](20130226.html)
[20130119 - Understanding the Speed of Light of Game Input Latency](20130119.html)
**2012**
[20121229 - Practical Non-Atomic CPU/GPU Communication](20121229.html)
[20121203 - Simple Custom Web Server Tricks](20121203.html)
[20121202 - Winged Doom: Stealer](20121202.html)
[20121001 - Linux Distros and Compression](20121001.html)
[20120903 - Linux Threading Via Syscalls](20120903.html)
[20120802 - DX Camera Motion from Depth](20120802.html)
[20120706 - Exposure Render](20120706.html)
[20120513 - Frame Stutter Reduction Via Time Smoothing](20120513.html)
[20120414 - Engine Scaling on April 2012 GPUs](20120414.html)
[20120211 - Old School: Modems](20120211.html)
**2011**
[20111031 - Exclusive Core Access](20111031.html)
[20110907 - Parallel Programming With Clones](20110907.html)
[20110331 - DX11 Tessellation and Level Building Blocks](20110331.html)
**2010**
[20101005 - MSVC Optimizing Static Constant Data Copy?](20101005.html)
[20101004 - MSVC Optimizing Static Constant Function Tables?](20101004.html)
[20100108 - AntiPlanet2](20100108.html)
[20100105 - Game Engine Architecture](20100105.html)
[20100104 - OnLive Notes](20100104.html)
[20100102 - PC CPU Task Parallelism Limits](20100102.html)
**2009**
[20091229 - DirectCompute 3D Fluid Simulation Tube](20091229.html)
[20090917 - Food-For-Thought Supermarket Aisle](20090917.html)
[20090909 - L1 Misses](20090909.html)
[20090812 - Stochastic Visibility in Distorted Fisheye](20090812.html)
[20090804 - Aras's Compact Normal Storage](20090804.html)
[20090728 - Morphological AA Part II](20090728.html)
[20090714 - Hybrid Cached Raycast and Reproject Raster](20090714.html)
[20090710 - Video of Particles via L-System and Stochastic Visibility](20090710.html)
[20090709 - Stochastic Visibility Update](20090709.html)
[20090708 - GPU Ray Traversal Efficiency](20090708.html)
[20090705 - Odd Transparent Rendering Ideas](20090705.html)
[20090611 - Factoring Out the Job Scheduler](20090611.html)
[20090606 - Thread Scheduling Part 3](20090606.html)
[20090605 - SIMD Binning And Caches](20090605.html)
[20090604 - Thread Scheduling Part 2](20090604.html)
[20090602 - Thread Scheduling Part 1](20090602.html)
[20090519 - GPU REYES](20090519.html)
[20090513 - Gaussian KD Trees](20090513.html)
[20090506 - Electromagnetic Spectrum and Rendering](20090506.html)
[20090505 - Compute Mega Post](20090505.html)
[20090501 - 32bpp HDR Blending Idea](20090501.html)
[20090422 - WFA Image Compression](20090422.html)
[20090407 - DXT Tip](20090407.html)
[20090318 - Reattachable Code](20090318.html)
[20090110 - Hole Filling](20090110.html)
**2008**
[20081218 - Reprojection 2](20081218.html)
[20081216 - Reprojection 0](20081216.html)
[20081209 - Atom Updates](20081209.html)
[20081030 - Parallel Rapid Development Architecture](20081030.html)
[20081020 - Temporal Binned Ring Buffers](20081020.html)
[20081014 - Octahedron Mapping](20081014.html)
[20081010 - Temporal Locality](20081010.html)
[20080918 - General Purpose](20080918.html)
[20080709 - Anti-Aliasing](20080709.html)
[20080704 - Micro Polygons II](20080704.html)
[20080628 - Micro Polygons](20080628.html)
**2007**
[20071126 - Optimization and More](20071126.html)
[20071121 - Deferred Shading III](20071121.html)
[20071116 - Deferred Shading II](20071116.html)
[20071026 - Transform Feedback](20071026.html)
[20071025 - Motion Cards](20071025.html)
[20071024 - Geometry Shader Woes](20071024.html)
[20071018 - Cubemap Concepts](20071018.html)
[20071015 - Drawing in Reverse II](20071015.html)
[20070926 - Drawing in Reverse](20070926.html)
[20070921 - Assembler in Atom4th](20070921.html)
[20070919 - Editor Working](20070919.html)
[20070915 - Building the Chicken Without an Egg](20070915.html)
[20070912 - The Making of a Font](20070912.html)
[20070910 - 2 4th | !2 4th](20070910.html)
[20070822 - New Pipeline Progress](20070822.html)
[20070819 - High Dynamic Range](20070819.html)
[20070818 - Deferred Fractal Environment Shading](20070818.html)
[20070817 - Videos Update](20070817.html)

View File

@@ -0,0 +1,23 @@
# Bootstrap yourself into conviviality by writing your own Forth
**Source:** https://vimeo.com/859408
Bootstrap yourself into conviviality by writing your own Forth
# Verify to continue
To continue, please confirm that you're a human (and not a spambot).
## Checking if the site connection is secure
vimeo.com needs to review the security of your connection before
proceeding.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,291 @@
# Building a tiny FORTH for an Arduino UNO in one week
**Source:** https://www.thanassis.space/miniforth.html
Building a tiny FORTH for an Arduino UNO in one week
Building a tiny FORTH for an Arduino UNO in one week
*(July 2021)*
[![Fork me on GitHub](forkme_right_darkblue_121621.png)](https://github.com/ttsiodras/MiniForth/)
It was raining hard, a week ago.
And what could you possibly do on a rainy Saturday afternoon?
Well... I was inspired by [a series of articles on Hackaday](https://hackaday.com/2017/01/27/forth-the-hackers-language/) to...
*...make a Forth interpreter/compiler from scratch...
...then put it inside a 1.5$ Blue Pill microcontroller...
...then repeatedly squash it until it fits inside an Arduino UNO...
...i.e. inside 2K of RAM!*
I haven't done anything even *remotely* close to this in decades.
I *loved* building it :-)
The rainy afternoon turned into a week-long hackfest *(was looking
forward every day to the post-work FORTH-tinkering in the afternoon...)*
The result: [a tiny, mini-Forth](https://github.com/ttsiodras/MiniForth/). In portable C++ :-)
It has...
* basic arithmetic
* star-slash (double-word accurate muldiv)
* literals
* constants
* variables
* direct memory access
* string printing
* reseting
* comments
* nested DO/LOOP
* comparisons
* nested IF/ELSE/THEN
* ...and of course, functions (Forth words)
Here's a recording of it in action:
...and another one, where a small Forth program blinks the Arduino LED:
# ArduinoSTL and Valgrind / AddressSanitizer checks
I meant it when I said "portable" - the [source code](https://github.com/ttsiodras/MiniForth/)
compiles as-is for both native and Arduino builds.
Another part of my reasoning was that
in addition to targeting multiple platforms (e.g. BluePill and
Arduino) I wanted to be able to use Valgrind and AddressSanitizer
to detect - in the host! - any issues I have with my memory handling.
And just as important, debugging with GDB in the native host is much easier/faster.
Since I had embedded targets in mind, I tried ArduinoSTL - but it was too
wasteful memory-wise. It also made the build process significantly slower.
I therefore built my own [memory pool, as well as list, tuple and string-like C++ templates](https://github.com/ttsiodras/MiniForth/tree/master/src/mini_stl.h). It was a nice challenge, re-inventing a tiny C++ STL...
And I understand STL a lot better now, after building small pieces of it myself :-)
# Simulation / Debugging
I setup simulation via [simavr](https://github.com/buserror/simavr.git).
This tremendously improved my developing speed, since a simulator
spawns and runs much faster than the real board. Due to the code
being portable, debugging took place mostly in the host GDB;
and after Valgrind and AddressSanitizer gave their blessing, I usually
found out that the simulator (and the real board) worked fine as well.
# BluePill vs Arduino UNO
Thanks to ArduinoSTL, I quickly reached the point of running inside the BluePill. The 1.5$ mini-monster has 10 times more SRAM than an Arduino UNO;
so in a couple of days, I had a [working branch](https://github.com/ttsiodras/MiniForth/tree/BluePill-STM32F103C).
![Before the Arduino UNO, I run my mini-FORTH inside the 1.5$ Blue Pill](BluePill.jpg)
*Before the Arduino UNO, I run my mini-FORTH inside the 1.5$ Blue Pill*
But as said above, that wasn't nearly enough to make it work in my
Arduino UNO. That required far more work *(see below)*.
As for the BluePill, I should note that, as in all my other embedded targets,
I prefer a development workflow that is based on normal bootloaders
*(not on programmers)*. I therefore burned the
[stm32duino](https://github.com/rogerclarkmelbourne/STM32duino-bootloader)
bootloader on the BluePill, which allowed me to easily program it
in subsequent iterations via the USB connection (and a simple `make upload`).
The same USB connection would then function as a serial port immediately
afterwards - allowing me to interact with the newly uploaded Forth in the
BluePill.
The screenshot below is from a `tmux`: on the left, the output from `make upload`;
and on the right, I used `picocom` to interact with my mini-Forth
over the serial port:
![Compiling, uploading and testing](itworks.jpg)
*Compiling, uploading and testing*
# Memory - the final frontier
That covered the first two days.
But when I tried compiling for the Arduino UNO, I realised that the ArduinoSTL
was not enough. I run out of memory...
So I built my own [mini-STL](https://github.com/ttsiodras/MiniForth/tree/master/src/mini_stl.h),
and tightly controlled *all* memory utilisation.
I also used macro-magic to move all strings to Flash at compile-time
(see `dprintf` in the code)... And saved memory everywhere I could,
re-using error messages across various operations - and storing the
entire array of native operations in Flash.
Nothing flexes your coding muscles as much as optimising; whether it is
for speed or for space. See the implementation of ".S" for example,
where the (obvious) stack reversal code is also the most wasteful...
Changing it to a slower but memory-preserving algorithm allowed me
to use ".S" even when almost all my memory is full.
# C++ vs C
I know that many developers hate C++. I even wrote a
[blog post](cpp.html) about it.
And I understand why - they see code like this...
```
#include "mini_stl.h"
template<class T>
typename forward_list<T>::box *forward_list<T>::_freeList = NULL;
```
...and they start screaming - "what the hell is that", "incomprehensible
madness", etc.
But there are very important benefits in using C++ - and templates
in particular. You write less code, with no additional run-time or
memory overhead compared to C, and with a lot more compile-time checks
that watch your back (for things that would otherwise blow up in your face).
See my Optional for example, that emulates (badly) the optional
type of Rust/OCaml/F#/Scala/Kotlin etc. It **forces** you to check
your returned error codes:
```
Optional<int> Forth::needs_a_number(const __FlashStringHelper *msg)
{
if (_stack.empty())
return error(emptyMsgFlash, msg);
auto topVal = *_stack.begin();
if (topVal._kind == StackNode::LIT)
return topVal._u.intVal;
else
return FAILURE;
}
```
You can't "forget" to check the potential for a failure coded inside
your returned value - because your code has to "unwrap" it. I could have
done this better, but I chose to implement it via simple tuples
(this was a one-weeks-afternoons hack, after all :-)
As for the template "magic" incantation above - it *is* true magic: My
`forward_list` template is using free-lists to store the `pop_front`-ed
elements and reuse them in subsequent allocations. I wanted these free-lists to
be global (i.e. static members) because lists of the same type must re-use a
single, commonly-shared free-list. The magic spell tells the compiler I want to
instantiate these globals *once*, for each type T that I use in any
lists in my code.
# My Forth test scenario - including a FizzBuzz!
Yep, FizzBuzz - we are fully Turing complete. And would surely pass
Joel's interview :-)
```
." Reset... " RESET
." Check comments... " \ Yes, we support the new-style comments :-)
." Computing simple addition of 3 + 4... " 3 4 + .
." Is 1 = 2 ?... " 1 2 = .
." Is 1 > 2 ?... " 1 2 > .
." Is 1 < 2 ?... " 1 2 < .
." Define pi at double-word precision... " : pi 355 113 */ ;
." Use definition to compute 10K times PI... " 10000 pi .
." Check: 23 mod 7... " 23 7 MOD .
." Defining 1st level function1... " : x2 2 * ;
." Defining 1st level function2... " : p4 4 + ;
." 2nd level word using both - must print 24... " 10 x2 p4 .
." Defining a variable with value 123... " 123 variable ot3
." Printing variable's value... " ot3 @ .
." Defining The Constant (TM)... " 42 constant lifeUniverse
." Printing The Constant (TM)... " lifeUniverse .
." Setting the variable to The Constant (TM)... " lifeUniverse ot3 !
." Printing variable's value... " ot3 @ .
." Setting the variable to hex 0x11... " $11 ot3 !
." Printing variable's value... " ot3 @ .
." Defining helper... " : p5 5 U.R . ;
." Defining 3 times loop... " : x3lp 3 0 DO I p5 LOOP ;
." Calling loop... " x3lp
." Defining loop calling loop 2 times... " : x6lp 2 0 DO x3lp LOOP ;
." Nested-looping 2x3 times... " x6lp
." Inline: " : m 3 1 DO 3 1 DO CR J p5 I p5 ." = " J I * p5 LOOP LOOP ;
." Use inline loops with two indexes... " m
." Make multiples of 7 via DUP... " : m7s 10 0 DO DUP I * . LOOP DROP ;
." Print them and DROP the 7... " 7 m7s
." Reset... " RESET
\ Time for Turing completeness...
." Let's do Fizz-Buzz! " \ Turing Completeness check...
\ fizz ( n -- 0_or_1 n )
." Define fizz... " : fizz DUP 3 MOD 0 = IF ." fizz " 1 ELSE 0 THEN SWAP ;
\ buzz ( n -- 0_or_1 n )
." Define buzz... " : buzz DUP 5 MOD 0 = IF ." buzz " 1 ELSE 0 THEN SWAP ;
\ emitNum ( 0_or_1 0_or_1 n -- )
." Define emitNum... " : emitNum ROT ROT + 0 = if . ELSE DROP THEN ;
\ mainloop ( n -- )
." Define mainloop... " : mainloop fizz buzz emitNum ;
\ fb ( -- )
." Define fizzbuzz... " : fb 37 1 DO I mainloop LOOP ;
." Run it! " fb
." Report memory usage... " .S
```
# Automation
I am a strong believer in automation. The final form of my `Makefile`
therefore has many rules - e.g. `make arduino-sim` - that automate
various parts of the workflow.
Here's what they do:
* **arduino**: Compiles the code for Arduino UNO - builds `src/tmp/myforth.ino.{elf,hex}`
* **arduino-sim**: After building, launches the compiled mini-Forth in `simduino`.
* **upload**: After building, uploads to an Arduino attached to the port
configured inside `config.mk`.
* **terminal**: After uploading, launches a `picocom` terminal with
all appropriate settings to interact with my Forth.
* **x86**: Builds for x86. Actually, should easily build for any native target (ARM, etc).
* **test-address-sanitizer**: Uses the x86 binary to test the code, executing
all steps of the scenario shown above. The binary is built with the
address sanitizer enabled (to detect memory issues).
* **test-valgrind**: Same, but with Valgrind.
* **test-simulator**: Spawns `simavr` and sends the entire test scenario shown
above to it - while showing the responses received from it.
* **test-arduino**: Sends the entire test scenario shown above to an
Arduino Uno connected to the port specified in `config.mk`
and shows the responses received over that serial port.
Another example of automation - the complete test scenario shown in the
previous section, is not just an example in the documentation; it is
extracted automatically from this text and fed into the Valgrind and
AddressSanitizer tests... and also into the Python testing script that
sends the data to the board in real-time.
[DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself), folks.
# Conclusion
I thoroughly enjoyed building this. I know full well that Forths are not
supposed to be built in C++; they are supposed to be built in assembly,
and also, utilise the Flash to store the user-compiled code at run-time.
But that wasn't the point of this - the point was to have fun and learn Forth.
What better way to learn a language... than to actually implement it! :-)
And... as a child of the 80s... I now know first-hand what
[Jupiter Ace](https://en.wikipedia.org/wiki/Jupiter_Ace) was about :-)
Fork the code, and enjoy tinkering with it!
---
[![profile for ttsiodras at Stack Overflow, Q&A for professional and enthusiast programmers](382050.png "profile for ttsiodras at Stack Overflow, Q&A for professional and enthusiast programmers")](https://stackoverflow.com/users/382050/ttsiodras)
[![GitHub member ttsiodras](github.png "GitHub member ttsiodras")](https://github.com/ttsiodras)
| | | |
| --- | --- | --- |
| [Index](index.html) | [CV](cv.pdf) | *Updated: Sun Nov 19 23:06:10 2023* |

View File

@@ -0,0 +1,17 @@
# C2-Wiki: Chuck Moore
**Source:** https://wiki.c2.com/?ChuckMoore
**notice**
javascript required to view this site
**why**
measured improvement in server performance
awesome incremental search
![](spin.gif)
This site uses features not available in older browsers.

View File

@@ -0,0 +1,17 @@
# C2-Wiki: colorFORTH
**Source:** https://wiki.c2.com/?ColorForth
**notice**
javascript required to view this site
**why**
measured improvement in server performance
awesome incremental search
![](spin.gif)
This site uses features not available in older browsers.

View File

@@ -0,0 +1,422 @@
# Callisto
**Source:** https://github.com/callisto-lang/compiler
GitHub - callisto-lang/compiler: The Callisto compiler of the 13th month, and other language extras
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fcallisto-lang%2Fcompiler)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fcallisto-lang%2Fcompiler)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=callisto-lang%2Fcompiler)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[callisto-lang](/callisto-lang)
/
**[compiler](/callisto-lang/compiler)**
Public
* [Notifications](/login?return_to=%2Fcallisto-lang%2Fcompiler) You must be signed in to change notification settings
* [Fork
8](/login?return_to=%2Fcallisto-lang%2Fcompiler)
* [Star
76](/login?return_to=%2Fcallisto-lang%2Fcompiler)
The Callisto compiler of the 13th month, and other language extras
[callisto.mesyeti.uk](https://callisto.mesyeti.uk "https://callisto.mesyeti.uk")
### License
[MIT license](/callisto-lang/compiler/blob/main/LICENSE)
[76
stars](/callisto-lang/compiler/stargazers) [8
forks](/callisto-lang/compiler/forks) [Branches](/callisto-lang/compiler/branches) [Tags](/callisto-lang/compiler/tags) [Activity](/callisto-lang/compiler/activity)
[Star](/login?return_to=%2Fcallisto-lang%2Fcompiler)
[Notifications](/login?return_to=%2Fcallisto-lang%2Fcompiler) You must be signed in to change notification settings
* [Code](/callisto-lang/compiler)
* [Issues
0](/callisto-lang/compiler/issues)
* [Pull requests
0](/callisto-lang/compiler/pulls)
* [Actions](/callisto-lang/compiler/actions)
* [Projects
0](/callisto-lang/compiler/projects)
* [Security
0](/callisto-lang/compiler/security)
* [Insights](/callisto-lang/compiler/pulse)
Additional navigation options
* [Code](/callisto-lang/compiler)
* [Issues](/callisto-lang/compiler/issues)
* [Pull requests](/callisto-lang/compiler/pulls)
* [Actions](/callisto-lang/compiler/actions)
* [Projects](/callisto-lang/compiler/projects)
* [Security](/callisto-lang/compiler/security)
* [Insights](/callisto-lang/compiler/pulse)
# callisto-lang/compiler
main
[Branches](/callisto-lang/compiler/branches)[Tags](/callisto-lang/compiler/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[474 Commits](/callisto-lang/compiler/commits/main/) 474 Commits | | |
| [.gitub-temp-disabled/workflows](/callisto-lang/compiler/tree/main/.gitub-temp-disabled/workflows "This path skips through empty directories") | | [.gitub-temp-disabled/workflows](/callisto-lang/compiler/tree/main/.gitub-temp-disabled/workflows "This path skips through empty directories") | | |
| [docs](/callisto-lang/compiler/tree/main/docs "docs") | | [docs](/callisto-lang/compiler/tree/main/docs "docs") | | |
| [editors](/callisto-lang/compiler/tree/main/editors "editors") | | [editors](/callisto-lang/compiler/tree/main/editors "editors") | | |
| [examples](/callisto-lang/compiler/tree/main/examples "examples") | | [examples](/callisto-lang/compiler/tree/main/examples "examples") | | |
| [source](/callisto-lang/compiler/tree/main/source "source") | | [source](/callisto-lang/compiler/tree/main/source "source") | | |
| [std @ 4c0918c](/callisto-lang/std/tree/4c0918cfa12a9b80f65732b044a0a0c11365204e "std") | | [std @ 4c0918c](/callisto-lang/std/tree/4c0918cfa12a9b80f65732b044a0a0c11365204e "std") | | |
| [.gitattributes](/callisto-lang/compiler/blob/main/.gitattributes ".gitattributes") | | [.gitattributes](/callisto-lang/compiler/blob/main/.gitattributes ".gitattributes") | | |
| [.gitignore](/callisto-lang/compiler/blob/main/.gitignore ".gitignore") | | [.gitignore](/callisto-lang/compiler/blob/main/.gitignore ".gitignore") | | |
| [.gitmodules](/callisto-lang/compiler/blob/main/.gitmodules ".gitmodules") | | [.gitmodules](/callisto-lang/compiler/blob/main/.gitmodules ".gitmodules") | | |
| [LICENSE](/callisto-lang/compiler/blob/main/LICENSE "LICENSE") | | [LICENSE](/callisto-lang/compiler/blob/main/LICENSE "LICENSE") | | |
| [README.md](/callisto-lang/compiler/blob/main/README.md "README.md") | | [README.md](/callisto-lang/compiler/blob/main/README.md "README.md") | | |
| [STYLE.md](/callisto-lang/compiler/blob/main/STYLE.md "STYLE.md") | | [STYLE.md](/callisto-lang/compiler/blob/main/STYLE.md "STYLE.md") | | |
| [TODO.md](/callisto-lang/compiler/blob/main/TODO.md "TODO.md") | | [TODO.md](/callisto-lang/compiler/blob/main/TODO.md "TODO.md") | | |
| [dub.json](/callisto-lang/compiler/blob/main/dub.json "dub.json") | | [dub.json](/callisto-lang/compiler/blob/main/dub.json "dub.json") | | |
| [flake.nix](/callisto-lang/compiler/blob/main/flake.nix "flake.nix") | | [flake.nix](/callisto-lang/compiler/blob/main/flake.nix "flake.nix") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [MIT license](#)
[![](https://camo.githubusercontent.com/4bdb739c0513e67abf8868948c01b60d12189f18d85f06ebb6abd6cf6e156804/68747470733a2f2f63616c6c6973746f2e6d6573796574692e756b2f6c6f676f5f736861646f772e706e67)](https://camo.githubusercontent.com/4bdb739c0513e67abf8868948c01b60d12189f18d85f06ebb6abd6cf6e156804/68747470733a2f2f63616c6c6973746f2e6d6573796574692e756b2f6c6f676f5f736861646f772e706e67)
# The Callisto Programming Language
[Website](https://callisto.mesyeti.uk/) |
[Docs](https://callisto.mesyeti.uk/docs) |
[Awesome List](https://github.com/callisto-lang/awesome-callisto) |
[Discord](https://discord.com/invite/QHAtc4GWq7)
**Callisto** is a stack-based imperative programming language with stack safety enforced
by the compiler (which is optional).
It also has a subset called CallistoScript made to compile to scripting languages like
Lua, while keeping its low level features (like direct access to memory).
## Supported targets
* x86 real mode - MS-DOS, bare metal
* x86\_64 - Linux, macOS, FreeBSD (partial)
* ARM64 - Linux, macOS
* Uxn - Varvara
* Lua
## Build
```
dub build --compiler=ldc
```
The compiler executable will be called `cac`
Warning
Compilation may freeze due to a bug in the Digital Mars D compiler. If this happens,
compile with this command: `dub build --compiler=ldc`.
If that doesn't work, then run with `--compiler=ldc2` instead.
## Run example programs
Make sure you get the standard library
```
git submodule update --remote
```
Then compile example programs like this
```
cac examples/exampleNameHere.cal -i std
```
The output executable will be called `out`. Any example programs that require extra flags
for compilation will have a compile command in a comment at the top of the source file.
## IRC Channel
Join `#callisto-lang` on irc.libera.chat.
## About
The Callisto compiler of the 13th month, and other language extras
[callisto.mesyeti.uk](https://callisto.mesyeti.uk "https://callisto.mesyeti.uk")
### Topics
[programming-language](/topics/programming-language "Topic: programming-language")
[compiler](/topics/compiler "Topic: compiler")
[x86-64](/topics/x86-64 "Topic: x86-64")
[concatenative](/topics/concatenative "Topic: concatenative")
[concatenative-language](/topics/concatenative-language "Topic: concatenative-language")
[concatenative-programming-language](/topics/concatenative-programming-language "Topic: concatenative-programming-language")
[uxn](/topics/uxn "Topic: uxn")
[uxntal](/topics/uxntal "Topic: uxntal")
### Resources
[Readme](#readme-ov-file)
### License
[MIT license](#MIT-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/callisto-lang/compiler/activity)
[Custom properties](/callisto-lang/compiler/custom-properties)
### Stars
[**76**
stars](/callisto-lang/compiler/stargazers)
### Watchers
[**1**
watching](/callisto-lang/compiler/watchers)
### Forks
[**8**
forks](/callisto-lang/compiler/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fcallisto-lang%2Fcompiler&report=callisto-lang+%28user%29)
## [Releases 23](/callisto-lang/compiler/releases)
[Beta 0.13.0 - Modules part 1
Latest
Nov 15, 2025](/callisto-lang/compiler/releases/tag/b0.13.0)
[+ 22 releases](/callisto-lang/compiler/releases)
## [Packages 0](/orgs/callisto-lang/packages?repo_name=compiler)
No packages published
### Uh oh!
There was an error while loading. Please reload this page.
## [Contributors 7](/callisto-lang/compiler/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [D
99.6%](/callisto-lang/compiler/search?l=d)
* [Nix
0.4%](/callisto-lang/compiler/search?l=nix)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,98 @@
# Cognate
**Source:** https://cognate-lang.github.io
Cognate: Readable and concise concatenative programming
# Cognate
## Readable and concise concatenative programming
```
~~ Fizzbuzz in Cognate
Def Fizzbuzz (
Let N be Of (Integer?);
Def Multiple as (Zero? Modulo Swap N);
If Multiple of 15 then "fizzbuzz"
If Multiple of 3 then "fizz"
If Multiple of 5 then "buzz"
else N
);
For each in Range 1 to 100 (Print Fizzbuzz);
```
Cognate is a project aiming to create a human readable programming language with as little syntax as possible. Where natural language programming usually uses many complex syntax rules, instead Cognate takes them away. What it adds is simple, a way to embed comments into statements.
```
~~ Towers of Hanoi in Cognate
Def Move discs as (
Let N be number of discs;
Let A be first rod;
Let B be second rod;
Let C be third rod;
Unless Zero? N (
Move - 1 N discs from A via C to B;
Prints ("Move disc " N " from " A " to " C);
Move - 1 N discs from B via A to C;
)
);
Move 5 discs from "a" via "b" to "c";
```
As you can see, Cognate ignores words starting with lowercase letters, allowing them to be used to describe functionality and enhance readability. This makes Cognate codebases intuitive and maintainable.
```
~~ Square numbers in Cognate
Def Square as (* Twin);
Map (Square) over Range 1 to 10;
Print;
```
Cognate is a stack-oriented programming language similar to Forth or Factor, except statements are evaluated right to left. This gives the expressiveness of concatenative programming as well as the readability of prefix notation. Statements can be delimited at arbitrary points, allowing them to read as sentences would in English.
```
~~ Prime numbers in Cognate
Def Factor (Zero? Modulo Swap);
Def Primes (
Fold (
Let I be our potential prime;
Let Primes are the found primes;
Let To-check be Take-while (<= Sqrt I) Primes;
When None (Factor of I) To-check
(Append List (I)) to Primes;
) from List () over Range from 2
);
Print Primes up to 1000;
```
Cognate borrows from other concatenative languages, but also adds unique features of its own.
* Point-free functions
* Operation chaining
* Multiple return values
* Combinator oriented programming
* Predicate pattern matching
* Natural language programming
Interested? Read the [tutorial](/learn/), and check out one of Cognates implementations:
* [CognaC](https://github.com/cognate-lang/cognate) is the original compiler it performs type inference and produces efficient binaries.
* [Cognate Playground](https://cognate-playground.hedy.dev/) (developed by [hedyhli](https://github.com/hedyhli)) runs Cognate programs in a web browser.
* [Cogni](https://github.com/dragoncoder047/cogni) (developed by [dragoncoder047](https://github.com/dragoncoder047)) interprets Cognate programs and is optimised to run on microcontrollers.

View File

@@ -0,0 +1,389 @@
# Color
**Source:** https://github.com/AshleyF/Color/tree/master
GitHub - AshleyF/Color: Fun playing around with colorForth and GreenArrays architecture.
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2FAshleyF%2FColor%2Ftree%2Fmaster)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2FAshleyF%2FColor%2Ftree%2Fmaster)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=AshleyF%2FColor)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[AshleyF](/AshleyF)
/
**[Color](/AshleyF/Color)**
Public
* [Notifications](/login?return_to=%2FAshleyF%2FColor) You must be signed in to change notification settings
* [Fork
22](/login?return_to=%2FAshleyF%2FColor)
* [Star
135](/login?return_to=%2FAshleyF%2FColor)
Fun playing around with colorForth and GreenArrays architecture.
### License
[Unlicense license](/AshleyF/Color/blob/master/LICENSE)
[135
stars](/AshleyF/Color/stargazers) [22
forks](/AshleyF/Color/forks) [Branches](/AshleyF/Color/branches) [Tags](/AshleyF/Color/tags) [Activity](/AshleyF/Color/activity)
[Star](/login?return_to=%2FAshleyF%2FColor)
[Notifications](/login?return_to=%2FAshleyF%2FColor) You must be signed in to change notification settings
* [Code](/AshleyF/Color)
* [Issues
0](/AshleyF/Color/issues)
* [Pull requests
0](/AshleyF/Color/pulls)
* [Actions](/AshleyF/Color/actions)
* [Projects
0](/AshleyF/Color/projects)
* [Wiki](/AshleyF/Color/wiki)
* [Security
0](/AshleyF/Color/security)
* [Insights](/AshleyF/Color/pulse)
Additional navigation options
* [Code](/AshleyF/Color)
* [Issues](/AshleyF/Color/issues)
* [Pull requests](/AshleyF/Color/pulls)
* [Actions](/AshleyF/Color/actions)
* [Projects](/AshleyF/Color/projects)
* [Wiki](/AshleyF/Color/wiki)
* [Security](/AshleyF/Color/security)
* [Insights](/AshleyF/Color/pulse)
# AshleyF/Color
master
[Branches](/AshleyF/Color/branches)[Tags](/AshleyF/Color/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[67 Commits](/AshleyF/Color/commits/master/) 67 Commits | | |
| [Assembler](/AshleyF/Color/tree/master/Assembler "Assembler") | | [Assembler](/AshleyF/Color/tree/master/Assembler "Assembler") | | |
| [Blocks](/AshleyF/Color/tree/master/Blocks "Blocks") | | [Blocks](/AshleyF/Color/tree/master/Blocks "Blocks") | | |
| [Docs](/AshleyF/Color/tree/master/Docs "Docs") | | [Docs](/AshleyF/Color/tree/master/Docs "Docs") | | |
| [Editor](/AshleyF/Color/tree/master/Editor "Editor") | | [Editor](/AshleyF/Color/tree/master/Editor "Editor") | | |
| [Machine](/AshleyF/Color/tree/master/Machine "Machine") | | [Machine](/AshleyF/Color/tree/master/Machine "Machine") | | |
| [Synthesis](/AshleyF/Color/tree/master/Synthesis "Synthesis") | | [Synthesis](/AshleyF/Color/tree/master/Synthesis "Synthesis") | | |
| [Utility](/AshleyF/Color/tree/master/Utility "Utility") | | [Utility](/AshleyF/Color/tree/master/Utility "Utility") | | |
| [.gitignore](/AshleyF/Color/blob/master/.gitignore ".gitignore") | | [.gitignore](/AshleyF/Color/blob/master/.gitignore ".gitignore") | | |
| [Color.sln](/AshleyF/Color/blob/master/Color.sln "Color.sln") | | [Color.sln](/AshleyF/Color/blob/master/Color.sln "Color.sln") | | |
| [LICENSE](/AshleyF/Color/blob/master/LICENSE "LICENSE") | | [LICENSE](/AshleyF/Color/blob/master/LICENSE "LICENSE") | | |
| [README.md](/AshleyF/Color/blob/master/README.md "README.md") | | [README.md](/AshleyF/Color/blob/master/README.md "README.md") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [Unlicense license](#)
# Color
Having fun playing around with [colorForth](http://www.colorforth.com/cf.htm) and [GreenArrays](http://www.greenarraychips.com/) architecture. See the [demo](https://youtu.be/LYtQMmvgg6w) presented to the [Forth2020 Group](http://www.forth2020.org/) in AUG 2021 and [~~blog series~~](http://blogs.msdn.com/b/ashleyf/archive/tags/color/) - Blog series moved here to Github:
* [Chuck Moore's Creations](/AshleyF/Color/blob/master/Docs/chuck_moores_creations.md)
* [Programming the F18](/AshleyF/Color/blob/master/Docs/programming_the_f18.md)
* [Beautiful Simplicity of colorForth](/AshleyF/Color/blob/master/Docs/beautiful_simplicity.md)
* [Multiply-step Instruction](/AshleyF/Color/blob/master/Docs/multiply_step.md)
* [Simple Variables](/AshleyF/Color/blob/master/Docs/simple_variables.md)
[![Editor/Assembler](/AshleyF/Color/raw/master/Docs/images/editor_assembler.png)](/AshleyF/Color/blob/master/Docs/images/editor_assembler.png)
The assembler watches for changes to the block files saved by the editor. I leave an instance of this running in one terminal window (right) while working in the editor in another (left). Later I run the machine in a third window.
## Setup
Everything is written in F# and uses solution (`.sln`) and project (`.fsproj`) files compatible with Visual Studio or `dotnet build`. I personally have been using plain Vim (with the [excellent F# bindings](https://github.com/fsharp/fsharpbinding)). Here's setup steps for Ubuntu:
**Install .NET Core**
* Install the [.NET SDK](https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu). For example, for *Ubuntu 21.04* in particular:
```
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y apt-transport-https
sudo apt-get update
sudo apt-get install -y dotnet-sdk-5.0
```
**Pull down the project**
```
git clone http://github.com/AshleyF/Color
```
**Build**
```
dotnet build Color.sln
```
Each project produces an executable (`Assembler.exe`, `Editor.exe`, `Machine.exe`) within `bin/`
**Play!**
The editor edits block files (`/Blocks/*.blk`) while the assembler waits for changes to blocks and assembles them (to block 0). Running the machine executes block 0.
The normal way of working is to run the `./Editor` and `./Assembler` at the same time (in separate tabs or tmux splits, etc.). Each time a block is saved (by pressing `s` in the editor), it's assembled. Then run the `./Machine` to try it out.
## About
Fun playing around with colorForth and GreenArrays architecture.
### Resources
[Readme](#readme-ov-file)
### License
[Unlicense license](#Unlicense-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/AshleyF/Color/activity)
### Stars
[**135**
stars](/AshleyF/Color/stargazers)
### Watchers
[**8**
watching](/AshleyF/Color/watchers)
### Forks
[**22**
forks](/AshleyF/Color/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2FAshleyF%2FColor&report=AshleyF+%28user%29)
## [Releases](/AshleyF/Color/releases)
No releases published
## [Packages 0](/users/AshleyF/packages?repo_name=Color)
No packages published
### Uh oh!
There was an error while loading. Please reload this page.
## [Contributors 2](/AshleyF/Color/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [F#
100.0%](/AshleyF/Color/search?l=f%23)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,185 @@
# Concatenative language
**Source:** https://concatenative.org/wiki/view/Concatenative%20language
Concatenative language
![](data:image/svg+xml;utf8,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 xmlns:xlink=%27http://www.w3.org/1999/xlink%27 width=%2724%27 height=%2716%27 viewBox=%270 0 120 100%27 fill=%27rgb(0,0,0)%27%3E%3Crect y=%270%27 width=%27120%27 height=%2720%27 rx=%2710%27 /%3E%3Crect y=%2740%27 width=%27120%27 height=%2720%27 rx=%2710%27 /%3E%3Crect y=%2780%27 width=%27120%27 height=%2720%27 rx=%2710%27 /%3E%3C/svg%3E)
[Front Page](https://concatenative.org/wiki/)
[All Articles](https://concatenative.org/wiki/articles)
[Recent Changes](https://concatenative.org/wiki/changes)
[Random Article](https://concatenative.org/wiki/random)
## [Contents](https://concatenative.org/wiki/view/Contents)
[Concatenative language](https://concatenative.org/wiki/view/Concatenative%20language)
* [ACL](https://concatenative.org/wiki/view/ACL)
* [Ait](https://concatenative.org/wiki/view/Ait)
* [Aocla](https://concatenative.org/wiki/view/Aocla)
* [Breeze](https://concatenative.org/wiki/view/Breeze)
* [Callisto](https://concatenative.org/wiki/view/Callisto)
* [Cat](https://concatenative.org/wiki/view/Cat)
* [Cognate](https://concatenative.org/wiki/view/Cognate)
* [colorForth](https://concatenative.org/wiki/view/colorForth)
* [Concata](https://concatenative.org/wiki/view/Concata)
* [CoSy](https://concatenative.org/wiki/view/CoSy)
* [Deque](https://concatenative.org/wiki/view/Deque)
* [DSSP](https://concatenative.org/wiki/view/DSSP)
* [dt](https://concatenative.org/wiki/view/dt)
* [Elymas](https://concatenative.org/wiki/view/Elymas)
* [Enchilada](https://concatenative.org/wiki/view/Enchilada)
* [ERIShell](https://concatenative.org/wiki/view/ERIShell)
* [ETAC](https://concatenative.org/wiki/view/ETAC)
* [F](https://concatenative.org/wiki/view/F)
* [Factor](https://concatenative.org/wiki/view/Factor)
* [Fiveth](https://concatenative.org/wiki/view/Fiveth)
* [Forth](https://concatenative.org/wiki/view/Forth)
* [Fourth](https://concatenative.org/wiki/view/Fourth)
* [Freelang](https://concatenative.org/wiki/view/Freelang)
* [Gershwin](https://concatenative.org/wiki/view/Gershwin)
* [hex](https://concatenative.org/wiki/view/hex)
* [iNet](https://concatenative.org/wiki/view/iNet)
* [Joy](https://concatenative.org/wiki/view/Joy)
* [Joy of Postfix](https://concatenative.org/wiki/view/Joy%20of%20Postfix) *App*
* [kcats](https://concatenative.org/wiki/view/kcats)
* [Kitten](https://concatenative.org/wiki/view/Kitten)
* [lang5](https://concatenative.org/wiki/view/lang5)
* [Listack](https://concatenative.org/wiki/view/Listack)
* [LSE64](https://concatenative.org/wiki/view/LSE64)
* [Lviv](https://concatenative.org/wiki/view/Lviv)
* [Meow5](https://concatenative.org/wiki/view/Meow5)
* [min](https://concatenative.org/wiki/view/min)
* [Mirth](https://concatenative.org/wiki/view/Mirth)
* [mjoy](https://concatenative.org/wiki/view/mjoy)
* [Mlatu](https://concatenative.org/wiki/view/Mlatu)
* [Ode](https://concatenative.org/wiki/view/Ode)
* [OForth](https://concatenative.org/wiki/view/OForth)
* [Om](https://concatenative.org/wiki/view/Om)
* [Onion](https://concatenative.org/wiki/view/Onion)
* [Onyx](https://concatenative.org/wiki/view/Onyx)
* [Plorth](https://concatenative.org/wiki/view/Plorth)
* [Popr](https://concatenative.org/wiki/view/Popr)
* [Porth](https://concatenative.org/wiki/view/Porth)
* [PostScript](https://concatenative.org/wiki/view/PostScript)
* [Prowl](https://concatenative.org/wiki/view/Prowl)
* [Quackery](https://concatenative.org/wiki/view/Quackery)
* [Quadrate](https://concatenative.org/wiki/view/Quadrate)
* [Quest32](https://concatenative.org/wiki/view/Quest32)
* [r3](https://concatenative.org/wiki/view/r3)
* [Raven](https://concatenative.org/wiki/view/Raven)
* [Retro](https://concatenative.org/wiki/view/Retro)
* [RPL](https://concatenative.org/wiki/view/RPL)
* [SPL](https://concatenative.org/wiki/view/SPL)
* [Staapl](https://concatenative.org/wiki/view/Staapl)
* [Stabel](https://concatenative.org/wiki/view/Stabel)
* [Tal](https://concatenative.org/wiki/view/Tal)
* [Titan](https://concatenative.org/wiki/view/Titan)
* [Trith](https://concatenative.org/wiki/view/Trith)
* [Uiua](https://concatenative.org/wiki/view/Uiua)
* [Worst](https://concatenative.org/wiki/view/Worst)
* [xs](https://concatenative.org/wiki/view/xs)
* [XY](https://concatenative.org/wiki/view/XY)
* [5th](https://concatenative.org/wiki/view/5th)
* [8th](https://concatenative.org/wiki/view/8th)
Concatenative topics
* [Compilers](https://concatenative.org/wiki/view/Compilers)
* [Interpreters](https://concatenative.org/wiki/view/Interpreters)
* [Type systems](https://concatenative.org/wiki/view/Type%20systems)
* [Object systems](https://concatenative.org/wiki/view/Object%20systems)
* [Quotations](https://concatenative.org/wiki/view/Quotations)
* [Variables](https://concatenative.org/wiki/view/Variables)
* [Garbage collection](https://concatenative.org/wiki/view/Garbage%20collection)
* [Example programs](https://concatenative.org/wiki/view/Example%20programs)
Concatenative meta
* [People](https://concatenative.org/wiki/view/People)
* [Communities](https://concatenative.org/wiki/view/Communities)
* [Events](https://concatenative.org/wiki/view/Events)
Other languages
* [APL](https://concatenative.org/wiki/view/APL)
* [C++](https://concatenative.org/wiki/view/C%2B%2B)
* [Erlang](https://concatenative.org/wiki/view/Erlang)
* [FP trivia](https://concatenative.org/wiki/view/FP%20trivia)
* [Haskell](https://concatenative.org/wiki/view/Haskell)
* [Io](https://concatenative.org/wiki/view/Io)
* [Java](https://concatenative.org/wiki/view/Java)
* [JavaScript](https://concatenative.org/wiki/view/JavaScript)
* [Lisp](https://concatenative.org/wiki/view/Lisp)
* [ML](https://concatenative.org/wiki/view/ML)
* [Oberon](https://concatenative.org/wiki/view/Oberon)
* [RPL](https://concatenative.org/wiki/view/RPL)
* [Self](https://concatenative.org/wiki/view/Self)
* [Slate](https://concatenative.org/wiki/view/Slate)
* [Smalltalk](https://concatenative.org/wiki/view/Smalltalk)
Meta
* [**Search**](http://www.google.com/custom?hl=en&cof=&domains=concatenative.org&btnG=Search&sitesearch=concatenative.org)
* [Farkup wiki format](https://concatenative.org/wiki/view/Farkup)
* [Etiquette](https://concatenative.org/wiki/view/Etiquette)
* [Sandbox](https://concatenative.org/wiki/view/Sandbox)
# Concatenative language
There are many ways to categorize programming languages; one is to define them as either "concatenative" or "applicative". In an applicative language, things are evaluated by applying functions to arguments. This includes almost all programming languages in wide use, such as [C](https://concatenative.org/wiki/view/C), [Python](https://concatenative.org/wiki/view/Python), [ML](https://concatenative.org/wiki/view/ML), [Haskell](https://concatenative.org/wiki/view/Haskell), and [Java](https://concatenative.org/wiki/view/Java). In a concatenative programming language, things are evaluated by composing several functions which all operate on a single piece of data, passed from function to function. This piece of data is usually in the form of a stack. Additionally, in concatenative languages, this function composition is indicated by concatenating programs. Examples of concatenative languages include [Forth](https://concatenative.org/wiki/view/Forth), [Joy](https://concatenative.org/wiki/view/Joy), [PostScript](https://concatenative.org/wiki/view/PostScript), [Cat](https://concatenative.org/wiki/view/Cat), and [Factor](https://concatenative.org/wiki/view/Factor).
# Concatenative and stack languages
Although the terms *stack language* and *concatenative language* sometimes get thrown around interchangeably, they actually represent similar but distinct classes of languages. A concatenative language is not necessarily a stack language. For example, [Om](https://concatenative.org/wiki/view/Om) uses prefix notation, rather than postfix, and passes the remainder of the program as the data from function to function. See [Deque](https://concatenative.org/wiki/view/Deque) for another example of a stack-free concatenative language.
Stacks are a pretty fundamental concept in computer science, and many languages use stacks internally in the implementation. Any language that allows recursive definitions uses some type of call stack to save return addresses between function calls, and often the same stack is used to spill values which cannot be allocated in registers. However, this is just implementation detail, and this call stack is not exposed directly to the programmer (except in languages with first-class continuations; I'll touch upon this later).
So what makes stack languages different? The key concept here is that there are *multiple* stacks: all stack languages have a call stack to support recursion, but they also have a data stack (sometimes called an operand stack) to pass values between functions. The latter is what stack language programmers mean when they talk about "the" stack.
Most languages in widespread use today are *applicative languages*: the central construct in the language is some form of function call, where a function is *applied* to a set of parameters, where each parameter is itself the result of a function call, the name of a variable, or a constant. In stack languages, a function call is made by simply writing the name of the function; the parameters are implicit, and they have to *already* be on the stack when the call is made. The result of the function call (if any) is then left on the stack after the function returns, for the next function to consume, and so on. Because functions are invoked simply by mentioning their name without any additional syntax, Forth and Factor refer to functions as "words", because in the syntax they really are just words.
# One mutable stack or functions from stacks to stacks?
Sometimes, people talk about words pushing and popping values on "the stack". Other programmers, mostly those who prefer the term "concatenative language", instead talk about words as being functions which take a stack as input, and return a whole new stack as output. The first point of view is more intuitive, and it is also how most implementations work: there really is a location in memory that is the data stack. The latter is more amenable to formal reasoning: it is easier to work with rewrite rules and type systems if your functions are pure. However, these two points of view are equivalent: because in a given thread of execution, only one stack is "live" at any given point in time, updating the stack in-place has the same semantics as the purely functional world view. More details about this can be found in [Manfred von Thun](https://concatenative.org/wiki/view/Manfred%20von%20Thun)'s paper [Mathematical Foundations of Joy](https://hypercubed.github.io/joy/html/j02maf.html).
# Fundamentals of concatenative languages
* [Name code not values](https://concatenative.org/wiki/view/Concatenative%20language/Name%20code%20not%20values)
* [Multiple return values](https://concatenative.org/wiki/view/Concatenative%20language/Multiple%20return%20values)
* [Concatenation is composition](https://concatenative.org/wiki/view/Concatenative%20language/Concatenation%20is%20composition)
* [Left to right evaluation](https://concatenative.org/wiki/view/Concatenative%20language/Left%20to%20right%20evaluation)
# Concatenative idioms
* [Keyword parameters](https://concatenative.org/wiki/view/Concatenative%20language/Keyword%20parameters)
* [Rest parameters](https://concatenative.org/wiki/view/Concatenative%20language/Rest%20parameters)
* [Pipeline style](https://concatenative.org/wiki/view/Pipeline%20style)
# Other interesting properties
* [Concision](https://concatenative.org/wiki/view/Concatenative%20language/Concision)
* [Simplicity](https://concatenative.org/wiki/view/Concatenative%20language/Simplicity)
* [Meta-programming](https://concatenative.org/wiki/view/Concatenative%20language/Meta-programming)
* [Continuations](https://concatenative.org/wiki/view/Concatenative%20language/Continuations)
* [Interactive development](https://concatenative.org/wiki/view/Concatenative%20language/Interactive%20development)
# Publications
* [Publications](https://concatenative.org/wiki/view/Concatenative%20language/Publications)
*This revision created on Fri, 10 Sep 2021 18:36:34 by [AliAsshole](https://concatenative.org/wiki/user-edits/AliAsshole)
(Replaced dead link with live one)*
[Latest](https://concatenative.org/wiki/view/Concatenative%20language)
[Revisions](https://concatenative.org/wiki/revisions/Concatenative%20language)
[Edit](https://concatenative.org/wiki/edit/Concatenative%20language)
Delete
All content is © 2008-2024 by its respective authors. By adding content to this wiki, you agree to release it under the [BSD license](https://factorcode.org/license.txt).

View File

@@ -0,0 +1,71 @@
# Factor
**Source:** https://factorcode.org
Factor programming language
![Factor programming language](logo.png)
# Why Factor
The **Factor programming language** is a [concatenative](http://www.concatenative.org/), stack-based programming language with [high-level features](http://concatenative.org/wiki/view/Factor/Features/The%20language) including dynamic types, extensible syntax, macros, and garbage collection. On a practical side, Factor has a [full-featured library](http://docs.factorcode.org/content/article-vocab-index.html), supports many different platforms, and has been extensively documented.
The implementation is [fully compiled](http://concatenative.org/wiki/view/Factor/Optimizing%20compiler) for performance, while still supporting [interactive development](http://concatenative.org/wiki/view/Factor/Interactive%20development). Factor applications are portable between all common platforms. Factor can [deploy stand-alone applications](http://concatenative.org/wiki/view/Factor/Deployment) on all platforms. Full [source code](https://github.com/factor/factor) for the Factor project is available under a [BSD license](https://factorcode.org/license.txt).
* [Learn more about Factor](https://concatenative.org/wiki/view/Factor)
* [Get started programming with Factor](https://concatenative.org/wiki/view/Factor/Learning)
* [Get answers to frequently-asked questions](https://concatenative.org/wiki/view/Factor/FAQ)
* [Read Factor documentation online](https://docs.factorcode.org/)
* [Learn about concatenative programming](https://concatenative.org/wiki/view/Concatenative%20language)
* [See some example programs](https://concatenative.org/wiki/view/Factor/Examples)
* [Report a bug](https://github.com/factor/factor/issues)
* Screenshots on [macOS](https://factorcode.org/factor-macos.png), [Windows](https://factorcode.org/factor-windows7.png)
```
USING: io kernel sequences ;
4 <iota> [
"Happy Birthday " write
2 = "dear NAME" "to You" ? print
] each
```
# Downloads
To download a binary, follow the link for the desired OS / CPU configuration. Binary packages are the recommended route for new users who wish to try Factor.
## Stable release: [0.101](https://re.factorcode.org/2025/12/factor-0-101-now-available.html)
| OS/CPU | Windows | macOS | Linux |
| --- | --- | --- | --- |
| x86 | [0.101](https://builds.factorcode.org/release?os=windows&cpu=x86.32) | | [0.101](https://builds.factorcode.org/release?os=linux&cpu=x86.32) |
| x86-64 | [0.101](https://builds.factorcode.org/release?os=windows&cpu=x86.64) | [0.101](https://builds.factorcode.org/release?os=macos&cpu=x86.64) | [0.101](https://builds.factorcode.org/release?os=linux&cpu=x86.64) |
**Source code**:
[0.101](https://downloads.factorcode.org/releases/0.101/factor-src-0.101.zip)
## Development release
| OS/CPU | Windows | macOS | Linux |
| --- | --- | --- | --- |
| x86 | [2025-12-17](https://builds.factorcode.org/package?os=windows&cpu=x86.32) | | [2026-02-11](https://builds.factorcode.org/package?os=linux&cpu=x86.32) |
| x86-64 | [2025-12-17](https://builds.factorcode.org/package?os=windows&cpu=x86.64) | [2026-02-09](https://builds.factorcode.org/package?os=macos&cpu=x86.64) | [2026-02-11](https://builds.factorcode.org/package?os=linux&cpu=x86.64) |
**Source code**: available via [github](https://github.com/factor/factor/) or [gitweb](https://gitweb.factorcode.org/) or [cgit](https://cgit.factorcode.org/).
Stable and development releases are built and uploaded by the [build farm](https://concatenative.org/wiki/view/Factor/Build%20farm). Follow [@FactorBuilds](https://twitter.com/FactorBuilds) on Twitter to receive notifications. If you're curious, take a look at the [build farm dashboard](https://builds.factorcode.org/dashboard). You can also [build Factor](https://concatenative.org/wiki/view/Factor/Building%20Factor) on your own platform from source.
## Older releases
[Download older releases](https://downloads.factorcode.org/releases/) from [Factor 0.29](https://downloads.factorcode.org/releases/0.29/) to the current release.
# Community
* [Join the mailing list](https://concatenative.org/wiki/view/Factor/Mailing%20list)
* [Join the Discord](https://discord.gg/QxJYZx3QDf)
* [Join the IRC channel](https://concatenative.org/wiki/view/Concatenative%20IRC%20channel)
* [Factor community blogs](https://planet.factorcode.org/)
* [Factor community pastebin](https://paste.factorcode.org/) - if you're in an IRC channel and want to share some code
* [Academic publications](https://concatenative.org/wiki/view/Concatenative%20language/Publications)

View File

@@ -0,0 +1,377 @@
# Forth- The Early Years
**Source:** https://colorforth.github.io/HOPL.html
Chuck Moore: The Invention of Forth
# Forth - The Early Years
Chuck Moore
[chipchuck@colorforth.com](mailto:chipchuck@colorforth.com)
1991
## Abstract
Forth is a simple, natural computer language. It has achieved remarkable acceptance where efficiency is valued. It evolved in the 1960s on a journey from university through business to laboratory. This is the story of how a simple interpreter expanded its abilities to become a complete programming language/operating system.
## Forward 1999
This paper was written for the HOPL II (History of programming languages) conference. It was summarily rejected, apparently because of its style. Much of the content was included in the accepted paper [Rather 1993].
This HTML version was reformatted from the original typescript. Minimal changes were made to the text. Examples of source code were suggested by reviewer Phil Koopman. They've not yet been added.
## Contents
Forth
MIT, SAO, 1958
Stanford, SLAC, 1961
Free-lance, 1965
Mohasco, 1968
NRAO, 1971
Moral
## Forth
Forth evolved during the decade of the 60s, across America, within university, business and laboratory, amongst established languages. During this period, I was its only programmer and it had no name until the end. This account is retrieved from memory, prompted by sparse documentation and surviving listings.
Forth is hardly original, but it is a unique combination of ingredients. I'm grateful to the people and organizations who permitted me to develop it - often unbeknownst to them. And to you, for being interested enough to read about it.
Forth is a simple, natural computer language. Today it is accepted as a world-class programming language. That it has achieved this without industry, university or government support is a tribute to its efficiency, reliability and versatility. Forth is the language of choice when its efficiency outweighs the popularity of other languages. This is more often the case in real-world applications such as control and communication.
A number of Forth organizations and a plethora of small companies provide systems, applications and documentation. Annual conferences are held in North America, Europe and Asia. A draft ANSI standard will soon be submitted [ANS 1991].
None of the books about Forth quite capture its flavor. I think the best is still the first, Starting Forth by Leo Brodie [Brodie 1981]. Another window is provided by JFAR's invaluable subject and author index [Martin 1987].
The classic Forth we are discussing provides the minimum support a programmer needs to develop a language optimized for his application. It is intended for a work-station environment: keyboard, display, computer and disk.
Forth is a text-based language that is essentially context-free. It combines 'words' separated by spaces, to construct new words. About 150 such words constitute a system that provides (with date of introduction)
```
SAO 1958 Interpreter
SLAC 1961 Data stack
RSI 1966 Keyboard input
Display output, OK
Editor
Mohasco 1968 Compiler
Return stack
Dictionary
Virtual memory (disk)
Multiprogrammer
NRAO 1971 Threaded code
Fixed-point arithmetic
```
Such a system has 3-8K bytes of code compiled from 10-20 pages of source. It can easily be implemented by a single programmer on a small computer.
This account necessarily follows my career. But it is intended to be the autobiography of Forth. I will discuss the features listed above; and the names of the words associated with them. The meaning of many words is obvious. Some warrant description and some are beyond the scope of this paper.
That portion of the Forth dictionary to be mentioned is summarized here:
```
Interpreter
WORD NUMBER INTERPRET ABORT
HASH FIND ' FORGET
BASE OCTAL DECIMAL HEX
LOAD EXIT EXECUTE (
Terminal
KEY EXPECT
EMIT CR SPACE SPACES DIGIT TYPE DUMP
Data stack
DUP DROP SWAP OVER
+ - * / MOD NEGATE
ABS MAX MIN
AND OR XOR NOT
0< 0= =
@ ! +! C@ C!
SQRT SIN.COS ATAN EXP LOG
Return stack
: ; PUSH POP I
Disk
BLOCK UPDATE FLUSH BUFFER PREV OLDEST
Compiler
CREATE ALLOT , SMUDGE
VARIABLE CONSTANT
[ ] LITERAL ." COMPILE
BEGIN UNTIL AGAIN WHILE REPEAT
DO LOOP +LOOP IF ELSE THEN
```
## MIT, SAO, 1958
October, 1957 was Sputnik - a most exciting time. I was a sophmore at MIT and got a part-time job with SAO (Smithsonian Astrophysical Observatory, 14 syllables) at Harvard.
SAO was responsible for optical tracking of satellites - Moonwatch visual observations and Baker-Nunn tracking cameras. Caught off-guard by Sputnik, they hired undergraduates to compute predictions with Friden desk calculators. John Gaustad told me about MIT's IBM EDPM 704 and loaned me his Fortran II manual. My first program, Ephemeris 4, eliminated my job [Moore 1958].
Now a Programmer, I worked with George Veis to apply his method of least-squares fitting to determine orbital elements, station positions and ultimately the shape of Earth [Veis 1960]. Of course, this part-time job was at least 40 hours, and yes, my grades went to hell.
At MIT, John McCarthy taught an incredible course on LISP. That was my introduction to recursion, and to the marvelous variety of computer language. Wil Baden has noted that LISP is to Lambda Calculus as Forth is to Lukasewcleicz Postfix.
APL was also a topical language, with its weird right-left parsing. Although I admire and emulate its operators, I'm not persuaded they constitute an optimal set.
The programming environment in the 50s was more severe than today. My source code filled 2 trays with punch cards. They had to be carried about to be put through machines, mostly by me. Compile took 30 minutes (just like C) but limited computer time meant one run per day, except maybe 3rd shift.
So I wrote this simple interpreter to read input cards and control the program. It also directed calculations. The five orbital elements each had an empirical equation to account for atmospheric drag and the non-spherical Earth. Thus I could compose different equations for the several satellites without re-compiling.
These equations summed terms such as P2 (polynomial of degree 2) and S (sine). 36-bit floating-point dominated calculation time so overhead was small. A data stack was unnecessary, and probably unknown to me.
The Forth interpreter began here with the words
```
WORD NUMBER INTERPRET ABORT
```
They weren't spelled that way because they were statement numbers.
INTERPRET uses WORD to read words separated by spaces and NUMBER to convert a word to binary (in this case, floating-point). Such free-format input was unusual, but was more efficient (smaller and faster) and reliable. Fortran input was formatted into specific columns and typographic errors had caused numerous delays.
This interpreter used an IF ... ELSE IF construct, coded in Fortran, finding a match on a single character. Error handling consisted of terminating the run. Then, as now, ABORT asked the user what to do. Since input cards were listed as they were read, you knew where the error was.
## Stanford, SLAC, 1961
In 1961 I went to Stanford to study mathematics. Although Stanford was building its computer science department, I was interested in real computing. I was impressed that they could (dared?) write their own Algol compiler. And I fatefully encountered the Burroughs B5500 computer.
I got another 'part-time' job at SLAC (Stanford Linear Accelerator Center, 12 syllables) writing code to optimize beam steering for the pending 2-mile electron accelerator. This was a natural application of my least-squares experience to phase-space. Hal Butler was in charge of our group and the program, TRANSPORT, was quite successful.
Another application of least-squares was the program CURVE, coded in Algol (1964). It is a general-purpose non-linear differential-corrections data-fitting program. Its statistical rigor provides insight into agreement between model and data.
The data format and model equations were interpreted and a push-down stack used to facilitate evaluation. CURVE was an impressive precursor to Forth. It introduced these words to provide the capability to fit models much more elaborate than simple equations:
```
+ - * NEGATE
IF ELSE THEN <
DUP DROP SWAP
: ; VARIABLE ! (
SIN ATAN EXP LOG
```
Spelling was quite different:
```
NEGATE was MINUS
DROP ;
SWAP .
! <
VARIABLE DECLARE
; END
( ...) COMMENT ...;
```
The interpreter used IF ... ELSE IF to identify a 6-character input word called ATOM (from LISP). DUP DROP and SWAP are 5500 instructions; I'm surprised at the spelling change. The word : was taken from the Algol label format, flipped for left-right parsing (to prevent the interpreter encountering an undefined word):
```
Algol - LABEL:
CURVE - : LABEL
```
In fact, : marked a position in the input string to be interpreted later. Interpretation was stopped by ; . A version of : was named DEFINE .
The store operator ( ! ) appeared in connection with VARIABLE . But fetching ( @ ) was automatic. Note the input had become complex enough to warrant comments. The sometime-criticised postfix conditional dates from here:
```
Algol - IF expression THEN true ELSE false
CURVE - stack IF true ELSE false THEN
```
True is interpreted if stack is non-zero. THEN provides unique termination, the lack of which always confused me in Algol. Such expressions were interpreted: IF would scan ahead for ELSE or THEN.
The word < introduces the convention that relations leave a truth value on the stack, 1 for true and 0 for false. The transcendental functions are, of course, library calls.
## Free-lance
I left Stanford in 1965 to become a free-lance programmer in the New York City area. This was not unusual, and I found work programming in Fortran, Algol, Jovial, PL/I and various assemblers. I literally carried my card deck about and recoded it as necessary.
Minicomputers were appearing, and with them terminals. The interpreter was ideal for teletype input, and soon included code to handle output. So we aquire the words
```
KEY EXPECT
EMIT CR SPACE SPACES DIGIT TYPE
```
EXPECT is a loop calling KEY to read a keystroke. TYPE is a loop calling EMIT to display a character.
With the TTY came paper-tape and some of the most un-friendly software imaginable - hours of editing and punching and loading and assembling and printing and loading and testing and repeating. I remember a terrible Sunday in a Manhattan skyscraper when I couldn't find splicing tape (nothing else works) and swore that 'There must be a better way'.
I did considerable work for Bob Davis at Realtime Systems, Inc (RSI). I became a 5500 MCP guru to support his time-sharing service (remote input to a mainframe) and wrote a Fortran-Algol translator and file editing utilities. The translator taught me the value of spaces between words, not required by Fortran.
The interpreter still accepted words with the first 6 characters significant (the 5500 had 48-bit words). The words
```
LIST EDIT BEGIN AGAIN EXIT
```
appear, with BEGIN ... AGAIN spelled START ... REPEAT and used to bracket the editor commands
```
T TYPE I INSERT D DELETE F FIND
```
later used in NRAO's editor. The word FIELD was used in the manner of Mohasco and Forth, Inc's data-base management.
One of Forth's distinctive features comes from here. The rule is that Forth acknowledge each line of input by appending OK when interpretation is complete. This may be difficult, for when input is terminated by CR a blank must be echoed, and the CR included with OK. At RSI, OK was on the next line, but it still conveyed friendly reassurance over an intimidating communications line:
```
56 INSERT ALGOL IS VERY ADAPTABLE
OK
```
This postfix notation suggests a data stack, but it only had to be one deep.
## Mohasco, 1968
In 1968 I transformed into a business programmer at Mohasco Industries, Inc in Amsterdam NY. They are a major home-furnishing company - carpets and furniture. I had worked with Geoff Leach at RSI and he persuaded me to follow him up-state. I had just married, and Amsterdam has a lovely small-town atmosphere to contrast with NYC.
I rewrote my code in COBOL and learned the truth about business software. Bob Rayco was in charge of Corporate data processing and assigned me two relevant projects:
He leased an IBM 1130 minicomputer with a 2250 graphic display. The object was to see if computer graphics helped design patterned carpets. The answer was 'not without color' and the 1130 went away.
Meanwhile I had the latest minicomputer environment: 16-bit CPU, 8K RAM, disk (my first), keyboard, printer, card reader/punch, Fortran compiler. The reader/punch provided disk backup. I ported my interpreter again (back to Fortran) and added a cross-assembler to generate code for the 2250.
The system was a great success. It could draw animated 3-D images when IBM could barely draw static 2-D. Since this was my first real-time graphics, I coded Spacewar, that first video game. I also converted my Algol chess program into Forth and was duely impressed how much simpler it became.
The file holding the interpreter was labeled FORTH, for 4th (next) generation software - but the operating system restricted file names to 5 characters.
This environment for programming the 2250 was far superior to the Fortran environment, so I extended the 2250 cross-assembler into an 1130 compiler. This introduced a flock of words
```
DO LOOP UNTIL
BLOCK LOAD UPDATE FLUSH
BASE CONTEXT STATE INTERPRET DUMP
CREATE CODE ;CODE CONSTANT SMUDGE
@ OVER AND OR NOT 0= 0<
```
They were still differently spelled
```
LOOP was CONTINUE
UNTIL END
BLOCK GET
LOAD READ
TYPE SEND
INTERPRET QUERY
CREATE ENTER
CODE the cent symbol
```
The only use I've ever found for the cent symbol. The loop index and limit were on the data stack. DO and CONTINUE were meant to acknowledge Fortran.
BLOCK manages a number of buffers to minimize disk access. LOAD reads source from a 1024-byte block. 1024 was chosen as a nice modular amount of disk, and has proven a good choice. UPDATE allows a block to be marked and later rewritten to disk, when its buffer is needed (or by FLUSH ). It implements virtual memory and is concealed in store ( ! ) words.
BASE allows octal and hex numbers as well as decimal. CONTEXT was the first hint of vocabularies and served to isolate editor words. STATE distinguished compiling from interpreting. During compilation, the count and first 3 characters of a word were compiled for later interpretation. Strangely, words could be terminated by a special character, an aberration quickly abandoned. The fetch operator ( @ ) appeared in many guises, since fetching from variables, arrays and disk had to be distinguished. DUMP became important for examining memory.
But most important, there was now a dictionary. Interpret code now had a name and searched a linked-list for a match. CREATE constructs the classic dictionary entry:
```
link to previous entry
count and 3 characters
code to be executed
parameters
```
The code field was an important innovation, since an indirect jump was the only overhead, once a word had been found. The value of the count in distinguishing words, I learned from the compiler writers of Stanford.
An important class of words appeared with CODE . Machine instructions followed in the parameter field. So any word within the capability of the computer could now be defined. ;CODE specifies the code to be executed for a new class of words, and introduced what are now called objects.
SMUDGE avoided recursion during the interpretation of a definition. Since the dictionary would be searched from newest to oldest definitions, recursion would normally occur.
Finally, the return stack appeared. Heretofor, definitions had not been nested, or used the data stack for their return address. Altogether a time of great innovation in the punctuated evolution of Forth.
The first paper on Forth, an internal Mohasco report, was written by Geoff and me [Moore 1970]. It would not be out of place today.
In 1970 Bob ordered a Univac 1108. An ambitious project to support a network of leased lines for an order-entry system. I had coded a report generator in Forth and was confident I could code order-entry. I ported Forth to the 5500 (standalone!) to add credibility. But corporate software was COBOL. The marvelous compromise was to install a Forth system on the 1108 that interfaced with COBOL modules to do transaction processing.
I vividly recall commuting to Schenectady that winter to borrow 1107 time 3rd shift. My TR4-A lacked floor and window so it became a nightly survival exercise. But the system was an incredible success. Even Univac was impressed with its efficiency (Les Sharp was project liason). The ultimate measure was response time, but I was determined to keep it maintainable (small and simple). Alas, an economic downturn led Management to cancel the 1108. I still think it was a bad call. I was the first to resign.
1108 Forth must have been coded in assembler. It buffered input and output messages and shared the CPU among tasks handling each line. Your classic operating system. But it also interpreted the input and PERFORMed the appropriate COBOL module. It maintained drum buffers and packed/unpacked records. The words
```
BUFFER PREV OLDEST
TASK ACTIVATE GET RELEASE
```
date from here. BUFFER avoided a disk read when the desired block was known empty. PREV (previous) and OLDEST are system variables that implement least-recently-used buffer management. TASK defines a task at boot time and ACTIVATE starts it when needed. GET and RELEASE manage shared resources (drum, printer). PAUSE is how a task relinquishes control of the CPU. It is included in all I/O operations and is invisible to transaction code. It allows a simple round-robin scheduling algorithm that avoids lock-out.
After giving notice, I wrote an angry poem and a book that has never been published. It described how to develop Forth software and encouraged simplicity and innovation. It also described indirect-threaded code, but the first implementation was at NRAO.
I struggled with the concept of meta-language, language that talks about language. Forth could now interpret an assembler, that was assembling a compiler, that would compile the interpreter. Eventually I decided the terminology wasn't helpful, but the term Meta-compile for recompiling Forth is still used.
## NRAO, 1971
George Conant offered me a position at NRAO (National Radio Astronomy Observatory, 15 syllables). I had known him at SAO and he liked Ephemeris 4. So we moved to Charlottesville VA and spent summers in Tucson AZ when the radio-telescope on Kitt Peak was available for maintainance.
The project was to program a Honeywell 316 minicomputer to control a new filter-bank for the 36' millimeter telescope. It had a 9-track tape and Tektronix storage-tube terminal. George gave me a free hand to develop the system, though he wasn't pleased with the result. NRAO was a Fortran shop and by now I was calling Forth a language. He was right in that organizations have to standardize on a single language. Other programmers now wanted their own languages.
Anyhow, I had coded Forth in assembler on the IBM 360/50 mainframe. Then I cross-compiled it onto the 316. Then I re-compiled it on the 316 (Although I had a terminal on the 360, response time was terrible). The application was easy once the system was available. There were two modes of observing, continuum and spectral-line. Spectral-line was the most fun, for I could display spectra as they were collected and fit line-shapes with least-squares [Moore 1973].
The system was well-received in Tucson, where Ned Conklin was in charge. It did advance the state-of-the-art in on-line data reduction. Astronomers used it to discover and map inter-stellar molecules just as that became hot research.
Bess Rather was hired to provide on-site support. She had first to learn the Forth system and then explain and document it, with minimal help from me. The next year I reprogrammed the DDP-116 to optimize telescope pointing. The next, Bess and I replaced the 116 and 316 with a DEC PDP-11.
The development that made all this possible was indirect-threaded code. It was a natural development from my work at Mohasco, though I later heard that DEC had used direct-threaded code in one of their compilers. Rather than re-interpret the text of a definition, compile the address of each dictionary entry. This improved efficiency for each reference required only 2 bytes and an address interpreter could sequence through a definition enormously faster. In fact, this interpreter was a 2-word macro on the 11:
```
: NEXT IP )+ W MOV W )+ ) JMP ;
```
Now Forth was complete. And I knew it. I could write code more quickly that was more efficient and reliable. Moreover, it was portable. I proceeded to recode the 116 pointing the 300' Green Bank telescope, and the HP mini that was inaugurating VLBI astronomy. George gave me a ModComp and I did Fourier transforms for interferometry and pulsar search (64K data). I even demonstrated that complex multiply on the 360 was 20% faster in Forth than assembler.
NRAO appreciated what I had wrought. They had an arrangement with a consulting firm to identify spin-off technology. The issue of patenting Forth was discussed at length. But since software patents were controversial and might involve the Supreme Court, NRAO declined to pursue the matter. Whereupon, rights reverted to me. I don't think ideas should be patentable. Hindsight agrees that Forth's only chance lay in the public domain. Where it has flourished.
Threaded-code changed the structure words (such as DO LOOP IF THEN ). They acquired an elegant implementation with addresses on the data stack during compilation.
Now each Forth had an assembler for its particular computer. It uses post-fix op-codes and composes addresses on the data stack, with Forth-like structure words for branching. The manufacturer's mnemonics are defined as word classes by ;CODE . Might take an afternoon to code. An example is the macro for NEXT above.
Unconventional arithmetic operators proved their value
```
M* */ /MOD SQRT SIN.COS ATAN EXP LOG
```
M\* is the usual hardware multiply of 2 16-bit numbers to a 32-bit product (arguments, of course, on the data stack). \*/ follows that with a divide to implement rational arithmetic. /MOD returns both quotient and remainder and is ideal for locating records within a file. SQRT produces a 16-bit result from a 32-bit argument. SIN.COS returns both sine and cosine as is useful for vector and complex arithmetic (FFT). ATAN is its inverse and has no quadrant ambiguity. EXP and LOG were base 2.
These functions used fixed-point arithmetic - 14 or 30 bits right of a binary point for trig, 10 for logs. This became a characteristic of Forth since it's simpler, faster and more accurate than floating-point. But hardware and software floating-point are easy to implement.
I'd like to applaud the invaluable work of Hart [Hart 1978] in tabulating function approximations with various accuracies. They have provided freedom from the limitations of existing libraries to those of us in the trenches.
The word DOES> appeared (spelled ;: ). It defines a class of words (like ;CODE ) by specifying the definition to be interpreted when the word is referenced. It was tricky to invent, but particularly useful for defining op-codes.
Nonetheless, I failed to persuade Charlottesville that Forth was suitable. I wasn't going to be allowed to program the VLA. Of any group, 25% like Forth and 25% hate it. Arguments can get violent and compromise is rare. So the friendlies joined forces and formed Forth, Inc. And that's another story.
## Moral
The Forth story has the making of a morality play: Persistant young programmer struggles against indifference to discover Truth and save his suffering comrades. It gets better: Watch Forth. Inc go head to head with IBM over a French banking system.
I know Forth is the best language so far. I'm pleased at its success, especially in the ultra-conservative arena of Artificial Intelligence. I'm disturbed that people who should, don't appreciate how it embodies their own description of the ideal programming language.
But I'm still exploring without license. Forth has led to an architecture that promises a wonderful integration of software and silicon. And another new programming environment.
## References
[ANS 1991] Draft Proposed ANS Forth, document number X3.215-199x, available from Global Engineering Documents, 2805 McGaw Ave., Irvine CA 92714.
[Brodie, 1981] Brodie, Leo, Starting FORTH, Englewood Cliffs NJ: Prentice-Hall, 1981, ISBN 0 13 842930 8.
[Hart, 1968] Hart, John F. et al, Computer Approximations. Malabar FL: Krieger, 1968; (Second Edition), 1978, ISBN 0 88275 642 7.
[Martin, 1987] Martin, Thea, A Bibliography of Forth References, 3rd Ed, Rochester NY: Institute for Applied Forth Research, 1987, ISBN 0 914593 07 2.
[Moore, 1958] Moore, Charles H. and Lautman, Don A., Predictions for photographic tracking stations - APO Ephemeris 4, in SAO Special Report No. 11, Schilling G. F., Ed., Cambridge MA: Smithsonian Astrophysical Observatory, 1958 March.
[Moore, 1970] --- and Leach, Geoffrey C., FORTH - A Language for Interactive Computing, Amsterdam NY: Mohasco Industries, Inc. (internal pub.) 1970.
[Moore, 1972] --- and Rather, Elizabeth D., The FORTH program for spectral line observing on NRAO's 36 ft telescope, Astronomy & Astrophysics Supplement Series, Vol. 15, No. 3, 1974 June, Proceedings of the Symposium on the Collection and Analysis of Astrophysical Data, Charlottesville VA, 1972 Nov. 13-15.
[Moore, 1980] ---, The evolution of FORTH, an unusual language, Byte, 5:8, 1980 August.
[Rather, 1993] Rather, Elizabeth D., Colburn, Donald R. and Moore, Charles H., The Evolution of Forth, in History of Programming Languages-II, Bergin T. J. and Gibson, R. G., Ed., New York NY: Addison-Wesley, 1996, ISBN 0-201-89502-1.
[Veis, 1960] Veis, George and Moore, C. H., SAO differential orbit improvement program, in Tracking Programs and Orbit Determination Seminar Proceedings, Pasadena CA: JPL, 1960 February 23-26.

View File

@@ -0,0 +1,42 @@
# Forth
**Source:** https://www.taygeta.com/forth.html
Forth Information on Taygeta, Taygeta Scientific Inc.
# Forth Information on Taygeta
*Last updated 26 November 2004*
![====](/icons/maroonbar.gif)
Taygeta Scientific provides custom software and consulting for applications
using Forth for real-time applications, embedded systems, signal processing,
robotics, Unix scripting, and WWW CGI programs.
[Contact us](mailto:office@taygeta.com) for details.
---
![](/icons/archiv.gif) [**Forth Literature and Education**](forthlit.html)
---
### Software:
![](/icons/star.gif) [**Forth Compilers**](forthcomp.html) ![](/icons/star.gif) [**TCP/IP networking with Forth**](networking/forthnet.html)
#### Applications:
![](/icons/pink.gif) John Hayes's ANS compiler validation program (27 Nov 95 version) (two files), [tester.fr V1.1](ftp://ftp.taygeta.com/pub/Forth/Applications/ANS/tester.fr) and [core.fr V1.2](ftp://ftp.taygeta.com/pub/Forth/Applications/ANS/core.fr) ![](/icons/pink.gif) The [Forth Scientific Library](fsl/sciforth.html) project Info ![](/icons/pink.gif) The [UUDECODE utility](ftp://ftp.taygeta.com/pub/Forth/Applications/ANS/uudecode.seq) (ANS). ![](/icons/pink.gif) The [UUENCODE utility](ftp://ftp.taygeta.com/pub/Forth/Applications/ANS/uuencode.seq) (ANS). ![](/icons/pink.gif) The **LZ77 Data Compression** utility, [Info](ftp://ftp.taygeta.com/pub/Forth/Applications/ANS/lzss.doc), and [code](ftp://ftp.taygeta.com/pub/Forth/Applications/ANS/lzss.fo). ![](/icons/pink.gif) An implementation of the [**ANS Memory-Allocation Wordset**](ftp://ftp.taygeta.com/pub/Forth/Applications/ANS/memory.fth).
#### Development tools:
![](/icons/pink.gif) [**Joerg Plewe**'s **ANS Debugger (From Forth Dimensions)**](ftp://ftp.taygeta.com/pub/Forth/Applications/ANS/debugger.ans) ![](/icons/pink.gif) [EMACS Forth Mode](ftp://ftp.taygeta.com/pub/Forth/Tools/forth.el) elisp file (V2.10) by **Goran Rydqvist**. ![](/icons/pink.gif) A [Condordance generator for Forth source files](ftp://ftp.taygeta.com/pub/Forth/Tools/concordance.fth) (V1.6) [(PFE version)](ftp://ftp.taygeta.com/pub/Forth/Tools/pfe/concordance.fth) ![](/icons/pink.gif) An [EMACS **TAGS** for Forth source files](ftp://ftp.taygeta.com/pub/Forth/Tools/ftags.fth) (V1.5) [(PFE version)](ftp://ftp.taygeta.com/pub/Forth/Tools/ftags.fth) ![](/icons/pink.gif) A [Forth source code obfuscator](ftp://ftp.taygeta.com/pub/Forth/Tools/gfob-0.1.0.tar.gz) (V0.1.0) by **Pierre Abbat** ([phma@trellis.net](mailto:phma@trellis.net)).
#### Interesting Forth Applications: [Gray Forth Parser generator](ftp://ftp.complang.tuwien.ac.at/pub/forth) (ANS version) [MIX emulator, assembler, disassembler](ftp://iaehv.iaehv.nl/pub/users/mhx) by **Marcel Hendrix**. 190 MB of Forth Online ! --- Other WWW Forth resources: [The **Forth Interest Group** home page](http://www.forth.org). --- Sites: [AM Research](http://www.amresearch.com) Embedded control systems page with Forth information and software [ATHENA](ftp://ftp.uu.net/vendor/minerva/uathena.htm) Programming, Inc. [ftp.cygnus.com](ftp://ftp.cygnus.com/pub/forth) Forth directory. [Asterix FTP](ftp://ftp.dei.isep.ipp.pt/pub/forth) site (Portugal), [Asterix MIRROR FTP](ftp://col.hp.com/mirrors) site. The [**Forth Research Page at Bournemouth**](http://dec.bournemouth.ac.uk/forth). * The [**DeloSoft**](http://www.delosoft.com/) site, has **dsForth** for WindowsCE on MIPS, SH3 and Intel processors. [ForthChip](http://www.forthchip.com/), a site primarily about the F21 family of processors [**TILE** Forth](ftp://ftp.lysator.liu.se/pub/languages/forth) FTP site. Other [Forth](http://pisa.rockefeller.edu:8080/FORTH/) related info. * The [**Pocket Forth**](http://chemlab.pc.maricopa.edu/pocket.html) site. The [South Ontario FIG Chapter Library](ftp://pc-solntseff-n.dcss.mcmaster.ca) (after hours, 8:30 to 5:30 EST Mondays to Fridays, please). [ACM SIGFORTH](gopher://gopher.acm.org/11[the_files.sig_forums.sigFORTH]) directory. [Forth in French](http://perso.wanadoo.fr/mp7/forth). [ITCN](http://www.cera2.com/forth.htm) Forth Resources page * The [JForth site](http://jforth.org/) (for the Amiga) * The [Pysmatic Forth center](http://www.pysmatic.com/forth/). * The [**Russian Forth Interest Group**](http://www.forth.org.ru/) * The [**EServ (Forth Web Server) Open source site**](http://www.opensource.org.ru/eserv-src/src.html) (in Russian) * [**SP-Forth**](http://www.enet.ru/win/cherezov/) Russian site, Windows 95/NT Forth A list of [Forth applications in space](http://forth.gsfc.nasa.gov) [Transport Control Technology Ltd.](http://www.tcontec.demon.co.uk) Control system design consultants * The [Treasure Isle of Forth](http://www.stejskal.de/web/computer/forth/_index.html) --- **The Forth Webring** [[Prev](http://www.webring.org/cgi-bin/webring?ring=forth&id=10&prev)] [[Random](http://www.webring.org/cgi-bin/webring?random&ring=forth)] [[List Sites](http://www.webring.org/cgi-bin/webring?ring=forth&list)] [[Next](http://www.webring.org/cgi-bin/webring?ring=forth&id=10&next)] [[Next 5](http://www.webring.org/cgi-bin/webring?ring=forth&id=10&next5)] [Dr. Everett (Skip) F. Carter Jr.](EFCBio-General.html) [Taygeta Scientific Inc.](taygeta.html) 1340 Munras Ave., Suite 314 Monterey, CA. 93940-6140 | voice: 831.641.0645 FAX: 831.641.0647 INTERNET:[skip@taygeta.com](http://www.taygeta.com/mailme.html) WWW:<http://www.taygeta.com/> | [Taygeta's home page](http://www.taygeta.com/index.html)

View File

@@ -0,0 +1,17 @@
# Forth Landing
**Source:** https://wiki.c2.com/?ForthLanguage
**notice**
javascript required to view this site
**why**
measured improvement in server performance
awesome incremental search
![](spin.gif)
This site uses features not available in older browsers.

View File

@@ -0,0 +1,17 @@
# Forth Values
**Source:** https://wiki.c2.com/?ForthValues
**notice**
javascript required to view this site
**why**
measured improvement in server performance
awesome incremental search
![](spin.gif)
This site uses features not available in older browsers.

View File

@@ -0,0 +1,311 @@
# GDForth
**Source:** https://github.com/yumaikas/GDForth
GitHub - yumaikas/GDForth: A Forth-alike for better async GDScript
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fyumaikas%2FGDForth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fyumaikas%2FGDForth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=yumaikas%2FGDForth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[yumaikas](/yumaikas)
/
**[GDForth](/yumaikas/GDForth)**
Public
* [Notifications](/login?return_to=%2Fyumaikas%2FGDForth) You must be signed in to change notification settings
* [Fork
0](/login?return_to=%2Fyumaikas%2FGDForth)
* [Star
2](/login?return_to=%2Fyumaikas%2FGDForth)
A Forth-alike for better async GDScript
[2
stars](/yumaikas/GDForth/stargazers) [0
forks](/yumaikas/GDForth/forks) [Branches](/yumaikas/GDForth/branches) [Tags](/yumaikas/GDForth/tags) [Activity](/yumaikas/GDForth/activity)
[Star](/login?return_to=%2Fyumaikas%2FGDForth)
[Notifications](/login?return_to=%2Fyumaikas%2FGDForth) You must be signed in to change notification settings
* [Code](/yumaikas/GDForth)
* [Issues
0](/yumaikas/GDForth/issues)
* [Pull requests
0](/yumaikas/GDForth/pulls)
* [Actions](/yumaikas/GDForth/actions)
* [Projects
0](/yumaikas/GDForth/projects)
* [Security
0](/yumaikas/GDForth/security)
* [Insights](/yumaikas/GDForth/pulse)
Additional navigation options
* [Code](/yumaikas/GDForth)
* [Issues](/yumaikas/GDForth/issues)
* [Pull requests](/yumaikas/GDForth/pulls)
* [Actions](/yumaikas/GDForth/actions)
* [Projects](/yumaikas/GDForth/projects)
* [Security](/yumaikas/GDForth/security)
* [Insights](/yumaikas/GDForth/pulse)
# yumaikas/GDForth
main
[Branches](/yumaikas/GDForth/branches)[Tags](/yumaikas/GDForth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[44 Commits](/yumaikas/GDForth/commits/main/) 44 Commits | | |
| [addons/GDForth](/yumaikas/GDForth/tree/main/addons/GDForth "This path skips through empty directories") | | [addons/GDForth](/yumaikas/GDForth/tree/main/addons/GDForth "This path skips through empty directories") | | |
| [.gitignore](/yumaikas/GDForth/blob/main/.gitignore ".gitignore") | | [.gitignore](/yumaikas/GDForth/blob/main/.gitignore ".gitignore") | | |
| [README.md](/yumaikas/GDForth/blob/main/README.md "README.md") | | [README.md](/yumaikas/GDForth/blob/main/README.md "README.md") | | |
| View all files | | |
## Repository files navigation
* [README](#)
Refer to <./addons/GDForth/README.md> for project details
## About
A Forth-alike for better async GDScript
### Resources
[Readme](#readme-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/yumaikas/GDForth/activity)
### Stars
[**2**
stars](/yumaikas/GDForth/stargazers)
### Watchers
[**1**
watching](/yumaikas/GDForth/watchers)
### Forks
[**0**
forks](/yumaikas/GDForth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fyumaikas%2FGDForth&report=yumaikas+%28user%29)
## [Releases](/yumaikas/GDForth/releases)
No releases published
## [Packages 0](/users/yumaikas/packages?repo_name=GDForth)
No packages published
## Languages
* [GDScript
99.8%](/yumaikas/GDForth/search?l=gdscript)
* [Shell
0.2%](/yumaikas/GDForth/search?l=shell)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
# Homepage
**Source:** https://colorforth.github.io/index.html
Chuck Moore's colorForth, OKAD and S40 Forth Multicomputer chip
### *Updated* 2013 November 6IntroductionThis site is getting some 500-600 visitors a day. Thank you for your interest. *There's a quotation attributed to Burke: "All that is required for evil to triumph is for good men to do nothing."**[Blog](blog.htm)*Comments about life, colorForth and GreenArrays You're welcome to email me your comments. I like to hear from people, and appreciate your suggestions. But there are several problems: * Such email usually arrives in my junk mail folder. I try to retrieve them, but a distinguishing subject line would help.* I won't respond to these emails, except on future postings. 'Cause I don't know who you are, and the the web is full of predators. *[Eval Blog](haypress.htm)*My experience programming GreenArrays' Evaluation Board. [colorForth](cf.htm)A dialect of Forth that uses color to replace punctuation. Native Pentium and Windows versions. Produces extremely compact programs. Instant compile from pre-parsed source. Latest changes are compressed source: colorForth, OKAD and GA4 in 290K (25%). Also blue words that are executed at edit time, for formatting text.[OKAD](vlsi.html)A suite of VLSI design tools for layout and simulation. Compact description of gates, cells and chip. Resulting GDS II file ready for fabrication. [S40 Multicomputer Chip](S40.htm) Spectacular chip! 40 microcomputers, each with 128 words of 18-bit memory. Each capable of 700 Mips. [GreenArrays, Inc](http://greenarraychips.com/)I'm pleased to announce the formation of this company. We plan to develop and exploit the concept of multi-computer chips. That gives me another point of contact: [chuck@greenarraychips.com](mailto:chuck@greenarraychips.com). *[Chuck Moore](bio.html)*[chipchuck@colorforth.com](mailto:chipchuck@colorforth.com) Lives in Nevada at Lake Tahoe. Loves to [hike](hiking.htm) the Tahoe Rim Trail as well as the Pacific Crest Trail. *[Min Moore](min.htm) 1932 - 2005*[Eric Moore](eric.htm)Some pictures of my son[Recipes](recipes.htm)[Programming a Problem-Oriented Language](POL.htm)This is a book I wrote about 1970. It describes the software that became Forth.[Thoughts about Pi](pi.htm)[colorForth Primer](primer.htm)[Books](books.htm)Books I likePoemsSometimes the pros say it best. To be perfectly clear, I've emphasized some lines. [Henry V, Shakespeare [Stout-Hearted Men, Hammerstein](stout.htm) [Invictus, Henley](Invictus.htm) [The Weariest River, Swinburne](WeariestRiver.htm) [Coloring, Sarah Hall Maney](coloring.html) [Road Not Taken, Robert Frost](road.htm) [Mending Wall, Robert Frost](mending.htm) [Stopping by Woods on a Snowy Evening, Robert Frost](stopping.htm) [Ulysses, Alfred Lord Tennyson](tennyson.htm) [The Explorer, Rudyard Kipling](kipling.htm) [My Lost Youth, Henry Wadsworth Longfellow](longfellow.htm) [High Flight, John Gillespie Magee](magee.htm)](Crispin.htm)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,398 @@
# JonesForth-arm
**Source:** https://github.com/M2IHP13-admin/JonesForth-arm
GitHub - M2IHP13-admin/JonesForth-arm
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2FM2IHP13-admin%2FJonesForth-arm)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2FM2IHP13-admin%2FJonesForth-arm)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=M2IHP13-admin%2FJonesForth-arm)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[M2IHP13-admin](/M2IHP13-admin)
/
**[JonesForth-arm](/M2IHP13-admin/JonesForth-arm)**
Public
* [Notifications](/login?return_to=%2FM2IHP13-admin%2FJonesForth-arm) You must be signed in to change notification settings
* [Fork
52](/login?return_to=%2FM2IHP13-admin%2FJonesForth-arm)
* [Star
89](/login?return_to=%2FM2IHP13-admin%2FJonesForth-arm)
### License
[LGPL-3.0 license](/M2IHP13-admin/JonesForth-arm/blob/master/LICENSE)
[89
stars](/M2IHP13-admin/JonesForth-arm/stargazers) [52
forks](/M2IHP13-admin/JonesForth-arm/forks) [Branches](/M2IHP13-admin/JonesForth-arm/branches) [Tags](/M2IHP13-admin/JonesForth-arm/tags) [Activity](/M2IHP13-admin/JonesForth-arm/activity)
[Star](/login?return_to=%2FM2IHP13-admin%2FJonesForth-arm)
[Notifications](/login?return_to=%2FM2IHP13-admin%2FJonesForth-arm) You must be signed in to change notification settings
* [Code](/M2IHP13-admin/JonesForth-arm)
* [Issues
0](/M2IHP13-admin/JonesForth-arm/issues)
* [Pull requests
0](/M2IHP13-admin/JonesForth-arm/pulls)
* [Actions](/M2IHP13-admin/JonesForth-arm/actions)
* [Projects
0](/M2IHP13-admin/JonesForth-arm/projects)
* [Wiki](/M2IHP13-admin/JonesForth-arm/wiki)
* [Security
0](/M2IHP13-admin/JonesForth-arm/security)
* [Insights](/M2IHP13-admin/JonesForth-arm/pulse)
Additional navigation options
* [Code](/M2IHP13-admin/JonesForth-arm)
* [Issues](/M2IHP13-admin/JonesForth-arm/issues)
* [Pull requests](/M2IHP13-admin/JonesForth-arm/pulls)
* [Actions](/M2IHP13-admin/JonesForth-arm/actions)
* [Projects](/M2IHP13-admin/JonesForth-arm/projects)
* [Wiki](/M2IHP13-admin/JonesForth-arm/wiki)
* [Security](/M2IHP13-admin/JonesForth-arm/security)
* [Insights](/M2IHP13-admin/JonesForth-arm/pulse)
# M2IHP13-admin/JonesForth-arm
master
[Branches](/M2IHP13-admin/JonesForth-arm/branches)[Tags](/M2IHP13-admin/JonesForth-arm/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[58 Commits](/M2IHP13-admin/JonesForth-arm/commits/master/) 58 Commits | | |
| [.gitattributes](/M2IHP13-admin/JonesForth-arm/blob/master/.gitattributes ".gitattributes") | | [.gitattributes](/M2IHP13-admin/JonesForth-arm/blob/master/.gitattributes ".gitattributes") | | |
| [AUTHORS](/M2IHP13-admin/JonesForth-arm/blob/master/AUTHORS "AUTHORS") | | [AUTHORS](/M2IHP13-admin/JonesForth-arm/blob/master/AUTHORS "AUTHORS") | | |
| [LICENSE](/M2IHP13-admin/JonesForth-arm/blob/master/LICENSE "LICENSE") | | [LICENSE](/M2IHP13-admin/JonesForth-arm/blob/master/LICENSE "LICENSE") | | |
| [Makefile](/M2IHP13-admin/JonesForth-arm/blob/master/Makefile "Makefile") | | [Makefile](/M2IHP13-admin/JonesForth-arm/blob/master/Makefile "Makefile") | | |
| [README.md](/M2IHP13-admin/JonesForth-arm/blob/master/README.md "README.md") | | [README.md](/M2IHP13-admin/JonesForth-arm/blob/master/README.md "README.md") | | |
| [jonesforth.S](/M2IHP13-admin/JonesForth-arm/blob/master/jonesforth.S "jonesforth.S") | | [jonesforth.S](/M2IHP13-admin/JonesForth-arm/blob/master/jonesforth.S "jonesforth.S") | | |
| [jonesforth.f](/M2IHP13-admin/JonesForth-arm/blob/master/jonesforth.f "jonesforth.f") | | [jonesforth.f](/M2IHP13-admin/JonesForth-arm/blob/master/jonesforth.f "jonesforth.f") | | |
| [perf\_dupdrop.c](/M2IHP13-admin/JonesForth-arm/blob/master/perf_dupdrop.c "perf_dupdrop.c") | | [perf\_dupdrop.c](/M2IHP13-admin/JonesForth-arm/blob/master/perf_dupdrop.c "perf_dupdrop.c") | | |
| [perf\_dupdrop.f](/M2IHP13-admin/JonesForth-arm/blob/master/perf_dupdrop.f "perf_dupdrop.f") | | [perf\_dupdrop.f](/M2IHP13-admin/JonesForth-arm/blob/master/perf_dupdrop.f "perf_dupdrop.f") | | |
| [test\_comparison.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_comparison.f "test_comparison.f") | | [test\_comparison.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_comparison.f "test_comparison.f") | | |
| [test\_comparison.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_comparison.f.out "test_comparison.f.out") | | [test\_comparison.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_comparison.f.out "test_comparison.f.out") | | |
| [test\_exception.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_exception.f "test_exception.f") | | [test\_exception.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_exception.f "test_exception.f") | | |
| [test\_exception.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_exception.f.out "test_exception.f.out") | | [test\_exception.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_exception.f.out "test_exception.f.out") | | |
| [test\_nqueens.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_nqueens.f "test_nqueens.f") | | [test\_nqueens.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_nqueens.f "test_nqueens.f") | | |
| [test\_nqueens.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_nqueens.f.out "test_nqueens.f.out") | | [test\_nqueens.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_nqueens.f.out "test_nqueens.f.out") | | |
| [test\_number.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_number.f "test_number.f") | | [test\_number.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_number.f "test_number.f") | | |
| [test\_number.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_number.f.out "test_number.f.out") | | [test\_number.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_number.f.out "test_number.f.out") | | |
| [test\_read\_file.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_read_file.f "test_read_file.f") | | [test\_read\_file.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_read_file.f "test_read_file.f") | | |
| [test\_read\_file.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_read_file.f.out "test_read_file.f.out") | | [test\_read\_file.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_read_file.f.out "test_read_file.f.out") | | |
| [test\_stack.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_stack.f "test_stack.f") | | [test\_stack.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_stack.f "test_stack.f") | | |
| [test\_stack.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_stack.f.out "test_stack.f.out") | | [test\_stack.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_stack.f.out "test_stack.f.out") | | |
| [test\_stack\_trace.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_stack_trace.f "test_stack_trace.f") | | [test\_stack\_trace.f](/M2IHP13-admin/JonesForth-arm/blob/master/test_stack_trace.f "test_stack_trace.f") | | |
| [test\_stack\_trace.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_stack_trace.f.out "test_stack_trace.f.out") | | [test\_stack\_trace.f.out](/M2IHP13-admin/JonesForth-arm/blob/master/test_stack_trace.f.out "test_stack_trace.f.out") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [LGPL-3.0 license](#)
# Jonesforth-ARM
An ARM port of X86 JonesForth by Richard W.M. Jones [rich@annexia.org](mailto:rich@annexia.org)
at <http://annexia.org/forth>.
## What is this ?
Jonesforth-ARM is a Forth interpreter developed for ARM.
The algorithm for our unsigned DIVMOD instruction is extracted from 'ARM
Software Development Toolkit User Guide v2.50' published by ARM in 1997-1998
Compared to the original interpreter:
* We did not keep the jonesforth.f section allowing to compile assembly from
the Forth interpreter because it was X86 specific.
* We pass all the original JonesForth's tests on ARM (except one which
depends on the above X86 assembly compilation).
* We added a native signed DIVMOD instruction (S/MOD)
Another project porting Jonesforth on ARM is ongoing at
<https://github.com/phf/forth>
## Build and run instructions
If you are building on the ARM target, just type,
```
$ make
```
to build the forth interpreter.
After building, we recommend that you run the test-suite by executing,
```
$ make test
```
To launch the forth interpreter, type
```
$ cat jonesforth.f - | ./jonesforth
```
## Contributors:
ABECASSIS Felix, BISPO VIEIRA Ricardo, BLANC Benjamin, BORDESSOULES Arthur,
BOUDJEMAI Yassine, BRICAGE Marie, ETSCHMANN Marc, GAYE Ndeye Aram,
GONCALVES Thomas, GOUGEAUD Sebastien, HAINE Christopher, OLIVEIRA Pablo,
PLAZA ONATE Florian, POPOV Mihail
## About
No description, website, or topics provided.
### Resources
[Readme](#readme-ov-file)
### License
[LGPL-3.0 license](#LGPL-3.0-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/M2IHP13-admin/JonesForth-arm/activity)
### Stars
[**89**
stars](/M2IHP13-admin/JonesForth-arm/stargazers)
### Watchers
[**14**
watching](/M2IHP13-admin/JonesForth-arm/watchers)
### Forks
[**52**
forks](/M2IHP13-admin/JonesForth-arm/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2FM2IHP13-admin%2FJonesForth-arm&report=M2IHP13-admin+%28user%29)
## [Releases](/M2IHP13-admin/JonesForth-arm/releases)
No releases published
## [Packages 0](/users/M2IHP13-admin/packages?repo_name=JonesForth-arm)
No packages published
## [Contributors 4](/M2IHP13-admin/JonesForth-arm/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [Forth
62.4%](/M2IHP13-admin/JonesForth-arm/search?l=forth)
* [Assembly
35.9%](/M2IHP13-admin/JonesForth-arm/search?l=assembly)
* Other
1.7%
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,68 @@
# Jonesforth.git
**Source:** http://git.annexia.org/?p=jonesforth.git;a=summary
xml version="1.0" encoding="utf-8"?
annexia.org >> repositories - jonesforth.git/summary
[![git](static/git-logo.png)](http://git-scm.com/ "git homepage")[git.annexia.org](http://git.annexia.org/) / [jonesforth.git](/?p=jonesforth.git;a=summary) / summary
commit
grep
author
committer
pickaxe
[?](/?p=jonesforth.git;a=search_help) search:
re
summary | [shortlog](/?p=jonesforth.git;a=shortlog) | [log](/?p=jonesforth.git;a=log) | [commit](/?p=jonesforth.git;a=commit;h=66c56998125f3ac265a3a1df9821fd52cfeee8cc) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=66c56998125f3ac265a3a1df9821fd52cfeee8cc) | [tree](/?p=jonesforth.git;a=tree)
| | |
| --- | --- |
| description | JONESFORTH - A sometimes minimal FORTH compiler and tutorial |
| owner | |
| last change | Fri, 11 Sep 2009 08:33:13 +0000 (08:33 +0000) |
| URL | git://git.annexia.org/jonesforth.git |
[shortlog](/?p=jonesforth.git;a=shortlog)
| | | | |
| --- | --- | --- | --- |
| *2009-09-11* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Version 47](/?p=jonesforth.git;a=commit;h=66c56998125f3ac265a3a1df9821fd52cfeee8cc) [master](/?p=jonesforth.git;a=shortlog;h=refs/heads/master) | [commit](/?p=jonesforth.git;a=commit;h=66c56998125f3ac265a3a1df9821fd52cfeee8cc) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=66c56998125f3ac265a3a1df9821fd52cfeee8cc) | [tree](/?p=jonesforth.git;a=tree;h=66c56998125f3ac265a3a1df9821fd52cfeee8cc;hb=66c56998125f3ac265a3a1df9821fd52cfeee8cc) | [snapshot](/?p=jonesforth.git;a=snapshot;h=66c56998125f3ac265a3a1df9821fd52cfeee8cc;sf=tgz "in format: tar.gz") |
| *2009-09-11* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Fix ROT/-ROT (Ian Osgood).](/?p=jonesforth.git;a=commit;h=dccbff0e169d5467a78be5c6d935fa505f6a029f) | [commit](/?p=jonesforth.git;a=commit;h=dccbff0e169d5467a78be5c6d935fa505f6a029f) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=dccbff0e169d5467a78be5c6d935fa505f6a029f) | [tree](/?p=jonesforth.git;a=tree;h=dccbff0e169d5467a78be5c6d935fa505f6a029f;hb=dccbff0e169d5467a78be5c6d935fa505f6a029f) | [snapshot](/?p=jonesforth.git;a=snapshot;h=dccbff0e169d5467a78be5c6d935fa505f6a029f;sf=tgz "in format: tar.gz") |
| *2007-10-22* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Fix test\_read\_file so it reads its own output (which...](/?p=jonesforth.git;a=commit;h=092aa5189f24fbfb1714c1d2d31c26a666102c3c "Fix test_read_file so it reads its own output (which should obviously") | [commit](/?p=jonesforth.git;a=commit;h=092aa5189f24fbfb1714c1d2d31c26a666102c3c) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=092aa5189f24fbfb1714c1d2d31c26a666102c3c) | [tree](/?p=jonesforth.git;a=tree;h=092aa5189f24fbfb1714c1d2d31c26a666102c3c;hb=092aa5189f24fbfb1714c1d2d31c26a666102c3c) | [snapshot](/?p=jonesforth.git;a=snapshot;h=092aa5189f24fbfb1714c1d2d31c26a666102c3c;sf=tgz "in format: tar.gz") |
| *2007-10-12* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Documentation.](/?p=jonesforth.git;a=commit;h=c089529de15a934abb14f8e9b0aa5ef08e6edd00) | [commit](/?p=jonesforth.git;a=commit;h=c089529de15a934abb14f8e9b0aa5ef08e6edd00) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=c089529de15a934abb14f8e9b0aa5ef08e6edd00) | [tree](/?p=jonesforth.git;a=tree;h=c089529de15a934abb14f8e9b0aa5ef08e6edd00;hb=c089529de15a934abb14f8e9b0aa5ef08e6edd00) | [snapshot](/?p=jonesforth.git;a=snapshot;h=c089529de15a934abb14f8e9b0aa5ef08e6edd00;sf=tgz "in format: tar.gz") |
| *2007-10-12* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Fix perf\_dupdrop forth test.](/?p=jonesforth.git;a=commit;h=cea392870a443a3d773d18d1627fa94712387cf5) | [commit](/?p=jonesforth.git;a=commit;h=cea392870a443a3d773d18d1627fa94712387cf5) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=cea392870a443a3d773d18d1627fa94712387cf5) | [tree](/?p=jonesforth.git;a=tree;h=cea392870a443a3d773d18d1627fa94712387cf5;hb=cea392870a443a3d773d18d1627fa94712387cf5) | [snapshot](/?p=jonesforth.git;a=snapshot;h=cea392870a443a3d773d18d1627fa94712387cf5;sf=tgz "in format: tar.gz") |
| *2007-10-12* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Tip on dumping out the latest word.](/?p=jonesforth.git;a=commit;h=a9bb8b18891404c2fd315f2fc5cbeaf6c25e9b43) | [commit](/?p=jonesforth.git;a=commit;h=a9bb8b18891404c2fd315f2fc5cbeaf6c25e9b43) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=a9bb8b18891404c2fd315f2fc5cbeaf6c25e9b43) | [tree](/?p=jonesforth.git;a=tree;h=a9bb8b18891404c2fd315f2fc5cbeaf6c25e9b43;hb=a9bb8b18891404c2fd315f2fc5cbeaf6c25e9b43) | [snapshot](/?p=jonesforth.git;a=snapshot;h=a9bb8b18891404c2fd315f2fc5cbeaf6c25e9b43;sf=tgz "in format: tar.gz") |
| *2007-10-11* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Wrote code to do performance comparisons.](/?p=jonesforth.git;a=commit;h=aa173d5f30ea45f0c06799c858c4a91681cf0cf7) | [commit](/?p=jonesforth.git;a=commit;h=aa173d5f30ea45f0c06799c858c4a91681cf0cf7) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=aa173d5f30ea45f0c06799c858c4a91681cf0cf7) | [tree](/?p=jonesforth.git;a=tree;h=aa173d5f30ea45f0c06799c858c4a91681cf0cf7;hb=aa173d5f30ea45f0c06799c858c4a91681cf0cf7) | [snapshot](/?p=jonesforth.git;a=snapshot;h=aa173d5f30ea45f0c06799c858c4a91681cf0cf7;sf=tgz "in format: tar.gz") |
| *2007-10-11* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Test assembler & INLINE](/?p=jonesforth.git;a=commit;h=f8688e0ca6ee2928ae1441ba2b7f5d2c8f43dea5) | [commit](/?p=jonesforth.git;a=commit;h=f8688e0ca6ee2928ae1441ba2b7f5d2c8f43dea5) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=f8688e0ca6ee2928ae1441ba2b7f5d2c8f43dea5) | [tree](/?p=jonesforth.git;a=tree;h=f8688e0ca6ee2928ae1441ba2b7f5d2c8f43dea5;hb=f8688e0ca6ee2928ae1441ba2b7f5d2c8f43dea5) | [snapshot](/?p=jonesforth.git;a=snapshot;h=f8688e0ca6ee2928ae1441ba2b7f5d2c8f43dea5;sf=tgz "in format: tar.gz") |
| *2007-10-11* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Basic stack tests](/?p=jonesforth.git;a=commit;h=a28fd94bb9711f62659bc89a275af9eb7134bece) | [commit](/?p=jonesforth.git;a=commit;h=a28fd94bb9711f62659bc89a275af9eb7134bece) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=a28fd94bb9711f62659bc89a275af9eb7134bece) | [tree](/?p=jonesforth.git;a=tree;h=a28fd94bb9711f62659bc89a275af9eb7134bece;hb=a28fd94bb9711f62659bc89a275af9eb7134bece) | [snapshot](/?p=jonesforth.git;a=snapshot;h=a28fd94bb9711f62659bc89a275af9eb7134bece;sf=tgz "in format: tar.gz") |
| *2007-10-11* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [INLINE assembly](/?p=jonesforth.git;a=commit;h=ac014bc0a927ca7ab4177636056fd267384a8f47) | [commit](/?p=jonesforth.git;a=commit;h=ac014bc0a927ca7ab4177636056fd267384a8f47) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=ac014bc0a927ca7ab4177636056fd267384a8f47) | [tree](/?p=jonesforth.git;a=tree;h=ac014bc0a927ca7ab4177636056fd267384a8f47;hb=ac014bc0a927ca7ab4177636056fd267384a8f47) | [snapshot](/?p=jonesforth.git;a=snapshot;h=ac014bc0a927ca7ab4177636056fd267384a8f47;sf=tgz "in format: tar.gz") |
| *2007-10-11* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Implement 2DROP, 2DUP, 2SWAP as asm primitives.](/?p=jonesforth.git;a=commit;h=ae7508776fa28d069e0d890e6878f09a8e3f05ee) | [commit](/?p=jonesforth.git;a=commit;h=ae7508776fa28d069e0d890e6878f09a8e3f05ee) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=ae7508776fa28d069e0d890e6878f09a8e3f05ee) | [tree](/?p=jonesforth.git;a=tree;h=ae7508776fa28d069e0d890e6878f09a8e3f05ee;hb=ae7508776fa28d069e0d890e6878f09a8e3f05ee) | [snapshot](/?p=jonesforth.git;a=snapshot;h=ae7508776fa28d069e0d890e6878f09a8e3f05ee;sf=tgz "in format: tar.gz") |
| *2007-10-10* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Assembly code.](/?p=jonesforth.git;a=commit;h=465979550d58288f6bee28c49064d9c841a6f45f) | [commit](/?p=jonesforth.git;a=commit;h=465979550d58288f6bee28c49064d9c841a6f45f) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=465979550d58288f6bee28c49064d9c841a6f45f) | [tree](/?p=jonesforth.git;a=tree;h=465979550d58288f6bee28c49064d9c841a6f45f;hb=465979550d58288f6bee28c49064d9c841a6f45f) | [snapshot](/?p=jonesforth.git;a=snapshot;h=465979550d58288f6bee28c49064d9c841a6f45f;sf=tgz "in format: tar.gz") |
| *2007-10-07* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Restructure Makefile to add automated tests.](/?p=jonesforth.git;a=commit;h=83c6612bf07228f70d25136c850f660721379632) | [commit](/?p=jonesforth.git;a=commit;h=83c6612bf07228f70d25136c850f660721379632) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=83c6612bf07228f70d25136c850f660721379632) | [tree](/?p=jonesforth.git;a=tree;h=83c6612bf07228f70d25136c850f660721379632;hb=83c6612bf07228f70d25136c850f660721379632) | [snapshot](/?p=jonesforth.git;a=snapshot;h=83c6612bf07228f70d25136c850f660721379632;sf=tgz "in format: tar.gz") |
| *2007-09-30* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Fix CLOSE](/?p=jonesforth.git;a=commit;h=bedb4b2f3f229eb41f7eb6af84aff5d1d660c805) | [commit](/?p=jonesforth.git;a=commit;h=bedb4b2f3f229eb41f7eb6af84aff5d1d660c805) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=bedb4b2f3f229eb41f7eb6af84aff5d1d660c805) | [tree](/?p=jonesforth.git;a=tree;h=bedb4b2f3f229eb41f7eb6af84aff5d1d660c805;hb=bedb4b2f3f229eb41f7eb6af84aff5d1d660c805) | [snapshot](/?p=jonesforth.git;a=snapshot;h=bedb4b2f3f229eb41f7eb6af84aff5d1d660c805;sf=tgz "in format: tar.gz") |
| *2007-09-29* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | ['SPACE' -> BL (standard FORTH word)](/?p=jonesforth.git;a=commit;h=912d572e049973aac0dd5ae44c81944a76236883) | [commit](/?p=jonesforth.git;a=commit;h=912d572e049973aac0dd5ae44c81944a76236883) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=912d572e049973aac0dd5ae44c81944a76236883) | [tree](/?p=jonesforth.git;a=tree;h=912d572e049973aac0dd5ae44c81944a76236883;hb=912d572e049973aac0dd5ae44c81944a76236883) | [snapshot](/?p=jonesforth.git;a=snapshot;h=912d572e049973aac0dd5ae44c81944a76236883;sf=tgz "in format: tar.gz") |
| *2007-09-29* | [rich](/?p=jonesforth.git;a=search;s=rich;st=author "Search for commits authored by rich") | [Added O\_\* constants for open(2) syscall](/?p=jonesforth.git;a=commit;h=abcbc5d578daa147d957f9e3c5874690ae779328) | [commit](/?p=jonesforth.git;a=commit;h=abcbc5d578daa147d957f9e3c5874690ae779328) | [commitdiff](/?p=jonesforth.git;a=commitdiff;h=abcbc5d578daa147d957f9e3c5874690ae779328) | [tree](/?p=jonesforth.git;a=tree;h=abcbc5d578daa147d957f9e3c5874690ae779328;hb=abcbc5d578daa147d957f9e3c5874690ae779328) | [snapshot](/?p=jonesforth.git;a=snapshot;h=abcbc5d578daa147d957f9e3c5874690ae779328;sf=tgz "in format: tar.gz") |
| [...](/?p=jonesforth.git;a=shortlog) | | | |
[heads](/?p=jonesforth.git;a=heads)
| | | |
| --- | --- | --- |
| *16 years ago* | [master](/?p=jonesforth.git;a=shortlog;h=refs/heads/master) | [shortlog](/?p=jonesforth.git;a=shortlog;h=refs/heads/master) | [log](/?p=jonesforth.git;a=log;h=refs/heads/master) | [tree](/?p=jonesforth.git;a=tree;h=refs/heads/master;hb=refs/heads/master) |
JONESFORTH - A sometimes minimal FORTH compiler and tutorial
[RSS](/?p=jonesforth.git;a=rss "log RSS feed")
[Atom](/?p=jonesforth.git;a=atom "log Atom feed")

View File

@@ -0,0 +1,195 @@
# Literals, ifs, and loops
**Source:** https://muforth.dev/threaded-code-literals-ifs-and-loops/
Threaded code: Literals, ifs, and loops muforth
# Threaded code: Literals, ifs, and loops
---
While writing my [introduction to threaded code](/threaded-code/) I suggested that non-leaf routines colon words, in Forth lingo can be represented as a list of addresses that get executed in sequence. This suggested that all code executes in a straight line and then returns to its caller. We all know this isnt true, but threaded code that runs in a straight line is already tricky and tedious to explain; explaining literals and control structures at the same time seemed like too much.
But we are here now, and we understand how threading-in-a-straight-line works, so lets see how loops, branches, and literals work in a threaded world.
---
In the real world, code doesnt always execute in a straight line and then return and yet, at the moment, which the machinery that weve defined so far, thats all we can do. We also have no way to represent literal data addresses or numbers that we might want to compute with. We can write a code word called `+` that pops two values off the data stack, adds them, and pushes the result, but if we want to add 8 to something, how do we do that?
With just three runtime code words we can add if/then/else, while loops, and literals to our system.
The names are arbitrary, but in many Forth systems the convention is to give them parenthesized names. These are not words that mere mortals normally execute; they exist as part of the hidden “runtime fabric” of the system. The parentheses suggest their “underlying” or “runtime” nature.
Here they are:
```
(lit) Fetch into W the address pointed to by IP
Increment IP by address size (skip literal)
Push W onto the data stack
Execute NEXT
```
```
(branch) Fetch into W the address pointed to by IP
Set IP to W
Execute NEXT
```
```
(0branch) Pop a value off the data stack
If the value is zero, execute (branch)
Otherwise, increment IP by address size (skip branch address)
```
The `(branch)` above does an *absolute* branch. If you prefer relative branches, modify it thus:
```
(branch) Fetch into W the address pointed to by IP
Set IP to IP + W
Execute NEXT
```
Lets assume we have a code word `+` that adds two values. To create a word that adds 8 to whatever is on the top of the stack, we would create a colon word with the following (textual) definition:
```
: add8 8 + ;
```
which, assuming an ITC system, would get compiled to:
```
add8
~~~~
address of NEST ( all colon words start with this)
address of (lit)
8
address of +
address of UNNEST
```
The `;` adds the address of UNNEST at the end and ends the compilation.
(This is getting outside the scope of our discussion, which is about the *execution machinery*, but in Forth systems `;` has *two* tasks: to compile the address of UNNEST, and to exit “compilation mode” a special mode of *textual* interpretation that is the essence of the Forth compiler and return to normal “interpretation” mode.)
For if/then/else and looping we use *flag* values truth values that we compute and leave on the stack for `(0branch)` to test and consume.
To make this even more concrete, lets add five more code words to our system:
```
< Pop two values off the data stack
If the first is less than the second, push -1
Otherwise, push 0
Execute NEXT
```
```
0= Pop a value off the data stack
If the value is zero, push -1
Otherwise, push 0
Execute NEXT
```
```
dup Pop a value off the data stack
Push it back onto data stack
Push it a second time
Execute NEXT
```
```
2dup Pop two values off the data stack
Push them back onto data stack, in the same order
Push them a second time, also in the same order
Execute NEXT
```
```
swap Pop two values off the data stack
Push them back onto data stack, in the reverse order
Execute NEXT
```
In many Forth systems -1 is the preferred “true” value because it is represented (on almost all machines!!) by an all-ones bit pattern, which can be logically ANDed with other values... but we digress. ;-)
From our definition of `(0branch)` above it should be clear that *any* non-zero value is true, and only zero is false.
Lets write a simple loop. (There is a better, more efficient, and more idiomatic way to do this, but it is outside the scope of this example. ;-)
```
-8 begin 1 + dup 0= until
```
This will get compiled to the following “address list”:
```
00 address of (lit)
04 -8
08 address of (lit)
0c 1
10 address of +
14 address of dup
18 address of 0=
1c address of (0branch)
20 08
24 ...
```
We have to `dup` the value before we test it with `0=` because `0=` *consumes* the value before pushing its true or false flag.
The word `begin` compiles no code; it “marks” the location that `(0branch)` later branches back to.
Ive added memory addresses in hex (which assume a byte-addressed machine with 32-bit addresses) to make the branch destination easier to describe.
We write if/then like this:
```
2dup < if swap then
```
This compiles to the following:
```
00 address of 2dup
04 address of <
08 address of (0branch)
0c 1c
10 address of swap
1c ...
```
As before, we `2dup` the values because `<` consumes them.
Like `begin`, `then` compiles no code; it resolves the forward branch that `if` compiled. Words like if, then, begin, and until are called *compiling* words because they execute at compile time and do something special, like resolve a forward or backward branch address.
Adding an `else` clause looks like this:
```
0= if 4 else 8 then +
```
This code compiles to:
```
00 address of 0=
04 address of (0branch)
08 1c
0c address of (lit)
10 4
14 address of (branch)
18 24
1c address of (lit)
20 8
24 address of +
28 ...
```
`if` compiles the `(0branch)`, `else` compiles the `(branch)` and resolves the forward `(0branch)`, and `then` resolves the forward `(branch)`.
Remember: `(0branch)` means branch if *false*.
---
[Send feedback](/cdn-cgi/l/email-protection#ba9f8d8d9f8c8f9f8c889f8c829f8c8b9f8cde9f8d899f8d8e9f8c8f9f8d889f8e8a9f8cdf9f8c839f8cde9f8c889f8cd99f8c8f9f8cde9f8c8b9f8c899f8c829f8c839f8cdf9f8c8f9f8d899f88df9f8c899f8cdc9f8cde85c9cfd8d0dfd9ce879f8fd8d7cfdcd5c8ced29f8fde9f888aeed2c8dfdbdedfde9f888ad9d5dedf9f89db9f888af6d3cedfc8dbd6c99f88d99f888ad3dcc99f88d99f888adbd4de9f888ad6d5d5cac9) on this page (last edited 2017 May 01)
Browse [all pages](/all-pages/)
Return [home](/)

View File

@@ -0,0 +1,621 @@
# MiniForth
**Source:** https://github.com/ttsiodras/MiniForth
GitHub - ttsiodras/MiniForth: A tiny Forth I built in a week. Blog post: https://www.thanassis.space/miniforth.html
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fttsiodras%2FMiniForth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fttsiodras%2FMiniForth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=ttsiodras%2FMiniForth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[ttsiodras](/ttsiodras)
/
**[MiniForth](/ttsiodras/MiniForth)**
Public
* [Notifications](/login?return_to=%2Fttsiodras%2FMiniForth) You must be signed in to change notification settings
* [Fork
7](/login?return_to=%2Fttsiodras%2FMiniForth)
* [Star
95](/login?return_to=%2Fttsiodras%2FMiniForth)
A tiny Forth I built in a week. Blog post: <https://www.thanassis.space/miniforth.html>
### License
[MIT license](/ttsiodras/MiniForth/blob/master/LICENSE)
[95
stars](/ttsiodras/MiniForth/stargazers) [7
forks](/ttsiodras/MiniForth/forks) [Branches](/ttsiodras/MiniForth/branches) [Tags](/ttsiodras/MiniForth/tags) [Activity](/ttsiodras/MiniForth/activity)
[Star](/login?return_to=%2Fttsiodras%2FMiniForth)
[Notifications](/login?return_to=%2Fttsiodras%2FMiniForth) You must be signed in to change notification settings
* [Code](/ttsiodras/MiniForth)
* [Issues
0](/ttsiodras/MiniForth/issues)
* [Pull requests
0](/ttsiodras/MiniForth/pulls)
* [Actions](/ttsiodras/MiniForth/actions)
* [Projects
0](/ttsiodras/MiniForth/projects)
* [Security
0](/ttsiodras/MiniForth/security)
* [Insights](/ttsiodras/MiniForth/pulse)
Additional navigation options
* [Code](/ttsiodras/MiniForth)
* [Issues](/ttsiodras/MiniForth/issues)
* [Pull requests](/ttsiodras/MiniForth/pulls)
* [Actions](/ttsiodras/MiniForth/actions)
* [Projects](/ttsiodras/MiniForth/projects)
* [Security](/ttsiodras/MiniForth/security)
* [Insights](/ttsiodras/MiniForth/pulse)
# ttsiodras/MiniForth
master
[Branches](/ttsiodras/MiniForth/branches)[Tags](/ttsiodras/MiniForth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[41 Commits](/ttsiodras/MiniForth/commits/master/) 41 Commits | | |
| [contrib](/ttsiodras/MiniForth/tree/master/contrib "contrib") | | [contrib](/ttsiodras/MiniForth/tree/master/contrib "contrib") | | |
| [simavr @ a56b550](/buserror/simavr/tree/a56b550872906a971ac128002772d90c9e30377d "simavr") | | [simavr @ a56b550](/buserror/simavr/tree/a56b550872906a971ac128002772d90c9e30377d "simavr") | | |
| [src](/ttsiodras/MiniForth/tree/master/src "src") | | [src](/ttsiodras/MiniForth/tree/master/src "src") | | |
| [src\_x86](/ttsiodras/MiniForth/tree/master/src_x86 "src_x86") | | [src\_x86](/ttsiodras/MiniForth/tree/master/src_x86 "src_x86") | | |
| [testing](/ttsiodras/MiniForth/tree/master/testing "testing") | | [testing](/ttsiodras/MiniForth/tree/master/testing "testing") | | |
| [.gitignore](/ttsiodras/MiniForth/blob/master/.gitignore ".gitignore") | | [.gitignore](/ttsiodras/MiniForth/blob/master/.gitignore ".gitignore") | | |
| [.gitmodules](/ttsiodras/MiniForth/blob/master/.gitmodules ".gitmodules") | | [.gitmodules](/ttsiodras/MiniForth/blob/master/.gitmodules ".gitmodules") | | |
| [LICENSE](/ttsiodras/MiniForth/blob/master/LICENSE "LICENSE") | | [LICENSE](/ttsiodras/MiniForth/blob/master/LICENSE "LICENSE") | | |
| [Makefile](/ttsiodras/MiniForth/blob/master/Makefile "Makefile") | | [Makefile](/ttsiodras/MiniForth/blob/master/Makefile "Makefile") | | |
| [README.md](/ttsiodras/MiniForth/blob/master/README.md "README.md") | | [README.md](/ttsiodras/MiniForth/blob/master/README.md "README.md") | | |
| [config.mk](/ttsiodras/MiniForth/blob/master/config.mk "config.mk") | | [config.mk](/ttsiodras/MiniForth/blob/master/config.mk "config.mk") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [MIT license](#)
*( Wrote [a blog post about this here](https://www.thanassis.space/miniforth.html) )*
It was raining hard, a week ago.
And what could you possibly do on a rainy Saturday afternoon?
Well...
You can make a Forth interpreter/compiler from scratch...
...then put it inside a 1.5$ Blue Pill microcontroller...
...and finally, inside an Arduino UNO...
... within its tiny 2K RAM!
Click on the image to watch it blinking the LED of my Arduino:
[![Here's a video of it action, blinking my Arduino :-)](https://camo.githubusercontent.com/10dcc45a92a8eb1fbc79bbcf7127dea99324e316bf5b5ce1bd0515f9c86e5da5/68747470733a2f2f696d672e796f75747562652e636f6d2f76692f7865506f6c6c62437a6f772f302e6a7067)](https://www.youtube.com/watch?v=xePollbCzow)
I haven't done anything even *remotely* close to this in decades...
I *loved* building it.
The rainy afternoon turned into a week-long hackfest *(was looking
forward every day to the post-work FORTH-tinkering in the afternoon...)*
The result: a tiny, mini, micro Forth. In portable C++ :-)
It has...
* basic arithmetic
* star-slash (double-word accurate muldiv)
* literals
* constants
* variables
* direct memory access
* string printing
* reseting
* comments
* nested DO/LOOP
* comparisons
* nested IF/ELSE/THEN
* ...and of course, functions (Forth words)
Here's an ascii-cast recording of it in action:
[![Recording of building and uploading on an Arduino UNO](https://camo.githubusercontent.com/429594b830bb91d714d4beb75bd9684a0108521b63c4a5669fa2ce955d2b396d/68747470733a2f2f61736369696e656d612e6f72672f612f3432333634392e737667)](https://asciinema.org/a/423649?autoplay=1)
Read the test scenario below to see my supported Forth constructs.
# Portability, ArduinoSTL and Valgrind/AddressSanitizer checks
I meant it when I said "portable". Part of my reasoning was, that
in addition to targeting multiple platforms (e.g. BluePill and
Arduino) I wanted to be able to use Valgrind and AddressSanitizer
to detect - in the host! - any issues I have with my memory handling.
Since I had embedded targets in mind, I tried ArduinoSTL - but it was too
wasteful memory-wise. It also made the build process significantly slower.
I therefore built my own [memory pool, as well as list, tuple and string-like
C++ templates](https://github.com/ttsiodras/MiniForth/tree/master/src/mini_stl.h). It was a nice challenge, re-inventing a tiny C++ STL...
And I understand STL a lot better now, after building small pieces of it myself :-)
# Simulation / Debugging
I setup simulation via [simavr](https://github.com/buserror/simavr.git).
This tremendously improved my developing speed, since a simulator
spawns and runs much faster than the real board. Due to the code
being portable, debugging took place mostly in the host GDB;
and after Valgrind and AddressSanitizer gave their blessing, I usually
found out that the simulator (and the real board) worked fine as well.
# BluePill vs Arduino UNO
Thanks to ArduinoSTL, I quickly reached the point of running inside the
BluePill. The 1.5$ mini-monster has 10 times more SRAM than an Arduino UNO;
so in a couple of days, I had a [working branch](https://github.com/ttsiodras/MiniForth/tree/BluePill-STM32F103C).
[![The 1.5$ 'Beast'](/ttsiodras/MiniForth/raw/master/contrib/BluePill.jpg "The 1.5$ 'Beast'")](/ttsiodras/MiniForth/blob/master/contrib/BluePill.jpg)
But as said above, that wasn't nearly enough to make it work in my
Arduino UNO. That required far more work *(see below)*.
As for the BluePill, I should note that, as in all my other embedded targets,
I prefer a development workflow that is based on normal bootloaders
*(not on programmers)*. I therefore burned the
[stm32duino](https://github.com/rogerclarkmelbourne/STM32duino-bootloader)
bootloader on the BluePill, which allowed me to easily program it
in subsequent iterations via the USB connection (and a simple `make upload`).
The same USB connection would then function as a serial port immediately
afterwards - allowing me to interact with the newly uploaded Forth in the
BluePill.
The screenshot below is from a `tmux`: on the left, the output from `make upload`;
and on the right, I used `picocom` to interact with my mini-Forth
over the serial port:
[![Compiling, uploading and testing](/ttsiodras/MiniForth/raw/master/contrib/itworks.jpg "Compiling, uploading and testing")](/ttsiodras/MiniForth/blob/master/contrib/itworks.jpg)
# Memory - the final frontier
That covered the first two days.
But when I tried compiling for the Arduino UNO, I realised that the ArduinoSTL
was not enough. I run out of memory...
So I built my own [mini-STL](https://github.com/ttsiodras/MiniForth/tree/master/src/mini_stl.h),
and tightly controlled *all* memory utilisation.
I also used macro-magic to move all strings to Flash at compile-time
(see `dprintf` in the code)... And saved memory everywhere I could,
re-using error messages across various operations - and storing the
entire array of native operations in Flash.
Nothing flexes your coding muscles as much as optimising; whether it is
for speed or for space. See the implementation of ".S" for example,
where the (obvious) stack reversal code is also the most wasteful...
Changing it to a slower but memory-preserving algorithm allowed me
to use ".S" even when almost all my memory is full.
# C++ vs C
I know that many developers hate C++. I even wrote a
[blog post](https://www.thanassis.space/cpp.html) about it.
And I understand why - they see code like this...
```
#include "mini_stl.h"
template<class T>
typename forward_list<T>::box *forward_list<T>::_freeList = NULL;
```
...and they start screaming - "what the hell is that", "incomprehensible
madness", etc.
But there are very important benefits in using C++ - and templates
in particular. You write less code, with no additional run-time or
memory overhead compared to C, and with a lot more compile-time checks
that watch your back (for things that would otherwise blow up in your face).
See my Optional for example, that emulates (badly) the optional
type of Rust/OCaml/F#/Scala/Kotlin etc. It **forces** you to check
your returned error codes:
```
Optional<int> Forth::needs_a_number(const __FlashStringHelper *msg)
{
if (_stack.empty())
return error(emptyMsgFlash, msg);
auto topVal = *_stack.begin();
if (topVal._kind == StackNode::LIT)
return topVal._u.intVal;
else
return FAILURE;
}
```
You can't "forget" to check the potential for a failure coded inside
your returned value - because your code has to "unwrap" it. I could have
done this better, but I chose to implement it via simple tuples
(this was a one-weeks-afternoons hack, after all :-)
As for the template "magic" incantation above - it *is* true magic: My
`forward_list` template is using free-lists to store the `pop_front`-ed
elements and reuse them in subsequent allocations. I wanted these free-lists to
be global (i.e. static members) because lists of the same type must re-use a
single, commonly-shared free-list. The magic spell tells the compiler I want to
instantiate these globals *once*, for each type T that I use in any
lists in my code.
# My Forth test scenario - including a FizzBuzz!
Yep, FizzBuzz - we are fully Turing complete. And would surely pass
Joel's interview :-)
```
." Reset... " RESET
." Check comments... " \ Yes, we support the new-style comments :-)
." Computing simple addition of 3 + 4... " 3 4 + .
." Is 1 = 2 ?... " 1 2 = .
." Is 1 > 2 ?... " 1 2 > .
." Is 1 < 2 ?... " 1 2 < .
." Define pi at double-word precision... " : pi 355 113 */ ;
." Use definition to compute 10K times PI... " 10000 pi .
." Check: 23 mod 7... " 23 7 MOD .
." Defining 1st level function1... " : x2 2 * ;
." Defining 1st level function2... " : p4 4 + ;
." 2nd level word using both - must print 24... " 10 x2 p4 .
." Defining a variable with value 123... " 123 variable ot3
." Printing variable's value... " ot3 @ .
." Defining The Constant (TM)... " 42 constant lifeUniverse
." Printing The Constant (TM)... " lifeUniverse .
." Setting the variable to The Constant (TM)... " lifeUniverse ot3 !
." Printing variable's value... " ot3 @ .
." Setting the variable to hex 0x11... " $11 ot3 !
." Printing variable's value... " ot3 @ .
." Setting the variable to binary 10100101... " %10100101 ot3 !
." Printing variable's value... " ot3 @ .
." Defining helper... " : p5 5 U.R . ;
." Defining 3 times loop... " : x3lp 3 0 DO I p5 LOOP ;
." Calling loop... " x3lp
." Defining loop calling loop 2 times... " : x6lp 2 0 DO x3lp LOOP ;
." Nested-looping 2x3 times... " x6lp
." Inline: " : m 3 1 DO 3 1 DO CR J p5 I p5 ." = " J I * p5 LOOP LOOP ;
." Use inline loops with two indexes... " m
." Make multiples of 7 via DUP... " : m7s 10 0 DO DUP I * . LOOP DROP ;
." Print them and DROP the 7... " 7 m7s
." Reset... " RESET
\ Time for Turing completeness...
." Let's do Fizz-Buzz! " \ Turing Completeness check...
\ fizz ( n -- 0_or_1 n )
." Define fizz... " : fizz DUP 3 MOD 0 = IF ." fizz " 1 ELSE 0 THEN SWAP ;
\ buzz ( n -- 0_or_1 n )
." Define buzz... " : buzz DUP 5 MOD 0 = IF ." buzz " 1 ELSE 0 THEN SWAP ;
\ emitNum ( 0_or_1 0_or_1 n -- )
." Define emitNum... " : emitNum ROT ROT + 0 = if . ELSE DROP THEN ;
\ mainloop ( n -- )
." Define mainloop... " : mainloop ." ( " fizz buzz emitNum ." ) " ;
\ fb ( -- )
." Define fizzbuzz... " : fb 37 1 DO I mainloop LOOP ;
." Run it! " fb
." Report memory usage... " .S
." All done! "
```
# Automation
I am a strong believer in automation. The final form of my `Makefile`
therefore has many rules - e.g. `make arduino-sim` - that automate
various parts of the workflow.
Here's what they do:
* **arduino**: Compiles the code for Arduino UNO - builds `src/tmp/myforth.ino.{elf,hex}`
* **arduino-sim**: After building, launches the compiled mini-Forth in `simduino`.
* **upload**: After building, uploads to an Arduino attached to the port
configured inside `config.mk`.
* **terminal**: After uploading, launches a `picocom` terminal with
all appropriate settings to interact with my Forth.
* **x86**: Builds for x86. Actually, should easily build for any native target (ARM, etc).
* **test-address-sanitizer**: Uses the x86 binary to test the code, executing
all steps of the scenario shown above. The binary is built with the
address sanitizer enabled (to detect memory issues).
* **test-valgrind**: Same, but with Valgrind.
* **test-simulator**: Spawns `simavr` and sends the entire test scenario shown
above to it - while showing the responses received from it.
* **test-arduino**: Sends the entire test scenario shown above to an
Arduino Uno connected to the port specified in `config.mk`
and shows the responses received over that serial port.
* **blink-arduino**: Sends the "hello word" of the HW world: a tiny
[Forth program](/ttsiodras/MiniForth/blob/master/testing/blinky.fs) blinking the Arduino's LED.
Another example of automation - the complete test scenario shown in the
previous section, is not just an example in the documentation; it is
extracted automatically from this README and fed into the Valgrind and
AddressSanitizer tests... and also into the Python testing script that
sends the data to the board in real-time.
[DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself), folks.
# Conclusion
I thoroughly enjoyed building this. I know full well that Forths are not
supposed to be built in C++; they are supposed to be built in assembly,
and also, utilise the Flash to store the user-compiled code at run-time.
But that wasn't the point of this - the point was to have fun and learn Forth.
And what better way to learn a language than to actually implement it! :-)
And... as a child of the 80s... I now know first-hand what
[Jupiter Ace](https://en.wikipedia.org/wiki/Jupiter_Ace) was about :-)
Fork the code, and enjoy tinkering with it!
Thanassis.
## About
A tiny Forth I built in a week. Blog post: <https://www.thanassis.space/miniforth.html>
### Topics
[arduino](/topics/arduino "Topic: arduino")
[cpp](/topics/cpp "Topic: cpp")
[forth](/topics/forth "Topic: forth")
### Resources
[Readme](#readme-ov-file)
### License
[MIT license](#MIT-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/ttsiodras/MiniForth/activity)
### Stars
[**95**
stars](/ttsiodras/MiniForth/stargazers)
### Watchers
[**6**
watching](/ttsiodras/MiniForth/watchers)
### Forks
[**7**
forks](/ttsiodras/MiniForth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fttsiodras%2FMiniForth&report=ttsiodras+%28user%29)
## [Releases 2](/ttsiodras/MiniForth/releases)
[Final release - optimal memory/flash use everywhere.
Latest
Jul 9, 2021](/ttsiodras/MiniForth/releases/tag/v1.1)
[+ 1 release](/ttsiodras/MiniForth/releases)
## [Packages 0](/users/ttsiodras/packages?repo_name=MiniForth)
No packages published
## Languages
* [C++
80.5%](/ttsiodras/MiniForth/search?l=c%2B%2B)
* [C
10.9%](/ttsiodras/MiniForth/search?l=c)
* [Makefile
4.9%](/ttsiodras/MiniForth/search?l=makefile)
* [Python
1.5%](/ttsiodras/MiniForth/search?l=python)
* [Shell
1.3%](/ttsiodras/MiniForth/search?l=shell)
* [Forth
0.9%](/ttsiodras/MiniForth/search?l=forth)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,466 @@
# Repo
**Source:** https://github.com/nimblemachines/muforth#under-active-development
GitHub - nimblemachines/muforth: A simple, indirect-threaded Forth, written in C; for target compiling; runs on Linux, BSD, OSX, and Cygwin
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fnimblemachines%2Fmuforth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fnimblemachines%2Fmuforth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=nimblemachines%2Fmuforth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[nimblemachines](/nimblemachines)
/
**[muforth](/nimblemachines/muforth)**
Public
* [Notifications](/login?return_to=%2Fnimblemachines%2Fmuforth) You must be signed in to change notification settings
* [Fork
34](/login?return_to=%2Fnimblemachines%2Fmuforth)
* [Star
153](/login?return_to=%2Fnimblemachines%2Fmuforth)
A simple, indirect-threaded Forth, written in C; for target compiling; runs on Linux, BSD, OSX, and Cygwin
[muforth.dev/](https://muforth.dev/ "https://muforth.dev/")
### License
[View license](/nimblemachines/muforth/blob/master/LICENSE)
[153
stars](/nimblemachines/muforth/stargazers) [34
forks](/nimblemachines/muforth/forks) [Branches](/nimblemachines/muforth/branches) [Tags](/nimblemachines/muforth/tags) [Activity](/nimblemachines/muforth/activity)
[Star](/login?return_to=%2Fnimblemachines%2Fmuforth)
[Notifications](/login?return_to=%2Fnimblemachines%2Fmuforth) You must be signed in to change notification settings
* [Code](/nimblemachines/muforth)
* [Issues
17](/nimblemachines/muforth/issues)
* [Pull requests
1](/nimblemachines/muforth/pulls)
* [Actions](/nimblemachines/muforth/actions)
* [Projects
0](/nimblemachines/muforth/projects)
* [Security
0](/nimblemachines/muforth/security)
* [Insights](/nimblemachines/muforth/pulse)
Additional navigation options
* [Code](/nimblemachines/muforth)
* [Issues](/nimblemachines/muforth/issues)
* [Pull requests](/nimblemachines/muforth/pulls)
* [Actions](/nimblemachines/muforth/actions)
* [Projects](/nimblemachines/muforth/projects)
* [Security](/nimblemachines/muforth/security)
* [Insights](/nimblemachines/muforth/pulse)
# nimblemachines/muforth
master
[Branches](/nimblemachines/muforth/branches)[Tags](/nimblemachines/muforth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[3,159 Commits](/nimblemachines/muforth/commits/master/) 3,159 Commits | | |
| [.vim](/nimblemachines/muforth/tree/master/.vim ".vim") | | [.vim](/nimblemachines/muforth/tree/master/.vim ".vim") | | |
| [doc](/nimblemachines/muforth/tree/master/doc "doc") | | [doc](/nimblemachines/muforth/tree/master/doc "doc") | | |
| [mu](/nimblemachines/muforth/tree/master/mu "mu") | | [mu](/nimblemachines/muforth/tree/master/mu "mu") | | |
| [scripts](/nimblemachines/muforth/tree/master/scripts "scripts") | | [scripts](/nimblemachines/muforth/tree/master/scripts "scripts") | | |
| [src](/nimblemachines/muforth/tree/master/src "src") | | [src](/nimblemachines/muforth/tree/master/src "src") | | |
| [talks](/nimblemachines/muforth/tree/master/talks "talks") | | [talks](/nimblemachines/muforth/tree/master/talks "talks") | | |
| [.gitattributes](/nimblemachines/muforth/blob/master/.gitattributes ".gitattributes") | | [.gitattributes](/nimblemachines/muforth/blob/master/.gitattributes ".gitattributes") | | |
| [BUILDING](/nimblemachines/muforth/blob/master/BUILDING "BUILDING") | | [BUILDING](/nimblemachines/muforth/blob/master/BUILDING "BUILDING") | | |
| [LICENSE](/nimblemachines/muforth/blob/master/LICENSE "LICENSE") | | [LICENSE](/nimblemachines/muforth/blob/master/LICENSE "LICENSE") | | |
| [README.md](/nimblemachines/muforth/blob/master/README.md "README.md") | | [README.md](/nimblemachines/muforth/blob/master/README.md "README.md") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [License](#)
# What is muforth?
muforth is a small, simple, fast, indirect-threaded code (ITC) Forth intended
for use as a cross-compiler for microcontrollers and other embedded devices.
It is written in C and its core is very portable. Because of its Forth nature,
it is naturally extensible, scriptable, and customizable.
muforth is very well-suited to interactive coding, debugging, and exploration,
and is a great tool for bringing up new hardware.
It has support in varying degrees of completeness for a number of
different architectures and chip families.
* [8051](/nimblemachines/muforth/blob/master/mu/target/8051)
* [ARMv6-m](/nimblemachines/muforth/blob/master/mu/target/ARM/v6-m) (aka Cortex-M0/M0+)
* [ARMv7-m](/nimblemachines/muforth/blob/master/mu/target/ARM/v7-m) (aka Cortex-M3/M4/M7)
* [AVR](/nimblemachines/muforth/blob/master/mu/target/AVR) (Atmel/Microchip)
* [HC08 and HCS08](/nimblemachines/muforth/blob/master/mu/target/S08) (Motorola/Freescale/NXP)
* [MSP430](/nimblemachines/muforth/blob/master/mu/target/MSP430) (TI)
* [PIC18](/nimblemachines/muforth/blob/master/mu/target/PIC18) (Microchip)
* [RISC-V](/nimblemachines/muforth/blob/master/mu/target/RISC-V) (initially, the SiFive FE310 and GigaDevice
GD32VF103)
# Tethered vs self-hosted
Unlike a "self-hosted" Forth, where the target contains the dictionary, the
text interpreter, and all the tools necessary for assembling and compiling
code, muforth supports a *tethered* development model. muforth runs on the
*host* machine, compiling code and data that are later copied to the *target*
machine and executed there.
Because the dictionary and all the compilation tools reside on the *host*,
only the *compiled* code and data reside on the target. This makes it possible
to target *very* small devices that only have a few kilobytes of flash and a
few hundred bytes of RAM. In contrast, a self-hosted Forth often needs 16 KiB
(or more) of flash to be useful, and consumes RAM for the text interpreter and
compiler.
The host machine is also orders of magnitude faster than the target, so doing
the compilation on the host is essentially instantaneous.
# Why yet another Forth?
I initially wrote muforth because I wanted to try out some implementation
ideas. The core language primitives are written in C, but initially muforth
compiled Forth words via a simple native code compiler for the x86. I quickly
realized that simplicity and portability were more important than speed. The
current implementation is a straightforward indirect-threaded Forth - and it
is *quite* fast!
Its implementation is no longer the point. Its sole reason for existing is to
be a cross-compiler for *other* Forths, and their implementations are in no
way tied to muforths. In fact, muforth can be used to compile *any* sort of
code onto the target. I've used it very successfully as a smart assembler for
writing AVR and S08 code.
By keeping it small and simple, it is much more likely to be a useful tool
that people can customize.
Its [BSD licensed](/nimblemachines/muforth/blob/master/LICENSE), so do what you want with it! Id love to hear
about innovative or unusual uses of muforth.
# Starting points
[BUILDING](/nimblemachines/muforth/blob/master/BUILDING) will tell you how to build muforth. Its very simple.
Look in [mu/target/](/nimblemachines/muforth/blob/master/mu/target) to find a target that interests you. There is
generally a `mu/target/<target-name>/build.mu4` that loads the cross-build
environment. Use it as an “index” to find the assembler, disassembler,
meta-compiler, kernel, and other key pieces of code.
# Documentation
Sadly, there isnt a lot of documentation right now. A good place to start is
to read the source.
The code both the C code that implements the Forth virtual machine and the
muforth code that does everything else is carefully and in some cases
extensively (even obsessively!) commented. Right now your best source of
documentation is the code! Luckily for you, there isnt that much of it, so
reading it is actually possible. Thats part of the point of muforth; I want
it to be a [convivial tool](https://www.nimblemachines.com/convivial-tool/).
The heart of the system is the Forth code that muforth reads when it first
starts: [mu/startup.mu4](/nimblemachines/muforth/blob/master/mu/startup.mu4). Youll learn a lot by reading this!
[muforth.dev](https://muforth.dev/) will
eventually host the muforth documentation. At the moment, it is a collection
of [journals, essays, and “getting started” pages](https://muforth.dev/all-pages/).
# News
Follow [@muforth.dev](https://bsky.app/profile/muforth.dev) for updates about
the project and related things (eg, interesting development boards) that I'm
thinking about.
# Talks
In March 2008 I gave a [talk](https://vimeo.com/859408) about bootstrapping,
muforth, and [convivial tools](https://www.nimblemachines.com/convivial-tool/).
Warning: I wave my arms around a lot, and the audio and video quality isnt
that great, but you might find it interesting, or at least amusing.
Its also hard to see my slides. If you want to “follow along”,
[download my slides](https://raw.githubusercontent.com/nimblemachines/muforth/master/talks/2008-mar-30-PNCA),
and use `less` to view them ideally in a text window that is at least 30
lines high like so:
```
less -30 ~/muforth/talks/2008-mar-30-PNCA
```
[![March 2008 talk on Vimeo](https://user-images.githubusercontent.com/3320/214488827-47171f1b-5221-44d0-b9d9-7febcff83628.png)](https://vimeo.com/859408)
# Above all, enjoy!
## About
A simple, indirect-threaded Forth, written in C; for target compiling; runs on Linux, BSD, OSX, and Cygwin
[muforth.dev/](https://muforth.dev/ "https://muforth.dev/")
### Resources
[Readme](#readme-ov-file)
### License
[View license](#License-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/nimblemachines/muforth/activity)
### Stars
[**153**
stars](/nimblemachines/muforth/stargazers)
### Watchers
[**20**
watching](/nimblemachines/muforth/watchers)
### Forks
[**34**
forks](/nimblemachines/muforth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fnimblemachines%2Fmuforth&report=nimblemachines+%28user%29)
## [Releases](/nimblemachines/muforth/releases)
No releases published
## [Packages 0](/users/nimblemachines/packages?repo_name=muforth)
No packages published
### Uh oh!
There was an error while loading. Please reload this page.
## [Contributors 4](/nimblemachines/muforth/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [Forth
90.9%](/nimblemachines/muforth/search?l=forth)
* [Assembly
3.3%](/nimblemachines/muforth/search?l=assembly)
* [Lua
2.9%](/nimblemachines/muforth/search?l=lua)
* [C
2.1%](/nimblemachines/muforth/search?l=c)
* [Roff
0.3%](/nimblemachines/muforth/search?l=roff)
* [Shell
0.2%](/nimblemachines/muforth/search?l=shell)
* Other
0.3%
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,357 @@
# SmithForth_RISC-V
**Source:** https://github.com/AndreiDuma/SmithForth_RISC-V
GitHub - AndreiDuma/SmithForth\_RISC-V: An accessible Forth written in machine code for the RISC-V architecture.
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2FAndreiDuma%2FSmithForth_RISC-V)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2FAndreiDuma%2FSmithForth_RISC-V)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=AndreiDuma%2FSmithForth_RISC-V)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[AndreiDuma](/AndreiDuma)
/
**[SmithForth\_RISC-V](/AndreiDuma/SmithForth_RISC-V)**
Public
* [Notifications](/login?return_to=%2FAndreiDuma%2FSmithForth_RISC-V) You must be signed in to change notification settings
* [Fork
2](/login?return_to=%2FAndreiDuma%2FSmithForth_RISC-V)
* [Star
23](/login?return_to=%2FAndreiDuma%2FSmithForth_RISC-V)
An accessible Forth written in machine code for the RISC-V architecture.
### License
[EUPL-1.2 license](/AndreiDuma/SmithForth_RISC-V/blob/main/LICENSE)
[23
stars](/AndreiDuma/SmithForth_RISC-V/stargazers) [2
forks](/AndreiDuma/SmithForth_RISC-V/forks) [Branches](/AndreiDuma/SmithForth_RISC-V/branches) [Tags](/AndreiDuma/SmithForth_RISC-V/tags) [Activity](/AndreiDuma/SmithForth_RISC-V/activity)
[Star](/login?return_to=%2FAndreiDuma%2FSmithForth_RISC-V)
[Notifications](/login?return_to=%2FAndreiDuma%2FSmithForth_RISC-V) You must be signed in to change notification settings
* [Code](/AndreiDuma/SmithForth_RISC-V)
* [Issues
2](/AndreiDuma/SmithForth_RISC-V/issues)
* [Pull requests
0](/AndreiDuma/SmithForth_RISC-V/pulls)
* [Security
0](/AndreiDuma/SmithForth_RISC-V/security)
* [Insights](/AndreiDuma/SmithForth_RISC-V/pulse)
Additional navigation options
* [Code](/AndreiDuma/SmithForth_RISC-V)
* [Issues](/AndreiDuma/SmithForth_RISC-V/issues)
* [Pull requests](/AndreiDuma/SmithForth_RISC-V/pulls)
* [Security](/AndreiDuma/SmithForth_RISC-V/security)
* [Insights](/AndreiDuma/SmithForth_RISC-V/pulse)
# AndreiDuma/SmithForth\_RISC-V
main
[Branches](/AndreiDuma/SmithForth_RISC-V/branches)[Tags](/AndreiDuma/SmithForth_RISC-V/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[4 Commits](/AndreiDuma/SmithForth_RISC-V/commits/main/) 4 Commits | | |
| [.gitignore](/AndreiDuma/SmithForth_RISC-V/blob/main/.gitignore ".gitignore") | | [.gitignore](/AndreiDuma/SmithForth_RISC-V/blob/main/.gitignore ".gitignore") | | |
| [LICENSE](/AndreiDuma/SmithForth_RISC-V/blob/main/LICENSE "LICENSE") | | [LICENSE](/AndreiDuma/SmithForth_RISC-V/blob/main/LICENSE "LICENSE") | | |
| [Makefile](/AndreiDuma/SmithForth_RISC-V/blob/main/Makefile "Makefile") | | [Makefile](/AndreiDuma/SmithForth_RISC-V/blob/main/Makefile "Makefile") | | |
| [README.md](/AndreiDuma/SmithForth_RISC-V/blob/main/README.md "README.md") | | [README.md](/AndreiDuma/SmithForth_RISC-V/blob/main/README.md "README.md") | | |
| [SForth.dmp](/AndreiDuma/SmithForth_RISC-V/blob/main/SForth.dmp "SForth.dmp") | | [SForth.dmp](/AndreiDuma/SmithForth_RISC-V/blob/main/SForth.dmp "SForth.dmp") | | |
| [build.sh](/AndreiDuma/SmithForth_RISC-V/blob/main/build.sh "build.sh") | | [build.sh](/AndreiDuma/SmithForth_RISC-V/blob/main/build.sh "build.sh") | | |
| [input.fs](/AndreiDuma/SmithForth_RISC-V/blob/main/input.fs "input.fs") | | [input.fs](/AndreiDuma/SmithForth_RISC-V/blob/main/input.fs "input.fs") | | |
| [system.fs](/AndreiDuma/SmithForth_RISC-V/blob/main/system.fs "system.fs") | | [system.fs](/AndreiDuma/SmithForth_RISC-V/blob/main/system.fs "system.fs") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [EUPL-1.2 license](#)
This is an accessible Forth implementation written directly in machine
code for the RISC-V architecture. It is an adaptation of David
Smith's excellent x86-64 [SmithForth](https://dacvs.neocities.org/SF/).
Run with `make run`. You will need to run Linux either on RISC-V
hardware or in a QEMU environment.
This project was developed as part of my Master's [thesis](https://github.com/AndreiDuma/SmithForth_RISC-V/releases/download/v1.0/From_x86-64_Forth_to_RISC-V_Andrei_Dorian_Duma_2024.pdf), in
which I thoroughly annotate SmithForth's machine code before porting
it to RISC-V. The abstract of my thesis is given below:
> In this thesis we present the implementation of a usable Forth
> system, built using only RISC-V machine code and the Linux operating
> system as foundations. We begin by justifying the need for
> accessible programming language implementations, discussing
> desirable features in educational compilers. Having selected Forth
> as our language of choice for an educational language
> implementation, we review existing Forth systems and we motivate why
> creating a RISC-V port is a worthwhile task. Next we thoroughly
> examine SmithForth, a high-quality Forth system for the x86-64
> architecture. After understanding its principles, we port it to
> RISC-V, adapting it to our purposes. Finally, we extend this Forth
> system in Forth itself: we write a RISC- V assembler, we provide
> useful arithmetic and logic operators plus conditional and looping
> constructs. We complete our demonstration with a Forth
> implementation of FizzBuzz, showing the usability of the system.
Those interested can [download](https://github.com/AndreiDuma/SmithForth_RISC-V/releases/download/v1.0/From_x86-64_Forth_to_RISC-V_Andrei_Dorian_Duma_2024.pdf) the thesis document in PDF format.
## About
An accessible Forth written in machine code for the RISC-V architecture.
### Topics
[compiler](/topics/compiler "Topic: compiler")
[master-thesis](/topics/master-thesis "Topic: master-thesis")
[forth](/topics/forth "Topic: forth")
[machine-code](/topics/machine-code "Topic: machine-code")
[risc-v](/topics/risc-v "Topic: risc-v")
### Resources
[Readme](#readme-ov-file)
### License
[EUPL-1.2 license](#EUPL-1.2-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/AndreiDuma/SmithForth_RISC-V/activity)
### Stars
[**23**
stars](/AndreiDuma/SmithForth_RISC-V/stargazers)
### Watchers
[**4**
watching](/AndreiDuma/SmithForth_RISC-V/watchers)
### Forks
[**2**
forks](/AndreiDuma/SmithForth_RISC-V/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2FAndreiDuma%2FSmithForth_RISC-V&report=AndreiDuma+%28user%29)
## [Releases 1](/AndreiDuma/SmithForth_RISC-V/releases)
[Thesis v1.0
Latest
Sep 12, 2024](/AndreiDuma/SmithForth_RISC-V/releases/tag/v1.0)
## Languages
* [Forth
95.2%](/AndreiDuma/SmithForth_RISC-V/search?l=forth)
* [Shell
3.3%](/AndreiDuma/SmithForth_RISC-V/search?l=shell)
* [Makefile
1.5%](/AndreiDuma/SmithForth_RISC-V/search?l=makefile)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,878 @@
# StoneKnifeForth
**Source:** https://github.com/kragen/stoneknifeforth
GitHub - kragen/stoneknifeforth: a tiny self-hosted Forth implementation
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fkragen%2Fstoneknifeforth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fkragen%2Fstoneknifeforth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=kragen%2Fstoneknifeforth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[kragen](/kragen)
/
**[stoneknifeforth](/kragen/stoneknifeforth)**
Public
* [Notifications](/login?return_to=%2Fkragen%2Fstoneknifeforth) You must be signed in to change notification settings
* [Fork
24](/login?return_to=%2Fkragen%2Fstoneknifeforth)
* [Star
436](/login?return_to=%2Fkragen%2Fstoneknifeforth)
a tiny self-hosted Forth implementation
### License
[CC0-1.0 license](/kragen/stoneknifeforth/blob/master/LICENSE.md)
[436
stars](/kragen/stoneknifeforth/stargazers) [24
forks](/kragen/stoneknifeforth/forks) [Branches](/kragen/stoneknifeforth/branches) [Tags](/kragen/stoneknifeforth/tags) [Activity](/kragen/stoneknifeforth/activity)
[Star](/login?return_to=%2Fkragen%2Fstoneknifeforth)
[Notifications](/login?return_to=%2Fkragen%2Fstoneknifeforth) You must be signed in to change notification settings
* [Code](/kragen/stoneknifeforth)
* [Issues
2](/kragen/stoneknifeforth/issues)
* [Pull requests
2](/kragen/stoneknifeforth/pulls)
* [Actions](/kragen/stoneknifeforth/actions)
* [Projects
0](/kragen/stoneknifeforth/projects)
* [Wiki](/kragen/stoneknifeforth/wiki)
* [Security
0](/kragen/stoneknifeforth/security)
* [Insights](/kragen/stoneknifeforth/pulse)
Additional navigation options
* [Code](/kragen/stoneknifeforth)
* [Issues](/kragen/stoneknifeforth/issues)
* [Pull requests](/kragen/stoneknifeforth/pulls)
* [Actions](/kragen/stoneknifeforth/actions)
* [Projects](/kragen/stoneknifeforth/projects)
* [Wiki](/kragen/stoneknifeforth/wiki)
* [Security](/kragen/stoneknifeforth/security)
* [Insights](/kragen/stoneknifeforth/pulse)
# kragen/stoneknifeforth
master
[Branches](/kragen/stoneknifeforth/branches)[Tags](/kragen/stoneknifeforth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[113 Commits](/kragen/stoneknifeforth/commits/master/) 113 Commits | | |
| [.gitattributes](/kragen/stoneknifeforth/blob/master/.gitattributes ".gitattributes") | | [.gitattributes](/kragen/stoneknifeforth/blob/master/.gitattributes ".gitattributes") | | |
| [.gitignore](/kragen/stoneknifeforth/blob/master/.gitignore ".gitignore") | | [.gitignore](/kragen/stoneknifeforth/blob/master/.gitignore ".gitignore") | | |
| [386.c](/kragen/stoneknifeforth/blob/master/386.c "386.c") | | [386.c](/kragen/stoneknifeforth/blob/master/386.c "386.c") | | |
| [LICENSE.md](/kragen/stoneknifeforth/blob/master/LICENSE.md "LICENSE.md") | | [LICENSE.md](/kragen/stoneknifeforth/blob/master/LICENSE.md "LICENSE.md") | | |
| [Makefile](/kragen/stoneknifeforth/blob/master/Makefile "Makefile") | | [Makefile](/kragen/stoneknifeforth/blob/master/Makefile "Makefile") | | |
| [Q.tbf1](/kragen/stoneknifeforth/blob/master/Q.tbf1 "Q.tbf1") | | [Q.tbf1](/kragen/stoneknifeforth/blob/master/Q.tbf1 "Q.tbf1") | | |
| [README.md](/kragen/stoneknifeforth/blob/master/README.md "README.md") | | [README.md](/kragen/stoneknifeforth/blob/master/README.md "README.md") | | |
| [TODO](/kragen/stoneknifeforth/blob/master/TODO "TODO") | | [TODO](/kragen/stoneknifeforth/blob/master/TODO "TODO") | | |
| [build](/kragen/stoneknifeforth/blob/master/build "build") | | [build](/kragen/stoneknifeforth/blob/master/build "build") | | |
| [cat.tbf1](/kragen/stoneknifeforth/blob/master/cat.tbf1 "cat.tbf1") | | [cat.tbf1](/kragen/stoneknifeforth/blob/master/cat.tbf1 "cat.tbf1") | | |
| [cat1.tbf1](/kragen/stoneknifeforth/blob/master/cat1.tbf1 "cat1.tbf1") | | [cat1.tbf1](/kragen/stoneknifeforth/blob/master/cat1.tbf1 "cat1.tbf1") | | |
| [disassemble](/kragen/stoneknifeforth/blob/master/disassemble "disassemble") | | [disassemble](/kragen/stoneknifeforth/blob/master/disassemble "disassemble") | | |
| [hello42.tbf1](/kragen/stoneknifeforth/blob/master/hello42.tbf1 "hello42.tbf1") | | [hello42.tbf1](/kragen/stoneknifeforth/blob/master/hello42.tbf1 "hello42.tbf1") | | |
| [hi.tbf1](/kragen/stoneknifeforth/blob/master/hi.tbf1 "hi.tbf1") | | [hi.tbf1](/kragen/stoneknifeforth/blob/master/hi.tbf1 "hi.tbf1") | | |
| [onescreen.tbf1](/kragen/stoneknifeforth/blob/master/onescreen.tbf1 "onescreen.tbf1") | | [onescreen.tbf1](/kragen/stoneknifeforth/blob/master/onescreen.tbf1 "onescreen.tbf1") | | |
| [star.tbf1](/kragen/stoneknifeforth/blob/master/star.tbf1 "star.tbf1") | | [star.tbf1](/kragen/stoneknifeforth/blob/master/star.tbf1 "star.tbf1") | | |
| [tiny.asm](/kragen/stoneknifeforth/blob/master/tiny.asm "tiny.asm") | | [tiny.asm](/kragen/stoneknifeforth/blob/master/tiny.asm "tiny.asm") | | |
| [tinyboot.py](/kragen/stoneknifeforth/blob/master/tinyboot.py "tinyboot.py") | | [tinyboot.py](/kragen/stoneknifeforth/blob/master/tinyboot.py "tinyboot.py") | | |
| [tinyboot.s](/kragen/stoneknifeforth/blob/master/tinyboot.s "tinyboot.s") | | [tinyboot.s](/kragen/stoneknifeforth/blob/master/tinyboot.s "tinyboot.s") | | |
| [tinyboot1.tbf1](/kragen/stoneknifeforth/blob/master/tinyboot1.tbf1 "tinyboot1.tbf1") | | [tinyboot1.tbf1](/kragen/stoneknifeforth/blob/master/tinyboot1.tbf1 "tinyboot1.tbf1") | | |
| [trace.py](/kragen/stoneknifeforth/blob/master/trace.py "trace.py") | | [trace.py](/kragen/stoneknifeforth/blob/master/trace.py "trace.py") | | |
| [trim.py](/kragen/stoneknifeforth/blob/master/trim.py "trim.py") | | [trim.py](/kragen/stoneknifeforth/blob/master/trim.py "trim.py") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [CC0-1.0 license](#)
# StoneKnifeForth
This is StoneKnifeForth, a very simple language inspired by Forth. It
is not expected to be useful; instead, its purpose is to show how
simple a compiler can be. The compiler is a bit under two pages of
code when the comments are removed.
This package includes a “metacircular compiler” which is written in
StoneKnifeForth and compiles StoneKnifeForth to an x86 Linux ELF
executable.
There is also a StoneKnifeForth interpreter written in Python (tested
with Python 2.4). It seems to be about 100× slower than code emitted
by the compiler.
(All of the measurements below may be a bit out of date.)
On my 700MHz laptop, measuring wall-clock time:
* compiling the compiler, using the compiler running in the interpreter,
takes about 10 seconds;
* compiling the compiler, using the compiler compiled with the compiler,
takes about 0.1 seconds;
* compiling a version of the compiler from which comments and extra
whitespace have been “trimmed”, using the compiler compiled with the
compiler, takes about 0.02 seconds.
So this is a programming language implementation that can recompile
itself from source twice per 24fps movie frame. The entire “trimmed”
source code is 1902 bytes, which is less than half the size of the
nearest comparable project that Im aware of, `otccelf`, which is 4748
bytes.
As demonstrated by the interpreter written in Python, the programming
language itself is essentially machine-independent, with very few
x86 quirks:
* items on the stack are 32 bits in size;
* arithmetic is 32-bit;
* stack items stored in memory not only take up 4 bytes, but they are
little-endian.
(It would be fairly easy to make a tiny “compiler” if the source
language were, say, x86 machine code.)
The output executable is 4063 bytes, containing about 1400
instructions. `valgrind` reports that it takes 1,813,395 instructions
to compile itself. (So you would think that it could compile itself
in 2.6 ms. The long runtimes are a result of reading its input one
byte at at time.)
## Why? To Know What Im Doing
A year and a half ago, I wrote a [metacircular Bicicleta-language
interpreter](http://lists.canonical.org/pipermail/kragen-hacks/2007-February/000450.html), and I said:
> Alan Kay frequently expresses enthusiasm over the metacircular Lisp
> interpreter in the Lisp 1.5 Programmers Manual. For example, in
> <http://acmqueue.com/modules.php?name=Content&pa=showpage&pid=273&page=4>
> he writes:
>
> > ```
> > Yes, that was the big revelation to me when I was in graduate
> > school — when I finally understood that the half page of code on
> > the bottom of page 13 of the Lisp 1.5 manual was Lisp in
> > itself. These were “Maxwells Equations of Software!” This is the
> > whole world of programming in a few lines that I can put my hand
> > over.
> >
> > I realized that anytime I want to know what Im doing, I can just
> > write down the kernel of this thing in a half page and its not
> > going to lose any power. In fact, its going to gain power by
> > being able to reenter itself much more readily than most systems
> > done the other way can possibly do.
> > ```
But if you try to implement a Lisp interpreter in a low-level language
by translating that metacircular interpreter into it (as [I did later
that year](http://lists.canonical.org/pipermail/kragen-hacks/2007-September/000464.html)) you run into a problem. The metacircular interpreter
glosses over a large number of things that turn out to be nontrivial
to implement — indeed, about half of the code is devoted to things
outside of the scope of the metacircular interpreter. Heres a list
of issues that the Lisp 1.5 metacircular interpreter neglects, some
semantic and some merely implementational:
* memory management
* argument evaluation order
* laziness vs. strictness
* other aspects of control flow
* representation and comparison of atoms
* representation of pairs
* parsing
* type checking and type testing (atom)
* recursive function call and return
* tail-calls
* lexical vs. dynamic scoping
In John C. Reynoldss paper, “[Definitional Interpreters
Revisited](http://www.brics.dk/~hosc/local/HOSC-11-4-pp355-361.pdf)”, Higher-Order and Symbolic Computation, 11, 355361
(1998), he says:
> In the fourth and third paragraphs before the end of Section 5, I
> should have emphasized the fact that a metacircular interpreter is
> not really a definition, since it is trivial when the defining
> language is understood, and otherwise it is ambiguous. In
> particular, Interpreters I and II say nothing about order of
> application, while Interpreters I and III say little about
> higher-order functions. Jim Morris put the matter more strongly:
>
> > The activity of defining features in terms of themselves is highly
> > suspect, especially when they are as subtle as functional
> > objects. It is a fad that should be debunked, in my opinion. A
> > real significance of [a self-defined] interpreter . . . is that it
> > displays a simple universal function for the language in
> > question.
>
> On the other hand, I clearly remember that John McCarthys
> definition of LISP [1DI], which is a definitional interpreter in the
> style of II, was a great help when I first learned that language. But
> it was not the sole support of my understanding.
(For what its worth, it may not even the case that self-defined
interpreters are necessarily Turing-complete; it might be possible to
write a non-Turing-complete metacircular interpreter for a
non-Turing-complete language, such as David Turners Total Functional
Programming systems.)
A metacircular compiler forces you to confront this extra complexity.
Moreover, metacircular compilers are self-sustaining in a way that
interpreters arent; once you have the compiler running, you are free
to add features to the language it supports, then take advantage of
those features in the compiler.
So this is a “stone knife” programming tool: bootstrapped out of
almost nothing as quickly as possible.
## Why? To Develop a Compiler Incrementally
When I wrote Ur-Scheme, my thought was to see if I could figure out
how to develop a compiler incrementally, starting by building a small
working metacircular compiler in less than a day, and adding features
from there. I pretty much failed; it took me two and a half weeks to
get it to compile itself successfully.
Part of the problem is that a minimal subset of R5RS Scheme powerful
enough to write a compiler in — without making the compiler even
larger due to writing it in a low-level language — is still a
relatively large language. Ur-Scheme doesnt have much arithmetic,
but it does have integers, dynamic typing, closures, characters,
strings, lists, recursion, booleans, variadic functions, `let` to
introduce local variables, character and string literals, a sort of
crude macro system, five different conditional forms (if, cond, case,
and, or), quotation, tail-call optimization, function argument count
verification, bounds checking, symbols, buffered input to keep it from
taking multiple seconds to compile itself, and a library of functions
for processing lists, strings, and characters. And each of those
things was added because it was necessary to get the compiler to be
able to compile itself. The end result was that the compiler is 90
kilobytes of source code, about 1600 lines if you leave out the
comments.
Now, maybe you can write 1600 lines of working Scheme in a day, but I
sure as hell cant. Its still not a very large compiler, as
compilers go, but its a lot bigger than `otccelf`. So I hypothesized
that maybe a simpler language, without a requirement for compatibility
with something else, would enable me to get a compiler bootstrapped
more easily.
So StoneKnifeForth was born. Its inspired by Forth, so it inherits
most of Forths traditional simplifications:
* no expressions;
* no statements;
* no types, dynamic or static;
* no floating-point (although Ur-Scheme doesnt have floating-point either);
* no scoping, lexical or dynamic;
* no dynamic memory allocation;
And it added a few of its own:
* no names of more than one byte;
* no user-defined IMMEDIATE words (the Forth equivalent of Lisp macros);
* no interpretation state, so no compile-time evaluation at all;
* no interactive REPL;
* no `do` loops;
* no `else` on `if` statements;
* no recursion;
* no access to the return stack;
* no access to the filesystem, just stdin and stdout;
* no multithreading.
Surprisingly, the language that results is still almost bearable to
write a compiler in, although it definitely has the flavor of an
assembler.
Unfortunately, I still totally failed to get it done in a day. It was
15 days from when I first started scribbling about it in my notebook
until it was able to compile itself successfully, although `git` only
shows active development happening on six of those days (including
some help from my friend Aristotle). So thats an improvement, but
not as much of an improvement as I would like. At that point, it was
13k of source, 114 non-comment lines of code, which is definitely a
lot smaller than Ur-Schemes 90k and 1600 lines. (Although there are
another 181 lines of Python for the bootstrap interpreter.)
Its possible to imagine writing and debugging 114 lines of code in a
day, or even 300 lines. Its still maybe a bit optimistic to think I could
do that in a day, so maybe I need to find a way to increase
incrementality further.
My theory was that once I had a working compiler, I could add features
to the language incrementally and test them as I went. So far I
havent gotten to that part.
## Why? Wirth envy
[Michael Franz writes](http://www.ics.uci.edu/~franz/Site/pubs-pdf/BC03.pdf "Oberon — the overlooked jewel"):
> In order to find the optimal cost/benefit ratio, Wirth used a highly
> intuitive metric, the origin of which is unknown to me but that may
> very well be Wirths own invention. He used the compilers
> self-compilation speed as a measure of the compilers
> quality. Considering that Wirths compilers were written in the
> languages they compiled, and that compilers are substantial and
> non-trivial pieces of software in their own right, this introduced a
> highly practical benchmark that directly contested a compilers
> complexity against its performance. Under the self-compilation speed
> benchmark, only those optimizations were allowed to be incorporated
> into a compiler that accelerated it by so much that the intrinsic
> cost of the new code addition was fully compensated.
Wirth is clearly one of the great apostles of simplicity in
programming, together with with Edsger Dijkstra and Chuck Moore. But
I doubt very much that the Oberon compiler could ever compile itself
in 2 million instructions, given the complexity of the Oberon
language.
R. Kent Dybvig used the same criterion; speaking of the 19851987
development of Chez Scheme, [he writes](http://www.cs.indiana.edu/~dyb/pubs/hocs.pdf "The Development of Chez Scheme"):
> At some point we actually instituted the following rule to keep a
> lid on compilation overhead: if an optimization doesnt make the
> compiler itself enough faster to make up for the cost of doing the
> optimization, the optimization is discarded. This ruled out several
> optimizations we tried, including an early attempt at a source
> optimizer.
## Far-Fetched Ways This Code Could Actually be Useful
The obvious way that it could be useful is that you could read it and
learn things from it, then put them to use in actually useful
software. This section is about the far-fetched ways instead.
If you want to counter Ken Thompsons “Trusting Trust” attack, you
would want to start with a minimal compiler on a minimal chip;
StoneKnifeForth might be a good approach.
## Blind Alleys
Here are some things I thought about but didnt do.
### Making More Things Into Primitives
There are straightforward changes to reduce the executable size
further, but they would make the compiler more complicated, not
simpler. Some of the most-referenced routines should be open-coded,
which should also speed it up, as well as making them available to
other programs compiled with the same compiler. Here are the routines
that were called in more than 10 places some time ago:
```
11 0x169 xchg
13 0xc20 Lit
22 0x190 - (now replaced by +, which is only used in 25 places)
25 0x15b pop
26 0x1bc =
35 0x13d dup
60 0x286 .
```
Of these, `xchg`, `pop`, `-`, `=`, and `dup` could all be open-coded
at zero or negative cost at the call sites, and then their definitions
and temporary variables could be removed.
I tried out open-coding `xchg`, `pop`, `dup`, and `+`. The executable
shrank by 346 bytes (from 4223 bytes to 3877 bytes, an 18% reduction;
it also executed 42% fewer instructions to compile itself, from
1,492,993 down to 870,863 on the “trimmed” version of itself), and the
source code stayed almost exactly the same size, at 119 non-comment
lines; the machine-code definitions were one line each. They look
like this:
```
dup 'd = [ pop 80 . ; ] ( dup is `push %eax` )
dup 'p = [ pop 88 . ; ] ( pop is `pop %eax` )
dup 'x = [ pop 135 . 4 . 36 . ; ] ( xchg is xchg %eax, (%esp)
dup '+ = [ pop 3 . 4 . 36 . 89 . ; ] ( `add [%esp], %eax; pop %ecx` )
```
However, I decided not to do this. The current compiler already
contains 58 bytes of machine code, and this would add another 9 bytes
to that. The high-level Forth definitions (`: dup X ! ;` and the
like) are, I think, easier to understand and verify the correctness
of; and they dont depend on lower-level details like what
architecture were compiling for, or how we represent the stacks.
Additionally, it adds another step to the bootstrap process.
### Putting the Operand Stack on `%edi`
Forth uses two stacks: one for procedure nesting (the “return stack”)
and one for parameter passing (the “data stack” or “operand stack”).
This arrangement is shared by other Forth-like languages such as
PostScript and HP calculator programs. Normally, in Forth, unlike in
these other languages, the “return stack” is directly accessible to
the user.
Right now, StoneKnifeForth stores these two stacks mostly in memory,
although it keeps the top item of the operand stack in `%eax`. The
registers `%esp` and `%ebp` point to the locations of the stacks in
memory; the one thats currently being used is in `%esp`, and the
other one is in `%ebp`. So the compiler has to emit an `xchg %esp, %ebp` instruction whenever it switches between the two stacks. As a
result, when compiling itself, something like 30% of the instructions
it emits are `xchg %esp, %ebp`.
Inspired, I think, by colorForth, I considered just keeping the
operand stack pointer in `%edi` and using it directly from there,
rather than swapping it into `%esp`. The x86 has a `stosd`
instruction (GCC calls it `stosl`) which will write a 32-bit value in
`%eax` into memory at `%edi` and increment (or decrement) `%edi` by 4,
which is ideal for pushing values from `%eax` (as in `Lit`, to make
room for the new value). Popping values off the stack, though,
becomes somewhat hairier. The `lodsd` or `lodsl` instruction that
corresponds to `stosl` uses `%esi` instead of `%edi`, you have to set
“DF”, the direction flag, to get it to decrement instead of
incrementing, and like `stosl`, it accesses memory *before* updating
the index register, not after.
So, although we would eliminate a lot of redundant and ugly `xchg`
instructions in the output, as well as the `Restack`, `u`, `U`, and
`%flush` functions, a bunch of the relatively simple instruction
sequences currently emitted by the compiler would become hairier.
I think the changes are more or less as follows:
* `!` is currently `pop (%eax); pop %eax`, which is three bytes; this
occurs 17 times in the output. The new code would be:
sub $8, %edi
mov 4(%edi), %ecx
mov %ecx, (%eax)
mov (%edi), %eax
This is ten bytes. `store`, the byte version of `!`, is similar.
* `-` is currently `sub %eax, (%esp); pop %eax`, which is four bytes;
this occurs 23 times in the output. The new code would be seven
bytes:
sub $4, %edi
sub %eax, (%edi)
mov (%edi), %eax
There's something analogous in `<`, although it only occurs three
times.
* in `JZ`, `jnz`, and `Getchar`, there are occurrences of `pop %eax`,
which is one byte (88). The new code would be five bytes:
sub $4, %edi
mov (%edi), %eax
`JZ` occurs 38 times in the output, `jnz` occurs 5 times, and
Getchar occurs once.
* `Msyscall` would change a bit.
There are 193 occurrences of `push %eax` in the output code at the
moment, each of which is followed by a move-immediate into %eax.
These would just change to `stosd`, which is also one byte.
So this change would increase the amount of machine code in the
compiler source by 10 - 3 + 7 - 4 + 5 - 1 + 5 - 1 + 5 - 1 = 22 bytes,
which is a lot given that theres only 58 bytes there now; I think
that would make the compiler harder to follow, although `Restack` does
too. It would also increase the size of the compiler output by (10 -
3) \* 17 + (7 - 4) \* 23 + (5 - 1) \* (38 + 5 + 1) = 364 bytes, although
it would eliminate 430 `xchg %esp, %ebp` instructions, two bytes each,
for a total of 2 \* 430 - 364 = 496 bytes less; and the resulting
program would gain (4 - 2) \* 17 + (3 - 2) \* 23 + (2 - 1) \* (38 + 5 +
1. = 101 instructions, then lose the 430 `xchg` instructions.
My initial thought was that it would be silly to space-optimize
popping at the expense of pushing; although they happen the same
number of times during the execution of the program, generally more
data is passed to callees than is returned to callers, so the number
of push sites is greater than the number of pop sites. (In this
program, its about a factor of 2, according to the above numbers.)
Also, consumers of values from the stack often want to do something
interesting with the top two values on the stack, not just discard the
top-of-stack: `-` subtracts, `<` compares, `!` and `store` send it to
memory. Only `JZ` and `jnz` (and `pop`) just want to discard
top-of-stack — but to my surprise, they make up half of the pops.
However, I wasnt thinking about the number of places in the compiler
where machine code would be added. What if I used `%esi` instead of
`%edi`, to get a single-byte single-instruction pop (in the form of
`lodsl`) instead of a single-byte push? This would make `Lit` (the
only thing that increases the depth of the operand stack) uglier, and
each of the 193 occurrencies of `push %eax` that result from the 193
calls to `Lit` in the compilation process would get four bytes bigger
(totaling 772 extra bytes) but the seven or so primitives that
*decrease* the depth of the operand stack would gain less extra
complexity. And wed still lose the `xchg %esp, %ebp` crap, including
the code to avoid emitting them.
## Whats Next
Maybe putting the operand stack on `%esi`.
Maybe factor some commonality out of the implementation of `-` and
`<`.
If we move the creation of the ELF header and `Msyscall` and `/buf` to
run-time instead of compile-time, we could eliminate the `#` and
`byte` compile-time directives, both from the compiler and the
interpreter; the output would be simpler; `Msyscall` and `/buf`
wouldn't need two separate names and tricky code to poke them into the
output; the tricky code wouldnt need a nine-line comment explaining
it; the characters E, L, and F wouldnt need to be magic
numbers.
Maybe factor out "0 1 -"!
Maybe pull the interpreter and compiler code into a literate document
that explains them.
Maybe building a compiler for a slightly bigger and better language on
top of this one. Maybe something like Lua, Scheme, or Smalltalk. A
first step toward that would be something that makes parsing a little
more convenient. Another step might be to establish some kind of
intermediate representation in the compiler, and perhaps some kind of
pattern-matching facility to make it easier to specify rewrites on the
intermediate representation (either for optimizations or for code
generation).
Certainly the system as it exists is not that convenient to program
in, the code is pretty hard to read, and when it fails, it is hard to
debug — especially in the compiler, which doesnt have any way to emit
error messages. Garbage collection, arrays with bounds-checking,
finite maps (associative arrays), strong typing (any typing, really),
dynamic dispatch, some thing that saves you from incorrect stack
effects, metaprogramming, and so on, these would all help; an
interactive REPL would be a useful non-linguistic feature.
## Copyright status
I (Kragen Javier Sitaker) wrote StoneKnifeForth in 2008 and published
it immediately in Argentina. I didn't add an explicit copyright
license at the time, but here is one now:
> [To the extent possible under law, Kragen Javier Sitaker has waived
> all copyright and related or neighboring rights to
> StoneKnifeForth](https://creativecommons.org/publicdomain/zero/1.0/). This
> work is published from: Argentina.
For more details, I've included the CC0 "legal code" in
[LICENSE.md](/kragen/stoneknifeforth/blob/master/LICENSE.md).
## Related work
Andre Adrians 2008 BASICO: <http://www.andreadrian.de/tbng/>
> * is a small imperative programming language that is just powerful
> enough to compile itself (compiler bootstrapping).
> * has no GOTO, but has while-break-wend and multiple return
> * has C-like string handling.
> * is implemented in less then 1000 source code lines for the compiler.
> * produces real binary programs for x86 processors, not P-code or
> Byte-Code.
> * uses the C compiler toolchain (assembler, linker)
> * uses C library functions like printf(), getchar(), strcpy(),
> isdigit(), rand() for run-time support.
Actually it produces assembly, not executables.
Version 0.9 was released 15 Jul 2006. The 1000 source lines include a
recursive-descent parser and a hand-coded lexer.
Sample code:
```
// return 1 if ch is in s, 0 else
func in(ch: char, s: array char): int
var i: int
begin
i = 0
while s[i] # 0 do
if ch = s[i] then
return 1
endif
i = i + 1
wend
return 0
end
```
FIRST and THIRD, from [the IOCCC entry](http://www.ioccc.org/1992/buzzard.2.design).
[Ian Piumartas COLA](http://piumarta.com/software/cola/) system.
Oberon.
Fabrice Bellards [OTCC](https://bellard.org/otcc/).
[F-83](https://github.com/ForthHub/F83).
eForth, especially the ITC [eForth](http://www.exemark.com/FORTH/eForthOverviewv5.pdf).
Jack Crenshaws [Lets Build a Compiler](http://compilers.iecc.com/crenshaw/). This is a how-to book
that walks you through an incrementally-constructed compiler for a toy
language, written in Pascal, in about 340 pages of text. The text is
really easy to read, but it will still take at least three to ten
hours to read. It uses recursive-descent parsing, no intermediate
representation, and it emits 68000 assembly code.
Ikarus.
[Ur-Scheme](http://canonical.org/~kragen/sw/urscheme/).
PyPy.
Bootstrapping a simple compiler from nothing:
Edmund GRIMLEY EVANS
2001
<http://web.archive.org/web/20061108010907/http://www.rano.org/bcompiler.html>
## About
a tiny self-hosted Forth implementation
### Resources
[Readme](#readme-ov-file)
### License
[CC0-1.0 license](#CC0-1.0-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/kragen/stoneknifeforth/activity)
### Stars
[**436**
stars](/kragen/stoneknifeforth/stargazers)
### Watchers
[**21**
watching](/kragen/stoneknifeforth/watchers)
### Forks
[**24**
forks](/kragen/stoneknifeforth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fkragen%2Fstoneknifeforth&report=kragen+%28user%29)
## [Releases](/kragen/stoneknifeforth/releases)
No releases published
## [Packages 0](/users/kragen/packages?repo_name=stoneknifeforth)
No packages published
## [Contributors 4](/kragen/stoneknifeforth/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [Forth
50.1%](/kragen/stoneknifeforth/search?l=forth)
* [C
23.4%](/kragen/stoneknifeforth/search?l=c)
* [Python
16.6%](/kragen/stoneknifeforth/search?l=python)
* [Assembly
7.6%](/kragen/stoneknifeforth/search?l=assembly)
* [Shell
2.3%](/kragen/stoneknifeforth/search?l=shell)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,316 @@
# Substack Article
**Source:** https://edsabode.substack.com/p/onats-kyra-compiled-forths-a-new
Onat's KYRA, Compiled FORTHs, a new rabbit hole..
[![Eds Abode](https://substackcdn.com/image/fetch/$s_!CWqS!,w_40,h_40,c_fill,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F269dc3fe-008b-4f8a-bc69-13c53c840346_376x378.png)](/)
# [Eds Abode](/)
SubscribeSign in
# Onat's KYRA, Compiled FORTHs, a new rabbit hole..
[![Ed's avatar](https://substackcdn.com/image/fetch/$s_!_PzK!,w_36,h_36,c_fill,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8fed2663-82a9-4c29-9a20-fab2605e47f3_376x378.png)](https://substack.com/@edsabode)
[Ed](https://substack.com/@edsabode)
May 30, 2025
2
Share
While on twitter doing the usual engagements, someone linked me a vod of a non-text based editor done entirely in a custom toolchain:
I cant write yet on everything thats going on in this talk. But what I do know is that I will be making time to learn. Below will be notes that Ive accumulated so far in this pursuit.
Onat has a website an [article](https://onatto.github.io/lang.html) on KYRA. We immediately learn that its a “concatenative language” derived from offshoots of FORTH. Particularly Moores own [colorFORTH](https://colorforth.github.io/cf.htm) along with taking heavy inspiration from Timothy Lottess custom compiled Forth-like he worked on throughout the late 2000s up to 2016 at least (his blog is dead and the only archive of it is a github [repo](https://github.com/gomson/TimothyLottes.github.io)).
[![](https://substackcdn.com/image/fetch/$s_!Dx2Y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1cb08da-0b75-4db5-b33a-0040de289d41_1920x1080.png)](https://substackcdn.com/image/fetch/$s_!Dx2Y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa1cb08da-0b75-4db5-b33a-0040de289d41_1920x1080.png)
[![](https://substackcdn.com/image/fetch/$s_!7nj0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e2a374d-a99f-4a64-bd07-b36ef76e625d_1920x1080.png)](https://substackcdn.com/image/fetch/$s_!7nj0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5e2a374d-a99f-4a64-bd07-b36ef76e625d_1920x1080.png)
Edit - Older Vod from 2020:
---
## TimothyLottes.github.io
I will catalogue below all the relevant pages from Timothy Lottess archived blog. They can previewed without download a zip archive with the preview button on the top right-corner of githubs text viewer:
[![](https://substackcdn.com/image/fetch/$s_!sFJ6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c5bb33e-94db-4eeb-a5d2-b6a3e99519b1_1258x269.png)](https://substackcdn.com/image/fetch/$s_!sFJ6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6c5bb33e-94db-4eeb-a5d2-b6a3e99519b1_1258x269.png)
* [20070910 - 2 4th | !2 4th](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070910.html)
* [20070912 - The Making of a Font](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070912.html)
* [20070915 - Building the Chicken Without an Egg](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070915.html)
* [20070919 - Editor Working](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070919.html)
* [20070921 - Assembler in Atom4th](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070921.html)
[![](https://substackcdn.com/image/fetch/$s_!APbi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81401d69-cd06-4ec5-ad3c-c1357ff9577e_640x480.jpeg)](https://substackcdn.com/image/fetch/$s_!APbi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F81401d69-cd06-4ec5-ad3c-c1357ff9577e_640x480.jpeg)
* [20140816 - Vintage Programming](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20140816.html)
[![](https://substackcdn.com/image/fetch/$s_!_ApA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde18f837-12fd-4edc-b265-7ecd2371bb8a_640x640.png)](https://substackcdn.com/image/fetch/$s_!_ApA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde18f837-12fd-4edc-b265-7ecd2371bb8a_640x640.png)
* [20141231 - Continued Notes on Custom Language](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20141231.html)
* [20150414 - From Scratch Bug](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150414.html)
* [20150420 - From Scratch Bug 2 : Source-Less Programming](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150420.html)
+ [20150422 - Source-Less Programming : 2](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150422.html)
+ [20150423 - Source-Less Programming : 3](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150423.html)
+ [20150424 - Source-Less Programming : 4](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150424.html)
+ [20150426 - Source-Less Programming : 5](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150426.html)
* [20150710 - Inspiration Reboot](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150710.html)
* [20150714 - 1536-1 : The Programmer Addiction = Feedback](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150714.html)
+ [20150715 - 1536-2 : Assembling From the Nothing](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150715.html)
+ [20150722 - 1536-3 : Simplify, Repeat](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150722.html)
+ [20150809 - 1536-4 : Coloring](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150809.html)
[![](https://substackcdn.com/image/fetch/$s_!Sc2T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0799032f-f2d8-43ec-a7ee-bf3b8fcdc16f_640x400.png)](https://substackcdn.com/image/fetch/$s_!Sc2T!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0799032f-f2d8-43ec-a7ee-bf3b8fcdc16f_640x400.png)
+ [20150810 - 1536-5 : Keys](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150810.html)
[![](https://substackcdn.com/image/fetch/$s_!wv3-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faff0bdf1-272a-4d85-929e-3a9d7917c628_640x400.png)](https://substackcdn.com/image/fetch/$s_!wv3-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faff0bdf1-272a-4d85-929e-3a9d7917c628_640x400.png)
* [20151113 - Rethinking the Symbolic Dictionary](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20151113.html)
* [20151222 - Random Holiday 2015](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20151222.html)
* [20161113 - Vintage Programming 2](https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20161113.html)
* github.com/TimothyLottes/A (DEAD)
---
The above is great and all, but very difficult to enter the world of if you dont have any assembly background. In my case; Ive only recently began to focus on curating my C, C++ and more recently: Odin code more closely; as of being introduced to the “Handmade” communities around 2019. With the furthest Ive gone being reducing runtime symbol pollution, making sure my code paths and data structures are simple and sane. I can read disassembly to a useful extent… So whats the best place to start?
As with most things I find its easiest to learn something by constructive a narrative to world build off of. So gaining a historical perspective of FORTHs development and attempting to chain that in with some “Trial By Fire” guide to forth and a “compiled” FORTH. Most forths have this interpreter layer and operation with how they behave that seems to act as a mock repl or editor. From what I can tell Onats and Lottess goals are something else, where the editor provided that mechanism not the “language” processing layer.
* The classic *start* page for FORTH: [Forth Language](https://wiki.c2.com/?ForthLanguage)
+ History and more laid out there
+ *StartingForth* book..
* [jonesforth.S](https://github.com/nornagon/jonesforth/blob/master/jonesforth.S) seems to be the best introduction to the original language.
After I finish my initial knowledge base curation I think Ill start with getting jonesforth ported to a windows x64 process sandbox. Ill need to learn dealing with assembly directly. Ill probably will go with GAS, FASM, or MASM, whichever provides an easier debugging experience. The original source is targeting x86-32 linux. I could try to get that ported to work on a steam deck instead after as well… Much to digest.
2
Share
#### Discussion about this post
CommentsRestacks
![User's avatar](https://substackcdn.com/image/fetch/$s_!TnFC!,w_32,h_32,c_fill,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack.com%2Fimg%2Favatars%2Fdefault-light.png)
TopLatest
No posts
### Ready for more?
Subscribe
© 2026 Ed · [Privacy](https://substack.com/privacy) ∙ [Terms](https://substack.com/tos) ∙ [Collection notice](https://substack.com/ccpa#personal-data-collected)
[Start your Substack](https://substack.com/signup?utm_source=substack&utm_medium=web&utm_content=footer)[Get the app](https://substack.com/app/app-store-redirect?utm_campaign=app-marketing&utm_content=web-footer-button)
[Substack](https://substack.com) is the home for great culture
This site requires JavaScript to run correctly. Please [turn on JavaScript](https://enable-javascript.com/) or unblock scripts

View File

@@ -0,0 +1,315 @@
# Threaded code
**Source:** https://muforth.dev/threaded-code/
Threaded code muforth
# Threaded code
---
My aim here is to tackle threaded code: What it is, why it is, how it works, and why its great (and not so great).
Rather than starting with a definition and then attempting an explanation of the definition, I want to start with a thought experiment.
Take a program. Then refactor it in such a way that it consists entirely of only two kinds of routines:
* leaf routines, which compute and do I/O, but which make no calls to other code
* twig routines, which do *no* computation or I/O; instead, they *only* call other code (which can be twig or leaf routines)
(I was tempted to use the usual tree-structure names of “leaf” and “branch”, but branch is overloaded with the idea of a jump, which might be confusing in this context. So: twig.)
The performance-minded among you are now aghast. “What? No open-coded arithmetic? No inlining of functions?”
Yes, its true. Our restructuring has a performance cost, but it has advantages too. Well get to both.
Since our twig routines now consist entirely of calls (except for the last instruction, a “return”) we can remove the call opcodes. We end up with a list of addresses. The return instruction that ended our original routine is replaced by the address of a special “exit” routine.
The tail-recursively-minded among you will have already objected “But that last call and return can be replaced by a jump!” Not so with threaded code. There is no way to say we want to “jump” to an address rather than “call” it, so we lose the ability to convert tail calls to jumps. Twig routines always end with the address of the “exit” routine. Another disadvantage to threading. However, we soldier on.
With the opcodes removed, our twig routines are no longer code. We cant “call” one and expect anything good to happen. The CPU will happily start interpreting the list of addresses as instructions and head off into the weeds.
We need a *header* of some kind that tells the CPU that this is not a leaf routine (which we havent changed leaf routines are still machine code) but a twig routine. The header is generally a call to *another* special “runtime” routine. What should this routine do? Because we have been *called*, we must have been called by another twig routine. Just as with machine code that calls other machine code, we need to push a call stack of some kind. But what do we push onto the stack?
Lets back up. We havent talked about *how we are interpreting the list of addresses* that make up the body of a twig routine.
We need a tiny piece of code somewhere that fetches the next address and “executes” the routine that it points to. (I am being purposely vague here.) We are fetching and executing “instructions”, which means we need our own “program counter” or “address pointer” or whatever you want to call it, which will always point to the next “instruction” (really an address) to execute. In the Forth world this pointer is usually called **IP** the “instruction” (or perhaps “interpretation”) pointer. Our tiny piece of code will fetch the “instruction” (address) that IP points to, increment IP by the size (in bytes) of an address, and then somehow “execute” the code at that address.
Im not sure about other language communities, but in the Forth community this tiny piece of code is called **NEXT**. Its only job: to execute the next address in the list.
Now that we have an idea of what it means to execute a list of addresses, what happens when a twig routine calls another twig routine? In order to interpret the list of addresses in the *called* twig routine we have to set IP to point to the *first* of the list of addresses and then run NEXT. But at that moment IP points to the place in the callers list of addresses that we should return to, and we dont want to clobber it, otherwise we would “lose our place” in the execution of the calling twig routine.
Thus, before setting IP to point to the first address in the called word, we have to push the callers IP onto our call stack.
And this is *precisely* the code that the header of our twig routine calls. I call it **NEST**. It is often called **DOCOLON** (for reasons that should become clear later).
The dual of this the special “exit” routine alluded to above, the address of which ends every list of addresses in a twig routine I call **UNNEST**. It pops the previous IP off the call stack, and then runs NEXT, thus resuming interpretation in the calling twig routine. (Many Forths call this **EXIT**, for obvious reasons.)
We have all the pieces now, but a few questions remain. Where is NEXT? And *what* is NEXT?
We can do another thought experiment. Lets say we are executing NEST. We push the callers IP, set IP to point to the first address in our called twig routine... And then what? Do we return? If so, to what? There isnt a “main” machine code routine to return to. Weirdly, there isnt a loop somewhere that repeatedly executes NEXT. Instead, NEXT is *everywhere*.
Every leaf routine ends, not with a return instruction, but with NEXT. NEST ends with NEXT. UNNEST ends with NEXT.
To “fire up” this interpreter, all we have to do is set IP to point somewhere, and then execute NEXT. Any NEXT. Anywhere. At this point, our threaded code interpreter is off and running.
To recap: We need three small routines to make all this work: NEXT, NEST, and UNNEST.
```
NEXT: Fetch the address pointed to by IP
Increment IP by address size
Jump to fetched address
```
```
NEST: Push IP onto call stack
Set IP to point to the first address of the called twig routine
Execute NEXT
```
```
UNNEST: Pop IP from call stack
Execute NEXT
```
Because NEXT is short often one to three instructions it is usually copied inline into the body of NEST, UNNEST, and any other leaf routines.
### [Direct-threaded code (DTC)](#direct-threaded-code-dtc)
What I have just described is usually referred to as *direct-threaded code* (DTC). It is *direct* because NEXT jumps directly to the address fetched from the list of addresses that make up the body of a twig routine.
Because Forth has two stacks a data (or parameter) stack, and a return (or call) stack, we should be clear that NEST and UNNEST push and pop the *return* stack (often called the R stack). In fact, I dont see how this threading model can work with a single stack.
(Side note: Forths call stack and the machines call stack do not have to be the same! And often they are not. If the machine has push and pop operations it is usually more efficient to use the machines call stack as the Forth data stack, and to put the Forth call stack (the return, or “R” stack) somewhere else.)
Its not clear from my description above how NEST computes the new IP (the address of the first address in the list). There are two ways to do it.
If the “header” of the twig routine is a *call* to NEST, then NEST can pop the (machines) call stack. The popped address will be the address of the first address in the list. (This is the semantics of any call instruction: push the following address onto the machines call stack, then jump to the destination. We are “misusing” call to push the address of the list of addresses, which immediately follow the call in memory.)
But there is another way, and its often more efficient. We designate another pointer register often called W (for “word”, as pieces of Forth code are usually referred to as “words”) for use by NEXT and NEST, and modify them thus:
```
NEXT: Fetch into W the address pointed to by IP
Increment IP by address size
Jump to W
```
```
NEST: Push IP onto call stack
Set IP to W + sizeof(Jump)
Execute NEXT
```
Now the “call NEST” is replaced by “jump NEST” in the twig routines header. Since W points to the header, by offseting it (by the size of the jump instruction), we can calculate the address of the first address in the list, which directly follows the jump to NEST. We set IP to this address.
Our two kinds of words leaf and twig now look like this:
```
leaf word twig word
~~~~~~~~~ ~~~~~~~~~
machine code jump NEST
machine code address 1
... address 2
machine code ...
NEXT address n
address of UNNEST
```
When NEXT executes a leaf word, that “Jump to W” jumps directly to machine code. But when it executes a twig word, it jumps to a jump. We all know how terrible this is! Pipeline refill time!
What if we replaced this “code indirection” a jump to a jump with a *data* indirection?
Enter...
### [Indirect-threaded code (ITC)](#indirect-threaded-code-itc)
By replacing the jump NEST (or call NEST) instruction at the beginning of every twig word with a *pointer* to NEST, and by adding an indirection to NEXT:
```
NEXT: Fetch into W the address pointed to by IP
Increment IP by address size
Fetch into X the address pointed to by W
Jump to X
```
and by making a small change to NEST:
```
NEST: Push IP onto call stack
Set IP to W + address size
Execute NEXT
```
we arrive at indirect-threaded code, also known as ITC.
Remember: DTC is *direct* because NEXT jumps directly to the address fetched from the list of addresses that make up the body of a twig routine.
Thus: ITC is *indirect* because NEXT jumps indirectly *through* the address fetched from the list of addresses that make up the body of a twig routine.
Ive written the above version of ITC NEXT the way you would write it for a RISC machine. A CISC machine with auto-increment addressing can collapse the first two instructions into one; one with indirect addressing can collapse the last two into one.
ITC NEXT is two instructions on the MSP430, and four basically the four steps outlined above on RISC-V.
There is another change we need to make for indirect threading to work. With DTC the bodies of both leaf and twig words started with *machine code*; with ITC, the bodies of both have to start with a *pointer to machine code*.
Which means we have to change our leaf words for ITC. We add a machine code pointer that simply points to the code that follows it.
```
leaf word twig word
+----------+ +----------+
| addr |---+ | addr |-------> NEST
+----------+ | +----------+
machine code <-+ address 1
machine code address 2
... ...
machine code address n
NEXT address of UNNEST
```
### [Useful nomenclature](#useful-nomenclature)
Since its tricky to explain all this, its useful to have a common vocabulary when talking about threading and the structure of words in a threaded system. Again, since its what Im familiar with, Im going to use the Forth terminology.
The machine code pointer at the start of every word in an ITC system is called a **code pointer**.
That first slot of a word in both ITC and DTC systems is called the **code field**, and the body that follows machine code in the case of a leaf word, and addresses in a twig word is called the **parameter field**.
Leaf words are called **code** words, and twig words are called **colon** words. These names come from the Forth words that construct them: `code` and `:`.
Since we would like to be able to think and talk clearly about indirection, we give names to two important addresses:
* The address of a code field is called, unsurprisingly, a **code field address** usually abbreviated **cfa**.
* The address of a parameter field is called, also unsurprisingly, a **parameter field address** usually abbreviated **pfa**.
In a DTC system, a cfa points to a code field, which *contains* machine code.
In an ITC system, a cfa points to a code field, which *points to* machine code.
In both cases, the addresses in the body (parameter field) of a colon word (twig word) are all cfas. (Note: Its possible to use pfas instead, and [there are good reasons to do this](/threaded-code-variations/).
### [Everything is executable!](#everything-is-executable)
We are not yet at the end of our story!
It turns out that code and colon (leaf and twig) words are *not* the only kinds of words in a threaded code system. What about data?
Ill use the examples of two common Forth data types: variables and constants
While there are probably other approaches, on threaded Forth systems everything in the system including data types! has executable behavior. You can and indeed *must* execute *everything*. (Curiously, in this way a threaded Forth is somewhat like Lisp: code and data are isomorphic.)
What might it mean to *execute* a variable or a constant? Lets start with constants, since they are simpler (though both are straightforward).
A constant pushes its value onto the data stack. Thats it!
Can we turn this *idea* of a constant into a structure in memory that will work with our threaded interpreter? After defining a constant called `hex-fives` with the value 5555\_5555, we would have the following representation in memory:
```
DTC ITC
hex-fives hex-fives
~~~~~~~~~ ~~~~~~~~~
jump to CONSTANT address of CONSTANT (code field)
5555_5555 5555_5555 (parameter field)
```
In both cases DTC and ITC the representation consists of a code field and a parameter field just like code and colon words. Whereas colon words have a code field that refers to NEST, constants have a code field that refers to CONSTANT, which looks like this:
```
CONSTANT: Add to W the size of the code field (calculate pfa)
Fetch value pointed to by W into W (fetch contents)
Push W onto the data stack
Execute NEXT
```
Remember that after executing NEXT, W contains a cfa: it points to the code field, *not* the parameter field. (Actually, this isnt [written in stone](/threaded-code-variations/).)
If we use `hex-fives` in a colon word, it gets compiled like any other word. To add `hex-fives` to the value on the top of the data stack, we would compile the following address list:
```
address of hex-fives
address of +
```
Variables are only slightly more complicated. Variables in Forth are treated like ML references: you have to explicitly dereference them. There are two words to do this: `@` (“fetch”) and `!` (“store”). `@` consumes an address from the data stack, fetches its value from memory, and pushes that value onto to the data stack; `!` consumes a value and an address from the data stack, and stores the value at that address in memory.
What does a variable *do*? It pushes the *address* of its value onto the data stack.
Variables look like this:
```
DTC ITC
radix radix
~~~~~~~~~ ~~~~~~~~~
jump to VARIABLE address of VARIABLE (code field)
2 2 (parameter field)
```
Here we have a variable called “radix” with the current value 2 (we are in binary).
The code that all variables execute is remarkably similar to CONSTANT. Where CONSTANT pushed *value* stored in the parameter field, VARIABLE pushes the *address* of the parameter field the **pfa**.
```
VARIABLE: Add to W the size of the code field (calculate pfa)
Push W onto the data stack (push pfa)
Execute NEXT
```
Simple examples:
```
radix @
```
fetches the current value;
```
10 radix !
```
changes the radix to 10 (now we are in decimal).
It is out of the scope of this discussion, but every Forth system has mechanisms for creating new kinds of data with their own, specific execution behaviors.
### [Threaded code advantages](#threaded-code-advantages)
Elegance, simplicity, uniformity, code density.
Its quite easy to bring up a threaded-code implementation on a new architecture, and, once running, high-level tools written for a completely different architecture are likely to work unmodified, or with very small modifications.
The structural uniformity makes it very easy to extend and modify *without changing the underlying implementation*. I can add new data structures and new control structures at will without modifying the core compiler.
Because we cannot inline code, everything becomes a separate word. This has an interesting side effect: it aggressively removes *redundancy* from programs, which tend to become much smaller.
On occasion, threading is actually *faster* than native code. In native code a subroutine call requires the equivalent of two jumps: the call, and the return. On pipelined machines these can take several cycles.
When executing code words in a threaded system, only *one* jump is required! Only *one* execution of NEXT is required to execute a word. As a result, on some systems, DTC can be faster than call/return, and ITC is often no worse than call/return (but much more powerful).
### [Threaded code disadvantages](#threaded-code-disadvantages)
Speed, and, sometimes, size.
Since we lose the ablitily to do any kind of code inlining, even simple things like “add these two numbers” have to be written as separate routines and “called” via NEXT. This is obviously slower than inlining.
In terms of size, on processors where an instruction is smaller than an address eg, on 32-bit machines with 16-bit instructions native code can sometimes be denser, but generally the “deduplication” that threading encourages will offset this.
### [Conclusions](#conclusions)
Threaded code is an extraordinarily simple and elegant way to implement language interpreters. Compared to bytecoded interpreters it is quite fast, and compilers for it are essentially trivial.
Because it creates a system entirely composed of uniform pieces, extensibility of the system by users is almost unlimited, and building generic tools is dramatically simplified!
All this for a modest execution time penalty... ;-)
### [To explore further](#to-explore-further)
Read about [threaded code variations](/threaded-code-variations/). I talk about why sometimes it makes sense to put pfas rather than cfas into address lists (colon word bodies).
Read about [literals, ifs, and loops](/threaded-code-literals-ifs-and-loops/) in threaded code systems. Ive suggested here that all colon words consist of a list of addresses that are executed in sequence. Real code branches and loops. And uses literal numbers.
Read about the [difference between a “call” instruction and a “branch-and-link” instruction](/call-versus-branch-and-link/), and how both relate to threaded code.
---
[Send feedback](/cdn-cgi/l/email-protection#3b1e0c0c1e0d0e1e0d091e0d031e0d0a1e0d5f1e0c081e0c0f1e0d0e1e0c091e0f0b1e0d5e1e0d021e0d5f1e0d091e0d581e0d0e1e0d5f1e0d0a1e0d081e0d031e0d021e0d5e1e0d0e1e0c081e095e1e0d081e0d5d1e0d5f04484e59515e584f061e0e59564e5d54494f531e0e5f1e090b6f53495e5a5f5e5f1e090b58545f5e) on this page (last edited 2021 June 07)
Browse [all pages](/all-pages/)
Return [home](/)

View File

@@ -0,0 +1,117 @@
# Variations
**Source:** https://muforth.dev/threaded-code-variations/
Threaded code: Variations muforth
# Threaded code: Variations
---
### [Address lists: cfas or pfas?](#address-lists:-cfas-or-pfas)
In my introduction to [threaded code](/threaded-code/) I mentioned that colon word bodies consist of a list of cfas (code field addresses), but that sometimes it makes sense to use pfas instead. We are going to explore that idea here.
First, lets recap the definitions:
The address of a code field is called, unsurprisingly, a **code field address** usually abbreviated **cfa**.
The address of a parameter field is called, also unsurprisingly, a **parameter field address** usually abbreviated **pfa**.
In a DTC system, a cfa points to a code field, which *contains* machine code.
In an ITC system, a cfa points to a code field, which *points to* machine code.
The main reason for using cfas in address lists is that its the *obvious* thing to do. The cfa points to the code field, which we either jump *to* (DTC) or jump *through* (ITC). Why would we want to use anything else?
The answer is suggested not by the code of NEXT, but by NEST, VARIABLE, and CONSTANT the “runtime” routines for colon words, variables, and constants, respectively. Lets look at them again:
```
DTC_NEST: Push IP onto call stack
Set IP to W + sizeof(Jump)
Execute NEXT
```
```
ITC_NEST: Push IP onto call stack
Set IP to W + address size
Execute NEXT
```
```
VARIABLE: Add to W the size of the code field (ie, calculate pfa)
Push W onto the data stack (push pfa)
Execute NEXT
```
```
CONSTANT: Add to W the size of the code field (calculate pfa)
Fetch value pointed to by W into W (fetch contents of parameter field)
Push W onto the data stack
Execute NEXT
```
Whether calculating the new IP in NEST, or calculating the address of the value in VARIABLE and CONSTANT, we are always adding an offset to W. Because of how NEXT works, W contains the cfa. We want the pfa.
Whenever a programmer creates a new data type that has an assembler runtime (using `;code`) they have to do this same arithmetic on W. Why not do it one place?
The natural “one place” is in NEXT. So what would we change? Our aim is to exit NEXT with W containing a pfa instead of a cfa.
Lets look at DTC first. Here is DTC NEXT:
```
NEXT: Fetch into W the address pointed to by IP
Increment IP by address size
Jump to W
```
We have conflicting requirements here. For DTC we have to jump *to* the code field. We have no choice there. But somehow we want W to point to the parameter field one memory cell higher. How to do both?
If the address list contains cfas, then the first step of NEXT will put a cfa into W. Can we jump to W and increment it in one instruction? Not likely.
What about using pfas in the address list. Does this help? W will have the right value when we exit from NEXT, but can we jump to W minus an offset? It depends on the machine. And it might make NEXT longer possibly significantly longer.
On some machines the best way to do DTC NEXT doesnt involve W at all. For example, on the MSP430 the shortest DTC NEXT is one instruction:
```
mov pc, (ip)+
```
This does the auto-increment of IP and the jump to the fetched cfa, but leaves to the runtimes the computation of the pfa. This approach requires that code fields contain *calls* rather than *jumps* in order to “capture” the pfa somewhere (it gets pushed onto the machines call stack).
DTC doesnt offer a lot of wiggle room. Maybe ITC is better. Lets take a look.
Here is ITC NEXT:
```
NEXT: Fetch into W the address pointed to by IP
Increment IP by address size
Fetch into X the address pointed to by W
Jump to X
```
As we did with DTC, lets start with the case where address lists contain cfas. Just as with DTC NEXT, the first step of ITC NEXT loads a cfa into W. On a machine with auto-increment addressing we can have the “Fetch into X” step increment W so that when we get to NEST (or one of the other “runtimes”) W will contain the pfa.
It might take an extra cycle (it does on the MSP430) but because in every case except executing a code word we will have to take at least a cycle to do arithmetic on W, it might make sense to auto-increment instead. Its also less error-prone to do it, correctly, in one place. (This is what I have done in the MSP430 ITC kernel.)
If we *dont* have auto-increment (eg, most true RISC machines ARM (excepting v6-M) doesnt count ;-) but can use a *negative offset* in our memory access instructions, then it makes sense to use pfas in our address lists instead of cfas. If we do this, the first step of NEXT loads W with a pfa, which is what we want. But the “Fetch into X” step needs to load from the cfa instead, so we offset *backwards* by the size of an address. This sounds convoluted, but its actually the most efficient approach.
Here is that version of ITC NEXT:
```
NEXT: Fetch into W the address pointed to by IP (this is a pfa, not a cfa!)
Increment IP by address size
Fetch into X the address pointed to by (W - address size)
Jump to X
```
This is what I have done for the RISC-V ITC NEXT.
You have to work *with* the strengths and *against* the weaknesses of your architecture not the other way around! There is no fixed answer. Using cfas is not always the “perfect and beautiful” approach. Nor is using pfas. It pays to tinker and draw pictures and pay attention to instruction cycle-times and sizes.
---
[Send feedback](/cdn-cgi/l/email-protection#0c293b3b293a39293a3e293a34293a3d293a68293b3f293b38293a39293b3e29383c293a69293a35293a68293a3e293a6f293a39293a68293a3d293a3f293a34293a35293a69293a39293b3f293e69293a3f293a6a293a68337f796e66696f783129396e61796a637e7864293968293e3c58647e696d686968293e3c6f636869293f6d293e3c5a6d7e656d786563627f) on this page (last edited 2017 April 24)
Browse [all pages](/all-pages/)
Return [home](/)

View File

@@ -0,0 +1,17 @@
# Website
**Source:** https://wiki.c2.com
**notice**
javascript required to view this site
**why**
measured improvement in server performance
awesome incremental search
![](spin.gif)
This site uses features not available in older browsers.

View File

@@ -0,0 +1,158 @@
# Website - Bit Test Complement
**Source:** https://onatto.github.io/lang.html
Bit Test Complement
Bit Test Complement
[Home](index.html)
[Language](lang.html)
[Journey](journey.html)
[Art](videos.html)
[Blog](blog.html)
## The Kyra Language
```
Kyra is an avant-garde concatenative language, built with entirely different principles from status quo and other forth-like languages.
The language is incredibly efficient for those who know how to wield it, I really can't go back to coding in C-like for personal stuff anymore.
It's a foundational meta-language built from first-principles, doesn't make any assumptions about runtime or the problems it solves.
It molds into whatever language needs to exist to solve given problems freely and usually much more efficiently than in other languages.
It builds on a simple design I got inspired from Timothy Lottes, an enigmatic legendary coder who understood Forth philosophy more than any.
The core idea is to invent new 'languages' to generate whatever we need to solve the problem at hand.
Concatenative nature lets compose words naturally, can invent a comfortable language whatever the problem is.
Programming is still stuck with cruft of the old, while having long forgotten important wisdom of the old, namely the Forth philosophy.
This philosophy piqued my curiousity around 2017, I didn't understand it fully until I built and coded a lot in Kyra.
I don't think most people who've coded in Forth understand it either.
They're either thinking too complex from implementation or philosophy perspective, mostly stuck in dogma from the past.
Coming from the C paradigm, coding freeform like this without any rules is already hard, it's especially hard without a proper IDE.
It's also quite unsafe, no types, no safety-belts, which are unnecessary anyway, although the world disagrees with this.
The compiler is implemented in 1800 bytes of x64 assembly, rest of the IDE is written in C, soon to be bootstrapped.
The editor uses compute-only Vulkan with GPA profiling for AMD, utilizing GPU pointers and bindless.
![](stuff/html.png)
Even this sites HTML/CSS is defined/generated in Kyra
![](stuff/markdown.png)
Custom Markdown-like lite language for content, freeform, parsed in Kyra generating HTML
```
## Conciseness/Expressivity
```
The language lets writing code as concise as possible from scratch, usually much more so than other languages.
Here's some figures for a codebase totalling 4K lines of code, no cheating via external/stdlib code:
- Complete x64 assembler, fastest in the world, in only 192 lines
- All base instructions, all SSE instructions without VEX-prefix, all addressing modes including RIP-relative
- Tiny in size, generated 194 instructions/756 bytes of x64 code + 3KB for instruction descriptor tables
- Hyper-optimized, millions of instructions generated per second per core
- Ryzen5900HX @3.6Ghz: 180M instr/second/core
- Ryzen1700X @3.4Ghz: 105M instr/second/core
- Ryzen2500U @2.0Ghz: 80M instr/second/core
- Compute-only SPIRV assembler with type checking and swizzles in 768 lines, rust-gpu is 23k lines in comparison
- Compiling shaders in <5ms (cached, mostly driver validation overhead) by generating SPIR-V fed to the driver directly
This bypasses glslang > file.out > hotload > fread > driver overhead entirely, which is ~100x faster.
- Line-based SDF font renderer 128 lines, custom font definition in 192 lines.
- HTML/CSS language which this site is generated in, totaling 448 lines along with a simple markdown-like format
- Building this whole site takes <10ms, most of it spent on file I/O
- Self-Gravitational Spin Systems in 256 lines defining 4 shaders
```
## Instant Iteration
```
Ideally everything should be instant: compiling, editing, testing, visualization, debugging, intellisense...
Currently my code compiles around 1-2 ms unless I'm dealing with external code such as the Vulkan driver or Capstone.
Less than 10ms iteration times(less than a frame) makes even 1 second feel like an eternity.
Instead of taking large steps, I take small steps which leads to a lot less bugs with instant testing.
I once had compiles go up to 5ms, profiled to understand why(thousand paper cuts), then optimized it back to 1ms in assembly.
This might seem extreme but performance regressions are cumulative, they're best profiled, understood and solved when they surface.
So when I see other languages compiling in seconds up to a minute I feel sad that no one thinks this is a big problem.
As usual with the attitude of programmers towards performance, compile-time performance too gets swept under the rug to be solved later.
Which is the worst time to solve this problem because you're left speculating where the papercuts may be after big offenders are gone.
Actually even 1ms is relatively long, in the next iteration of the language I plan to bring this down to sub-millisecond range.
```
## Performance/Optimizability
```
Optimal performance means squeezing every bit of given hardware instead of relying on compilers to generate good code.
Optimal performance everywhere doesn't matter when most code will be cold, so we can afford to generate less than optimal code.
When code is hot, we need to be consistently reason about the generated code instead of having to check if compiler is being stupid.
I eventually figured out optimal performance from a high-level representation is essentially impossible, it's literally an AI problem.
No compiler can hope to write generate as good as handwritten assembly by a coder who knows what they're doing in total control.
What matters is that code remains optimizable instead of magic optimizations applied everywhere, I want less magic, more control/optimizability.
Optimal register allocation across functions is unnecesarily complex and unreliable, a human mind can do this way better and reliable than a compiler.
Trying to be optimal regarding spills(3ns each) here and there won't help performance unless that code is hot.
Although thousand paper cuts kills performance real quick, it's bad to be equally slow everywhere, like having a stack machine or garbage collection.
```
## Profiling
```
Crucial to performance, we need to be able to profile a section or entirety of our codebase, continously and instantly within the IDE.
Continous profiling is especially crucial to track down performance regressions instead of trying to fix them later.
I use inline RDTSC for extreme fine-grained CPU profiling, sokol_time is quite nice/minimal for coarse-grained.
I've got integrated GPU profiling via AMD GPA.
Also examining generated GPU assembly is illuminating both for performance, debugging or getting angry at compilers shipped in drivers.
```
## Crash Resilience
```
Integrating the IDE and the app into a single program for instant-iteration is great until you hard-crash, which breaks the flow.
With crash-resilence the IDE not only survives the (soft)crash but also gives a full callstack.
This is especially necessary for environments like in VR where a crash is catastrophic, restart takes longer than desktop.
```
## Debuggability
```
Instant iteration makes debugging mostly trivial when workflow is making small changes followed by testing immediately.
There can be only few things going wrong with this kind of workflow, it works out quite well so I don't need much debugging.
Although sometimes things will go wrong and even with crash-resilience the IDE crashes.
This isn't too bad as it takes <1s to restart, still somewhat annoying once I've gotten used to not hard-crashing at all.
The debugger is still in research, I'll probably eventually write an external debugger, didn't have to so far.
Need disassembly+register dump for the crash site, that mostly gives enough of an idea how things have gone wrong.
```
## Visulization
```
Visualization is fundamental, before any output happens we've no idea whether the code we've written actually works.
A lot of the time in programming is spent on writing printfs just so we can understand what is going on.
With instant-iteration, having a few words which help with visualisation is good enough but this kind of UX can be vastly improved.
I still haven't implemented the ultimate immediate no-code visualization yet, I have a few approaches for the next iteration.
```
## Navigability
```
Also called 'intellisense', I can jump instantly to the definition and occurances of a word/variable, solved elegantly requiring minimal energy.
I can even visualize with a single word in which order given words are executed, quite handy and lacking in other languages.
However, I don't have code completion because it's not needed when most words are quite short.
```
## Version Control
```
The current IDE features custom builtin version control with up to 512 undo/redos for each version, no merge, single branch, quite good for a single developer.
I've got a few ideas for a version control system that works with multiple developers, no time or need to implement it yet.
```

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,804 @@
# Wikipedia Page
**Source:** https://en.wikipedia.org/wiki/Forth_(programming_language)
Forth (programming language) - Wikipedia
[Jump to content](#bodyContent)
Main menu
Main menu
move to sidebar
hide
Navigation
* [Main page](/wiki/Main_Page "Visit the main page [z]")
* [Contents](/wiki/Wikipedia:Contents "Guides to browsing Wikipedia")
* [Current events](/wiki/Portal:Current_events "Articles related to current events")
* [Random article](/wiki/Special:Random "Visit a randomly selected article [x]")
* [About Wikipedia](/wiki/Wikipedia:About "Learn about Wikipedia and how it works")
* [Contact us](//en.wikipedia.org/wiki/Wikipedia:Contact_us "How to contact Wikipedia")
Contribute
* [Help](/wiki/Help:Contents "Guidance on how to use and edit Wikipedia")
* [Learn to edit](/wiki/Help:Introduction "Learn how to edit Wikipedia")
* [Community portal](/wiki/Wikipedia:Community_portal "The hub for editors")
* [Recent changes](/wiki/Special:RecentChanges "A list of recent changes to Wikipedia [r]")
* [Upload file](/wiki/Wikipedia:File_upload_wizard "Add images or other media for use on Wikipedia")
* [Special pages](/wiki/Special:SpecialPages "A list of all special pages [q]")
[![](/static/images/icons/enwiki-25.svg)
![Wikipedia](/static/images/mobile/copyright/wikipedia-wordmark-en-25.svg)
![The Free Encyclopedia](/static/images/mobile/copyright/wikipedia-tagline-en-25.svg)](/wiki/Main_Page)
[Search](/wiki/Special:Search "Search Wikipedia [f]")
Search
Appearance
* [Donate](https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign=en.wikipedia.org&uselang=en)
* [Create account](/w/index.php?title=Special:CreateAccount&returnto=Forth+%28programming+language%29 "You are encouraged to create an account and log in; however, it is not mandatory")
* [Log in](/w/index.php?title=Special:UserLogin&returnto=Forth+%28programming+language%29 "You're encouraged to log in; however, it's not mandatory. [o]")
Personal tools
* [Donate](https://donate.wikimedia.org/?wmf_source=donate&wmf_medium=sidebar&wmf_campaign=en.wikipedia.org&uselang=en)
* [Create account](/w/index.php?title=Special:CreateAccount&returnto=Forth+%28programming+language%29 "You are encouraged to create an account and log in; however, it is not mandatory")
* [Log in](/w/index.php?title=Special:UserLogin&returnto=Forth+%28programming+language%29 "You're encouraged to log in; however, it's not mandatory. [o]")
## Contents
move to sidebar
hide
* [(Top)](#)
* [1
Uses](#Uses)
* [2
History](#History)
* [3
Overview](#Overview)
* [4
Facilities](#Facilities)
Toggle Facilities subsection
+ [4.1
Operating system, files, and multitasking](#Operating_system,_files,_and_multitasking)
+ [4.2
Self-compilation and cross compilation](#Self-compilation_and_cross_compilation)
* [5
Structure of the language](#Structure_of_the_language)
Toggle Structure of the language subsection
+ [5.1
Structure of the compiler](#Structure_of_the_compiler)
- [5.1.1
Compilation state and interpretation state](#Compilation_state_and_interpretation_state)
- [5.1.2
Immediate words](#Immediate_words)
- [5.1.3
Unnamed words and execution tokens](#Unnamed_words_and_execution_tokens)
- [5.1.4
Parsing words and comments](#Parsing_words_and_comments)
+ [5.2
Structure of code](#Structure_of_code)
+ [5.3
Data objects](#Data_objects)
* [6
Examples](#Examples)
Toggle Examples subsection
+ [6.1
“Hello, World!”](#“Hello,_World!”)
+ [6.2
Mixing states of compiling and interpreting](#Mixing_states_of_compiling_and_interpreting)
+ [6.3
RC4 cipher program](#RC4_cipher_program)
* [7
Forth engines](#Forth_engines)
* [8
Implementations](#Implementations)
* [9
See also](#See_also)
* [10
Notes](#Notes)
* [11
References](#References)
* [12
External links](#External_links)
Toggle the table of contents
# Forth (programming language)
34 languages
* [中文](https://zh.wikipedia.org/wiki/Forth "Forth Chinese")
* [Кыргызча](https://ky.wikipedia.org/wiki/%D0%A4%D0%BE%D1%80%D1%82_(%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B0%D0%BB%D0%BE%D0%BE_%D1%82%D0%B8%D0%BB%D0%B8) "Форт (программалоо тили) Kyrgyz")
* [한국어](https://ko.wikipedia.org/wiki/%ED%8F%AC%EC%8A%A4_(%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%B0%8D_%EC%96%B8%EC%96%B4) "포스 (프로그래밍 언어) Korean")
* [Français](https://fr.wikipedia.org/wiki/Forth_(langage) "Forth (langage) French")
* [Español](https://es.wikipedia.org/wiki/Forth "Forth Spanish")
* [Magyar](https://hu.wikipedia.org/wiki/Forth_(programoz%C3%A1si_nyelv) "Forth (programozási nyelv) Hungarian")
* [Italiano](https://it.wikipedia.org/wiki/Forth_(linguaggio) "Forth (linguaggio) Italian")
* [Galego](https://gl.wikipedia.org/wiki/Forth "Forth Galician")
* [Deutsch](https://de.wikipedia.org/wiki/Forth_(Programmiersprache) "Forth (Programmiersprache) German")
* [日本語](https://ja.wikipedia.org/wiki/Forth "Forth Japanese")
* [Ελληνικά](https://el.wikipedia.org/wiki/Forth "Forth Greek")
* [Simple English](https://simple.wikipedia.org/wiki/Forth "Forth Simple English")
* [العربية](https://ar.wikipedia.org/wiki/%D9%81%D9%88%D8%B1%D8%AB_(%D9%84%D8%BA%D8%A9_%D8%A8%D8%B1%D9%85%D8%AC%D8%A9) "فورث (لغة برمجة) Arabic")
* [Nederlands](https://nl.wikipedia.org/wiki/Forth_(programmeertaal) "Forth (programmeertaal) Dutch")
* [Svenska](https://sv.wikipedia.org/wiki/Forth_(programspr%C3%A5k) "Forth (programspråk) Swedish")
* [Português](https://pt.wikipedia.org/wiki/Forth "Forth Portuguese")
* [Esperanto](https://eo.wikipedia.org/wiki/Forth_(programlingvo) "Forth (programlingvo) Esperanto")
* [Тоҷикӣ](https://tg.wikipedia.org/wiki/Forth "Forth Tajik")
* [Русский](https://ru.wikipedia.org/wiki/%D0%A4%D0%BE%D1%80%D1%82_(%D1%8F%D0%B7%D1%8B%D0%BA_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D1%8F) "Форт (язык программирования) Russian")
* [Norsk bokmål](https://no.wikipedia.org/wiki/Forth_(programmeringsspr%C3%A5k) "Forth (programmeringsspråk) Norwegian Bokmål")
* [Català](https://ca.wikipedia.org/wiki/Forth "Forth Catalan")
* [Suomi](https://fi.wikipedia.org/wiki/Forth_(ohjelmointikieli) "Forth (ohjelmointikieli) Finnish")
* [Українська](https://uk.wikipedia.org/wiki/Forth "Forth Ukrainian")
* [Čeština](https://cs.wikipedia.org/wiki/Forth_(programovac%C3%AD_jazyk) "Forth (programovací jazyk) Czech")
* [Български](https://bg.wikipedia.org/wiki/Forth "Forth Bulgarian")
* [Interlingua](https://ia.wikipedia.org/wiki/Forth_(linguage_de_programmation) "Forth (linguage de programmation) Interlingua")
* [Беларуская](https://be.wikipedia.org/wiki/%D0%A4%D0%BE%D1%80%D1%82_(%D0%BC%D0%BE%D0%B2%D0%B0_%D0%BF%D1%80%D0%B0%D0%B3%D1%80%D0%B0%D0%BC%D0%B0%D0%B2%D0%B0%D0%BD%D0%BD%D1%8F) "Форт (мова праграмавання) Belarusian")
* [Latviešu](https://lv.wikipedia.org/wiki/Forth_(programm%C4%93%C5%A1anas_valoda) "Forth (programmēšanas valoda) Latvian")
* [Српски / srpski](https://sr.wikipedia.org/wiki/Forth_(%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D1%81%D0%BA%D0%B8_%D1%98%D0%B5%D0%B7%D0%B8%D0%BA) "Forth (програмски језик) Serbian")
* [فارسی](https://fa.wikipedia.org/wiki/%D8%B2%D8%A8%D8%A7%D9%86_%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87%E2%80%8C%D9%86%D9%88%DB%8C%D8%B3%DB%8C_%D9%81%D9%88%D8%B1%D8%AB "زبان برنامه‌نویسی فورث Persian")
* [Polski](https://pl.wikipedia.org/wiki/Forth_(j%C4%99zyk_programowania) "Forth (język programowania) Polish")
* [粵語](https://zh-yue.wikipedia.org/wiki/Forth "Forth Cantonese")
* [Slovenščina](https://sl.wikipedia.org/wiki/Forth_(programski_jezik) "Forth (programski jezik) Slovenian")
* [ꠍꠤꠟꠐꠤ](https://syl.wikipedia.org/wiki/%EA%A0%9A%EA%A0%9E%EA%A0%86%EA%A0%95 "ꠚꠞ꠆ꠕ Sylheti")
[Edit links](https://www.wikidata.org/wiki/Special:EntityPage/Q275472#sitelinks-wikipedia "Edit interlanguage links")
* [Article](/wiki/Forth_(programming_language) "View the content page [c]")
* [Talk](/wiki/Talk:Forth_(programming_language) "Discuss improvements to the content page [t]")
English
* [Read](/wiki/Forth_(programming_language))
* [Edit](/w/index.php?title=Forth_(programming_language)&action=edit "Edit this page [e]")
* [View history](/w/index.php?title=Forth_(programming_language)&action=history "Past revisions of this page [h]")
Tools
Tools
move to sidebar
hide
Actions
* [Read](/wiki/Forth_(programming_language))
* [Edit](/w/index.php?title=Forth_(programming_language)&action=edit "Edit this page [e]")
* [View history](/w/index.php?title=Forth_(programming_language)&action=history)
General
* [What links here](/wiki/Special:WhatLinksHere/Forth_(programming_language) "List of all English Wikipedia pages containing links to this page [j]")
* [Related changes](/wiki/Special:RecentChangesLinked/Forth_(programming_language) "Recent changes in pages linked from this page [k]")
* [Upload file](//en.wikipedia.org/wiki/Wikipedia:File_Upload_Wizard "Upload files [u]")
* [Permanent link](/w/index.php?title=Forth_(programming_language)&oldid=1330667744 "Permanent link to this revision of this page")
* [Page information](/w/index.php?title=Forth_(programming_language)&action=info "More information about this page")
* [Cite this page](/w/index.php?title=Special:CiteThisPage&page=Forth_%28programming_language%29&id=1330667744&wpFormIdentifier=titleform "Information on how to cite this page")
* [Get shortened URL](/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FForth_%28programming_language%29)
* [Download QR code](/w/index.php?title=Special:QrCode&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FForth_%28programming_language%29)
Print/export
* [Download as PDF](/w/index.php?title=Special:DownloadAsPdf&page=Forth_%28programming_language%29&action=show-download-screen "Download this page as a PDF file")
* [Printable version](/w/index.php?title=Forth_(programming_language)&printable=yes "Printable version of this page [p]")
In other projects
* [Wikimedia Commons](https://commons.wikimedia.org/wiki/Category:Forth_(programming_language))
* [Wikibooks](https://en.wikibooks.org/wiki/Forth)
* [Wikidata item](https://www.wikidata.org/wiki/Special:EntityPage/Q275472 "Structured data on this page hosted by Wikidata [g]")
Appearance
move to sidebar
hide
From Wikipedia, the free encyclopedia
Stack-based programming language
"FORTH" redirects here. For other uses, see [Forth (disambiguation)](/wiki/Forth_(disambiguation) "Forth (disambiguation)").
| Forth | |
| --- | --- |
| [Paradigm](/wiki/Programming_paradigm "Programming paradigm") | [concatenative](/wiki/Concatenative_programming_language "Concatenative programming language") ([stack-based](/wiki/Stack-oriented_programming "Stack-oriented programming")), [procedural](/wiki/Procedural_programming "Procedural programming"), [reflective](/wiki/Reflective_programming "Reflective programming") |
| [Designed by](/wiki/Software_design "Software design") | [Charles H. Moore](/wiki/Charles_H._Moore "Charles H. Moore") |
| First appeared | 1970; 56 years ago (1970) |
| [Typing discipline](/wiki/Type_system "Type system") | Typeless |
| [Filename extensions](/wiki/Filename_extension "Filename extension") | .fs, .fth, .4th, .f, .forth[*[citation needed](/wiki/Wikipedia:Citation_needed "Wikipedia:Citation needed")*] |
| Website | [forth-standard.org](https://forth-standard.org) |
| Major [implementations](/wiki/Programming_language_implementation "Programming language implementation") | |
| SwiftForth (Forth, Inc.) [Gforth](/wiki/Gforth "Gforth") (GNU Project) VFX Forth (MicroProcessor Engineering) | |
| Influenced | |
| [Bitcoin Script](/wiki/Bitcoin#Transactions "Bitcoin"), [Factor](/wiki/Factor_(programming_language) "Factor (programming language)"), [Joy](/wiki/Joy_(programming_language) "Joy (programming language)"), [RPL](/wiki/RPL_(programming_language) "RPL (programming language)"), [Rebol](/wiki/Rebol "Rebol"), [STOIC](/wiki/STOIC "STOIC"), [8th](/w/index.php?title=8th_(programming_language)&action=edit&redlink=1 "8th (programming language) (page does not exist)") | |
**Forth** is a [stack-oriented](/wiki/Stack-oriented_programming "Stack-oriented programming") [programming language](/wiki/Programming_language "Programming language") and interactive [integrated development environment](/wiki/Integrated_development_environment "Integrated development environment") designed by [Charles H. "Chuck" Moore](/wiki/Charles_H._Moore "Charles H. Moore") and first used by other programmers in 1970. Although not an [acronym](/wiki/Acronym "Acronym"), the language's name in its early years was often spelled in [all capital letters](/wiki/All_caps "All caps") as *FORTH*. The FORTH-79 and FORTH-83 implementations, which were not written by Moore, became *[de facto](/wiki/De_facto "De facto")* standards, and an official [technical standard](/wiki/Technical_standard "Technical standard") of the language was published in 1994 as ANS Forth. A wide range of Forth derivatives existed before and after ANS Forth. The [free and open-source software](/wiki/Free_and_open-source_software "Free and open-source software") [Gforth](/wiki/Gforth "Gforth") implementation is actively maintained, as are several [commercially](/wiki/Commercial_software "Commercial software") supported systems.
Forth typically combines a compiler with an integrated command shell, where the user interacts via [subroutines](/wiki/Subroutine "Subroutine") called *words*.[[a]](#cite_note-3)
Words can be defined, tested, redefined, and debugged without recompiling or restarting the whole program. All syntactic elements, including variables, operators, and control flow, are defined as words. A [stack](/wiki/Stack_(abstract_data_type) "Stack (abstract data type)") is used to pass parameters between words, leading to a [Reverse Polish notation](/wiki/Reverse_Polish_notation "Reverse Polish notation") style.
For much of Forth's existence, the standard technique was to compile to [threaded code](/wiki/Threaded_code "Threaded code"), which can be interpreted faster than [bytecode](/wiki/Bytecode "Bytecode"). One of the early benefits of Forth was size: an entire development environment—including compiler, editor, and user programs—could fit in memory on an 8-bit or similarly limited system. No longer constrained by space, there are modern implementations that generate [optimized](/wiki/Optimizing_compiler "Optimizing compiler") [machine code](/wiki/Machine_code "Machine code") like other language compilers.
The relative simplicity of creating a basic Forth system has led to many personal and proprietary variants, such as the custom Forth used to implement the bestselling 1986 video game *[Starflight](/wiki/Starflight "Starflight")* from [Electronic Arts](/wiki/Electronic_Arts "Electronic Arts").[[3]](#cite_note-maher-4) Forth is used in the [Open Firmware](/wiki/Open_Firmware "Open Firmware") [boot loader](/wiki/Boot_loader "Boot loader"), in [spaceflight](/wiki/Spaceflight "Spaceflight") applications[[4]](#cite_note-oSWRm-5) such as the [*Philae* spacecraft](/wiki/Philae_(spacecraft) "Philae (spacecraft)"),[[5]](#cite_note-zYmBe-6)[[6]](#cite_note-sgEMh-7) and in other embedded systems which involve interaction with hardware.
Beginning in the early 1980s, Moore developed a series of microprocessors for executing compiled Forth-like code directly and experimented with smaller languages based on Forth concepts, including cmForth and [colorForth](/wiki/ColorForth "ColorForth"). Most of these languages were created to support Moore's own projects, such as chip design.
## Uses
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=1 "Edit section: Uses")]
Forth has a niche in astronomical and space applications[[7]](#cite_note-C4Oss-8) as well as a history in [embedded systems](/wiki/Embedded_system "Embedded system"). The [Open Firmware](/wiki/Open_Firmware "Open Firmware") [boot ROMs](/wiki/Boot_ROM "Boot ROM") used by [Apple](/wiki/Apple_Inc. "Apple Inc."), [IBM](/wiki/IBM "IBM"), [Sun](/wiki/Sun_Microsystems "Sun Microsystems"), and [OLPC XO-1](/wiki/OLPC_XO "OLPC XO") contain a Forth environment.
Forth has often been used to bring up new hardware. Forth was the first [resident software](/wiki/Resident_monitor "Resident monitor") on the new [Intel 8086](/wiki/Intel_8086 "Intel 8086") chip in 1978, and MacFORTH was the first resident development system for the [Macintosh 128K](/wiki/Macintosh_128K "Macintosh 128K") in 1984.[[8]](#cite_note-evolution-9)
Circa 1982, [Atari, Inc.](/wiki/Atari,_Inc. "Atari, Inc.") used an elaborate animated demo written in Forth to showcase capabilities of the [Atari 8-bit computers](/wiki/Atari_8-bit_computers "Atari 8-bit computers") in department stores.[[9]](#cite_note-10) [Electronic Arts](/wiki/Electronic_Arts "Electronic Arts") published multiple video games in the 1980s that were written in Forth, including *[Worms?](/wiki/Worms%3F "Worms?")* (1983),[[10]](#cite_note-11) *[Adventure Construction Set](/wiki/Adventure_Construction_Set "Adventure Construction Set")* (1984),[[11]](#cite_note-12) *[Amnesia](/wiki/Amnesia_(1986_video_game) "Amnesia (1986 video game)")* (1986),[[12]](#cite_note-13) *[Starflight](/wiki/Starflight "Starflight")* (1986),[[3]](#cite_note-maher-4) and *[Lords of Conquest](/wiki/Lords_of_Conquest "Lords of Conquest")* (1986). Robot coding game *[ChipWits](/wiki/ChipWits "ChipWits")* (1984) was developed in MacFORTH for the [Macintosh 128K](/wiki/Macintosh_128K "Macintosh 128K"),[[13]](#cite_note-14) while the [Commodore 64](/wiki/Commodore_64 "Commodore 64") port was written with SuperForth 64.[[14]](#cite_note-15)
[Ashton-Tate's RapidFile](/wiki/Ashton-Tate#RapidFile "Ashton-Tate") (1986), a flat-file database program, and VP-Planner[[15]](#cite_note-16) from [Paperback Software International](/wiki/Paperback_Software_International "Paperback Software International") (1983), a spreadsheet program competing with [Lotus 1-2-3](/wiki/Lotus_1-2-3 "Lotus 1-2-3"), were written in Forth.
The [Canon Cat](/wiki/Canon_Cat "Canon Cat") (1987) uses Forth for its system programming.
[Rockwell](/wiki/Rockwell_International "Rockwell International") produced single-chip microcomputers with resident Forth kernels: the R65F11 and R65F12.
ASYST was a Forth expansion for measuring and controlling on PCs.[[16]](#cite_note-Rwirj-17)
## History
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=2 "Edit section: History")]
Forth evolved from [Charles H. Moore](/wiki/Charles_H._Moore "Charles H. Moore")'s personal programming system, which had been in continuous development since 1968.[[8]](#cite_note-evolution-9)[[17]](#cite_note-WYK4Z-18) Forth was first exposed to other programmers in the early 1970s, starting with [Elizabeth Rather](/wiki/Elizabeth_Rather "Elizabeth Rather") at the United States [National Radio Astronomy Observatory](/wiki/National_Radio_Astronomy_Observatory "National Radio Astronomy Observatory") (NRAO).[[8]](#cite_note-evolution-9) After their work at NRAO, Charles Moore and Elizabeth Rather formed FORTH, Inc. in 1973, refining and porting Forth systems to dozens of other platforms in the next decade.
Moore saw Forth as a successor to compile-link-go [third-generation programming languages](/wiki/Third-generation_programming_language "Third-generation programming language"), or software for "fourth generation" hardware. He recalls how the name was coined:[[18]](#cite_note-19)
> At [Mohasco](/wiki/Mohawk_Industries "Mohawk Industries") ["in the late 1960s"] I also worked directly on an [IBM 1130](/wiki/IBM_1130 "IBM 1130") interfaced with an [IBM 2250](/wiki/IBM_2250 "IBM 2250") graphics display. The 1130 was a very important computer: it had the first cartridge disk, as well as a card reader, a card punch (as backup for the disk), and a console typewriter. The 1130 let the programmer, for the first time, totally control the computer interactively.
> FORTH first appeared as an entity on that 1130. It was called F-O-R-T-H, a five-letter abbreviation of FOURTH, standing for fourth-generation computer language. That was the day, you may remember, of third-generation computers and I was going to leapfrog. But because FORTH ran on the 1130 (which permitted only five-character identifiers), the name was shortened.
FORTH, Inc.'s microFORTH was developed for the [Intel 8080](/wiki/Intel_8080 "Intel 8080"), [Motorola 6800](/wiki/Motorola_6800 "Motorola 6800"), [Zilog Z80](/wiki/Zilog_Z80 "Zilog Z80"), and [RCA 1802](/wiki/RCA_1802 "RCA 1802") microprocessors, starting in 1976. MicroFORTH was later used by hobbyists to generate Forth systems for other architectures, such as the [6502](/wiki/MOS_Technology_6502 "MOS Technology 6502") in 1978. The Forth Interest Group was formed in 1978.[[19]](#cite_note-20) It promoted and distributed its own version of the language, FIG-Forth, for most makes of home computer.
Forth was popular in the early 1980s,[[20]](#cite_note-1AvuY-21) because it was well suited to the limited memory of [microcomputers](/wiki/Microcomputer "Microcomputer"). The ease of implementing the language led to many implementations.[[21]](#cite_note-family-tree-22) The [Jupiter ACE](/wiki/Jupiter_Ace "Jupiter Ace") home computer has Forth in its [ROM](/wiki/Read-only_memory "Read-only memory")-resident operating system. Insoft GraFORTH is a version of Forth with graphics extensions for the Apple II.[[22]](#cite_note-gWyzb-23)
Common practice was codified in the de facto standards FORTH-79[[23]](#cite_note-qyrcN-24) and FORTH-83[[24]](#cite_note-BQ2oi-25) in the years 1979 and 1983, respectively. These standards were unified by [ANSI](/wiki/American_National_Standards_Institute "American National Standards Institute") in 1994, commonly referred to as ANS Forth.[[25]](#cite_note-IGDIN-26)[[26]](#cite_note-KojQK-27)
As of 2018, the source for the original 1130 version of FORTH has been recovered, and is now being updated to run on a restored or emulated 1130 system.[[27]](#cite_note-BtuRy-28)
## Overview
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=3 "Edit section: Overview")]
Further information: [Reverse Polish notation](/wiki/Reverse_Polish_notation "Reverse Polish notation")
Forth emphasizes the use of small, simple functions called *words*. Words for bigger tasks call upon many smaller words that each accomplish a distinct sub-task. A large Forth program is a hierarchy of words. These words, being distinct modules that communicate implicitly via a stack mechanism, can be prototyped, built and tested independently. The highest level of Forth code may resemble an English-language description of the application. Forth has been called a *meta-application language*: a language that can be used to create [problem-oriented languages](/wiki/Domain-specific_language "Domain-specific language").[[28]](#cite_note-29)
Forth relies on implicit use of a [data stack](/wiki/Stack_(abstract_data_type) "Stack (abstract data type)") and [reverse Polish notation](/wiki/Reverse_Polish_notation "Reverse Polish notation") which is commonly used in calculators from [Hewlett-Packard](/wiki/Hewlett-Packard "Hewlett-Packard"). In RPN, the operator is placed after its operands, as opposed to the more common [infix notation](/wiki/Infix_notation "Infix notation") where the operator is placed between its operands. Postfix notation makes the language easier to parse and extend; Forth's flexibility makes a static [BNF](/wiki/Backus-Naur_form "Backus-Naur form") grammar inappropriate, and it does not have a monolithic compiler. Extending the compiler only requires writing a new word, instead of modifying a grammar and changing the underlying implementation.
Using RPN, one can compute the value of the arithmetic expression (25 × 10) + 50 in the following way:
```
25 10 * 50 + CR .
300 ok
```
[![](//upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Stack1.svg/250px-Stack1.svg.png)](/wiki/File:Stack1.svg)
First the numbers 25 and 10 are put on the stack.
[![](//upload.wikimedia.org/wikipedia/commons/thumb/f/fd/Forthstack1_5.svg/250px-Forthstack1_5.svg.png)](/wiki/File:Forthstack1_5.svg)
The word `*` takes the top two numbers from the stack, multiplies them, and puts the product back on the stack.
[![](//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Forthstack2.svg/250px-Forthstack2.svg.png)](/wiki/File:Forthstack2.svg)
Then the number 50 is placed on the stack.
[![](//upload.wikimedia.org/wikipedia/commons/thumb/6/64/Forthstack3.svg/250px-Forthstack3.svg.png)](/wiki/File:Forthstack3.svg)
The word `+` takes the top two numbers from the stack, adds them, and puts the sum back on the stack. `CR` ([carriage return](/wiki/Carriage_return "Carriage return")) starts the output on a new line. Finally, `.` prints the result. As everything has completed successfully, the Forth system prints `OK`.[[29]](#cite_note-3yqc9-30)
Even Forth's structural features are stack-based. For example:
```
: FLOOR5 ( n -- n' ) DUP 6 < IF DROP 5 ELSE 1 - THEN ;
```
The colon indicates the beginning of a new definition, in this case a new word (again, *word* is the term used for a subroutine) called `FLOOR5`. The text in parentheses is a comment, advising that this word expects a number on the stack and will return a possibly changed number (on the stack).
The subroutine uses the following commands: `DUP` duplicates the number on the stack; `6` pushes a 6 on top of the stack; `<` compares the top two numbers on the stack (6 and the `DUP`ed input), and replaces them with a true-or-false value; `IF` takes a true-or-false value and chooses to execute commands immediately after it or to skip to the `ELSE`; `DROP` discards the value on the stack; `5` pushes a 5 on top of the stack; and `THEN` ends the conditional.
The `FLOOR5` word is equivalent to this function written in the [C programming language](/wiki/C_(programming_language) "C (programming language)") using the [conditional operator](/wiki/Ternary_conditional_operator "Ternary conditional operator") '?:'
```
int floor5(int v) {
return (v < 6) ? 5 : (v - 1);
}
```
This function is written more succinctly as:
```
: FLOOR5 ( n -- n' ) 1- 5 MAX ;
```
This can be run as follows:
```
1 FLOOR5 CR .
5 ok
8 FLOOR5 CR .
7 ok
```
First a number (1 or 8) is pushed onto the stack, `FLOOR5` is called, which pops the number again and pushes the result. `CR` moves the output to a new line (again, this is only here for readability). Finally, a call to `.` pops the result and prints.
## Facilities
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=4 "Edit section: Facilities")]
Forth's [grammar](/wiki/Formal_grammar "Formal grammar") has no official specification. Instead, it is defined by a simple algorithm. The interpreter reads a line of input from the user input device, which is then parsed for a word using spaces as a [delimiter](/wiki/Delimiter "Delimiter"); some systems recognise additional [whitespace](/wiki/Whitespace_character "Whitespace character") characters. When the interpreter finds a word, it looks the word up in the *dictionary*. If the word is found, the interpreter executes the code associated with the word, and then returns to parse the rest of the input stream. If the word isn't found, the word is assumed to be a number and an attempt is made to convert it into a number and push it on the stack; if successful, the interpreter continues parsing the input stream. Otherwise, if both the lookup and the number conversion fail, the interpreter prints the word followed by an error message indicating that the word is not recognised, flushes the input stream, and waits for new user input.[[30]](#cite_note-6dQ7P-31)
The definition of a new word is started with the word `:` (colon) and ends with the word `;` (semi-colon). For example,
```
: X DUP 1+ . . ;
```
will compile the word `X`, and makes the name findable in the dictionary. When executed by typing `10 X` at the console this will print `11 10`.[[31]](#cite_note-compiler-32)
Most Forth systems include an [assembler](/wiki/Assembly_language#Assembler "Assembly language") to write words using the processor's facilities. Forth assemblers often use a reverse Polish syntax in which the parameters of an instruction precede the instruction. A typical reverse Polish assembler prepares the operands on the stack and the mnemonic copies the whole instruction into memory as the last step. A Forth assembler is by nature a macro assembler, so that it is easy to define an alias for registers according to their role in the Forth system: e.g. "dsp" for the register used as the data stack pointer.[[32]](#cite_note-NAFQu-33)
### Operating system, files, and multitasking
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=5 "Edit section: Operating system, files, and multitasking")]
Most Forth systems run under a host operating system such as [Microsoft Windows](/wiki/Microsoft_Windows "Microsoft Windows"), [Linux](/wiki/Linux "Linux") or a version of [Unix](/wiki/Unix "Unix") and use the host operating system's file system for source and data files; the ANSI Forth Standard describes the words used for I/O. All modern Forth systems use normal text files for source, even if they are embedded. An embedded system with a resident compiler gets its source via a serial line.
Classic Forth systems traditionally use neither [operating system](/wiki/Operating_system "Operating system") nor [file system](/wiki/File_system "File system"). Instead of storing code in files, source code is stored in disk blocks written to physical disk addresses. The word `BLOCK` is employed to translate the number of a 1K-sized block of disk space into the address of a buffer containing the data, which is managed automatically by the Forth system. Block use has become rare since the mid-1990s. In a hosted system those blocks too are allocated in a normal file in any case.
[Multitasking](/wiki/Computer_multitasking "Computer multitasking"), most commonly [cooperative](/wiki/Computer_multitasking#Cooperative_multitasking/time-sharing "Computer multitasking") [round-robin scheduling](/wiki/Round-robin_scheduling "Round-robin scheduling"), is normally available (although multitasking words and support are not covered by the ANSI Forth Standard). The word `PAUSE` is used to save the current task's execution context, to locate the next task, and restore its execution context. Each task has its own stacks, private copies of some control variables and a scratch area. Swapping tasks is simple and efficient; as a result, Forth multitaskers are available even on very simple [microcontrollers](/wiki/Microcontroller "Microcontroller"), such as the [Intel 8051](/wiki/Intel_MCS-51 "Intel MCS-51"), [Atmel AVR](/wiki/Atmel_AVR "Atmel AVR"), and [TI MSP430](/wiki/TI_MSP430 "TI MSP430").[[33]](#cite_note-nxtDb-34)
Other non-standard facilities include a mechanism for issuing [calls](/wiki/System_call "System call") to the host OS or [windowing systems](/wiki/Windowing_system "Windowing system"), and many provide extensions that employ the scheduling provided by the operating system. Typically they have a larger and different set of words from the stand-alone Forth's `PAUSE` word for task creation, suspension, destruction and modification of priority.
### Self-compilation and cross compilation
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=6 "Edit section: Self-compilation and cross compilation")]
A full-featured Forth system with all source code will compile itself, a technique commonly called meta-compilation or [self-hosting](/wiki/Self-hosting_(compilers) "Self-hosting (compilers)"), by Forth programmers (although the term doesn't exactly match [meta-compilation](/wiki/Meta-Compilation "Meta-Compilation") as it is normally defined). The usual method is to redefine the handful of words that place compiled bits into memory. The compiler's words use specially named versions of fetch and store that can be redirected to a buffer area in memory. The buffer area simulates or accesses a memory area beginning at a different address than the code buffer. Such compilers define words to access both the target computer's memory, and the host (compiling) computer's memory.[[34]](#cite_note-Swdke-35)
After the fetch and store operations are redefined for the code space, the compiler, assembler, etc. are recompiled using the new definitions of fetch and store. This effectively reuses all the code of the compiler and interpreter. Then, the Forth system's code is compiled, but this version is stored in the buffer. The buffer in memory is written to disk, and ways are provided to load it temporarily into memory for testing. When the new version appears to work, it is written over the previous version.
Numerous variations of such compilers exist for different environments. For [embedded systems](/wiki/Embedded_system "Embedded system"), the code may instead be written to another computer, a technique known as [cross compilation](/wiki/Cross-compilation "Cross-compilation"), over a serial port or even a single [TTL](/wiki/Transistor%E2%80%93transistor_logic "Transistortransistor logic") bit, while keeping the word names and other non-executing parts of the dictionary in the original compiling computer. The minimum definitions for such a Forth compiler are the words that fetch and store a byte, and the word that commands a Forth word to be executed. Often the most time-consuming part of writing a remote port is constructing the initial program to implement fetch, store and execute, but many modern microprocessors have integrated debugging features (such as the [Motorola CPU32](/wiki/Motorola_CPU32 "Motorola CPU32")) that eliminate this task.[[35]](#cite_note-E5iFy-36)
## Structure of the language
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=7 "Edit section: Structure of the language")]
The basic data structure of Forth is the "dictionary" which maps "words" to executable code or named data structures. The dictionary is laid out in memory as a tree of [linked lists](/wiki/Linked_list "Linked list") with the links proceeding from the latest (most recently) defined word to the oldest, until a [sentinel value](/wiki/Sentinel_value "Sentinel value"), usually a NULL pointer, is found. A context switch causes a list search to start at a different leaf. A linked list search continues as the branch merges into the main trunk leading eventually back to the sentinel, the root.
There can be several dictionaries. In rare cases such as meta-compilation a dictionary might be isolated and stand-alone.
The effect resembles that of nesting namespaces and can overload keywords depending on the context.
A defined word generally consists of *head* and *body* with the head consisting of the *name field* (NF) and the *link field* (LF), and body consisting of the *code field* (CF) and the *parameter field* (PF).
Head and body of a dictionary entry are treated separately because they may not be contiguous. For example, when a Forth program is recompiled for a new platform, the head may remain on the compiling computer, while the body goes to the new platform. In some environments (such as [embedded systems](/wiki/Embedded_system "Embedded system")) the heads occupy memory unnecessarily. However, some cross-compilers may put heads in the target if the target itself is expected to support an interactive Forth.[[36]](#cite_note-lx5fY-37)
The exact format of a dictionary entry is not prescribed, and implementations vary.
### Structure of the compiler
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=8 "Edit section: Structure of the compiler")]
The compiler itself is not a monolithic program. It consists of Forth words visible to the system, and usable by a programmer. This allows a programmer to change the compiler's words for special purposes. Compilation in traditional Forth systems is straightforward and does not involve building and optimizing an abstract representation of the code. (Some newer Forth compilers use more elaborate compilation methods, as common in other languages.)
The "compile time" flag in the name field is set for words with "compile time" behavior. Most simple words execute the same code whether they are typed on a command line, or embedded in code. When compiling these, the compiler simply places code or a threaded pointer to the word.[[31]](#cite_note-compiler-32)
The classic examples of compile-time words are the [control structures](/wiki/Control_structure "Control structure") such as `IF` and `WHILE`. Almost all of Forth's control structures and almost all of its compiler are implemented as compile-time words. Apart from some rarely used [control flow](/wiki/Control_flow "Control flow") words only found in a few implementations, such as the conditional return word `?EXIT` used in Ulrich Hoffmann's preForth, all of Forth's [control flow](/wiki/Control_flow "Control flow") words are executed during compilation to compile various combinations of primitive words along with their branch addresses.[[1]](#cite_note-preForth_slides-1)[[2]](#cite_note-preForth-2)
For instance, `IF` and `WHILE`, and the words that match with those, set up `BRANCH` (unconditional branch) and `?BRANCH` (pop a value off the stack, and branch if it is false). Counted loop [control flow](/wiki/Control_flow "Control flow") words work similarly but set up combinations of primitive words that work with a counter, and so on. During compilation, the data stack is used to support control structure balancing, nesting, and back-patching of branch addresses. The snippet:
```
... DUP 6 < IF DROP 5 ELSE 1 - THEN ...
```
would often be compiled to the following sequence inside a definition:
```
... DUP LIT 6 < ?BRANCH 5 DROP LIT 5 BRANCH 3 LIT 1 - ...
```
The numbers after `BRANCH` represent relative jump addresses. `LIT` is the primitive word for pushing a "literal" number onto the data stack. (Faster, shorter code would be compiled using pointers to constants instead of `LIT` and embedded data, if any of the numbers involved have been separately defined as constants. There would be similar changes if yet other words were used instead of constants, and so on.)
#### Compilation state and interpretation state
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=9 "Edit section: Compilation state and interpretation state")]
The word `:` (colon) parses a name as a parameter, creates a dictionary entry (a *colon definition*) and enters compilation state. The interpreter continues to read space-delimited words from the user input device. If a word is found, the interpreter executes the *compilation semantics* associated with the word, instead of the *interpretation semantics*. The default compilation semantics of a word are to append its interpretation semantics to the current definition.[[31]](#cite_note-compiler-32)
The word `;` (semi-colon) finishes the current definition and returns to interpretation state. It is an example of a word whose compilation semantics differ from the default. The interpretation semantics of `;` (semi-colon), most control flow words, and several other words are undefined in ANS Forth, meaning that they must only be used inside of definitions and not on the interactive command line.[[31]](#cite_note-compiler-32)
The interpreter state can be changed manually with the words `[` (left-bracket) and `]` (right-bracket) which enter interpretation state or compilation state, respectively. These words can be used with the word `LITERAL` to calculate a value during a compilation and to insert the calculated value into the current colon definition. `LITERAL` has the compilation semantics to take an object from the data stack and to append semantics to the current colon definition to place that object on the data stack.
In ANS Forth, the current state of the interpreter can be read from the [flag](/wiki/Flag_(programming) "Flag (programming)") `STATE` which contains the value true when in compilation state and false otherwise. This allows the implementation of so-called *state-smart words* with behavior that changes according to the current state of the interpreter.
#### Immediate words
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=10 "Edit section: Immediate words")]
The word `IMMEDIATE` marks the most recent colon definition as an *immediate word*, effectively replacing its compilation semantics with its interpretation semantics.[[37]](#cite_note-odMGJ-38) Immediate words are normally executed during compilation, not compiled, but this can be overridden by the programmer in either state. `;` is an example of an immediate word. In ANS Forth, the word `POSTPONE` takes a name as a parameter and appends the compilation semantics of the named word to the current definition even if the word was marked immediate. Forth-83 defined separate words `COMPILE` and `[COMPILE]` to force the compilation of non-immediate and immediate words, respectively.
Instead of reserving space for an Immediate flag in every definition, some implementations of Forth use an Immediates Dictionary which is checked first when in compile mode.
#### Unnamed words and execution tokens
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=11 "Edit section: Unnamed words and execution tokens")]
In ANS Forth, unnamed words can be defined with the word `:NONAME` which compiles the following words up to the next `;` (semi-colon) and leaves an *execution token* on the data stack. The execution token provides an opaque handle for the compiled semantics, similar to the [function pointers](/wiki/Function_pointer "Function pointer") of the [C programming language](/wiki/C_(programming_language) "C (programming language)").
Execution tokens can be stored in variables. The word `EXECUTE` takes an execution token from the data stack and performs the associated semantics. The word `COMPILE,` (compile-comma) takes an execution token from the data stack and appends the associated semantics to the current definition.
The word `'` (tick) takes the name of a word as a parameter and returns the execution token associated with that word on the data stack. In interpretation state, `' RANDOM-WORD EXECUTE` is equivalent to `RANDOM-WORD`.[[38]](#cite_note-iUYBX-39)
#### Parsing words and comments
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=12 "Edit section: Parsing words and comments")]
The words `:` (colon), `POSTPONE`, `'` (tick) are examples of *parsing words* that take their arguments from the user input device instead of the data stack. Another example is the word `(` (paren) which reads and ignores the following words up to and including the next right parenthesis and is used to place comments in a colon definition. Similarly, the word `\` (backslash) is used for comments that continue to the end of the current line. To be parsed correctly, `(` (paren) and `\` (backslash) must be separated by whitespace from the following comment text.
### Structure of code
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=13 "Edit section: Structure of code")]
In most Forth systems, the body of a code definition consists of either [machine language](/wiki/Machine_language "Machine language"), or some form of [threaded code](/wiki/Threaded_code "Threaded code"). The original Forth which follows the informal FIG standard (Forth Interest Group), is a TIL (Threaded Interpretive Language). This is also called indirect-threaded code, but direct-threaded and subroutine threaded Forths have also become popular in modern times. The fastest modern Forths, such as SwiftForth, VFX Forth, and iForth, compile Forth to native machine code.
### Data objects
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=14 "Edit section: Data objects")]
When a word is a variable or other data object, the CF points to the runtime code associated with the defining word that created it. A defining word has a characteristic "defining behavior" (creating a dictionary entry plus possibly allocating and initializing data space) and also specifies the behavior of an instance of the class of words constructed by this defining word. Examples include:
`VARIABLE`
: Names an uninitialized, one-cell memory location. Instance behavior of a `VARIABLE` returns its address on the stack.
`CONSTANT`
: Names a value (specified as an argument to `CONSTANT`). Instance behavior returns the value.
`CREATE`
: Names a location; space may be allocated at this location, or it can be set to contain a string or other initialized value. Instance behavior returns the address of the beginning of this space.
Forth also provides a facility by which a programmer can define new application-specific defining words, specifying both a custom defining behavior and instance behavior. Some examples include circular buffers, named bits on an I/O port, and automatically indexed arrays.
Data objects defined by these and similar words are global in scope. The function provided by local variables in other languages is provided by the data stack in Forth (although Forth also has real local variables). Forth programming style uses very few named data objects compared with other languages; typically such data objects are used to contain data which is used by a number of words or tasks (in a multitasked implementation).[[39]](#cite_note-ceEJ3-40)
Forth does not enforce consistency of [data type](/wiki/Data_type "Data type") usage; it is the programmer's responsibility to use appropriate operators to fetch and store values or perform other operations on data.
## Examples
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=15 "Edit section: Examples")]
### “Hello, World!”
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=16 "Edit section: “Hello, World!”")]
```
: HELLO ( -- ) CR ." Hello, World!" ;
```
```
HELLO <cr>
Hello, World!
```
The word `CR` (Carriage Return) causes the output following `CR`
to be displayed on a new line. The parsing word `."` (dot-quote) reads a double-quote delimited string and appends code to the current definition so that the parsed string will be displayed upon execution. The space character separating the word `."` from the string `Hello, World!` is not included as part of the string. It is needed so that the parser recognizes `."` as a Forth word.
A standard Forth system is also an interpreter, and the same output can be obtained by typing the following code fragment into the Forth console:
```
CR .( Hello, World!)
```
`.(` (dot-paren) is an immediate word that parses a parenthesis-delimited string and displays it. As with the word `."` the space character separating `.(` from `Hello, World!` is not part of the string.
The word `CR` comes before the text to print. By convention, the Forth interpreter does not start output on a new line. Also by convention, the interpreter waits for input at the end of the previous line, after an `ok` prompt. There is no implied "flush-buffer" action in Forth's `CR`, as sometimes is in other programming languages.
### Mixing states of compiling and interpreting
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=17 "Edit section: Mixing states of compiling and interpreting")]
Here is the definition of a word `EMIT-Q` which when executed emits the single character `Q`:
```
: EMIT-Q 81 ( the ASCII value for the character 'Q' ) EMIT ;
```
This definition was written to use the [ASCII](/wiki/ASCII "ASCII") value of the `Q` character (81) directly. The text between the parentheses is a comment and is ignored by the compiler. The word `EMIT` takes a value from the data stack and displays the corresponding character.
The following redefinition of `EMIT-Q` uses the words `[` (left-bracket), `]` (right-bracket), `CHAR` and `LITERAL` to temporarily switch to interpreter state, calculate the ASCII value of the `Q` character, return to compilation state and append the calculated value to the current colon definition:
```
: EMIT-Q [ CHAR Q ] LITERAL EMIT ;
```
The parsing word `CHAR` takes a space-delimited word as parameter and places the value of its first character on the data stack. The word `[CHAR]` is an immediate version of `CHAR`. Using `[CHAR]`, the example definition for `EMIT-Q` could be rewritten like this:
```
: EMIT-Q [CHAR] Q EMIT ; \ Emit the single character 'Q'
```
This definition used `\` (backslash) for the describing comment.
Both `CHAR` and `[CHAR]` are predefined in ANS Forth. Using `IMMEDIATE` and `POSTPONE`, `[CHAR]` could have been defined like this:
```
: [CHAR] CHAR POSTPONE LITERAL ; IMMEDIATE
```
### RC4 cipher program
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=18 "Edit section: RC4 cipher program")]
In 1987, [Ron Rivest](/wiki/Ron_Rivest "Ron Rivest") developed the [RC4](/wiki/RC4 "RC4") cipher-system for RSA Data Security, Inc. Its description follows:
> We have an array of 256 bytes, all different. Every time the array is used it changes by swapping two bytes. The swaps are controlled by counters *i* and *j*, each initially 0. To get a new *i*, add 1. To get a new *j*, add the array byte at the new *i*. Exchange the array bytes at *i* and *j*. The code is the array byte at the sum of the array bytes at *i* and *j*. This is XORed with a byte of the plaintext to encrypt, or the ciphertext to decrypt. The array is initialized by first setting it to 0 through 255. Then step through it using *i* and *j*, getting the new *j* by adding to it the array byte at *i* and a key byte, and swapping the array bytes at *i* and *j*. Finally, *i* and *j* are set to 0. All additions are modulo 256.
The following Standard Forth version uses Core and Core Extension words only.
```
0 value ii 0 value jj
0 value KeyAddr 0 value KeyLen
create SArray 256 allot \ state array of 256 bytes
: KeyArray KeyLen mod KeyAddr ;
: get_byte + c@ ;
: set_byte + c! ;
: as_byte 255 and ;
: reset_ij 0 TO ii 0 TO jj ;
: i_update 1 + as_byte TO ii ;
: j_update ii SArray get_byte + as_byte TO jj ;
: swap_s_ij
jj SArray get_byte
ii SArray get_byte jj SArray set_byte
ii SArray set_byte
;
: rc4_init ( KeyAddr KeyLen -- )
256 min TO KeyLen TO KeyAddr
256 0 DO i i SArray set_byte LOOP
reset_ij
BEGIN
ii KeyArray get_byte jj + j_update
swap_s_ij
ii 255 < WHILE
ii i_update
REPEAT
reset_ij
;
: rc4_byte
ii i_update jj j_update
swap_s_ij
ii SArray get_byte jj SArray get_byte + as_byte SArray get_byte xor
;
```
This is one way to test the code:
```
hex
create AKey 61 c, 8A c, 63 c, D2 c, FB c,
: test cr 0 DO rc4_byte . LOOP cr ;
AKey 5 rc4_init
2C F9 4C EE DC 5 test \ output should be: F1 38 29 C9 DE
```
## Forth engines
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=19 "Edit section: Forth engines")]
A processor designed to support a specific programming language is called a language "engine".[[40]](#cite_note-dumse-41)
Forth engines are hardware platforms specifically designed to support developing and running programs written in Forth. (Likewise, [Lisp machines](/wiki/Lisp_machine "Lisp machine") were specifically designed to support developing and running programs written in Lisp, the [Pascal MicroEngine](/wiki/Pascal_MicroEngine "Pascal MicroEngine") was specifically designed to support developing and running programs written in Pascal, etc.).
The first commercially available single-chip Forth engine was the Rockwell R65F11,[[40]](#cite_note-dumse-41)
a chip that includes a Forth kernel in ROM,
an [enhanced 6502](/wiki/MOS_Technology_6502#Variations_and_derivatives "MOS Technology 6502"), SRAM, and various interface circuits that previously required peripheral chips.[[40]](#cite_note-dumse-41)[[41]](#cite_note-42)[[42]](#cite_note-43)[[43]](#cite_note-44)[[44]](#cite_note-45)
Many other commercial CPUs (Harris RTX-2000, Novix NC4016, F21, MARC4, KimKlone, etc.) and many [homebrew CPUs](/wiki/Homebrew_CPU "Homebrew CPU") (My4TH, J1, H2, Mark 1 FORTH Computer, etc.) are specifically designed to run Forth. Typically they implement common Forth primitives such as the "Forth NEXT" as single instructions.
## Implementations
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=20 "Edit section: Implementations")]
Because Forth is simple to implement and has no standard reference implementation, there are numerous versions of the language. In addition to supporting the standard varieties of desktop computer systems ([POSIX](/wiki/POSIX "POSIX"), [Microsoft Windows](/wiki/Microsoft_Windows "Microsoft Windows"), [macOS](/wiki/MacOS "MacOS")), many of these Forth systems also target a variety of [embedded systems](/wiki/Embedded_system "Embedded system"). Listed here are some of the systems which conform to the 1994 ANS Forth standard.
* ASYST, a Forth-like system for data collection and analysis [[45]](#cite_note-46)[[16]](#cite_note-Rwirj-17)
* [Gforth](/wiki/Gforth "Gforth"), a portable ANS Forth implementation from the [GNU Project](/wiki/GNU_Project "GNU Project")
* [noForth](https://home.hccnet.nl/anij/nof/noforth.html), an ANS Forth implementation (as far as possible) for Flash microcontrollers (MSP430, RISC-V & RP2040)
* [Open Firmware](/wiki/Open_Firmware "Open Firmware"), a [bootloader](/wiki/Bootloader "Bootloader") and [firmware](/wiki/Firmware "Firmware") standard based on ANS Forth
* [pForth](/wiki/PForth "PForth"), portable Forth written in C
* SP-Forth, ANS Forth implementation from the Russian Forth Interest Group (RuFIG)
* Swift Forth, machine code generating implementation from Forth, Inc.
* VFX Forth, optimizing native code Forth
* [Firth](https://littlemanstackmachine.org/firth.html), an adaptation of Forth for the Little Man Stack Machine computer.
* [Shi](https://gitlab.com/higaski/Shi), a fast and tiny embeddable Forth implementation written for the Thumb-2 ISA (ARMv7-M and newer).
## See also
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=21 "Edit section: See also")]
* [Video games written in Forth](/wiki/Category:Video_games_written_in_Forth "Category:Video games written in Forth")
* [RTX2010](/wiki/RTX2010 "RTX2010"), a CPU that runs Forth natively
## Notes
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=22 "Edit section: Notes")]
1. **[^](#cite_ref-3)**
There are exceptions, such as Ulrich Hoffmann's preForth[[1]](#cite_note-preForth_slides-1)[[2]](#cite_note-preForth-2) and Tom Zimmer's TCOM
## References
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=23 "Edit section: References")]
1. ^ [***a***](#cite_ref-preForth_slides_1-0) [***b***](#cite_ref-preForth_slides_1-1)
["Ulrich Hoffmann's preForth slides"](http://www.euroforth.org/ef18/papers/hoffmann-slides.pdf) (PDF).
2. ^ [***a***](#cite_ref-preForth_2-0) [***b***](#cite_ref-preForth_2-1)
["Ulrich Hoffmann's preForth"](http://www.euroforth.org/ef18/papers/hoffmann.pdf) (PDF).
3. ^ [***a***](#cite_ref-maher_4-0) [***b***](#cite_ref-maher_4-1) Maher, Jimmy (October 28, 2014). ["Starflight"](https://www.filfre.net/2014/10/starflight/). *The Digital Antiquarian*. Retrieved April 29, 2023.
4. **[^](#cite_ref-oSWRm_5-0)** [NASA applications of Forth](https://web.archive.org/web/20101024223709/http://forth.gsfc.nasa.gov/) (original NASA server no longer running, copy from archive.org)
5. **[^](#cite_ref-zYmBe_6-0)** ["Intersil's RTX processors and Forth software controlled the successful Philae landing"](https://web.archive.org/web/20230429195754/https://mpeforth.com/press/MPE_PR_From_Telescope_to_Comet_2014_11_13.pdf) (PDF). *MicroProcessor Engineering Limited*. October 13, 2014. Archived from [the original](https://mpeforth.com/press/MPE_PR_From_Telescope_to_Comet_2014_11_13.pdf) (PDF) on April 29, 2023. Retrieved April 29, 2023.
6. **[^](#cite_ref-sgEMh_7-0)** ["Here comes Philae! Powered by an RTX2010"](https://www.cpushack.com/2014/11/12/here-comes-philae-powered-by-an-rtx2010/). *The CPU Shack Museum*. October 12, 2014. Retrieved April 29, 2023.
7. **[^](#cite_ref-C4Oss_8-0)** ["Space Related Applications of Forth"](https://web.archive.org/web/20101024223709/http://forth.gsfc.nasa.gov/). Archived from [the original](https://forth.gsfc.nasa.gov) on 2010-10-24. Retrieved 2007-09-04.
8. ^ [***a***](#cite_ref-evolution_9-0) [***b***](#cite_ref-evolution_9-1) [***c***](#cite_ref-evolution_9-2) Rather, Elizabeth D.; Colburn, Donald R.; Moore, Charles H. (1996) [1993]. ["The evolution of Forth"](http://www.forth.com/resources/evolution/index.html). In Bergin, Thomas J.; Gibson, Richard G. (eds.). *History of programming languages---II*. Association for Computing Machinery. pp. 625670. [doi](/wiki/Doi_(identifier) "Doi (identifier)"):[10.1145/234286.1057832](https://doi.org/10.1145%2F234286.1057832). [ISBN](/wiki/ISBN_(identifier) "ISBN (identifier)") [0201895021](/wiki/Special:BookSources/0201895021 "Special:BookSources/0201895021").
9. **[^](#cite_ref-10)** ["Atari In-Store Demonstration Program"](http://www.atarimania.com/demo-atari-400-800-xl-xe-in-store-demonstration-program_19329.html). *Atari Mania*.
10. **[^](#cite_ref-11)** Maynard, David S. ["David Maynard: Software Artist"](https://www.software-artist.com).
11. **[^](#cite_ref-12)** John Romero (2020-09-23). ["Time Warp: Episode 9 - Stuart Smith"](https://appletimewarp.libsyn.com/episode-9-stuart-smith) (Podcast). Event occurs at 29:02.
12. **[^](#cite_ref-13)** Aycock, John (2023). [*Amnesia Remembered: Reverse Engineering a Digital Artifact*](https://www.berghahnbooks.com/title/AycockAmnesia). Berghahn Books. p. 79. [ISBN](/wiki/ISBN_(identifier) "ISBN (identifier)") [978-1800738676](/wiki/Special:BookSources/978-1800738676 "Special:BookSources/978-1800738676").
13. **[^](#cite_ref-14)** Sharp, Doug (8 April 2023). ["FORTH Programming Language (Going FORTH)"](https://chipwits.com/2023/04/08/forth-programming-language-going-forth/).
14. **[^](#cite_ref-15)** Rochat, Jan (February 6, 2025). ["Back to 1985: How We Remade ChipWits for the C64"](https://chipwits.com/2025/02/06/back-to-1985-how-we-remade-chipwits-for-the-c64/).
15. **[^](#cite_ref-16)** ["FORTH GETS ITS OWN SPECIAL INTEREST GROUP"](https://techmonitor.ai/technology/forth_gets_its_own_special_interest_group). *Tech Monitor*. 6 February 1989.
16. ^ [***a***](#cite_ref-Rwirj_17-0) [***b***](#cite_ref-Rwirj_17-1) Campbell et al, "Up and Running with Asyst 2.0", MacMillan Software Co., 1987
17. **[^](#cite_ref-WYK4Z_18-0)** Moore, Charles H. (1991). ["Forth - The Early Years"](https://web.archive.org/web/20060615025259/http://www.colorforth.com/HOPL.html). Archived from [the original](http://www.colorforth.com/HOPL.html) on 2006-06-15. Retrieved 2006-06-03.
18. **[^](#cite_ref-19)** Moore, Charles H. (August 1980). ["The Evolution of FORTH, an Unusual Language"](https://archive.org/details/byte-magazine-1980-08/page/n77/mode/2up). *BYTE Magazine*. **5** (8): 82.
19. **[^](#cite_ref-20)** ["ANS 1994 Specification, Annex C ("Perspective")"](https://www.taygeta.com/forth/dpansc.htm). *taygeta.com*.
20. **[^](#cite_ref-1AvuY_21-0)** ["The Forth Language"](https://archive.org/details/byte-magazine-1980-08/), *BYTE Magazine*, **5** (8), 1980
21. **[^](#cite_ref-family-tree_22-0)** M. Anton Ertl. ["Forth family tree and timeline"](https://www.complang.tuwien.ac.at/forth/family-tree/).
22. **[^](#cite_ref-gWyzb_23-0)** Lutus, Paul (1982). ["GraFORTH Language Manual"](https://archive.org/details/graforth1). *archive.org*. Insoft.
23. **[^](#cite_ref-qyrcN_24-0)** ["The Forth-79 Standard"](https://www.physics.wisc.edu/~lmaurer/forth/Forth-79.pdf) (PDF). Retrieved 2023-04-29.
24. **[^](#cite_ref-BQ2oi_25-0)** ["The Forth-83 Standard"](https://web.archive.org/web/20230405001333/https://forth.sourceforge.net/standard/fst83/). Archived from [the original](https://forth.sourceforge.net/standard/fst83/) on 2023-04-05. Retrieved 2023-04-29.
25. **[^](#cite_ref-IGDIN_26-0)** ["Programming Languages: Forth"](https://www.taygeta.com/forth/dpans.html). ANSI technical committee X3J14. 24 March 1994. Retrieved 2006-06-03.
26. **[^](#cite_ref-KojQK_27-0)** ["Standard Forth (ANSI INCITS 215-1994) Reference"](http://quartus.net/files/PalmOS/Forth/Docs/stdref.pdf) (PDF). Quartus Handheld Software. 13 September 2005. Retrieved 2023-04-29.
27. **[^](#cite_ref-BtuRy_28-0)** Claunch, Carl (2018-03-02). ["Restoring the original source code for FORTH on the IBM 1130"](https://rescue1130.blogspot.com/2018/03/restoring-original-source-code-for.html). *rescue1130*. Retrieved July 30, 2018.
28. **[^](#cite_ref-29)**
Brodie, Leo (1987). [*Starting Forth*](https://www.forth.com/starting-forth/index.html) (2nd ed.). Prentice-Hall. [ISBN](/wiki/ISBN_(identifier) "ISBN (identifier)") [978-0-13-843079-5](/wiki/Special:BookSources/978-0-13-843079-5 "Special:BookSources/978-0-13-843079-5").
29. **[^](#cite_ref-3yqc9_30-0)** [Brodie 1987](#CITEREFBrodie1987), p. 20
30. **[^](#cite_ref-6dQ7P_31-0)**
[Brodie 1987](#CITEREFBrodie1987), p. 14
31. ^ [***a***](#cite_ref-compiler_32-0) [***b***](#cite_ref-compiler_32-1) [***c***](#cite_ref-compiler_32-2) [***d***](#cite_ref-compiler_32-3)
[Brodie 1987](#CITEREFBrodie1987), p. 16
32. **[^](#cite_ref-NAFQu_33-0)** Rodriguez, Brad. ["Build Your Own Assembler, Part 2: a 6809 Forth Assembler"](https://www.bradrodriguez.com/papers/6809asm.txt). Retrieved 2023-04-29.
33. **[^](#cite_ref-nxtDb_34-0)** Rodriguez, Brad. ["Multitasking 8051 CamelForth"](https://www.bradrodriguez.com/papers/8051task.pdf) (PDF). Retrieved 2023-04-29.
34. **[^](#cite_ref-Swdke_35-0)** Rodriguez, Brad (JulyAugust 1995). ["MOVING FORTH, Part 8: CamelForth for the 6809"](https://www.bradrodriguez.com/papers/moving8.htm). Retrieved 2023-04-29.
35. **[^](#cite_ref-E5iFy_36-0)** Shoebridge, Peter (1998-12-21). ["Motorola Background Debugging Mode Driver for Windows NT"](https://web.archive.org/web/20070606083244/http://www.zeecube.com/archive/bdm/index.htm). Archived from [the original](http://www.zeecube.com/archive/bdm/index.htm) on 2007-06-06. Retrieved 2006-06-19.
36. **[^](#cite_ref-lx5fY_37-0)** Martin, Harold M. (March 1991). ["Developing a tethered Forth model"](https://doi.org/10.1145%2F122089.122091). *ACM SIGFORTH Newsletter*. **2** (3). ACM Press: 1719. [doi](/wiki/Doi_(identifier) "Doi (identifier)"):[10.1145/122089.122091](https://doi.org/10.1145%2F122089.122091). [S2CID](/wiki/S2CID_(identifier) "S2CID (identifier)") [26362015](https://api.semanticscholar.org/CorpusID:26362015).
37. **[^](#cite_ref-odMGJ_38-0)** [Brodie 1987](#CITEREFBrodie1987), p. 273
38. **[^](#cite_ref-iUYBX_39-0)** [Brodie 1987](#CITEREFBrodie1987), p. 199
39. **[^](#cite_ref-ceEJ3_40-0)** "Under The Hood". *[Brodie 1987](#CITEREFBrodie1987)*. p. 241. "To summarize, there are three kinds of variables: System variables contain values used by the entire Forth system. User variables contain values that are unique for each task, even though the definitions can be used by all tasks in the system. Regular variables can be accessible either system-wide or within a single task only, depending upon whether they are defined within `OPERATOR` or within a private task."
40. ^ [***a***](#cite_ref-dumse_41-0) [***b***](#cite_ref-dumse_41-1) [***c***](#cite_ref-dumse_41-2) Randy M. Dumse.
"The R65F11 and F68K Single-Chip Forth Computers".
[[1]](http://www.forth.org/bournemouth/jfar/vol2/no1/article1.pdf)[*[permanent dead link](/wiki/Wikipedia:Link_rot "Wikipedia:Link rot")*]
[[2]](http://soton.mpeforth.com/flag/jfar/vol2/no1/article1.pdf) [Archived](https://web.archive.org/web/20141202144044/http://soton.mpeforth.com/flag/jfar/vol2/no1/article1.pdf) 2014-12-02 at the [Wayback Machine](/wiki/Wayback_Machine "Wayback Machine")
1984.
41. **[^](#cite_ref-42)**
Ed Schmauch.
["A Computerized Corrosion Monitoring System"](http://www.forth.org/bournemouth/jfar/vol4/no2/article48.pdf)[*[permanent dead link](/wiki/Wikipedia:Link_rot "Wikipedia:Link rot")*].
1986.
42. **[^](#cite_ref-43)** Lawrence P. Forsley.
["Embedded systems: 1990 Rochester Forth Conference: June 12 16th, 1990 University of Rochester"](https://books.google.com/books?id=Yx8YAQAAMAAJ) [Archived](https://web.archive.org/web/20150325214054/http://books.google.com/books?id=Yx8YAQAAMAAJ) 2015-03-25 at the [Wayback Machine](/wiki/Wayback_Machine "Wayback Machine").
p. 51.
43. **[^](#cite_ref-44)** Rockwell.
["RSC-Forth User's Manual"](http://www.smallestplcoftheworld.org/RSC-FORTH_User's_Manual.pdf) [Archived](https://web.archive.org/web/20131207015149/http://smallestplcoftheworld.org/RSC-FORTH_User%27s_Manual.pdf) 2013-12-07 at the [Wayback Machine](/wiki/Wayback_Machine "Wayback Machine").
1983.
44. **[^](#cite_ref-45)** ["Rockwell R65F11 R65F12 Forth Based Microcomputers"](http://archive.6502.org/datasheets/rockwell_r65f11_r65f12_forth_microcomputers.pdf) (PDF). June 1987. [Archived](https://web.archive.org/web/20200804035007/http://archive.6502.org/datasheets/rockwell_r65f11_r65f12_forth_microcomputers.pdf) (PDF) from the original on 4 August 2020. Retrieved 28 Apr 2020.
45. **[^](#cite_ref-46)** Hary, David; Oshio, Koichi; Flanagan, Steven D. (1987). "The ASYST Software for Scientific Computing". *Science*. **236** (4805): 112832. [Bibcode](/wiki/Bibcode_(identifier) "Bibcode (identifier)"):[1987Sci...236.1128H](https://ui.adsabs.harvard.edu/abs/1987Sci...236.1128H). [doi](/wiki/Doi_(identifier) "Doi (identifier)"):[10.1126/science.236.4805.1128](https://doi.org/10.1126%2Fscience.236.4805.1128). [JSTOR](/wiki/JSTOR_(identifier) "JSTOR (identifier)") [1699106](https://www.jstor.org/stable/1699106). [PMID](/wiki/PMID_(identifier) "PMID (identifier)") [17799670](https://pubmed.ncbi.nlm.nih.gov/17799670). [S2CID](/wiki/S2CID_(identifier) "S2CID (identifier)") [30463062](https://api.semanticscholar.org/CorpusID:30463062).
## External links
[[edit](/w/index.php?title=Forth_(programming_language)&action=edit&section=24 "Edit section: External links")]
* [Forth 2012 Standard](https://forth-standard.org) official site
* [*Programming a problem-oriented language*](https://forth.org/POL.pdf) unpublished book by Charles H. Moore (1970)
* [Annual European Forth Conference](https://www.euroforth.org/) 1985present
* [Forth Research](https://www.complang.tuwien.ac.at/projects/forth.html) at Institut für Computersprachen
[![](//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/40px-Commons-logo.svg.png)](/wiki/File:Commons-logo.svg)
Wikimedia Commons has media related to [Forth (programming language)](https://commons.wikimedia.org/wiki/Category:Forth_(programming_language) "commons:Category:Forth (programming language)").
[![](//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikibooks-logo-en-noslogan.svg/40px-Wikibooks-logo-en-noslogan.svg.png)](/wiki/File:Wikibooks-logo-en-noslogan.svg)
Wikibooks has a book on the topic of: ***[Forth](https://en.wikibooks.org/wiki/Forth "wikibooks:Forth")***
| * [v](/wiki/Template:Programming_languages "Template:Programming languages") * [t](/wiki/Template_talk:Programming_languages "Template talk:Programming languages") * [e](/wiki/Special:EditPage/Template:Programming_languages "Special:EditPage/Template:Programming languages") [Programming languages](/wiki/Programming_language "Programming language") | |
| --- | --- |
| * [Comparison](/wiki/Comparison_of_programming_languages "Comparison of programming languages") * [Timeline](/wiki/Timeline_of_programming_languages "Timeline of programming languages") * [History](/wiki/History_of_programming_languages "History of programming languages") | |
| * [Ada](/wiki/Ada_(programming_language) "Ada (programming language)") * [ALGOL](/wiki/ALGOL "ALGOL") + [Simula](/wiki/Simula "Simula") * [APL](/wiki/APL_(programming_language) "APL (programming language)") * [Assembly](/wiki/Assembly_language "Assembly language") * [BASIC](/wiki/BASIC "BASIC") + [Visual Basic](/wiki/Visual_Basic "Visual Basic") - [classic](/wiki/Visual_Basic_(classic) "Visual Basic (classic)") - [.NET](/wiki/Visual_Basic_(.NET) "Visual Basic (.NET)") * [C](/wiki/C_(programming_language) "C (programming language)") * [C++](/wiki/C%2B%2B "C++") * [C#](/wiki/C_Sharp_(programming_language) "C Sharp (programming language)") * [COBOL](/wiki/COBOL "COBOL") * [Erlang](/wiki/Erlang_(programming_language) "Erlang (programming language)") + [Elixir](/wiki/Elixir_(programming_language) "Elixir (programming language)") * Forth * [Fortran](/wiki/Fortran "Fortran") * [Go](/wiki/Go_(programming_language) "Go (programming language)") * [Haskell](/wiki/Haskell "Haskell") * [Java](/wiki/Java_(programming_language) "Java (programming language)") * [JavaScript](/wiki/JavaScript "JavaScript") * [Julia](/wiki/Julia_(programming_language) "Julia (programming language)") * [Kotlin](/wiki/Kotlin "Kotlin") * [Lisp](/wiki/Lisp_(programming_language) "Lisp (programming language)") * [Lua](/wiki/Lua "Lua") * [MATLAB](/wiki/MATLAB "MATLAB") * [ML](/wiki/ML_(programming_language) "ML (programming language)") + [Caml](/wiki/Caml "Caml") - [OCaml](/wiki/OCaml "OCaml") + [Standard ML](/wiki/Standard_ML "Standard ML") * [Pascal](/wiki/Pascal_(programming_language) "Pascal (programming language)") + [Object Pascal](/wiki/Object_Pascal "Object Pascal") * [Perl](/wiki/Perl "Perl") + [Raku](/wiki/Raku_(programming_language) "Raku (programming language)") * [PHP](/wiki/PHP "PHP") * [Prolog](/wiki/Prolog "Prolog") * [Python](/wiki/Python_(programming_language) "Python (programming language)") * [R](/wiki/R_(programming_language) "R (programming language)") * [Ruby](/wiki/Ruby_(programming_language) "Ruby (programming language)") * [Rust](/wiki/Rust_(programming_language) "Rust (programming language)") * [SAS](/wiki/SAS_language "SAS language") * [SQL](/wiki/SQL "SQL") * [Scratch](/wiki/Scratch_(programming_language) "Scratch (programming language)") * [Shell](/wiki/Shell_script "Shell script") * [Smalltalk](/wiki/Smalltalk "Smalltalk") * [Swift](/wiki/Swift_(programming_language) "Swift (programming language)") * *[more...](/wiki/List_of_programming_languages "List of programming languages")* | |
| * **Lists:** [Alphabetical](/wiki/List_of_programming_languages "List of programming languages") * [Categorical](/wiki/List_of_programming_languages_by_type "List of programming languages by type") * [Generational](/wiki/Generational_list_of_programming_languages "Generational list of programming languages") * [Non-English-based](/wiki/Non-English-based_programming_languages "Non-English-based programming languages") * [Category](/wiki/Category:Programming_languages "Category:Programming languages") | |
| [Authority control databases](/wiki/Help:Authority_control "Help:Authority control") [Edit this at Wikidata](https://www.wikidata.org/wiki/Q275472#identifiers "Edit this at Wikidata") | |
| --- | --- |
| International | * [GND](https://d-nb.info/gnd/4017981-3) |
| National | * [United States](https://id.loc.gov/authorities/sh85050918) * [Israel](https://www.nli.org.il/en/authorities/987007545715805171) |
| Other | * [Yale LUX](https://lux.collections.yale.edu/view/concept/931111ef-f1ef-4ba1-8d0d-0108e93a3b91) |
![](https://en.wikipedia.org/wiki/Special:CentralAutoLogin/start?useformat=desktop&type=1x1&usesul3=1)
Retrieved from "<https://en.wikipedia.org/w/index.php?title=Forth_(programming_language)&oldid=1330667744>"
[Categories](/wiki/Help:Category "Help:Category"):
* [Forth programming language family](/wiki/Category:Forth_programming_language_family "Category:Forth programming language family")
* [Concatenative programming languages](/wiki/Category:Concatenative_programming_languages "Category:Concatenative programming languages")
* [Stack-based virtual machines](/wiki/Category:Stack-based_virtual_machines "Category:Stack-based virtual machines")
* [Systems programming languages](/wiki/Category:Systems_programming_languages "Category:Systems programming languages")
* [Programming languages created in 1970](/wiki/Category:Programming_languages_created_in_1970 "Category:Programming languages created in 1970")
* [Extensible syntax programming languages](/wiki/Category:Extensible_syntax_programming_languages "Category:Extensible syntax programming languages")
* [Programming languages with an ISO standard](/wiki/Category:Programming_languages_with_an_ISO_standard "Category:Programming languages with an ISO standard")
* [Programming languages](/wiki/Category:Programming_languages "Category:Programming languages")
* [1970 software](/wiki/Category:1970_software "Category:1970 software")
Hidden categories:
* [All articles with dead external links](/wiki/Category:All_articles_with_dead_external_links "Category:All articles with dead external links")
* [Articles with dead external links from May 2017](/wiki/Category:Articles_with_dead_external_links_from_May_2017 "Category:Articles with dead external links from May 2017")
* [Articles with permanently dead external links](/wiki/Category:Articles_with_permanently_dead_external_links "Category:Articles with permanently dead external links")
* [Webarchive template wayback links](/wiki/Category:Webarchive_template_wayback_links "Category:Webarchive template wayback links")
* [Articles with short description](/wiki/Category:Articles_with_short_description "Category:Articles with short description")
* [Short description is different from Wikidata](/wiki/Category:Short_description_is_different_from_Wikidata "Category:Short description is different from Wikidata")
* [All articles with unsourced statements](/wiki/Category:All_articles_with_unsourced_statements "Category:All articles with unsourced statements")
* [Articles with unsourced statements from April 2022](/wiki/Category:Articles_with_unsourced_statements_from_April_2022 "Category:Articles with unsourced statements from April 2022")
* [Commons category link is on Wikidata](/wiki/Category:Commons_category_link_is_on_Wikidata "Category:Commons category link is on Wikidata")
* [Articles with example C code](/wiki/Category:Articles_with_example_C_code "Category:Articles with example C code")
* This page was last edited on 1 January 2026, at 20:21 (UTC).
* Text is available under the [Creative Commons Attribution-ShareAlike 4.0 License](/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License "Wikipedia:Text of the Creative Commons Attribution-ShareAlike 4.0 International License");
additional terms may apply. By using this site, you agree to the [Terms of Use](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use "foundation:Special:MyLanguage/Policy:Terms of Use") and [Privacy Policy](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy "foundation:Special:MyLanguage/Policy:Privacy policy"). Wikipedia® is a registered trademark of the [Wikimedia Foundation, Inc.](https://wikimediafoundation.org/), a non-profit organization.
* [Privacy policy](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy)
* [About Wikipedia](/wiki/Wikipedia:About)
* [Disclaimers](/wiki/Wikipedia:General_disclaimer)
* [Contact Wikipedia](//en.wikipedia.org/wiki/Wikipedia:Contact_us)
* [Legal & safety contacts](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Legal:Wikimedia_Foundation_Legal_and_Safety_Contact_Information)
* [Code of Conduct](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct)
* [Developers](https://developer.wikimedia.org)
* [Statistics](https://stats.wikimedia.org/#/en.wikipedia.org)
* [Cookie statement](https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement)
* [Mobile view](//en.wikipedia.org/w/index.php?title=Forth_(programming_language)&mobileaction=toggle_view_mobile)
* [![Wikimedia Foundation](/static/images/footer/wikimedia.svg)](https://www.wikimedia.org/)
* [![Powered by MediaWiki](/w/resources/assets/mediawiki_compact.svg)](https://www.mediawiki.org/)
Search
Search
Toggle the table of contents
Forth (programming language)
34 languages
[Add topic](#)

View File

@@ -0,0 +1,445 @@
# b4 virtual machine
**Source:** https://github.com/tangentstorm/b4
GitHub - tangentstorm/b4: b4 : a tiny forth-like virtual machine
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Ftangentstorm%2Fb4)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Ftangentstorm%2Fb4)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=tangentstorm%2Fb4)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[tangentstorm](/tangentstorm)
/
**[b4](/tangentstorm/b4)**
Public
* [Notifications](/login?return_to=%2Ftangentstorm%2Fb4) You must be signed in to change notification settings
* [Fork
4](/login?return_to=%2Ftangentstorm%2Fb4)
* [Star
39](/login?return_to=%2Ftangentstorm%2Fb4)
b4 : a tiny forth-like virtual machine
[www.reddit.com/r/b4lang/](http://www.reddit.com/r/b4lang/ "http://www.reddit.com/r/b4lang/")
[39
stars](/tangentstorm/b4/stargazers) [4
forks](/tangentstorm/b4/forks) [Branches](/tangentstorm/b4/branches) [Tags](/tangentstorm/b4/tags) [Activity](/tangentstorm/b4/activity)
[Star](/login?return_to=%2Ftangentstorm%2Fb4)
[Notifications](/login?return_to=%2Ftangentstorm%2Fb4) You must be signed in to change notification settings
* [Code](/tangentstorm/b4)
* [Issues
0](/tangentstorm/b4/issues)
* [Pull requests
2](/tangentstorm/b4/pulls)
* [Actions](/tangentstorm/b4/actions)
* [Projects
0](/tangentstorm/b4/projects)
* [Wiki](/tangentstorm/b4/wiki)
* [Security
0](/tangentstorm/b4/security)
* [Insights](/tangentstorm/b4/pulse)
Additional navigation options
* [Code](/tangentstorm/b4)
* [Issues](/tangentstorm/b4/issues)
* [Pull requests](/tangentstorm/b4/pulls)
* [Actions](/tangentstorm/b4/actions)
* [Projects](/tangentstorm/b4/projects)
* [Wiki](/tangentstorm/b4/wiki)
* [Security](/tangentstorm/b4/security)
* [Insights](/tangentstorm/b4/pulse)
# tangentstorm/b4
main
[Branches](/tangentstorm/b4/branches)[Tags](/tangentstorm/b4/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[1,568 Commits](/tangentstorm/b4/commits/main/) 1,568 Commits | | |
| [b3a](/tangentstorm/b4/tree/main/b3a "b3a") | | [b3a](/tangentstorm/b4/tree/main/b3a "b3a") | | |
| [bios](/tangentstorm/b4/tree/main/bios "bios") | | [bios](/tangentstorm/b4/tree/main/bios "bios") | | |
| [doc](/tangentstorm/b4/tree/main/doc "doc") | | [doc](/tangentstorm/b4/tree/main/doc "doc") | | |
| [electron](/tangentstorm/b4/tree/main/electron "electron") | | [electron](/tangentstorm/b4/tree/main/electron "electron") | | |
| [etc](/tangentstorm/b4/tree/main/etc "etc") | | [etc](/tangentstorm/b4/tree/main/etc "etc") | | |
| [jlang](/tangentstorm/b4/tree/main/jlang "jlang") | | [jlang](/tangentstorm/b4/tree/main/jlang "jlang") | | |
| [js](/tangentstorm/b4/tree/main/js "js") | | [js](/tangentstorm/b4/tree/main/js "js") | | |
| [lil](/tangentstorm/b4/tree/main/lil "lil") | | [lil](/tangentstorm/b4/tree/main/lil "lil") | | |
| [mcp-b4i](/tangentstorm/b4/tree/main/mcp-b4i "mcp-b4i") | | [mcp-b4i](/tangentstorm/b4/tree/main/mcp-b4i "mcp-b4i") | | |
| [pas](/tangentstorm/b4/tree/main/pas "pas") | | [pas](/tangentstorm/b4/tree/main/pas "pas") | | |
| [ref](/tangentstorm/b4/tree/main/ref "ref") | | [ref](/tangentstorm/b4/tree/main/ref "ref") | | |
| [.gitignore](/tangentstorm/b4/blob/main/.gitignore ".gitignore") | | [.gitignore](/tangentstorm/b4/blob/main/.gitignore ".gitignore") | | |
| [ASSISTANTS.md](/tangentstorm/b4/blob/main/ASSISTANTS.md "ASSISTANTS.md") | | [ASSISTANTS.md](/tangentstorm/b4/blob/main/ASSISTANTS.md "ASSISTANTS.md") | | |
| [README.org](/tangentstorm/b4/blob/main/README.org "README.org") | | [README.org](/tangentstorm/b4/blob/main/README.org "README.org") | | |
| [b4-tests.org](/tangentstorm/b4/blob/main/b4-tests.org "b4-tests.org") | | [b4-tests.org](/tangentstorm/b4/blob/main/b4-tests.org "b4-tests.org") | | |
| [b4i](/tangentstorm/b4/blob/main/b4i "b4i") | | [b4i](/tangentstorm/b4/blob/main/b4i "b4i") | | |
| [b4i-tests.org](/tangentstorm/b4/blob/main/b4i-tests.org "b4i-tests.org") | | [b4i-tests.org](/tangentstorm/b4/blob/main/b4i-tests.org "b4i-tests.org") | | |
| [b4ix](/tangentstorm/b4/blob/main/b4ix "b4ix") | | [b4ix](/tangentstorm/b4/blob/main/b4ix "b4ix") | | |
| [b4s-tests.org](/tangentstorm/b4/blob/main/b4s-tests.org "b4s-tests.org") | | [b4s-tests.org](/tangentstorm/b4/blob/main/b4s-tests.org "b4s-tests.org") | | |
| [bios-tests.org](/tangentstorm/b4/blob/main/bios-tests.org "bios-tests.org") | | [bios-tests.org](/tangentstorm/b4/blob/main/bios-tests.org "bios-tests.org") | | |
| [goals.org](/tangentstorm/b4/blob/main/goals.org "goals.org") | | [goals.org](/tangentstorm/b4/blob/main/goals.org "goals.org") | | |
| [init.b4i](/tangentstorm/b4/blob/main/init.b4i "init.b4i") | | [init.b4i](/tangentstorm/b4/blob/main/init.b4i "init.b4i") | | |
| [plan.org](/tangentstorm/b4/blob/main/plan.org "plan.org") | | [plan.org](/tangentstorm/b4/blob/main/plan.org "plan.org") | | |
| [pre-tests.org](/tangentstorm/b4/blob/main/pre-tests.org "pre-tests.org") | | [pre-tests.org](/tangentstorm/b4/blob/main/pre-tests.org "pre-tests.org") | | |
| [test](/tangentstorm/b4/blob/main/test "test") | | [test](/tangentstorm/b4/blob/main/test "test") | | |
| [test-b4-b4a](/tangentstorm/b4/blob/main/test-b4-b4a "test-b4-b4a") | | [test-b4-b4a](/tangentstorm/b4/blob/main/test-b4-b4a "test-b4-b4a") | | |
| [test-b4-gd](/tangentstorm/b4/blob/main/test-b4-gd "test-b4-gd") | | [test-b4-gd](/tangentstorm/b4/blob/main/test-b4-gd "test-b4-gd") | | |
| [test-b4-j](/tangentstorm/b4/blob/main/test-b4-j "test-b4-j") | | [test-b4-j](/tangentstorm/b4/blob/main/test-b4-j "test-b4-j") | | |
| [test-b4-js](/tangentstorm/b4/blob/main/test-b4-js "test-b4-js") | | [test-b4-js](/tangentstorm/b4/blob/main/test-b4-js "test-b4-js") | | |
| [test-b4-lil](/tangentstorm/b4/blob/main/test-b4-lil "test-b4-lil") | | [test-b4-lil](/tangentstorm/b4/blob/main/test-b4-lil "test-b4-lil") | | |
| [test-b4-pas](/tangentstorm/b4/blob/main/test-b4-pas "test-b4-pas") | | [test-b4-pas](/tangentstorm/b4/blob/main/test-b4-pas "test-b4-pas") | | |
| [test-b4i-js](/tangentstorm/b4/blob/main/test-b4i-js "test-b4i-js") | | [test-b4i-js](/tangentstorm/b4/blob/main/test-b4i-js "test-b4i-js") | | |
| [test-b4i-lil](/tangentstorm/b4/blob/main/test-b4i-lil "test-b4i-lil") | | [test-b4i-lil](/tangentstorm/b4/blob/main/test-b4i-lil "test-b4i-lil") | | |
| [test-b4i-pas](/tangentstorm/b4/blob/main/test-b4i-pas "test-b4i-pas") | | [test-b4i-pas](/tangentstorm/b4/blob/main/test-b4i-pas "test-b4i-pas") | | |
| [test-b4s](/tangentstorm/b4/blob/main/test-b4s "test-b4s") | | [test-b4s](/tangentstorm/b4/blob/main/test-b4s "test-b4s") | | |
| [test-bios](/tangentstorm/b4/blob/main/test-bios "test-bios") | | [test-bios](/tangentstorm/b4/blob/main/test-bios "test-bios") | | |
| [test-pre](/tangentstorm/b4/blob/main/test-pre "test-pre") | | [test-pre](/tangentstorm/b4/blob/main/test-pre "test-pre") | | |
| View all files | | |
## Repository files navigation
* [README](#)
# The b4 virtual machine
# Demo
[![ref/b4ix-rosetta.png](/tangentstorm/b4/raw/main/ref/b4ix-rosetta.png)](/tangentstorm/b4/blob/main/ref/b4ix-rosetta.png)
The above screenshot is the `b4ix` enhanced interactive shell. The sceen is broken into three sections:
* on top, a view into the systems video buffer, which is pre-initialized with a logo from the bios.
* in the middle, an interactive shell for the `b4a` assembly language.
* at the bottom, a view of stacks and section of the machines ram
## explanation of the demo code
```
# https://rosettacode.org/wiki/Loops/For
:E lb 'e io rt # set up ^E to emit a character
:I cd cd du dc sw dc rt # set up ^I to fetch outer loop counter
:loop du .f du ^I sb c1 ad .f lb '. ^E .n lb '| ^E .n zp rt
5 loop
```
The `^E` syntax calls whatever function the `E` register is pointing at, and the assembler assigns it when it sees `:E`.
Here, `^E` loads the byte `'e` (quoted ascii char) and sends that as a command to the `io` op, which prints the next character on the stack.
The `^I` definition fetches the outer loop counter in a `.f``.n` (“for/next”) loop.
Since its a function call, we have to dig deep into the control stack (`cd` means copy from control stack to data stack), (`du`)plicate the counter, and then (`sw`)ap it with the return address so we can push that back onto the control stack (`dc` means data -> control), and then `rt` (return).
Then `:loop` dupes its argument and uses it as an argument to the `.f=/`.n= loop.
During these loops, the loop counter is on the control stack, so `^I` grabs it as explained earlier, but there is also a copy of the original loop length (5 in this case) on the data stack.
so `du ^I sb` duplicates the 5, subtracts the outer loop counter, and leaves the result on the stack.
`c1` is an op that adds the constant 1 to the stack, and `ad` adds the top two values, so `c1 ad` adds 1 to the previous expression to get the length of the inner loop.
`.f lb '. ^E .n` prints that many dots.
`lb '| ^E .n` prints the pipe character and ends the outer loop.
then `zp rt` removes that original `5` thats been sitting on the stack the whole time (passed in when we explicitly called `5 loop`) and returns to the calling function (in this case, the interactive “b4ix” shell.)
# About b4
**b4** is a tiny virtual machine, with a forth-like flavor.
There are currently five implementations:
* [./jlang/](/tangentstorm/b4/blob/main/jlang), implemented in [J](https://code.jsoftware.com/wiki/Main_Page).
* [./pas/](/tangentstorm/b4/blob/main/pas), implemented in [free pascal](https://www.freepascal.org/).
* [./lil/](/tangentstorm/b4/blob/main/lil), implemented in [lil](https://beyondloom.com/decker/lil.html).
* [./js/](/tangentstorm/b4/blob/main/js), implemented in javascript.
* [b4-gd](https://github.com/tangentstorm/b4-gd), implemented in GDScript for [Godot 4](https://docs.godotengine.org/en/stable/).
The implementations are kept in sync through the tests in [./b4-tests.org](/tangentstorm/b4/blob/main/b4-tests.org)
See [./bios/bios.b4a](/tangentstorm/b4/blob/main/bios/bios.b4a) for an example of b4 assembly language.
# Links
* [b4 github repo](https://github.com/tangentstorm/b4)
* twitter: [@tangentstorm](https://twitter.com/tangentstorm) / [#b4lang](https://twitter.com/#!/search/realtime/%23b4lang)
* reddit: [/r/b4lang](http://reddit.com/r/b4lang)
# Background
B4 is a forth-like virtual machine. Quick **intros to forth** (free and online):
* [Programming a Problem-Oriented Language](http://www.colorforth.com/POL.htm)
* [Starting Forth](http://www.forth.com/starting-forth/)
B4 was strongly influenced by the [ngaro virtual machine](http://retroforth.org/docs/The_Ngaro_Virtual_Machine.html) from retroforth 11,
as well as the [forth chips from greenarrays](https://www.greenarraychips.com/home/documents/index.php#architecture).
## About
b4 : a tiny forth-like virtual machine
[www.reddit.com/r/b4lang/](http://www.reddit.com/r/b4lang/ "http://www.reddit.com/r/b4lang/")
### Resources
[Readme](#readme-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/tangentstorm/b4/activity)
### Stars
[**39**
stars](/tangentstorm/b4/stargazers)
### Watchers
[**6**
watching](/tangentstorm/b4/watchers)
### Forks
[**4**
forks](/tangentstorm/b4/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Ftangentstorm%2Fb4&report=tangentstorm+%28user%29)
## [Releases](/tangentstorm/b4/releases)
No releases published
## [Packages 0](/users/tangentstorm/packages?repo_name=b4)
No packages published
### Uh oh!
There was an error while loading. Please reload this page.
## [Contributors 3](/tangentstorm/b4/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [Pascal
34.8%](/tangentstorm/b4/search?l=pascal)
* [Python
22.4%](/tangentstorm/b4/search?l=python)
* [JavaScript
10.7%](/tangentstorm/b4/search?l=javascript)
* [TypeScript
8.5%](/tangentstorm/b4/search?l=typescript)
* [Forth
7.8%](/tangentstorm/b4/search?l=forth)
* [J
5.9%](/tangentstorm/b4/search?l=j)
* Other
9.9%
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,12 @@
# c2-for-me
**Source:** http://marc.tries.fed.wiki/view/c2-for-me/ward.eu.wiki.org/c2-for-me
c2 for me
Site Owned by: Marc Pierson
 
 

View File

@@ -0,0 +1,184 @@
# call versus branch-and-link
**Source:** https://muforth.dev/call-versus-branch-and-link/
Call versus branch-and-link muforth
# Call versus branch-and-link
---
### [Whats the big difference?](#whats-the-big-difference)
Years ago, while pondering the “nature” of threaded code something struck me: In a threaded code system the *called* routine decides whether or not to push a return address onto the call stack.
This is in contrast to native code running on “traditional” architectures with “call” instructions. Call instructions *always* push the return address, even when its unnecessary. (Its unnecessary when the code being is called is *leaf* routine one that makes no further calls. But the caller doesnt and cant! know this.)
RISC architects realized that always pushing the return address was inefficient doing so creates unnecessary memory traffic and instead of call instructions specified “branch and link” instructions.
Whats the difference?
Operationally, a call instruction does two things:
* pushes onto the stack the address of the following instruction
* jumps to the destination
A branch-and-link instruction maybe it should be called link-and-branch? also does two things:
* captures in a register (the “link” register) the address of the following instruction
* jumps to the destination
If the *called* code is a leaf routine, it doesnt need to push the link register onto the stack. It is careful, however, to preserve its value; then, at exit, it returns to its caller by jumping to the address in the link register.
If the called code *will* be making calls to other code, on entry it pushes the link register (to preserve it), and on exit it *first* pops and restores it, and then retuns to its caller as above, by jumping to the address in the register.
### [Not created equal](#not-created-equal)
There are two variations of branch-and-link:
* one that always uses the same link register (eg, ARM)
* one that allows specification of the link register (RISC-V, and probably others Im not a RISC expert. ;-)
The latter is much more powerful. If all your code does is “normal” calls and returns, the difference is unimportant. But there is a curious class of uses for which the difference is important: when using a branch-and-link to capture the following address for a purpose *other* than to return to it later.
Say whaaaaat? Why would you ever do this?
### [Creative misuse](#creative-misuse)
I mentioned in my discussion of [threaded code](/threaded-code/) that one can “misuse” a call instruction to capture the following address. This is sometimes useful when writing the “runtime” behaviors of Forth words. But using call in this way is inefficient: you capture the following address by pushing it, but then immediately pop it and do something with it.
Misusing branch-and-link instructions to do the same thing is much more efficient. The address is captured in a register, and the code moves on. No push and pop. (There *is* a jump involved, so perhaps a pipeline refill occurs.)
And if, for some reason, we want to do this twice, in immediate succession, we simply specify a different link register in each of the branch-and-links. (Hmm, and now we are perhaps doing *two* pipeline refills in quick succession...)
But again, why?
In a non-threaded implementation of Forths create/does words, this is *precisely* what happens. Ill explain how this works by first showing how it works in a ITC (indirect-threaded code) system, and then replace some pointers with jump-and-link instructions.
Well look how three kinds of Forth words are represented: colon words, variables, and “incrementers” (which are going to be defined via create/does).
Our example colon word was defined in Forth like this:
```
: 4* 2* 2* ;
```
and its compiled form looks like this:
```
4*
~~~~~~~~~~~
addr of NEST ( code field)
addr of 2* ( parameter field)
addr of 2*
addr of UNNEST
```
Our variable looks like this:
```
radix
~~~~~~~~~~~
addr of VARIABLE (code field)
2 (parameter field)
```
And our created word the most complicated of our examples was created by the following Forth code:
```
: incr create , does> @ + ;
4 incr cell+
```
To further complicate this example which is really the *key* to my argument we will assume a tethered cross-compiled Forth, which means that the words `create , does>` execute on the host machine, and the target contains only the *runtime* pieces. `cell+` and `incr` look like this:
```
cell+
+----------+
| addr |---+ ( code field)
+----------+ |
4 | ( parameter field)
|
incr |
~~~~~~~~~~~ |
jal DODOES <-+
addr of @
addr of +
addr of UNNEST
```
```
DODOES: Push IP onto R stack
Push pfa onto D stack
Execute NEXT
```
Two notes about `incr`. It is *not* a normal Forth word with a code field and a parameter field. It is like the built-in “runtimes” for colon words or variables. In this case unlike with VARIABLE or NEST we want to express the runtime in *Forth* code rather than machine code. But runtimes have to *start* with machine code. And a `does>` runtime has to do two things: nest the execution of Forth (just as we would do if we were calling a colon word), and push the pfa of the created word (`cell+` in our example.)
Since this behavior is common to all `does>` runtimes, we compile it *once* and `jal` to it.
Thus, `incr` *begins* with `jal DODOES`. This is the *one* place in an ITC system where *code* specific to an architecture has to be compiled into a words body. The Forth code in a parent (defining) word that specifies the execution behavior of child words ie, the code following `does>` has to be *prefixed* by machine code of some kind so that the code field in child words can point to it. Code fields *always* point to machine code.
Now for the point of this exercise. Lets convert these three examples to “native” code, using jump-and-link instructions in the bodies of colon words instead of lists of pointers. Note that we use two different link registers: `w` in code fields, and `ra` in colon word bodies.
```
4*
~~~~~~~~~~~
jal w NEST (code field)
jal ra 2* (parameter field)
jal ra 2*
jal ra UNNEST
```
NEST in this world changes slightly from the ITC version. Notice that the `jal w NEST` captures the pfa which is the address of the first call to `2*` in `w`. NEST now looks like this:
```
NEST: Push RA onto R stack
jr 0(w)
```
That `jr 0(w)` means “return to the body of the colon word and start executing the code there”.
Our variable looks like this:
```
radix
~~~~~~~~~~~
jal w VARIABLE (code field)
2 (parameter field)
```
Again, the `jal w VARIABLE` captures the pfa in `w`.
Since there is one more level of “nesting” in `does>` words, we need a *third* link register. Lets use x.
```
cell+
~~~~~~~~~~~
jal w INCR (code field)
4 (parameter field)
```
```
INCR: jal x DODOES
jal ra @
jal ra +
jal ra UNNEST
```
```
DODOES: Push RA onto R stack
Push W (pfa) onto D stack
jr 0(x)
```
The `jal w INCR` in `cell+` captures the pfa in `w`. The `jal x DODOES` in INCR captures the address of the Forth code that will be executed after W is pushed onto D stack. DODOES pushes both stacks, and then “returns” to the body of INCR.
Its convoluted, and its possibly inefficient because we are executing *three* `jal` instructions in quick succession, and probably causing a series of pipeline refills but its very little code, and its elegant in a twisted way. ;-)
---
[Send feedback](/cdn-cgi/l/email-protection#2f0a18180a191a0a191d0a19170a191e0a194b0a181c0a181b0a191a0a181d0a1b1f0a194a0a19160a194b0a191d0a194c0a191a0a194b0a191e0a191c0a19170a19160a194a0a191a0a181c0a1d4a0a191c0a19490a194b105c5a4d454a4c5b120a1a4d425a49405d5b470a1a4b0a1d1f6c4e43430a1d1f594a5d5c5a5c0a1d1f4d5d4e414c47024e414b0243464144) on this page (last edited 2017 May 01)
Browse [all pages](/all-pages/)
Return [home](/)

View File

@@ -0,0 +1,322 @@
# cmFORTH
**Source:** https://github.com/ForthHub/cmFORTH
GitHub - ForthHub/cmFORTH: Copy of cmFORTH
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2FForthHub%2FcmFORTH)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2FForthHub%2FcmFORTH)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=ForthHub%2FcmFORTH)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[ForthHub](/ForthHub)
/
**[cmFORTH](/ForthHub/cmFORTH)**
Public
* [Notifications](/login?return_to=%2FForthHub%2FcmFORTH) You must be signed in to change notification settings
* [Fork
8](/login?return_to=%2FForthHub%2FcmFORTH)
* [Star
40](/login?return_to=%2FForthHub%2FcmFORTH)
Copy of cmFORTH
[40
stars](/ForthHub/cmFORTH/stargazers) [8
forks](/ForthHub/cmFORTH/forks) [Branches](/ForthHub/cmFORTH/branches) [Tags](/ForthHub/cmFORTH/tags) [Activity](/ForthHub/cmFORTH/activity)
[Star](/login?return_to=%2FForthHub%2FcmFORTH)
[Notifications](/login?return_to=%2FForthHub%2FcmFORTH) You must be signed in to change notification settings
* [Code](/ForthHub/cmFORTH)
* [Issues
0](/ForthHub/cmFORTH/issues)
* [Pull requests
0](/ForthHub/cmFORTH/pulls)
* [Actions](/ForthHub/cmFORTH/actions)
* [Projects
0](/ForthHub/cmFORTH/projects)
* [Wiki](/ForthHub/cmFORTH/wiki)
* [Security
0](/ForthHub/cmFORTH/security)
* [Insights](/ForthHub/cmFORTH/pulse)
Additional navigation options
* [Code](/ForthHub/cmFORTH)
* [Issues](/ForthHub/cmFORTH/issues)
* [Pull requests](/ForthHub/cmFORTH/pulls)
* [Actions](/ForthHub/cmFORTH/actions)
* [Projects](/ForthHub/cmFORTH/projects)
* [Wiki](/ForthHub/cmFORTH/wiki)
* [Security](/ForthHub/cmFORTH/security)
* [Insights](/ForthHub/cmFORTH/pulse)
# ForthHub/cmFORTH
master
[Branches](/ForthHub/cmFORTH/branches)[Tags](/ForthHub/cmFORTH/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[2 Commits](/ForthHub/cmFORTH/commits/master/) 2 Commits | | |
| [README](/ForthHub/cmFORTH/blob/master/README "README") | | [README](/ForthHub/cmFORTH/blob/master/README "README") | | |
| [cmforth.fth](/ForthHub/cmFORTH/blob/master/cmforth.fth "cmforth.fth") | | [cmforth.fth](/ForthHub/cmFORTH/blob/master/cmforth.fth "cmforth.fth") | | |
| [cmforth.txt](/ForthHub/cmFORTH/blob/master/cmforth.txt "cmforth.txt") | | [cmforth.txt](/ForthHub/cmFORTH/blob/master/cmforth.txt "cmforth.txt") | | |
| View all files | | |
## Repository files navigation
* [README](#)
```
Chuck Moore's Forth for the Novix NC4016, dated December 1987.
Code is in cmforth.fth, shadow blocks in cmforth.txt. They are combined
side-by-side in the 'combined' branch.
```
## About
Copy of cmFORTH
### Topics
[forth](/topics/forth "Topic: forth")
### Resources
[Readme](#readme-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/ForthHub/cmFORTH/activity)
[Custom properties](/ForthHub/cmFORTH/custom-properties)
### Stars
[**40**
stars](/ForthHub/cmFORTH/stargazers)
### Watchers
[**7**
watching](/ForthHub/cmFORTH/watchers)
### Forks
[**8**
forks](/ForthHub/cmFORTH/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2FForthHub%2FcmFORTH&report=ForthHub+%28user%29)
## [Releases](/ForthHub/cmFORTH/releases)
No releases published
## [Packages 0](/orgs/ForthHub/packages?repo_name=cmFORTH)
No packages published
## Languages
* [Forth
100.0%](/ForthHub/cmFORTH/search?l=forth)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,338 @@
# deckload
**Source:** https://github.com/JosephOziel/deckload
GitHub - JosephOziel/deckload: Compiled functional language
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2FJosephOziel%2Fdeckload)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2FJosephOziel%2Fdeckload)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=JosephOziel%2Fdeckload)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[JosephOziel](/JosephOziel)
/
**[deckload](/JosephOziel/deckload)**
Public
* [Notifications](/login?return_to=%2FJosephOziel%2Fdeckload) You must be signed in to change notification settings
* [Fork
1](/login?return_to=%2FJosephOziel%2Fdeckload)
* [Star
4](/login?return_to=%2FJosephOziel%2Fdeckload)
Compiled functional language
### License
[MIT license](/JosephOziel/deckload/blob/main/LICENSE)
[4
stars](/JosephOziel/deckload/stargazers) [1
fork](/JosephOziel/deckload/forks) [Branches](/JosephOziel/deckload/branches) [Tags](/JosephOziel/deckload/tags) [Activity](/JosephOziel/deckload/activity)
[Star](/login?return_to=%2FJosephOziel%2Fdeckload)
[Notifications](/login?return_to=%2FJosephOziel%2Fdeckload) You must be signed in to change notification settings
* [Code](/JosephOziel/deckload)
* [Issues
0](/JosephOziel/deckload/issues)
* [Pull requests
0](/JosephOziel/deckload/pulls)
* [Actions](/JosephOziel/deckload/actions)
* [Projects
0](/JosephOziel/deckload/projects)
* [Security
0](/JosephOziel/deckload/security)
* [Insights](/JosephOziel/deckload/pulse)
Additional navigation options
* [Code](/JosephOziel/deckload)
* [Issues](/JosephOziel/deckload/issues)
* [Pull requests](/JosephOziel/deckload/pulls)
* [Actions](/JosephOziel/deckload/actions)
* [Projects](/JosephOziel/deckload/projects)
* [Security](/JosephOziel/deckload/security)
* [Insights](/JosephOziel/deckload/pulse)
# JosephOziel/deckload
main
[Branches](/JosephOziel/deckload/branches)[Tags](/JosephOziel/deckload/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[69 Commits](/JosephOziel/deckload/commits/main/) 69 Commits | | |
| [backend-c](/JosephOziel/deckload/tree/main/backend-c "backend-c") | | [backend-c](/JosephOziel/deckload/tree/main/backend-c "backend-c") | | |
| [backend-factor](/JosephOziel/deckload/tree/main/backend-factor "backend-factor") | | [backend-factor](/JosephOziel/deckload/tree/main/backend-factor "backend-factor") | | |
| [examples](/JosephOziel/deckload/tree/main/examples "examples") | | [examples](/JosephOziel/deckload/tree/main/examples "examples") | | |
| [ir](/JosephOziel/deckload/tree/main/ir "ir") | | [ir](/JosephOziel/deckload/tree/main/ir "ir") | | |
| [parser](/JosephOziel/deckload/tree/main/parser "parser") | | [parser](/JosephOziel/deckload/tree/main/parser "parser") | | |
| [.gitattributes](/JosephOziel/deckload/blob/main/.gitattributes ".gitattributes") | | [.gitattributes](/JosephOziel/deckload/blob/main/.gitattributes ".gitattributes") | | |
| [LICENSE](/JosephOziel/deckload/blob/main/LICENSE "LICENSE") | | [LICENSE](/JosephOziel/deckload/blob/main/LICENSE "LICENSE") | | |
| [README.md](/JosephOziel/deckload/blob/main/README.md "README.md") | | [README.md](/JosephOziel/deckload/blob/main/README.md "README.md") | | |
| [TODO](/JosephOziel/deckload/blob/main/TODO "TODO") | | [TODO](/JosephOziel/deckload/blob/main/TODO "TODO") | | |
| [deckload.factor](/JosephOziel/deckload/blob/main/deckload.factor "deckload.factor") | | [deckload.factor](/JosephOziel/deckload/blob/main/deckload.factor "deckload.factor") | | |
| [spec.markdown](/JosephOziel/deckload/blob/main/spec.markdown "spec.markdown") | | [spec.markdown](/JosephOziel/deckload/blob/main/spec.markdown "spec.markdown") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [MIT license](#)
# Deckload
```
Best low level language compiling to x86 assembly based on rho calculus (tree rewriting + lambda calculus). also postfix notation.
```
## About
Compiled functional language
### Resources
[Readme](#readme-ov-file)
### License
[MIT license](#MIT-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/JosephOziel/deckload/activity)
### Stars
[**4**
stars](/JosephOziel/deckload/stargazers)
### Watchers
[**1**
watching](/JosephOziel/deckload/watchers)
### Forks
[**1**
fork](/JosephOziel/deckload/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2FJosephOziel%2Fdeckload&report=JosephOziel+%28user%29)
## [Releases](/JosephOziel/deckload/releases)
No releases published
## [Packages 0](/users/JosephOziel/packages?repo_name=deckload)
No packages published
## [Contributors 2](/JosephOziel/deckload/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [Factor
73.3%](/JosephOziel/deckload/search?l=factor)
* [C
26.7%](/JosephOziel/deckload/search?l=c)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,338 @@
# easyforth
**Source:** https://github.com/skilldrick/easyforth
GitHub - skilldrick/easyforth: Learn Forth!
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fskilldrick%2Feasyforth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fskilldrick%2Feasyforth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=skilldrick%2Feasyforth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[skilldrick](/skilldrick)
/
**[easyforth](/skilldrick/easyforth)**
Public
* [Notifications](/login?return_to=%2Fskilldrick%2Feasyforth) You must be signed in to change notification settings
* [Fork
46](/login?return_to=%2Fskilldrick%2Feasyforth)
* [Star
379](/login?return_to=%2Fskilldrick%2Feasyforth)
Learn Forth!
[skilldrick.github.io/easyforth/](http://skilldrick.github.io/easyforth/ "http://skilldrick.github.io/easyforth/")
[379
stars](/skilldrick/easyforth/stargazers) [46
forks](/skilldrick/easyforth/forks) [Branches](/skilldrick/easyforth/branches) [Tags](/skilldrick/easyforth/tags) [Activity](/skilldrick/easyforth/activity)
[Star](/login?return_to=%2Fskilldrick%2Feasyforth)
[Notifications](/login?return_to=%2Fskilldrick%2Feasyforth) You must be signed in to change notification settings
* [Code](/skilldrick/easyforth)
* [Issues
9](/skilldrick/easyforth/issues)
* [Pull requests
3](/skilldrick/easyforth/pulls)
* [Actions](/skilldrick/easyforth/actions)
* [Projects
0](/skilldrick/easyforth/projects)
* [Wiki](/skilldrick/easyforth/wiki)
* [Security
0](/skilldrick/easyforth/security)
* [Insights](/skilldrick/easyforth/pulse)
Additional navigation options
* [Code](/skilldrick/easyforth)
* [Issues](/skilldrick/easyforth/issues)
* [Pull requests](/skilldrick/easyforth/pulls)
* [Actions](/skilldrick/easyforth/actions)
* [Projects](/skilldrick/easyforth/projects)
* [Wiki](/skilldrick/easyforth/wiki)
* [Security](/skilldrick/easyforth/security)
* [Insights](/skilldrick/easyforth/pulse)
# skilldrick/easyforth
gh-pages
[Branches](/skilldrick/easyforth/branches)[Tags](/skilldrick/easyforth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[165 Commits](/skilldrick/easyforth/commits/gh-pages/) 165 Commits | | |
| [\_includes](/skilldrick/easyforth/tree/gh-pages/_includes "_includes") | | [\_includes](/skilldrick/easyforth/tree/gh-pages/_includes "_includes") | | |
| [\_layouts](/skilldrick/easyforth/tree/gh-pages/_layouts "_layouts") | | [\_layouts](/skilldrick/easyforth/tree/gh-pages/_layouts "_layouts") | | |
| [javascripts](/skilldrick/easyforth/tree/gh-pages/javascripts "javascripts") | | [javascripts](/skilldrick/easyforth/tree/gh-pages/javascripts "javascripts") | | |
| [stylesheets](/skilldrick/easyforth/tree/gh-pages/stylesheets "stylesheets") | | [stylesheets](/skilldrick/easyforth/tree/gh-pages/stylesheets "stylesheets") | | |
| [test](/skilldrick/easyforth/tree/gh-pages/test "test") | | [test](/skilldrick/easyforth/tree/gh-pages/test "test") | | |
| [.gitignore](/skilldrick/easyforth/blob/gh-pages/.gitignore ".gitignore") | | [.gitignore](/skilldrick/easyforth/blob/gh-pages/.gitignore ".gitignore") | | |
| [README.md](/skilldrick/easyforth/blob/gh-pages/README.md "README.md") | | [README.md](/skilldrick/easyforth/blob/gh-pages/README.md "README.md") | | |
| [\_config.yml](/skilldrick/easyforth/blob/gh-pages/_config.yml "_config.yml") | | [\_config.yml](/skilldrick/easyforth/blob/gh-pages/_config.yml "_config.yml") | | |
| [index.markdown](/skilldrick/easyforth/blob/gh-pages/index.markdown "index.markdown") | | [index.markdown](/skilldrick/easyforth/blob/gh-pages/index.markdown "index.markdown") | | |
| [params.json](/skilldrick/easyforth/blob/gh-pages/params.json "params.json") | | [params.json](/skilldrick/easyforth/blob/gh-pages/params.json "params.json") | | |
| [todo](/skilldrick/easyforth/blob/gh-pages/todo "todo") | | [todo](/skilldrick/easyforth/blob/gh-pages/todo "todo") | | |
| View all files | | |
## Repository files navigation
* [README](#)
# Easy Forth
Along the lines of [Easy 6502](http://skilldrick.github.io/easy6502/), Easy
Forth is a small ebook for learning the Forth language. It includes a
JavaScript Forth interpreter inline, making it easy to try writing small Forth
programs.
## About
Learn Forth!
[skilldrick.github.io/easyforth/](http://skilldrick.github.io/easyforth/ "http://skilldrick.github.io/easyforth/")
### Resources
[Readme](#readme-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/skilldrick/easyforth/activity)
### Stars
[**379**
stars](/skilldrick/easyforth/stargazers)
### Watchers
[**23**
watching](/skilldrick/easyforth/watchers)
### Forks
[**46**
forks](/skilldrick/easyforth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fskilldrick%2Feasyforth&report=skilldrick+%28user%29)
## [Releases](/skilldrick/easyforth/releases)
No releases published
## [Packages 0](/users/skilldrick/packages?repo_name=easyforth)
No packages published
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [JavaScript
92.7%](/skilldrick/easyforth/search?l=javascript)
* [CSS
3.5%](/skilldrick/easyforth/search?l=css)
* [HTML
2.1%](/skilldrick/easyforth/search?l=html)
* [Forth
1.7%](/skilldrick/easyforth/search?l=forth)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,372 @@
# fiveth
**Source:** https://github.com/dramforever/fiveth
GitHub - dramforever/fiveth: A stack-based language implemented in RISC-V assembly
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fdramforever%2Ffiveth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fdramforever%2Ffiveth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=dramforever%2Ffiveth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[dramforever](/dramforever)
/
**[fiveth](/dramforever/fiveth)**
Public
* [Notifications](/login?return_to=%2Fdramforever%2Ffiveth) You must be signed in to change notification settings
* [Fork
0](/login?return_to=%2Fdramforever%2Ffiveth)
* [Star
17](/login?return_to=%2Fdramforever%2Ffiveth)
A stack-based language implemented in RISC-V assembly
[17
stars](/dramforever/fiveth/stargazers) [0
forks](/dramforever/fiveth/forks) [Branches](/dramforever/fiveth/branches) [Tags](/dramforever/fiveth/tags) [Activity](/dramforever/fiveth/activity)
[Star](/login?return_to=%2Fdramforever%2Ffiveth)
[Notifications](/login?return_to=%2Fdramforever%2Ffiveth) You must be signed in to change notification settings
* [Code](/dramforever/fiveth)
* [Issues
0](/dramforever/fiveth/issues)
* [Pull requests
0](/dramforever/fiveth/pulls)
* [Actions](/dramforever/fiveth/actions)
* [Projects
0](/dramforever/fiveth/projects)
* [Security
0](/dramforever/fiveth/security)
* [Insights](/dramforever/fiveth/pulse)
Additional navigation options
* [Code](/dramforever/fiveth)
* [Issues](/dramforever/fiveth/issues)
* [Pull requests](/dramforever/fiveth/pulls)
* [Actions](/dramforever/fiveth/actions)
* [Projects](/dramforever/fiveth/projects)
* [Security](/dramforever/fiveth/security)
* [Insights](/dramforever/fiveth/pulse)
# dramforever/fiveth
main
[Branches](/dramforever/fiveth/branches)[Tags](/dramforever/fiveth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[96 Commits](/dramforever/fiveth/commits/main/) 96 Commits | | |
| [docs](/dramforever/fiveth/tree/main/docs "docs") | | [docs](/dramforever/fiveth/tree/main/docs "docs") | | |
| [src](/dramforever/fiveth/tree/main/src "src") | | [src](/dramforever/fiveth/tree/main/src "src") | | |
| [.envrc](/dramforever/fiveth/blob/main/.envrc ".envrc") | | [.envrc](/dramforever/fiveth/blob/main/.envrc ".envrc") | | |
| [.gitignore](/dramforever/fiveth/blob/main/.gitignore ".gitignore") | | [.gitignore](/dramforever/fiveth/blob/main/.gitignore ".gitignore") | | |
| [Makefile](/dramforever/fiveth/blob/main/Makefile "Makefile") | | [Makefile](/dramforever/fiveth/blob/main/Makefile "Makefile") | | |
| [README.md](/dramforever/fiveth/blob/main/README.md "README.md") | | [README.md](/dramforever/fiveth/blob/main/README.md "README.md") | | |
| [config.mk](/dramforever/fiveth/blob/main/config.mk "config.mk") | | [config.mk](/dramforever/fiveth/blob/main/config.mk "config.mk") | | |
| [flake.lock](/dramforever/fiveth/blob/main/flake.lock "flake.lock") | | [flake.lock](/dramforever/fiveth/blob/main/flake.lock "flake.lock") | | |
| [flake.nix](/dramforever/fiveth/blob/main/flake.nix "flake.nix") | | [flake.nix](/dramforever/fiveth/blob/main/flake.nix "flake.nix") | | |
| [shell.nix](/dramforever/fiveth/blob/main/shell.nix "shell.nix") | | [shell.nix](/dramforever/fiveth/blob/main/shell.nix "shell.nix") | | |
| View all files | | |
## Repository files navigation
* [README](#)
# Fiveth
A stack-based language implemented in RISC-V assembly.
## Building and running Fiveth
* Edit `config.mk` to suit your environment
* `make` to build the program
With the default config this should end a message like:
```
* Build complete: build/fiveth
```
The default configuration is to run an interactive Fiveth shell that works under
a 64-bit RISC-V Linux environment. You can now:
* `make qemu` to run it in QEMU user-mode emulation
* `make run` to run it directly, if you are actually on RISC-V
Try typing some simple Fiveth programs. Outputs are shown after a semicolon.
```
0 > 1 2 + . ; 3
0 > 10 [ . ] count ; 0 1 2 3 4 5 6 7 8 9
0 > "Hello, world!" s. ; Hello, world!
```
Press Ctrl-D to quit. [`docs/shell.md`](/dramforever/fiveth/blob/main/docs/shell.md) has more details on
running and using the Fiveth interactive shell.
## Installing the required tools
On Ubuntu 22.04:
```
# apt install qemu-user make
# # If using GNU toolchain
# apt install gcc-riscv64-linux-gnu
# # If using LLVM toolchain
# apt install clang lld
```
If you have Nix, you can try to use the provided `shell.nix` or `flake.nix`.
On other systems, you can try to acquire a LLVM toolchain or a RISC-V toolchain,
as well as GNU make. To run Fiveth in an emulator, `qemu-riscv64` can be used to
emulate a Linux binary but is only supported on Linux hosts.
## About
A stack-based language implemented in RISC-V assembly
### Topics
[assembly](/topics/assembly "Topic: assembly")
[riscv](/topics/riscv "Topic: riscv")
[forth-like](/topics/forth-like "Topic: forth-like")
### Resources
[Readme](#readme-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/dramforever/fiveth/activity)
### Stars
[**17**
stars](/dramforever/fiveth/stargazers)
### Watchers
[**2**
watching](/dramforever/fiveth/watchers)
### Forks
[**0**
forks](/dramforever/fiveth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fdramforever%2Ffiveth&report=dramforever+%28user%29)
## [Releases](/dramforever/fiveth/releases)
No releases published
## Languages
* [Assembly
89.1%](/dramforever/fiveth/search?l=assembly)
* [Makefile
7.1%](/dramforever/fiveth/search?l=makefile)
* [C
2.5%](/dramforever/fiveth/search?l=c)
* [Nix
1.3%](/dramforever/fiveth/search?l=nix)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,5 @@
# formic
**Source:** https://formic.id
formic.id

View File

@@ -0,0 +1,821 @@
# foth (forth in go)
**Source:** https://github.com/skx/foth
GitHub - skx/foth: Tutorial-style FORTH implementation written in golang
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fskx%2Ffoth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fskx%2Ffoth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=skx%2Ffoth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 10, 2025. It is now read-only.
[skx](/skx)
/
**[foth](/skx/foth)**
Public archive
* [Notifications](/login?return_to=%2Fskx%2Ffoth) You must be signed in to change notification settings
* [Fork
7](/login?return_to=%2Fskx%2Ffoth)
* [Star
94](/login?return_to=%2Fskx%2Ffoth)
Tutorial-style FORTH implementation written in golang
### License
[GPL-2.0 license](/skx/foth/blob/master/LICENSE)
[94
stars](/skx/foth/stargazers) [7
forks](/skx/foth/forks) [Branches](/skx/foth/branches) [Tags](/skx/foth/tags) [Activity](/skx/foth/activity)
[Star](/login?return_to=%2Fskx%2Ffoth)
[Notifications](/login?return_to=%2Fskx%2Ffoth) You must be signed in to change notification settings
* [Code](/skx/foth)
* [Issues
0](/skx/foth/issues)
* [Pull requests
0](/skx/foth/pulls)
* [Actions](/skx/foth/actions)
* [Security
0](/skx/foth/security)
* [Insights](/skx/foth/pulse)
Additional navigation options
* [Code](/skx/foth)
* [Issues](/skx/foth/issues)
* [Pull requests](/skx/foth/pulls)
* [Actions](/skx/foth/actions)
* [Security](/skx/foth/security)
* [Insights](/skx/foth/pulse)
# skx/foth
master
[Branches](/skx/foth/branches)[Tags](/skx/foth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[128 Commits](/skx/foth/commits/master/) 128 Commits | | |
| [.github](/skx/foth/tree/master/.github ".github") | | [.github](/skx/foth/tree/master/.github ".github") | | |
| [foth](/skx/foth/tree/master/foth "foth") | | [foth](/skx/foth/tree/master/foth "foth") | | |
| [part1](/skx/foth/tree/master/part1 "part1") | | [part1](/skx/foth/tree/master/part1 "part1") | | |
| [part2](/skx/foth/tree/master/part2 "part2") | | [part2](/skx/foth/tree/master/part2 "part2") | | |
| [part3](/skx/foth/tree/master/part3 "part3") | | [part3](/skx/foth/tree/master/part3 "part3") | | |
| [part4](/skx/foth/tree/master/part4 "part4") | | [part4](/skx/foth/tree/master/part4 "part4") | | |
| [part5](/skx/foth/tree/master/part5 "part5") | | [part5](/skx/foth/tree/master/part5 "part5") | | |
| [part6](/skx/foth/tree/master/part6 "part6") | | [part6](/skx/foth/tree/master/part6 "part6") | | |
| [part7](/skx/foth/tree/master/part7 "part7") | | [part7](/skx/foth/tree/master/part7 "part7") | | |
| [.gitignore](/skx/foth/blob/master/.gitignore ".gitignore") | | [.gitignore](/skx/foth/blob/master/.gitignore ".gitignore") | | |
| [LICENSE](/skx/foth/blob/master/LICENSE "LICENSE") | | [LICENSE](/skx/foth/blob/master/LICENSE "LICENSE") | | |
| [README.md](/skx/foth/blob/master/README.md "README.md") | | [README.md](/skx/foth/blob/master/README.md "README.md") | | |
| [go.mod](/skx/foth/blob/master/go.mod "go.mod") | | [go.mod](/skx/foth/blob/master/go.mod "go.mod") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [GPL-2.0 license](#)
[![GoDoc](https://camo.githubusercontent.com/4204d449c8ac17196f1a3a04ee0beb1b8c1b33e9cc5a11749b70dbac04462146/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d676f646f63266d6573736167653d7265666572656e636526636f6c6f723d626c7565)](https://pkg.go.dev/github.com/skx/foth@v0.3.0/foth?tab=overview)
[![Go Report Card](https://camo.githubusercontent.com/75428032b736d4c96cb10a52bea074f46d24d022713c7391693717e8b7bcc7fa/68747470733a2f2f676f7265706f7274636172642e636f6d2f62616467652f6769746875622e636f6d2f736b782f666f7468)](https://goreportcard.com/report/github.com/skx/foth)
[![license](https://camo.githubusercontent.com/006d1a4a70625534d799b46a49525f5e5be4dc2093a9059bf0fc5e00ce7d566c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736b782f666f74682e737667)](https://github.com/skx/foth/blob/master/LICENSE)
[![Release](https://camo.githubusercontent.com/92dbc628aa2ba50da637c4609b1eb0f73eccd0092975d54b431101c557c96a07/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f736b782f666f74682e737667)](https://github.com/skx/foth/releases/latest)
* [foth](#foth)
+ [Features](#features)
+ [Installation](#installation)
+ [Embedded Usage](#embedded-usage)
+ [Anti-Features](#anti-features)
+ [Implementation Approach](#implementation-approach)
+ [Implementation Overview](#implementation-overview)
- [Part 1](#part-1) - Minimal initial-implementation.
- [Part 2](#part-2) - Hard-coded recursive word definitions.
- [Part 3](#part-3) - Allow defining minimal words via the REPL.
- [Part 4](#part-4) - Allow defining improved words via the REPL.
- [Part 5](#part-5) - Allow executing loops via `do`/`loop`.
- [Part 6](#part-6) - Allow conditional execution via `if`/`then`.
- [Part 7](#part-7) - Added minimal support for strings.
- [Final Revision](#final-revision) - Idiomatic Go, test-cases, and many new words
+ [BUGS](#bugs)
- [loops](#loops) - zero expected-iterations actually runs once
+ [See Also](#see-also)
+ [Github Setup](#github-setup)
# foth
A simple implementation of a FORTH-like language, hence *foth* which is
close to *forth*.
If you're new to FORTH then [the wikipedia page](https://en.wikipedia.org/wiki/Forth_(programming_language)) is a good starting point, and there are more good reads online such as:
* [Forth in 7 easy steps](https://jeelabs.org/article/1612b/)
+ Just ignore any mention of the return-stack!
* [Starting FORTH](https://www.forth.com/starting-forth/)
+ A complete book, but the navigation of this site is non-obvious.
In brief FORTH is a stack-based language, which uses Reverse Polish notation. The basic *thing* in Forth is the "word", which is a named data item, subroutine, or operator. Programming consists largely of defining new words, which are stored in a so-called "dictionary", in terms of existing ones. Iteratively building up a local DSL suited to your particular task.
This repository was created by following the brief tutorial posted within the following Hacker News thread, designed to demonstrate how you could implement something *like* FORTH, in a series of simple steps:
* <https://news.ycombinator.com/item?id=13082825>
The comment-thread shows example-code and pseudo-code in C, of course this repository is written in Go.
## Features
The end-result of this work is a simple scripting-language which you could easily embed within your golang application, allowing users to write simple FORTH-like scripts. We implement the kind of features a FORTH-user would expect:
* Comments between `(` and `)` are ignored, as expected.
+ Single-line comments `\` to the end of the line are also supported.
* Support for floating-point numbers (anything that will fit inside a `float64`).
* Reverse-Polish mathematical operations.
+ Including support for `abs`, `min`, `max`, etc.
* Support for printing the top-most stack element (`.`, or `print`).
* Support for outputting ASCII characters (`emit`).
* Support for outputting strings (`." Hello, World "`).
+ Some additional string-support for counting lengths, etc.
* Support for basic stack operations (`clearstack`, `drop`, `dup`, `over`, `swap`, `.s`)
* Support for loops, via `do`/`loop`.
* Support for conditional-execution, via `if`, `else`, and `then`.
* Support for declaring variables with `variable`, and getting/setting their values with `@` and `!` respectively.
* Execute files specified on the command-line.
+ If no arguments are supplied run a simple REPL instead.
* A standard library is loaded, from the present directory, if it is present.
+ See what we load by default in [foth/foth.4th](/skx/foth/blob/master/foth/foth.4th).
* The use of recursive definitions, for example:
+ `: factorial recursive dup 1 > if dup 1 - factorial * then ;`
## Installation
You can find binary releases of the final-version upon the [project release page](https://github.com/skx/foth/releases), but if you prefer you can install from source easily.
Either run this to download and install the binary:
```
$ go get github.com/skx/foth/foth@v0.5.0
```
Or clone this repository, and build the executable like so:
```
cd foth
go build .
./foth
```
The executable will try to load [foth.4th](/skx/foth/blob/master/foth/foth.4th) from the current-directory, so you'll want to fetch that too. But otherwise it should work as you'd expect - the startup-file defines several useful words, so running without it is a little annoying but it isn't impossible.
## Embedded Usage
Although this is a minimal interpreter it *can* be embedded within a Golang host-application, allowing users to write scripts to control it.
As an example of this I put together a simple demo:
* <https://github.com/skx/turtle>
This embeds the interpreter within an application, and defines some new words to allow the user to create graphics - in the style of [turtle](https://en.wikipedia.org/wiki/Turtle_graphics).
## Anti-Features
The obvious omission from this implementation is support for strings in the general case (string support is pretty limited to calling strlen, and printing strings which are constant and "inline").
We also lack the meta-programming facilities that FORTH users would expect, in a FORTH system it is possible to implement new control-flow systems, for example, by working with words and the control-flow directly. Instead in this system these things are unavailable, and the implementation of IF/DO/LOOP/ELSE/THEN are handled in the golang-code in a way users cannot modify.
Basically we ignore the common FORTH-approach of using a return-stack, and implementing a VM with "cells". Instead we just emulate the *behaviour* of the more advanced words:
* So we implement `if` or `do`/`loop` in a hard-coded fashion.
+ That means we can't allow a user to define `while`, or similar.
+ But otherwise our language is flexible enough to allow *real* work to be done with it.
## Implementation Approach
The code evolves through a series of simple steps, [contained in the comment-thread](https://news.ycombinator.com/item?id=13082825), ultimately ending with a [final revision](#final-revision) which is actually useful, usable, and pretty flexible.
While it would certainly be possible to further improve the implementation I'm going to declare this project as "almost complete" for my own tastes:
* I'll make minor changes, as they occur to me.
* Comments, test-cases, and similar are fair game.
* Outright crashes will be resolved, if I spot any.
* But no major new features will be added.
If **you** wanted to extend things further then there are some obvious things to work upon:
* Adding more of the "standard" FORTH-words.
+ For example we're missing `pow`, etc.
* Enhanced the string-support, to allow an input/read from the user, and other primitives.
+ strcat, strstr, and similar C-like operations would be useful.
* Simplify the conditional/loop handling.
+ Both of these probably involve using a proper return-stack.
+ This would have the side-effect of allowing new control-flow primitives to be added.
+ As well as more meta-programming.
Pull-requests adding additional functionality will be accepted with thanks.
## Implementation Overview
Each subdirectory within this repository gets a bit further down the comment-chain.
In terms of implementation two files are *largely* unchanged in each example:
* `stack.go`, which contains a simple stack of `float64` numbers.
* `main.go`, contains a simple REPL/driver.
+ The final few examples will also allow loading a startup-file, if present.
Each example builds upon the previous ones, with a pair of implementation files that change:
* `builtins.go` contains the forth-words implemented in golang.
* `eval.go` is the workhorse which implements to FORTH-like interpreter.
+ This allows executing existing words, and defining new ones.
### Part 1
Part one of the implementation only deals with hard-coded execution
of "words". It only supports the basic mathematical operations, along
with the ability to print the top-most entry of the stack:
```
cd part1
go build .
./part1
> 2 3 + 4 5 + * print
45.000000
^D
```
See [part1/](/skx/foth/blob/master/part1) for details.
### Part 2
Part two allows the definition of new words in terms of existing ones,
which can even happen recursively.
We've added `dup` to pop an item off the stack, and push it back twice, which
has the ultimate effect of duplicating it.
To demonstrate the self-definition there is the new function `square` which
squares the number at the top of the stack.
```
cd part2
go build .
./part2
> 3 square .
9.000000
> 3 dup + .
6.000000
^D
```
See [part2/](/skx/foth/blob/master/part2) for details.
### Part 3
Part three allows the user to define their own words, right from within the
REPL!
This means we've removed the `square` implementation, because you can add your own:
```
cd part3
go build .
./part3
> : square dup * ;
> : cube dup square * ;
> 3 cube .
27.000000
> 25 square .
625.000000
^D
```
See [part3/](/skx/foth/blob/master/part3) for details.
**NOTE**: We don't support using numbers in definitions, yet. That will come in part4!
### Part 4
Part four allows the user to define their own words, including the use of numbers, from within the REPL. Here the magic is handling the input of numbers when in "compiling mode".
To support this we switched our `Words` array from `int` to `float64`, specifically to ensure that we could continue to support floating-point numbers.
```
cd part4
go build .
./part4
> : add1 1 + ;
> -100 add1 .
-99.000000
> 4 add1 .
5.000000
^D
```
See [part4/](/skx/foth/blob/master/part4) for details.
### Part 5
This part adds `do` and `loop`, allowing simple loops, and `emit` which outputs the ASCII character stored in the topmost stack-entry.
Sample usage would look like this:
```
> : cr 10 emit ;
> : star 42 emit ;
> : stars 0 do star loop cr ;
> 4 stars
****
> 5 stars
*****
> 1 stars
*
> 10 stars
**********
^D
```
Here we've defined two new words `cr` to print a return, and `star` to output a single star.
We then defined the `stars` word to use a loop to print the given number of stars.
(Note that the character `*` has the ASCII code 42).
`do` and `loop` are pretty basic, allowing only loops to be handled which increment by one each iteration. You cannot use the standard `i` token to get the current index, instead you can see them on the stack:
* Top-most entry is the current index.
* Second entry is the limit.
So to write out numbers you could try something like this, using `dup` to duplicate the current offset within the loop:
```
> : l 10 0 do dup . loop ;
> l
0.000000
1.000000
2.000000
..
8.000000
9.000000
> : nums 10 0 do dup 48 + emit loop ;
> nums
0123456789>
```
See [part5/](/skx/foth/blob/master/part5) for details.
### Part 6
This update adds a lot of new primitives to our dictionary of predefined words:
* `drop` - Removes an item from the stack.
* `swap` - Swaps the top-most two stack-items.
* `words` - Outputs a list of all defined words.
* `<`, `<=`, `=` (`==` as a synonym), `>`, `>=`
+ Remove two items from the stack, and compare them appropriately.
+ If the condition is true push `1` onto the stack, otherwise `0`.
* The biggest feature here is the support for using `if` & `then`, which allow conditional actions to be carried out.
+ (These are why we added the comparison operations.)
In addition to these new primitives the driver, `main.go`, was updated to load and evaluate [foth.4th](/skx/foth/blob/master/part6/foth.4th) on-startup if it is present.
Sample usage:
```
cd part6
go build .
./part6
> : hot 72 emit 111 emit 116 emit 10 emit ;
> : cold 67 emit 111 emit 108 emit 100 emit 10 emit ;
> : test_hot 0 > if hot then ;
> : test_cold 0 <= if cold then ;
> : test dup test_hot test_cold ;
> 10 test
Hot
> 0 test
Cold
> -1 test
Cold
> 10 test_hot
Hot
> 10 test_cold
> -1 test_cold
Cold
^D
```
See [part6/](/skx/foth/blob/master/part6) for the code.
**NOTE**: The `if` handler allows:
```
: foo $COND IF word1 [word2 .. wordN] then [more_word1 more_word2 ..] ;
```
This means if the condition is true then we run `word1`, `word2` .. and otherwise we skip them, and continue running after the `then` statement. Specifically note there is **no support for `else`**. That is why we call the `test_host` and `test_cold` words in our `test` definition. Each word tests separately.
As an example:
```
> : foo 0 > if star star then star star cr ;
```
If the test-passes, because you give a positive number, you'll see FOUR stars. if it fails you just get TWO:
```
> 2 foo
****
> 1 foo
****
> 0 foo
**
> -1 foo
**
```
This is because the code is synonymous with the following C-code:
```
if ( x > 0 ) {
printf("*");
printf("*");
}
printf("*");
printf("*");
printf("\n");
```
I found this page useful, it also documents `invert` which I added for completeness:
* <https://www.forth.com/starting-forth/4-conditional-if-then-statements/>
### Part 7
This update adds a basic level of support for strings.
* When we see a string we store it in an array of strings.
* We then push the offset of the new string entry onto the stack.
* This allows it to be referenced and used.
* Three new words are added:
+ `strings` Return the number of strings we've seen/stored.
+ `strlen` show the length of the string at the given address.
+ `strprn` print the string at the given address.
Sample usage:
```
cd part7
go build .
./part7
> : steve "steve" ;
> steve strlen .
5
> steve strprn .
steve
^D
```
See [part7/](/skx/foth/blob/master/part7) for the code.
### Final Revision
The final version, stored beneath [foth/](/skx/foth/blob/master/foth), is pretty similar to the previous part from an end-user point of view, however there have been a lot of changes behind the scenes:
* We've added near 100% test-coverage.
* We've added a simple [lexer](/skx/foth/blob/master/foth/lexer) to tokenize our input.
+ This was required to allow us to ignore comments, and handle string literals.
+ Merely splitting input-strings at whitespace characters would have made either of those impossible to handle correctly.
* The `if` handling has been updated to support an `else`-branch, the general form is now:
+ `$COND IF word1 [ .. wordN ] else alt_word1 [.. altN] then [more_word1 more_word2 ..]`
* It is now possible to use `if`, `else`, `then`, `do`, and `loop` outside word-definitions.
+ i.e. Immediately in the REPL.
* `do`/`loop` loops can be nested.
+ And the new words `i` and `m` used to return the current index and maximum index, respectively.
* There were many new words defined in the go-core:
+ `.s` to show the stack-contents.
+ `clearstack` to clear the stack.
+ `debug` to change the debug-flag.
+ `debug?` to reveal the status.
+ `dump` dumps the compiled form of the given word.
- You can view the definitions of all available words this:
- `#words 0 do i dump loop`
+ `#words` to return the number of defined words.
+ Variables can be declared, by name, with `variable`, and the value of the variable can be set/retrieved with `@` and `!` respectively.
- See this demonstrated in the [standard library](/skx/foth/blob/master/foth/foth.4th)
* There were some new words defined in the [standard library](/skx/foth/blob/master/foth/foth.4th)
+ e.g. `abs`, `even?`, `negate`, `odd?`,
* Removed all calls to `os.Exit()`
+ We now return `error` objects where appropriate, allowing the caller to detect problems.
* It is now possible to redefine existing words.
* Execute any files specified on the command line.
+ If no files are specified run the REPL.
* We've added support for recursive definitions, in #16 for example allowing:
+ `: factorial recursive dup 1 > if dup 1 - factorial * then ;`
See [foth/](/skx/foth/blob/master/foth) for the implementation.
## BUGS
A brief list of known-issues:
### Loops
The handling of loops isn't correct when there should be zero-iterations:
```
> : star 42 emit ;
> : stars 0 do star loop 10 emit ;
> 3 stars
***
> 1 stars
*
> 0 stars
*
^D
```
**NOTE**: In `gforth` the result of `0 0 do ... loop` is actually an **infinite** loop, which is perhaps worse!
In our `stars` definition we handle this case by explicitly testing the loop
value before we proceed, only running the loop if the value is non-zero.
# See Also
This repository was put together after [experimenting with a scripting language](https://github.com/skx/monkey/), an [evaluation engine](https://github.com/skx/evalfilter/), putting together a [TCL-like scripting language](https://github.com/skx/critical), writing a [BASIC interpreter](https://github.com/skx/gobasic) and creating [yet another lisp](https://github.com/skx/yal).
I've also played around with a couple of compilers which might be interesting to refer to:
* Brainfuck compiler:
+ <https://github.com/skx/bfcc/>
* A math-compiler:
+ <https://github.com/skx/math-compiler>
# Github Setup
This repository is configured to run tests upon every commit, and when pull-requests are created/updated. The testing is carried out via [.github/run-tests.sh](/skx/foth/blob/master/.github/run-tests.sh) which is used by the [github-action-tester](https://github.com/skx/github-action-tester) action.
## About
Tutorial-style FORTH implementation written in golang
### Topics
[go](/topics/go "Topic: go")
[golang](/topics/golang "Topic: golang")
[tutorial](/topics/tutorial "Topic: tutorial")
[interpreter](/topics/interpreter "Topic: interpreter")
[scripting-language](/topics/scripting-language "Topic: scripting-language")
[forth](/topics/forth "Topic: forth")
[tutorial-code](/topics/tutorial-code "Topic: tutorial-code")
[forth-like](/topics/forth-like "Topic: forth-like")
### Resources
[Readme](#readme-ov-file)
### License
[GPL-2.0 license](#GPL-2.0-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/skx/foth/activity)
### Stars
[**94**
stars](/skx/foth/stargazers)
### Watchers
[**0**
watching](/skx/foth/watchers)
### Forks
[**7**
forks](/skx/foth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fskx%2Ffoth&report=skx+%28user%29)
## [Releases 2](/skx/foth/releases)
[v0.5.0
Latest
Feb 15, 2024](/skx/foth/releases/tag/v0.5.0)
[+ 1 release](/skx/foth/releases)
## [Packages 0](/users/skx/packages?repo_name=foth)
No packages published
## Languages
* [Go
95.3%](/skx/foth/search?l=go)
* [Forth
4.7%](/skx/foth/search?l=forth)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,427 @@
# guitarvydas/forthish
**Source:** https://github.com/guitarvydas/forthish
GitHub - guitarvydas/forthish
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fguitarvydas%2Fforthish)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fguitarvydas%2Fforthish)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=guitarvydas%2Fforthish)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[guitarvydas](/guitarvydas)
/
**[forthish](/guitarvydas/forthish)**
Public
* [Notifications](/login?return_to=%2Fguitarvydas%2Fforthish) You must be signed in to change notification settings
* [Fork
0](/login?return_to=%2Fguitarvydas%2Fforthish)
* [Star
1](/login?return_to=%2Fguitarvydas%2Fforthish)
[1
star](/guitarvydas/forthish/stargazers) [0
forks](/guitarvydas/forthish/forks) [Branches](/guitarvydas/forthish/branches) [Tags](/guitarvydas/forthish/tags) [Activity](/guitarvydas/forthish/activity)
[Star](/login?return_to=%2Fguitarvydas%2Fforthish)
[Notifications](/login?return_to=%2Fguitarvydas%2Fforthish) You must be signed in to change notification settings
* [Code](/guitarvydas/forthish)
* [Issues
0](/guitarvydas/forthish/issues)
* [Pull requests
0](/guitarvydas/forthish/pulls)
* [Actions](/guitarvydas/forthish/actions)
* [Projects
0](/guitarvydas/forthish/projects)
* [Security
0](/guitarvydas/forthish/security)
* [Insights](/guitarvydas/forthish/pulse)
Additional navigation options
* [Code](/guitarvydas/forthish)
* [Issues](/guitarvydas/forthish/issues)
* [Pull requests](/guitarvydas/forthish/pulls)
* [Actions](/guitarvydas/forthish/actions)
* [Projects](/guitarvydas/forthish/projects)
* [Security](/guitarvydas/forthish/security)
* [Insights](/guitarvydas/forthish/pulse)
# guitarvydas/forthish
main
[Branches](/guitarvydas/forthish/branches)[Tags](/guitarvydas/forthish/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[26 Commits](/guitarvydas/forthish/commits/main/) 26 Commits | | |
| [.hg](/guitarvydas/forthish/tree/main/.hg ".hg") | | [.hg](/guitarvydas/forthish/tree/main/.hg ".hg") | | |
| [.obsidian](/guitarvydas/forthish/tree/main/.obsidian ".obsidian") | | [.obsidian](/guitarvydas/forthish/tree/main/.obsidian ".obsidian") | | |
| [assets](/guitarvydas/forthish/tree/main/assets "assets") | | [assets](/guitarvydas/forthish/tree/main/assets "assets") | | |
| [basic](/guitarvydas/forthish/tree/main/basic "basic") | | [basic](/guitarvydas/forthish/tree/main/basic "basic") | | |
| [course](/guitarvydas/forthish/tree/main/course "course") | | [course](/guitarvydas/forthish/tree/main/course "course") | | |
| [frish](/guitarvydas/forthish/tree/main/frish "frish") | | [frish](/guitarvydas/forthish/tree/main/frish "frish") | | |
| [.gitignore](/guitarvydas/forthish/blob/main/.gitignore ".gitignore") | | [.gitignore](/guitarvydas/forthish/blob/main/.gitignore ".gitignore") | | |
| [.hgignore](/guitarvydas/forthish/blob/main/.hgignore ".hgignore") | | [.hgignore](/guitarvydas/forthish/blob/main/.hgignore ".hgignore") | | |
| [INSTALL-hg.md](/guitarvydas/forthish/blob/main/INSTALL-hg.md "INSTALL-hg.md") | | [INSTALL-hg.md](/guitarvydas/forthish/blob/main/INSTALL-hg.md "INSTALL-hg.md") | | |
| [INSTALL.md](/guitarvydas/forthish/blob/main/INSTALL.md "INSTALL.md") | | [INSTALL.md](/guitarvydas/forthish/blob/main/INSTALL.md "INSTALL.md") | | |
| [README.md](/guitarvydas/forthish/blob/main/README.md "README.md") | | [README.md](/guitarvydas/forthish/blob/main/README.md "README.md") | | |
| View all files | | |
## Repository files navigation
* [README](#)
# Forth in $WHATEVER
This is a collection of Forth (or Forth-like) implementations in various languages. It is intended to provide examples of how you can leverage Forth to simplify and add extensibility to your programs.
## Python Implementations
### [simple.py](/guitarvydas/forthish/blob/main/simple.py?rev=tip)
The simplest thing that could be called a Forth (Mr. Moore will probably disagree with me). However, it provides a useful parser, stack and interface to the host system. Words in this implementation:
* **+** ( a b -- sum) Add two numbers on top of stack.
* **-** ( a b -- difference) Subtracts top number from next on stack.
* **.** ( n --) Pop top of stack and print it.
* **.s** ( --) Print contents of stack (nondestructive).
* **bye** ( --) Exit interpreter.
* **interpret** ( string --) Execute word on top of stack.
* **swap** ( a b -- b a) Swaps top two items on stack.
* **word** ( c -- string) Collect characters in input stream up to character c.
### [fram.py](/guitarvydas/forthish/blob/main/fram.py?rev=tip)
This implements a semi-traditional Forth dictionary in the RAM array. Words are stored with a name field, link field and code field. Instead of finding things directly with a Python dictionary, the `'` word searches for the xt, or "execution token", to be executed.
In real terms, a little slower, but offers some exciting benefits, which I'll explore later.
* **'** ( name -- xt) Finds word's xt in dictionary.
* **execute** ( xt --) Executes the code at xt.
* **negate** ( n -- -n) Makes number negative (or positive, if you use it twice).
* **words** ( --) Prints list of all words in dictionary.
### [fvars.py](/guitarvydas/forthish/blob/main/fvars.py?rev=tip)
Now we're getting into memory manipulations with variables and such. This introduces some new stuff in the code field -- a constant or variable is just like any other Forth word, except the code retrieves the values (or address of the values, for variables).
* **!** ( v a --) Store value at address a.
* **,** ( v --) Store v as next value in dictionary.
* **@** ( a -- v) Fetch value from address a.
* **constant** ( name | v --) Create constant with value v.
* **create** ( name | --) Create word name in dictionary.
* **dump** ( start n --) Dump n values starting from RAM address a.
* **variable** ( name | v --) Create variable name, with initial value v.
### [fcomp.py](/guitarvydas/forthish/blob/main/fcomp.py?rev=tip)
Stuff is getting tricky now... This implements user definitions. Also reworks some previous words.
#### Variables
* **state** Variable for interpreter state -- 0 = interpret, 1 = compile.
#### Special Words for Compilation
These words are used during compilation to handle literal values and control flow. You will generally not need to use them.
* **(literal)** Used when compiling literal values in definitions.
* **branch** Unconditional branch.
* **0branch** Branch on false.
#### Words for Definitions
The colon and semicolon begin and end a Forth definition. The if/else/then triad can only be used inside a definition (in traditional Forth).
* **:** ( name | --) Start compiling new definition.
* **;** ( --) End definition.
* **if** ( f --) Evaluate based on flag f.
* **else** ( --) What to do when if is false.
* **then** ( --) End if/else/then clause, continue with normal execution.
#### Regular Words
This is a grab bag of stuff that I found useful as I went. Notably, the `"` (quote) word is state-smart, meaning it can be used outside and inside a definition. Now that you know that, forget it...
* **find** ( name | -- name 0|xt 1|xt -1) Search for word name.
* **(** ( --) Start inline comment, reads until closing paren.
* **."** ( --) Prints text up to closing quote.
* **"** ( -- s) Reads text up to closing quote as a string, puts on stack.
* **/** ( a b -- div) Divides a by b.
* **\*** ( a b -- product) Multiplies a times b.
* **cr** ( --) Carriage return.
* **emit** ( c --) Prints ascii character c.
* **dup** ( a -- a a) Duplicate TOS.
* **drop** ( a --) Discards TOS.
If you care, this is effectively a DTC (Direct Threaded Code) implementation.
*Explanation of how colon definitions work goes here...*
## References
Some links to more information that will help in understanding why you might do with this and what to do with it once you've got it. If nothing else, please read Walker's essay at the first link.
### Essential
* [ATLAST](https://www.fourmilab.ch/atlast/) -- My first encounter with this concept, written by the legendary John Walker. He explains it better than I can.
* [Starting Forth](https://www.forth.com/starting-forth/) -- Classic Forth tutorial and textbook. Don't be fooled by the illustrations, this book not only teaches you how to use Forth, but actually gives you enough information to write your own as well.
* [Levels of FORTH](https://www.forth.org/literature/forthlev.html) -- Glen Haydon's taxonomy of Forth implementations, slightly outdated, but useful if you're trying to figure out what functionality to implement next.
### Supplemental
* [Forth Standard](https://forth-standard.org/standard/words) Yes, Forth has a language standard. Don't feel like you need to follow it slavishly, though...
* [JONESFORTH](https://github.com/nornagon/jonesforth/blob/master/jonesforth.S) -- A full implementation of Forth, in assembly.
* [Thinking Forth -- A Language and Philosophy for Solving Problems](https://www.forth.com/wp-content/uploads/2018/11/thinking-forth-color.pdf) -- Leo Brodie's masterwork, read this to figure out how to *really* use your new Forth implementation.
### Historical
* [Forth - The Early Years](https://colorforth.github.io/HOPL.html) -- Potted history of Forth, by its creator, Chuck Moore.
* [Programming a Problem Oriented Language](https://archive.org/details/chuck-moore-forth-book/page/10/mode/2up) -- Unpublished book by Chuck Moore describing early Forth.
## About
No description, website, or topics provided.
### Resources
[Readme](#readme-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/guitarvydas/forthish/activity)
### Stars
[**1**
star](/guitarvydas/forthish/stargazers)
### Watchers
[**0**
watching](/guitarvydas/forthish/watchers)
### Forks
[**0**
forks](/guitarvydas/forthish/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fguitarvydas%2Fforthish&report=guitarvydas+%28user%29)
## [Releases](/guitarvydas/forthish/releases)
No releases published
## [Packages 0](/users/guitarvydas/packages?repo_name=forthish)
No packages published
## Languages
* [Python
66.6%](/guitarvydas/forthish/search?l=python)
* [JavaScript
22.6%](/guitarvydas/forthish/search?l=javascript)
* [HTML
10.4%](/guitarvydas/forthish/search?l=html)
* Other
0.4%
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,5 @@
# iNet
**Source:** https://inet.run
iNet

View File

@@ -0,0 +1,384 @@
# jombloforth (x64 Jonesforth)
**Source:** https://github.com/matematikaadit/jombloforth
GitHub - matematikaadit/jombloforth: Minimal FORTH interpreter for 64-bit Linux systems. Based on jonesforth.
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fmatematikaadit%2Fjombloforth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fmatematikaadit%2Fjombloforth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=matematikaadit%2Fjombloforth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[matematikaadit](/matematikaadit)
/
**[jombloforth](/matematikaadit/jombloforth)**
Public
* [Notifications](/login?return_to=%2Fmatematikaadit%2Fjombloforth) You must be signed in to change notification settings
* [Fork
5](/login?return_to=%2Fmatematikaadit%2Fjombloforth)
* [Star
28](/login?return_to=%2Fmatematikaadit%2Fjombloforth)
Minimal FORTH interpreter for 64-bit Linux systems. Based on jonesforth.
### License
[Unlicense license](/matematikaadit/jombloforth/blob/master/UNLICENSE.txt)
[28
stars](/matematikaadit/jombloforth/stargazers) [5
forks](/matematikaadit/jombloforth/forks) [Branches](/matematikaadit/jombloforth/branches) [Tags](/matematikaadit/jombloforth/tags) [Activity](/matematikaadit/jombloforth/activity)
[Star](/login?return_to=%2Fmatematikaadit%2Fjombloforth)
[Notifications](/login?return_to=%2Fmatematikaadit%2Fjombloforth) You must be signed in to change notification settings
* [Code](/matematikaadit/jombloforth)
* [Issues
0](/matematikaadit/jombloforth/issues)
* [Pull requests
0](/matematikaadit/jombloforth/pulls)
* [Actions](/matematikaadit/jombloforth/actions)
* [Projects
0](/matematikaadit/jombloforth/projects)
* [Security
0](/matematikaadit/jombloforth/security)
* [Insights](/matematikaadit/jombloforth/pulse)
Additional navigation options
* [Code](/matematikaadit/jombloforth)
* [Issues](/matematikaadit/jombloforth/issues)
* [Pull requests](/matematikaadit/jombloforth/pulls)
* [Actions](/matematikaadit/jombloforth/actions)
* [Projects](/matematikaadit/jombloforth/projects)
* [Security](/matematikaadit/jombloforth/security)
* [Insights](/matematikaadit/jombloforth/pulse)
# matematikaadit/jombloforth
master
[Branches](/matematikaadit/jombloforth/branches)[Tags](/matematikaadit/jombloforth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[93 Commits](/matematikaadit/jombloforth/commits/master/) 93 Commits | | |
| [debug](/matematikaadit/jombloforth/tree/master/debug "debug") | | [debug](/matematikaadit/jombloforth/tree/master/debug "debug") | | |
| [experiment](/matematikaadit/jombloforth/tree/master/experiment "experiment") | | [experiment](/matematikaadit/jombloforth/tree/master/experiment "experiment") | | |
| [original](/matematikaadit/jombloforth/tree/master/original "original") | | [original](/matematikaadit/jombloforth/tree/master/original "original") | | |
| [tests](/matematikaadit/jombloforth/tree/master/tests "tests") | | [tests](/matematikaadit/jombloforth/tree/master/tests "tests") | | |
| [.gitignore](/matematikaadit/jombloforth/blob/master/.gitignore ".gitignore") | | [.gitignore](/matematikaadit/jombloforth/blob/master/.gitignore ".gitignore") | | |
| [Makefile](/matematikaadit/jombloforth/blob/master/Makefile "Makefile") | | [Makefile](/matematikaadit/jombloforth/blob/master/Makefile "Makefile") | | |
| [README.md](/matematikaadit/jombloforth/blob/master/README.md "README.md") | | [README.md](/matematikaadit/jombloforth/blob/master/README.md "README.md") | | |
| [UNLICENSE.txt](/matematikaadit/jombloforth/blob/master/UNLICENSE.txt "UNLICENSE.txt") | | [UNLICENSE.txt](/matematikaadit/jombloforth/blob/master/UNLICENSE.txt "UNLICENSE.txt") | | |
| [jombloforth.asm](/matematikaadit/jombloforth/blob/master/jombloforth.asm "jombloforth.asm") | | [jombloforth.asm](/matematikaadit/jombloforth/blob/master/jombloforth.asm "jombloforth.asm") | | |
| [jombloforth.f](/matematikaadit/jombloforth/blob/master/jombloforth.f "jombloforth.f") | | [jombloforth.f](/matematikaadit/jombloforth/blob/master/jombloforth.f "jombloforth.f") | | |
| [unistd\_64.inc](/matematikaadit/jombloforth/blob/master/unistd_64.inc "unistd_64.inc") | | [unistd\_64.inc](/matematikaadit/jombloforth/blob/master/unistd_64.inc "unistd_64.inc") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [Unlicense license](#)
# jombloforth
Minimal FORTH interpreter for 64-bit Linux systems. Based on
jonesforth tutorial.
## Compile
You needs make, nasm, and ld to build the executable. Runs the following to build them
```
make jombloforth
```
## Running
For a full forth system, runs:
```
make run
```
The interpreter will starts accepting input from stdin.
## Quick Forth Tutorial
After the interpreter starts, you can execute any forth command defined in the system. For example, adding two number and display it.
```
42 24 + . CR
```
Will print 66 followed by newline.
Defining new word and runs it:
```
: double DUP + ;
100 double . CR
```
Will print 200.
To exit the program, press CTRL+D
## License
UNLICENSE. See [UNLICENSE.txt](/matematikaadit/jombloforth/blob/master/UNLICENSE.txt)
## About
Minimal FORTH interpreter for 64-bit Linux systems. Based on jonesforth.
### Topics
[assembly](/topics/assembly "Topic: assembly")
[x64](/topics/x64 "Topic: x64")
[x86-64](/topics/x86-64 "Topic: x86-64")
[forth](/topics/forth "Topic: forth")
[nasm](/topics/nasm "Topic: nasm")
### Resources
[Readme](#readme-ov-file)
### License
[Unlicense license](#Unlicense-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/matematikaadit/jombloforth/activity)
### Stars
[**28**
stars](/matematikaadit/jombloforth/stargazers)
### Watchers
[**1**
watching](/matematikaadit/jombloforth/watchers)
### Forks
[**5**
forks](/matematikaadit/jombloforth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fmatematikaadit%2Fjombloforth&report=matematikaadit+%28user%29)
## [Releases](/matematikaadit/jombloforth/releases)
No releases published
## [Packages 0](/users/matematikaadit/packages?repo_name=jombloforth)
No packages published
## Languages
* [Assembly
85.7%](/matematikaadit/jombloforth/search?l=assembly)
* [Forth
13.4%](/matematikaadit/jombloforth/search?l=forth)
* Other
0.9%
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,390 @@
# kcats
**Source:** https://github.com/skyrod-vactai/kcats
GitHub - skyrod-vactai/kcats: A stack-based programming language based on Joy
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fskyrod-vactai%2Fkcats)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fskyrod-vactai%2Fkcats)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=skyrod-vactai%2Fkcats)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[skyrod-vactai](/skyrod-vactai)
/
**[kcats](/skyrod-vactai/kcats)**
Public
* [Notifications](/login?return_to=%2Fskyrod-vactai%2Fkcats) You must be signed in to change notification settings
* [Fork
1](/login?return_to=%2Fskyrod-vactai%2Fkcats)
* [Star
8](/login?return_to=%2Fskyrod-vactai%2Fkcats)
A stack-based programming language based on Joy
### License
[WTFPL license](/skyrod-vactai/kcats/blob/master/LICENSE-WTFPL)
[8
stars](/skyrod-vactai/kcats/stargazers) [1
fork](/skyrod-vactai/kcats/forks) [Branches](/skyrod-vactai/kcats/branches) [Tags](/skyrod-vactai/kcats/tags) [Activity](/skyrod-vactai/kcats/activity)
[Star](/login?return_to=%2Fskyrod-vactai%2Fkcats)
[Notifications](/login?return_to=%2Fskyrod-vactai%2Fkcats) You must be signed in to change notification settings
* [Code](/skyrod-vactai/kcats)
* [Issues
0](/skyrod-vactai/kcats/issues)
* [Pull requests
0](/skyrod-vactai/kcats/pulls)
* [Discussions](/skyrod-vactai/kcats/discussions)
* [Actions](/skyrod-vactai/kcats/actions)
* [Projects
0](/skyrod-vactai/kcats/projects)
* [Security
0](/skyrod-vactai/kcats/security)
* [Insights](/skyrod-vactai/kcats/pulse)
Additional navigation options
* [Code](/skyrod-vactai/kcats)
* [Issues](/skyrod-vactai/kcats/issues)
* [Pull requests](/skyrod-vactai/kcats/pulls)
* [Discussions](/skyrod-vactai/kcats/discussions)
* [Actions](/skyrod-vactai/kcats/actions)
* [Projects](/skyrod-vactai/kcats/projects)
* [Security](/skyrod-vactai/kcats/security)
* [Insights](/skyrod-vactai/kcats/pulse)
# skyrod-vactai/kcats
master
[Branches](/skyrod-vactai/kcats/branches)[Tags](/skyrod-vactai/kcats/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[1,445 Commits](/skyrod-vactai/kcats/commits/master/) 1,445 Commits | | |
| [.cargo](/skyrod-vactai/kcats/tree/master/.cargo ".cargo") | | [.cargo](/skyrod-vactai/kcats/tree/master/.cargo ".cargo") | | |
| [.devcontainer](/skyrod-vactai/kcats/tree/master/.devcontainer ".devcontainer") | | [.devcontainer](/skyrod-vactai/kcats/tree/master/.devcontainer ".devcontainer") | | |
| [.github/workflows](/skyrod-vactai/kcats/tree/master/.github/workflows "This path skips through empty directories") | | [.github/workflows](/skyrod-vactai/kcats/tree/master/.github/workflows "This path skips through empty directories") | | |
| [ai-model-training](/skyrod-vactai/kcats/tree/master/ai-model-training "ai-model-training") | | [ai-model-training](/skyrod-vactai/kcats/tree/master/ai-model-training "ai-model-training") | | |
| [edn-format](/skyrod-vactai/kcats/tree/master/edn-format "edn-format") | | [edn-format](/skyrod-vactai/kcats/tree/master/edn-format "edn-format") | | |
| [emacs](/skyrod-vactai/kcats/tree/master/emacs "emacs") | | [emacs](/skyrod-vactai/kcats/tree/master/emacs "emacs") | | |
| [examples](/skyrod-vactai/kcats/tree/master/examples "examples") | | [examples](/skyrod-vactai/kcats/tree/master/examples "examples") | | |
| [Cargo.toml](/skyrod-vactai/kcats/blob/master/Cargo.toml "Cargo.toml") | | [Cargo.toml](/skyrod-vactai/kcats/blob/master/Cargo.toml "Cargo.toml") | | |
| [LICENSE-WTFPL](/skyrod-vactai/kcats/blob/master/LICENSE-WTFPL "LICENSE-WTFPL") | | [LICENSE-WTFPL](/skyrod-vactai/kcats/blob/master/LICENSE-WTFPL "LICENSE-WTFPL") | | |
| [README.md](/skyrod-vactai/kcats/blob/master/README.md "README.md") | | [README.md](/skyrod-vactai/kcats/blob/master/README.md "README.md") | | |
| [book-of-kcats.org](/skyrod-vactai/kcats/blob/master/book-of-kcats.org "book-of-kcats.org") | | [book-of-kcats.org](/skyrod-vactai/kcats/blob/master/book-of-kcats.org "book-of-kcats.org") | | |
| [build.rs](/skyrod-vactai/kcats/blob/master/build.rs "build.rs") | | [build.rs](/skyrod-vactai/kcats/blob/master/build.rs "build.rs") | | |
| [docs-custom.css](/skyrod-vactai/kcats/blob/master/docs-custom.css "docs-custom.css") | | [docs-custom.css](/skyrod-vactai/kcats/blob/master/docs-custom.css "docs-custom.css") | | |
| [emacs-ide.org](/skyrod-vactai/kcats/blob/master/emacs-ide.org "emacs-ide.org") | | [emacs-ide.org](/skyrod-vactai/kcats/blob/master/emacs-ide.org "emacs-ide.org") | | |
| [export.el](/skyrod-vactai/kcats/blob/master/export.el "export.el") | | [export.el](/skyrod-vactai/kcats/blob/master/export.el "export.el") | | |
| [kcats-repl.gif](/skyrod-vactai/kcats/blob/master/kcats-repl.gif "kcats-repl.gif") | | [kcats-repl.gif](/skyrod-vactai/kcats/blob/master/kcats-repl.gif "kcats-repl.gif") | | |
| [kcats.org](/skyrod-vactai/kcats/blob/master/kcats.org "kcats.org") | | [kcats.org](/skyrod-vactai/kcats/blob/master/kcats.org "kcats.org") | | |
| [kcats.png](/skyrod-vactai/kcats/blob/master/kcats.png "kcats.png") | | [kcats.png](/skyrod-vactai/kcats/blob/master/kcats.png "kcats.png") | | |
| [lexicon.org](/skyrod-vactai/kcats/blob/master/lexicon.org "lexicon.org") | | [lexicon.org](/skyrod-vactai/kcats/blob/master/lexicon.org "lexicon.org") | | |
| [lib-toolchain-env.sh](/skyrod-vactai/kcats/blob/master/lib-toolchain-env.sh "lib-toolchain-env.sh") | | [lib-toolchain-env.sh](/skyrod-vactai/kcats/blob/master/lib-toolchain-env.sh "lib-toolchain-env.sh") | | |
| [production.org\_archive](/skyrod-vactai/kcats/blob/master/production.org_archive "production.org_archive") | | [production.org\_archive](/skyrod-vactai/kcats/blob/master/production.org_archive "production.org_archive") | | |
| [scratch.org](/skyrod-vactai/kcats/blob/master/scratch.org "scratch.org") | | [scratch.org](/skyrod-vactai/kcats/blob/master/scratch.org "scratch.org") | | |
| [tangle.el](/skyrod-vactai/kcats/blob/master/tangle.el "tangle.el") | | [tangle.el](/skyrod-vactai/kcats/blob/master/tangle.el "tangle.el") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [WTFPL license](#)
# The kcats Programming language
[Get started!](https://skyrod-vactai.github.io/kcats/book-of-kcats.html)
# Other Documentation
* [Lexicon](https://skyrod-vactai.github.io/kcats/lexicon.html)
* [The Implementation](https://skyrod-vactai.github.io/kcats/production.html)
# Contributing
## Issue reporting
Use github issues <https://github.com/skyrod-vactai/kcats/issues> if that's easiest.
Recommended: Instead of opening a github issue, create a fork and add a TODO subheading to the Issues heading in the respective `.org` file. You can edit org files right on github, in your own fork.
* For bugs add issues here under Issues heading in production.org
* For documentation problems add issues here under Issues heading in book-of-kcats.org
Then submit it as a pull request.
To see the status, check your PR. It will have more commits by the developers added to it.
## Other feedback
Please do report design improvements you'd like to see - for example, inconsistencies in how words expect stack arguments to be, ways to make the standard library easier to work with, etc.
## About
A stack-based programming language based on Joy
### Resources
[Readme](#readme-ov-file)
### License
[WTFPL license](#WTFPL-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/skyrod-vactai/kcats/activity)
### Stars
[**8**
stars](/skyrod-vactai/kcats/stargazers)
### Watchers
[**1**
watching](/skyrod-vactai/kcats/watchers)
### Forks
[**1**
fork](/skyrod-vactai/kcats/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fskyrod-vactai%2Fkcats&report=skyrod-vactai+%28user%29)
## [Releases 26](/skyrod-vactai/kcats/releases)
[Release v1.0.0-6
Latest
May 16, 2025](/skyrod-vactai/kcats/releases/tag/v1.0.0-6)
[+ 25 releases](/skyrod-vactai/kcats/releases)
## [Packages 0](/users/skyrod-vactai/packages?repo_name=kcats)
No packages published
### Uh oh!
There was an error while loading. Please reload this page.
## [Contributors 2](/skyrod-vactai/kcats/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [Rust
76.4%](/skyrod-vactai/kcats/search?l=rust)
* [Emacs Lisp
17.1%](/skyrod-vactai/kcats/search?l=emacs-lisp)
* [CSS
4.0%](/skyrod-vactai/kcats/search?l=css)
* [Python
1.6%](/skyrod-vactai/kcats/search?l=python)
* [Shell
0.9%](/skyrod-vactai/kcats/search?l=shell)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,68 @@
# kitten
**Source:** https://kittenlang.org
Kitten Programming Language
[Kitten](/)
* [Introduction](/intro/)
* [FAQ](/faq/)
* [Source](https://github.com/evincarofautumn/kitten/)
# Learn
* [FAQ](/faq/)
* [Introduction](/intro/)
* [Tutorial](/tutorial/)
* [Documentation](/documentation/)
# Contribute
* [Source](https://github.com/evincarofautumn/kitten)
* [Issues](https://github.com/evincarofautumn/kitten/issues)
* [IRC](irc://freenode.net/#concatenative)
# [The Kitten Programming Language](#the-kitten-programming-language)
**Kitten** is a statically typed, stack-based functional programming language designed to be simple and fast. It is a *concatenative* language, combining aspects of imperative and pure functional programming. There is [an introduction](/intro/) available and a [tutorial](/tutorial/) in progress.
## [Features](#features)
Concatenative Programming
: A compositional style of programming to make refactoring easier and improve code reuse.
Static Types
: Type inference based on HindleyMilner to help improve correctness and performance.
Permissions
: A system of effect types to control where side-effects are allowed.
Deterministic Resource Management
: Automatic management of memory and resources with no garbage collector.
## [Examples](#examples)
### [Hello world](#hello-world)
```
"meow" say // Kittens don't speak English.
```
### [Hello user](#hello-user)
```
define greet (List<Char> -> +IO):
-> name;
["Hello, ", name, "!"] concat say
"What is your name? " ask
greet
```
### [Larger examples](#larger-examples)
* [99 Bottles of Beer](https://github.com/evincarofautumn/kitten/blob/129d4bc7e5658a03cc765358ba0a1aba2dbf1c73/examples/beer.ktn)
* [Tic Tac Toe](https://github.com/evincarofautumn/kitten/blob/129d4bc7e5658a03cc765358ba0a1aba2dbf1c73/examples/tictactoe.ktn)
The [source code](https://github.com/evincarofautumn/kitten) is hosted on GitHub, and you can join [#concatenative on Freenode](irc://freenode.net/#concatenative) to keep up with the latest developments.

View File

@@ -0,0 +1,433 @@
# lbForth
**Source:** https://github.com/larsbrinkhoff/lbForth
GitHub - larsbrinkhoff/lbForth: Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Flarsbrinkhoff%2FlbForth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Flarsbrinkhoff%2FlbForth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=larsbrinkhoff%2FlbForth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[larsbrinkhoff](/larsbrinkhoff)
/
**[lbForth](/larsbrinkhoff/lbForth)**
Public
* [Notifications](/login?return_to=%2Flarsbrinkhoff%2FlbForth) You must be signed in to change notification settings
* [Fork
112](/login?return_to=%2Flarsbrinkhoff%2FlbForth)
* [Star
475](/login?return_to=%2Flarsbrinkhoff%2FlbForth)
Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
### License
[GPL-3.0 license](/larsbrinkhoff/lbForth/blob/master/LICENSE)
[475
stars](/larsbrinkhoff/lbForth/stargazers) [112
forks](/larsbrinkhoff/lbForth/forks) [Branches](/larsbrinkhoff/lbForth/branches) [Tags](/larsbrinkhoff/lbForth/tags) [Activity](/larsbrinkhoff/lbForth/activity)
[Star](/login?return_to=%2Flarsbrinkhoff%2FlbForth)
[Notifications](/login?return_to=%2Flarsbrinkhoff%2FlbForth) You must be signed in to change notification settings
* [Code](/larsbrinkhoff/lbForth)
* [Issues
40](/larsbrinkhoff/lbForth/issues)
* [Pull requests
1](/larsbrinkhoff/lbForth/pulls)
* [Actions](/larsbrinkhoff/lbForth/actions)
* [Projects
0](/larsbrinkhoff/lbForth/projects)
* [Wiki](/larsbrinkhoff/lbForth/wiki)
* [Security
0](/larsbrinkhoff/lbForth/security)
* [Insights](/larsbrinkhoff/lbForth/pulse)
Additional navigation options
* [Code](/larsbrinkhoff/lbForth)
* [Issues](/larsbrinkhoff/lbForth/issues)
* [Pull requests](/larsbrinkhoff/lbForth/pulls)
* [Actions](/larsbrinkhoff/lbForth/actions)
* [Projects](/larsbrinkhoff/lbForth/projects)
* [Wiki](/larsbrinkhoff/lbForth/wiki)
* [Security](/larsbrinkhoff/lbForth/security)
* [Insights](/larsbrinkhoff/lbForth/pulse)
# larsbrinkhoff/lbForth
master
[Branches](/larsbrinkhoff/lbForth/branches)[Tags](/larsbrinkhoff/lbForth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[815 Commits](/larsbrinkhoff/lbForth/commits/master/) 815 Commits | | |
| [contrib](/larsbrinkhoff/lbForth/tree/master/contrib "contrib") | | [contrib](/larsbrinkhoff/lbForth/tree/master/contrib "contrib") | | |
| [doc](/larsbrinkhoff/lbForth/tree/master/doc "doc") | | [doc](/larsbrinkhoff/lbForth/tree/master/doc "doc") | | |
| [experiments](/larsbrinkhoff/lbForth/tree/master/experiments "experiments") | | [experiments](/larsbrinkhoff/lbForth/tree/master/experiments "experiments") | | |
| [lib](/larsbrinkhoff/lbForth/tree/master/lib "lib") | | [lib](/larsbrinkhoff/lbForth/tree/master/lib "lib") | | |
| [lisp @ 40b99c0](/larsbrinkhoff/forth-metacompiler/tree/40b99c09628f616d94649009ba9894340088d77c "lisp") | | [lisp @ 40b99c0](/larsbrinkhoff/forth-metacompiler/tree/40b99c09628f616d94649009ba9894340088d77c "lisp") | | |
| [src](/larsbrinkhoff/lbForth/tree/master/src "src") | | [src](/larsbrinkhoff/lbForth/tree/master/src "src") | | |
| [targets](/larsbrinkhoff/lbForth/tree/master/targets "targets") | | [targets](/larsbrinkhoff/lbForth/tree/master/targets "targets") | | |
| [test](/larsbrinkhoff/lbForth/tree/master/test "test") | | [test](/larsbrinkhoff/lbForth/tree/master/test "test") | | |
| [.gdbinit](/larsbrinkhoff/lbForth/blob/master/.gdbinit ".gdbinit") | | [.gdbinit](/larsbrinkhoff/lbForth/blob/master/.gdbinit ".gdbinit") | | |
| [.gitattributes](/larsbrinkhoff/lbForth/blob/master/.gitattributes ".gitattributes") | | [.gitattributes](/larsbrinkhoff/lbForth/blob/master/.gitattributes ".gitattributes") | | |
| [.gitignore](/larsbrinkhoff/lbForth/blob/master/.gitignore ".gitignore") | | [.gitignore](/larsbrinkhoff/lbForth/blob/master/.gitignore ".gitignore") | | |
| [.gitlab-ci.yml](/larsbrinkhoff/lbForth/blob/master/.gitlab-ci.yml ".gitlab-ci.yml") | | [.gitlab-ci.yml](/larsbrinkhoff/lbForth/blob/master/.gitlab-ci.yml ".gitlab-ci.yml") | | |
| [.gitmodules](/larsbrinkhoff/lbForth/blob/master/.gitmodules ".gitmodules") | | [.gitmodules](/larsbrinkhoff/lbForth/blob/master/.gitmodules ".gitmodules") | | |
| [.scrutinizer.yml](/larsbrinkhoff/lbForth/blob/master/.scrutinizer.yml ".scrutinizer.yml") | | [.scrutinizer.yml](/larsbrinkhoff/lbForth/blob/master/.scrutinizer.yml ".scrutinizer.yml") | | |
| [.travis.yml](/larsbrinkhoff/lbForth/blob/master/.travis.yml ".travis.yml") | | [.travis.yml](/larsbrinkhoff/lbForth/blob/master/.travis.yml ".travis.yml") | | |
| [INSTALL](/larsbrinkhoff/lbForth/blob/master/INSTALL "INSTALL") | | [INSTALL](/larsbrinkhoff/lbForth/blob/master/INSTALL "INSTALL") | | |
| [LICENSE](/larsbrinkhoff/lbForth/blob/master/LICENSE "LICENSE") | | [LICENSE](/larsbrinkhoff/lbForth/blob/master/LICENSE "LICENSE") | | |
| [Makefile](/larsbrinkhoff/lbForth/blob/master/Makefile "Makefile") | | [Makefile](/larsbrinkhoff/lbForth/blob/master/Makefile "Makefile") | | |
| [PITCHME.md](/larsbrinkhoff/lbForth/blob/master/PITCHME.md "PITCHME.md") | | [PITCHME.md](/larsbrinkhoff/lbForth/blob/master/PITCHME.md "PITCHME.md") | | |
| [README.md](/larsbrinkhoff/lbForth/blob/master/README.md "README.md") | | [README.md](/larsbrinkhoff/lbForth/blob/master/README.md "README.md") | | |
| [appharbor.sln](/larsbrinkhoff/lbForth/blob/master/appharbor.sln "appharbor.sln") | | [appharbor.sln](/larsbrinkhoff/lbForth/blob/master/appharbor.sln "appharbor.sln") | | |
| [appveyor.yml](/larsbrinkhoff/lbForth/blob/master/appveyor.yml "appveyor.yml") | | [appveyor.yml](/larsbrinkhoff/lbForth/blob/master/appveyor.yml "appveyor.yml") | | |
| [bitrise.yml](/larsbrinkhoff/lbForth/blob/master/bitrise.yml "bitrise.yml") | | [bitrise.yml](/larsbrinkhoff/lbForth/blob/master/bitrise.yml "bitrise.yml") | | |
| [build.md](/larsbrinkhoff/lbForth/blob/master/build.md "build.md") | | [build.md](/larsbrinkhoff/lbForth/blob/master/build.md "build.md") | | |
| [build.vcxproj](/larsbrinkhoff/lbForth/blob/master/build.vcxproj "build.vcxproj") | | [build.vcxproj](/larsbrinkhoff/lbForth/blob/master/build.vcxproj "build.vcxproj") | | |
| [circle.yml](/larsbrinkhoff/lbForth/blob/master/circle.yml "circle.yml") | | [circle.yml](/larsbrinkhoff/lbForth/blob/master/circle.yml "circle.yml") | | |
| [configure](/larsbrinkhoff/lbForth/blob/master/configure "configure") | | [configure](/larsbrinkhoff/lbForth/blob/master/configure "configure") | | |
| [packages.config](/larsbrinkhoff/lbForth/blob/master/packages.config "packages.config") | | [packages.config](/larsbrinkhoff/lbForth/blob/master/packages.config "packages.config") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [GPL-3.0 license](#)
( Subset of Forth94 )
This is a self-hosted implementation of Forth, which can regenerate
itself from Forth source code. The bootstrapping process uses a
[metacompiler written in Lisp](https://github.com/larsbrinkhoff/forth-metacompiler) to target a
small inner interpreter and a handful of code words written in C. A
new [metacompiler written in Forth](/larsbrinkhoff/lbForth/blob/master/lib/meta.fth) generates an x86
executable using using [assembly language code words](/larsbrinkhoff/lbForth/blob/master/targets/x86/nucleus.fth).
There are also ARM, RISC-V, Motorola 68000, PDP-11, and asm.js
targets. There is a [cross
compiler](http://github.com/larsbrinkhoff/xForth) for 6502, 8051, AVR,
Cortex-M, MSP430, PDP-8, PIC, and STM8.
( Continuous integration )
The code is continuously built and tested in Linux, MacOS X, and
Windows using several cloud-based continuous integration services.
This is documented in [build.md](/larsbrinkhoff/lbForth/blob/master/build.md).
( Further reading )
[INSTALL](/larsbrinkhoff/lbForth/blob/master/INSTALL) \ How to build.
[doc](/larsbrinkhoff/lbForth/blob/master/doc) \ Classic (and recent) texts not related to this project.
[lib/README](/larsbrinkhoff/lbForth/blob/master/lib/README) \ Information about libraries.
[targets/README.md](/larsbrinkhoff/lbForth/blob/master/targets/README.md) \ Information about current and possibly future targets.
( Implementation guide )
The Forth kernel contains everything needed to read and compile the
rest of the system from source code, and not much else. It's composed
of two parts: a target-specific file nucleus.fth containing all
primitive CODE words, and a [target-independent
kernel.fth](/larsbrinkhoff/lbForth/blob/master/src/kernel.fth). These two are compiled by the
metacompiler.
The [C target nucleus](/larsbrinkhoff/lbForth/blob/master/targets/c/nucleus.fth) used for bootstrapping
has only twelve proper primitives. There is also the COLD word which
compiles to main(), and four I/O words.
When the kernel starts, it jumps to the word called WARM. This is
responsible for loading the rest of the system and entering the text
interpreter. The first file loaded by WARM is [core.fth](/larsbrinkhoff/lbForth/blob/master/src/core.fth),
which implements the CORE wordset. Because the kernel only has a bare
minimum of words, the start of core.fth looks a little strange.
## About
Self-hosting metacompiled Forth, bootstrapping from a few lines of C; targets Linux, Windows, ARM, RISC-V, 68000, PDP-11, asm.js.
### Topics
[linux](/topics/linux "Topic: linux")
[programming-language](/topics/programming-language "Topic: programming-language")
[avr](/topics/avr "Topic: avr")
[arm](/topics/arm "Topic: arm")
[interpreter](/topics/interpreter "Topic: interpreter")
[cortex-m](/topics/cortex-m "Topic: cortex-m")
[compiler](/topics/compiler "Topic: compiler")
[self-hosted](/topics/self-hosted "Topic: self-hosted")
[riscv](/topics/riscv "Topic: riscv")
[forth](/topics/forth "Topic: forth")
[x86](/topics/x86 "Topic: x86")
[msp430](/topics/msp430 "Topic: msp430")
[pdp11](/topics/pdp11 "Topic: pdp11")
[metacompiler](/topics/metacompiler "Topic: metacompiler")
[m68k](/topics/m68k "Topic: m68k")
[asmjs](/topics/asmjs "Topic: asmjs")
[6502](/topics/6502 "Topic: 6502")
[risc-v](/topics/risc-v "Topic: risc-v")
[8051](/topics/8051 "Topic: 8051")
### Resources
[Readme](#readme-ov-file)
### License
[GPL-3.0 license](#GPL-3.0-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/larsbrinkhoff/lbForth/activity)
### Stars
[**475**
stars](/larsbrinkhoff/lbForth/stargazers)
### Watchers
[**29**
watching](/larsbrinkhoff/lbForth/watchers)
### Forks
[**112**
forks](/larsbrinkhoff/lbForth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Flarsbrinkhoff%2FlbForth&report=larsbrinkhoff+%28user%29)
## [Releases](/larsbrinkhoff/lbForth/releases)
No releases published
## [Packages 0](/users/larsbrinkhoff/packages?repo_name=lbForth)
No packages published
### Uh oh!
There was an error while loading. Please reload this page.
## [Contributors 4](/larsbrinkhoff/lbForth/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [Forth
96.7%](/larsbrinkhoff/lbForth/search?l=forth)
* [Makefile
1.0%](/larsbrinkhoff/lbForth/search?l=makefile)
* [Emacs Lisp
0.8%](/larsbrinkhoff/lbForth/search?l=emacs-lisp)
* [Shell
0.7%](/larsbrinkhoff/lbForth/search?l=shell)
* [C
0.4%](/larsbrinkhoff/lbForth/search?l=c)
* [HTML
0.2%](/larsbrinkhoff/lbForth/search?l=html)
* Other
0.2%
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,434 @@
# luaforth
**Source:** https://github.com/vifino/luaforth
GitHub - vifino/luaforth: A simple Forth in Lua for embedded usage.
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fvifino%2Fluaforth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fvifino%2Fluaforth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=vifino%2Fluaforth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[vifino](/vifino)
/
**[luaforth](/vifino/luaforth)**
Public
* [Notifications](/login?return_to=%2Fvifino%2Fluaforth) You must be signed in to change notification settings
* [Fork
2](/login?return_to=%2Fvifino%2Fluaforth)
* [Star
6](/login?return_to=%2Fvifino%2Fluaforth)
A simple Forth in Lua for embedded usage.
### License
[MIT license](/vifino/luaforth/blob/master/LICENSE)
[6
stars](/vifino/luaforth/stargazers) [2
forks](/vifino/luaforth/forks) [Branches](/vifino/luaforth/branches) [Tags](/vifino/luaforth/tags) [Activity](/vifino/luaforth/activity)
[Star](/login?return_to=%2Fvifino%2Fluaforth)
[Notifications](/login?return_to=%2Fvifino%2Fluaforth) You must be signed in to change notification settings
* [Code](/vifino/luaforth)
* [Issues
0](/vifino/luaforth/issues)
* [Pull requests
0](/vifino/luaforth/pulls)
* [Actions](/vifino/luaforth/actions)
* [Projects
0](/vifino/luaforth/projects)
* [Security
0](/vifino/luaforth/security)
* [Insights](/vifino/luaforth/pulse)
Additional navigation options
* [Code](/vifino/luaforth)
* [Issues](/vifino/luaforth/issues)
* [Pull requests](/vifino/luaforth/pulls)
* [Actions](/vifino/luaforth/actions)
* [Projects](/vifino/luaforth/projects)
* [Security](/vifino/luaforth/security)
* [Insights](/vifino/luaforth/pulse)
# vifino/luaforth
master
[Branches](/vifino/luaforth/branches)[Tags](/vifino/luaforth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[27 Commits](/vifino/luaforth/commits/master/) 27 Commits | | |
| [bin](/vifino/luaforth/tree/master/bin "bin") | | [bin](/vifino/luaforth/tree/master/bin "bin") | | |
| [tests](/vifino/luaforth/tree/master/tests "tests") | | [tests](/vifino/luaforth/tree/master/tests "tests") | | |
| [.travis.yml](/vifino/luaforth/blob/master/.travis.yml ".travis.yml") | | [.travis.yml](/vifino/luaforth/blob/master/.travis.yml ".travis.yml") | | |
| [LICENSE](/vifino/luaforth/blob/master/LICENSE "LICENSE") | | [LICENSE](/vifino/luaforth/blob/master/LICENSE "LICENSE") | | |
| [Makefile](/vifino/luaforth/blob/master/Makefile "Makefile") | | [Makefile](/vifino/luaforth/blob/master/Makefile "Makefile") | | |
| [README.md](/vifino/luaforth/blob/master/README.md "README.md") | | [README.md](/vifino/luaforth/blob/master/README.md "README.md") | | |
| [app.lua](/vifino/luaforth/blob/master/app.lua "app.lua") | | [app.lua](/vifino/luaforth/blob/master/app.lua "app.lua") | | |
| [auto-run-tests-on-change.sh](/vifino/luaforth/blob/master/auto-run-tests-on-change.sh "auto-run-tests-on-change.sh") | | [auto-run-tests-on-change.sh](/vifino/luaforth/blob/master/auto-run-tests-on-change.sh "auto-run-tests-on-change.sh") | | |
| [luaforth.lua](/vifino/luaforth/blob/master/luaforth.lua "luaforth.lua") | | [luaforth.lua](/vifino/luaforth/blob/master/luaforth.lua "luaforth.lua") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [MIT license](#)
# luaforth
[![Build Status](https://camo.githubusercontent.com/f84f1765e4dc206c95e842195c97624b2fc6309edb929d618d902c914ae3de0e/68747470733a2f2f7472617669732d63692e6f72672f766966696e6f2f6c7561666f7274682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/vifino/luaforth) [![Coverage Status](https://camo.githubusercontent.com/92a923f80497d3e929dddec4c3199009e5b54f47d881a20b0aad9e406593c60b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f766966696e6f2f6c7561666f7274682f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/vifino/luaforth?branch=master)
A simplistic and decently fast base implementation of a Forth parser.
If you expect a fully featured forth here, you're wrong.
This is made for people who want to embed a Forth-like into their project.
# Usage
1. `require`/load luaforth.
2. Create an environment.
3. Call `new_stack, new_environment = luaforth.eval(program_source, environment[, stack, program_source_start_position])`.
Tada!
# Example
See `luaforth.simple_env` [here](https://github.com/vifino/luaforth/blob/master/luaforth.lua#L246-L253) or below.
```
-- Example env that has %L to evaluate the line and [L L] pairs to evaluate a small block of Lua code.
local simple_env = {
["%L"] = {
_fn=function(stack, env, str)
local f, err = loadstring("return " .. str)
if err then
f, err = loadstring(str)
if err then
error(err, 0)
end
end
return f()
end,
_parse = "line"
},
["[L"] = {
_fn=function(stack, env, str)
local f, err = loadstring("return " .. str)
if err then
f, err = loadstring(str)
if err then
error(err, 0)
end
end
return f()
end,
_parse = "endsign",
_endsign = "L]"
}
}
-- Function creation.
luaforth.simple_env[":"] = {
_fn = function(stack, env, fn)
local nme, prg = string.match(fn, "^(.-) (.-)$")
luaforth.simple_env[nme] = {
_fn = function(stack, env)
return luaforth.eval(prg, env, stack)
end,
_fnret = "newstack"
}
end,
_parse = "endsign",
_endsign = ";"
}
```
# Environment
Contains words, strings, booleans, numbers and other things that the forth instance will be able to use.
## Word Structure
Words are Forth jargon for functions.
Look here or below to see how they are structured in this implementation.
```
-- Word structure:
-- env[name] = {
-- _fn = func -- function that runs the logic
-- _fnret = ["pushtostack", "newstack"] -- wether the function's return values should be added to the stack or _be_ the stack. Defaults to pushtostack.
-- _args = n -- number of arguments which are pop'd from the stack, defaults to 0
-- _parse = ["line"|"word"|"endsign"|"pattern"] -- optional advanced parsing, line passes the whole line to the word, word only the next word, pattern parses given pattern, endsign until...
-- _endsign = string -- the given endsign appears.
-- _pattern = pattern -- pattern for parse option
-- }
```
# License
MIT
## About
A simple Forth in Lua for embedded usage.
### Topics
[lua-library](/topics/lua-library "Topic: lua-library")
[lua](/topics/lua "Topic: lua")
[forth](/topics/forth "Topic: forth")
### Resources
[Readme](#readme-ov-file)
### License
[MIT license](#MIT-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/vifino/luaforth/activity)
### Stars
[**6**
stars](/vifino/luaforth/stargazers)
### Watchers
[**2**
watching](/vifino/luaforth/watchers)
### Forks
[**2**
forks](/vifino/luaforth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fvifino%2Fluaforth&report=vifino+%28user%29)
## [Releases](/vifino/luaforth/releases)
No releases published
## [Packages 0](/users/vifino/packages?repo_name=luaforth)
No packages published
## [Contributors 2](/vifino/luaforth/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [Lua
95.7%](/vifino/luaforth/search?l=lua)
* [Forth
3.0%](/vifino/luaforth/search?l=forth)
* Other
1.3%
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,199 @@
# meow5
**Source:** https://ratfactor.com/meow5/
Meow5: An Extremely Concatenative Programming Language - ratfactor
[![vector ratfactor rat logo](/images/rat-logo.svg)](/)
[Home](/) |
[About](/about/) |
[Now](/now) |
[Repos](/repos/) |
[Cards](/cards/) |
[Contact](/contact-me/) |
[RSS![rss feed icon](/images/rss.svg)](/atom.xml)
# Meow5: An Extremely Concatenative Programming Language
Created: 2022-11-10
Updated: 2023-11-21
![meow5 kitty logo is black with two bright teal eyes and a pink nose](meow5.png)
**Update 2023-11-21:** Meow5 is done! [Read my conclusion here!](done)
Meow5 is a ["concatenative"](https://en.wikipedia.org/wiki/Concatenative_programming_language) (wikipedia.org)
programming language. I also consider it to be a "Forth-like" language since it follows the same
stack-based value passing method and borrows some of Forths syntax and nomenclature.
Hello world (in cat):
```
"Meow!" print
Meow!
```
* **The Repo:** [Meow5 Repo](/repos/meow5/)
* **Read more:** [Assembly Nights "Season 2"](../assembly-nights2)
might explain why I would do something like this
**Update 2023-11-01:** Well, would you look at that? Its just shy of a year after I started
this and I think Im actually going to be able to finish [it](done) quite soon.
(To see where Im currently at, scroll down to **Current progress** below.)
Its unique feature is its "inline all the things!" compiling method. A Meow5 function is
the recursively concatenated machine code of every function it calls. At the bottom are "primitive" functions
written in assembly language, which is where the machine code comes from.
Wait, you mean every time I call a function in another function, Im making a complete copy of that
function, which is a complete copy of every function *that* function calls, all the way down?
Yup! Pretty nuts, right? Feel free to run away from this page screaming now.
But when a primitive is just a dozen bytes long, you can make quite a few
copies of it before its a problem. Im very curious to see how it benchmarks
against other languages in various ways: size, speed, cuteness.
## Syntax
Meow5 borrows heavily from the ur-language **Forth**, which was delivered to our dimension by the
prophet Charles H. Moore in the late 1960s.
Creating a new function, `meow`, that prints the string "Meow" looks like this:
```
: meow "Meow." print ;
```
Creating a another function, `meow5`, which executes `meow` five times:
```
: meow5 meow meow meow meow meow ;
```
Invoke their names to call these functions:
```
meow
Meow.
meow5
Meow.Meow.Meow.Meow.Meow.
```
Thats a lot of meows! Whos a hungry kitty?
To drive home an earlier point: the above `meow5` function doesnt just *call* `meow` five times, it actually *contains* five consecutive copies of `meow`!
## Current Progress
Heres a list of milestones reached. The log text file references are from my
devlog files which I write as Im creating Meow5. You can find them in the repo!
(Note to self, when I put the logs up here like I did for [nasmjf](../nasmjf/), link these!)
* (log01.txt) Executing a *copy* of the machine code to print "Meow" at runtime
* (log01.txt) Programatically inlining multiple copies of the "Meow" printer
* (log02.txt) Added function "tail" metadata for linked list dictionary, to use Forth terminology
* (log02.txt) Added `find` function to lookup functions by name for inlining
* (log03.txt) Figured out how to call these machine code chunks so they can return to the call site
* (log03.txt) Have interpreter parsing tokens from a hard-coded input string and executing them
* (log04.txt) Have COMPILE vs IMMEDIATE modes and functions may opt-in for either
* (log05.txt) Using NASM macros to inline functions at the assembly level to build interpreter
* (log05.txt) **Major:** Finished `:` ("colon") and `;` ("semicolon") for function definitions!
* (log06.txt) Added string literals to the language can do this: `"Meow!" print`
* (log06.txt) Have string literals working in *compiled* functions!
* (log06.txt) DEBUG printing (can be inserted anywhere in the assembly)
* (log06.txt) **Major:** The canonical `meow5` function works as shown on this page!
* (log07.txt) Added `str2num` and `num2str` for numeric input/output
* (log07.txt) Have numeric interpolation in strings with `$` placeholders
* (log07.txt) Have string escape sequences (e.g. `\n`)
* (log07.txt) Functions 'inspect' and 'inspect\_all' print all functions with size in bytes
* (log08.txt) **Major:** Reading interpreter input from STDIN!
**TODO:** The above are badly in need of updating and links.
**Update 2023-11-01:** Ive finished the [mez](/repos/mez/) tools in Zig to
help me understand, create, and debug ELF executables and feel fully capable
of finishing the ELF output of Meow5. Lets do this! Also: "failed art project" below
was waaay too harsh. Its going to be a successful art project!
**Update 2023-10-17:** Five months later, Im back. I essentially consider
this to be a failed art project, but I am not willing to let it rest until
it compiles an ELF executable that prints "Meow" five times!
```
>o.o< --"Why yes, I do speak ASCII!"
```
## Technical Details
**32-bit x86 Linux:** Meow5 is written with the NASM assembler (<https://nasm.us/>) and targets the
32-bit i386 (x86) architecture. It makes direct Linux syscalls and uses no external
libraries. Portability is not a goal.
**Stack-oriented:** Meow5 uses the i386 `PUSH` and `POP` instructions in the normal fashion to set/get items
from the stack (a region of memory to which items are added or removed sequentially in
a "first in, last out" fashion). One thing thats neat about this is that alleviates the difficult task of putting
names to data. It also generally produces compact and uncluttered syntax.
<https://en.wikipedia.org/wiki/Stack-oriented_programming>
**Just in Time Compiled:** The moment you start compiling a new function `foo`, its machine code is being
inlined into memory. When you execute `foo`, a `JMP` instruction is issued to its machine code, which then
runs until it hits a chunk of "return code" inlined at the end of the definition, which jumps back to the
call site. It does not use `CALL` and `RET` and there can be only *one* level of direct function call
in this fashion, which, it turns out, is all you need for an interactive Meow5 interpreter.
**Inline All the Things!:** If you use function `foo` in the definition of a new function `bar`, the machine
code of `foo` (not including the "return code" mentioned above or the "tail" with function metadata) is
inlined into `bar`.
The logical conclusion is that a Meow5 **program** is a top-level function containing a continuous
stream of concatenated machine code. What I would like to do at some point is write out such a program
with an ELF header and see if I can make stand-alone Linux executables!
## OpenBSD
I was really curious what OpenBSD would think of this since my understanding is that it
has [W^X (wrote xor execute)](https://en.wikipedia.org/wiki/W%5EX) by default.
Sure enough, even the linker catches this:
```
ld: error: can't create dynamic relocation R_386_32 against local symbol in
readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext'
to allow text relocations in the output
>>> defined in meow5.o
>>> referenced by meow5.asm:167
>>> meow5.o:(tail_strlen)
```
which is in reference to:
```
%macro ENDWORD 3
...
tail_%1:
dd LAST_WORD_TAIL ; <---- this line
```
Where Im putting the address of the previous function in the tail of the
current one to make a linked list.
Im not sure what those two suggested options are. I might try them to see how far I get.
---
I made the SVG Meow5 logo in Inkscape 0.92. It uses the **Sazanami Mincho**
font by Yasuyuki Furukawa.
*Mincho* evidently means something very similar to what 'serif' means in Latin typefaces.
See [Ming typefaces](https://en.wikipedia.org/wiki/Ming_(typefaces)) (wikipedia.org).
This page was last generated 2023-11-21 15:13:54 -0500
All content © Copyright Dave Gauer

View File

@@ -0,0 +1,398 @@
# milliForth
**Source:** https://github.com/fuzzballcat/milliForth
GitHub - fuzzballcat/milliForth: A FORTH in 340 bytes — the smallest real programming language ever as of yet.
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Ffuzzballcat%2FmilliForth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Ffuzzballcat%2FmilliForth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=fuzzballcat%2FmilliForth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[fuzzballcat](/fuzzballcat)
/
**[milliForth](/fuzzballcat/milliForth)**
Public
* [Notifications](/login?return_to=%2Ffuzzballcat%2FmilliForth) You must be signed in to change notification settings
* [Fork
28](/login?return_to=%2Ffuzzballcat%2FmilliForth)
* [Star
623](/login?return_to=%2Ffuzzballcat%2FmilliForth)
A FORTH in 340 bytes — the smallest real programming language ever as of yet.
### License
[MIT license](/fuzzballcat/milliForth/blob/master/LICENSE)
[623
stars](/fuzzballcat/milliForth/stargazers) [28
forks](/fuzzballcat/milliForth/forks) [Branches](/fuzzballcat/milliForth/branches) [Tags](/fuzzballcat/milliForth/tags) [Activity](/fuzzballcat/milliForth/activity)
[Star](/login?return_to=%2Ffuzzballcat%2FmilliForth)
[Notifications](/login?return_to=%2Ffuzzballcat%2FmilliForth) You must be signed in to change notification settings
* [Code](/fuzzballcat/milliForth)
* [Issues
6](/fuzzballcat/milliForth/issues)
* [Pull requests
1](/fuzzballcat/milliForth/pulls)
* [Actions](/fuzzballcat/milliForth/actions)
* [Projects
0](/fuzzballcat/milliForth/projects)
* [Security
0](/fuzzballcat/milliForth/security)
* [Insights](/fuzzballcat/milliForth/pulse)
Additional navigation options
* [Code](/fuzzballcat/milliForth)
* [Issues](/fuzzballcat/milliForth/issues)
* [Pull requests](/fuzzballcat/milliForth/pulls)
* [Actions](/fuzzballcat/milliForth/actions)
* [Projects](/fuzzballcat/milliForth/projects)
* [Security](/fuzzballcat/milliForth/security)
* [Insights](/fuzzballcat/milliForth/pulse)
# fuzzballcat/milliForth
master
[Branches](/fuzzballcat/milliForth/branches)[Tags](/fuzzballcat/milliForth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[42 Commits](/fuzzballcat/milliForth/commits/master/) 42 Commits | | |
| [.gitignore](/fuzzballcat/milliForth/blob/master/.gitignore ".gitignore") | | [.gitignore](/fuzzballcat/milliForth/blob/master/.gitignore ".gitignore") | | |
| [LICENSE](/fuzzballcat/milliForth/blob/master/LICENSE "LICENSE") | | [LICENSE](/fuzzballcat/milliForth/blob/master/LICENSE "LICENSE") | | |
| [README.md](/fuzzballcat/milliForth/blob/master/README.md "README.md") | | [README.md](/fuzzballcat/milliForth/blob/master/README.md "README.md") | | |
| [bf.FORTH](/fuzzballcat/milliForth/blob/master/bf.FORTH "bf.FORTH") | | [bf.FORTH](/fuzzballcat/milliForth/blob/master/bf.FORTH "bf.FORTH") | | |
| [hello\_world.FORTH](/fuzzballcat/milliForth/blob/master/hello_world.FORTH "hello_world.FORTH") | | [hello\_world.FORTH](/fuzzballcat/milliForth/blob/master/hello_world.FORTH "hello_world.FORTH") | | |
| [makefile](/fuzzballcat/milliForth/blob/master/makefile "makefile") | | [makefile](/fuzzballcat/milliForth/blob/master/makefile "makefile") | | |
| [py\_autotype.py](/fuzzballcat/milliForth/blob/master/py_autotype.py "py_autotype.py") | | [py\_autotype.py](/fuzzballcat/milliForth/blob/master/py_autotype.py "py_autotype.py") | | |
| [sector.asm](/fuzzballcat/milliForth/blob/master/sector.asm "sector.asm") | | [sector.asm](/fuzzballcat/milliForth/blob/master/sector.asm "sector.asm") | | |
| [sector.bin](/fuzzballcat/milliForth/blob/master/sector.bin "sector.bin") | | [sector.bin](/fuzzballcat/milliForth/blob/master/sector.bin "sector.bin") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [MIT license](#)
# milliForth
A FORTH in 336 bytes — the smallest real programming language ever, as of yet.
[![milliFORTH_justhelloworld](https://private-user-images.githubusercontent.com/57006511/280563430-ef3d48cf-1581-4574-8625-8d97b00acaca.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzE1MzU2MzMsIm5iZiI6MTc3MTUzNTMzMywicGF0aCI6Ii81NzAwNjUxMS8yODA1NjM0MzAtZWYzZDQ4Y2YtMTU4MS00NTc0LTg2MjUtOGQ5N2IwMGFjYWNhLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMjE5VDIxMDg1M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcxNDY0NDE3Y2Y5ZDJlNzZjODJmMzg3Y2UxOTc0YzZkMmRkNTAxYzlhNjlmMzY0M2QwNTI1ZmFlNWZmN2I3MzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.i685Rg4zicP8T5zIc3OkurV6p1baueZnnnr_PEWah3c)](https://private-user-images.githubusercontent.com/57006511/280563430-ef3d48cf-1581-4574-8625-8d97b00acaca.gif?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzE1MzU2MzMsIm5iZiI6MTc3MTUzNTMzMywicGF0aCI6Ii81NzAwNjUxMS8yODA1NjM0MzAtZWYzZDQ4Y2YtMTU4MS00NTc0LTg2MjUtOGQ5N2IwMGFjYWNhLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjAyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwMjE5VDIxMDg1M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcxNDY0NDE3Y2Y5ZDJlNzZjODJmMzg3Y2UxOTc0YzZkMmRkNTAxYzlhNjlmMzY0M2QwNTI1ZmFlNWZmN2I3MzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.i685Rg4zicP8T5zIc3OkurV6p1baueZnnnr_PEWah3c)
*The code in the above gif, that of [an older version of] `hello_world.FORTH`, is a modified version of the hello world program used by sectorFORTH (see below)*
## bytes?
Yes, bytes. This is a FORTH so small it fits in a 512-byte boot sector. This isn't new — sectorFORTH[1](#user-content-fn-1-d37e1f81f2eea8c6e7bde869760db32c) successfully fit a FORTH within the boot sector. However, milliFORTH appears to be *the smallest* "real" programming language implementation ever, beating out sectorLISP[2](#user-content-fn-2-d37e1f81f2eea8c6e7bde869760db32c), a mind-blowing 436 byte implementation of LISP, by 96 bytes. ("real" excludes esolangs and other non-production languages - for example, the sectorLISP author's implementation of BF is just 99 bytes, but it clearly isn't used to any serious capacity.) It's now even smaller thanks to some really neat suggestions!
## Is it turing-complete?
Yes! This project now includes `bf.FORTH`, a compliant brainfuck interpreter, to illlustrate that this is truly a real language.
## Language
sectorFORTH[1](#user-content-fn-1-d37e1f81f2eea8c6e7bde869760db32c) was an extensive guide throughout the process of implementing milliFORTH, and milliFORTH's design actually converged on sectorFORTH unintentionally in a few areas. That said, the language implemented is intentionally very similar, being the 'minimal FORTH'.
FORTH itself will not be explained here (prior understanding assumed). Being so small, milliFORTH contains just a handful of words:
| Word | Signature | Function |
| --- | --- | --- |
| `@` | `( addr -- value )` | Get a value at an address |
| `!` | `( value addr -- )` | Store a value at an address |
| `sp@` | `( -- sp )` | Get pointer to top of the data stack |
| `rp@` | `( -- rp )` | Get pointer to top of the return stack |
| `0#` | `( value -- flag )` | Check if a value does not equal zero (-1 = TRUE, 0 = FALSE) |
| `+` | `( a b -- a+b )` | Sum two numbers |
| `nand` | `( a b -- aNANDb )` | NAND two numbers |
| `exit` | `( r:addr -- )` | Pop from the return stack, resume execution at the popped address |
| `key` | `( -- key )` | Read a keystroke |
| `emit` | `( char -- )` | Print out an ASCII character |
| `s@` | `( -- s@ )` | The "state struct" pointer. The cells of this struct are, in order: * `state`: The state of the interpreter (0 = compile words, 1 = execute words) * `>in`: Pointer to the current offset into the terminal input buffer * `latest`: The pointer to the most recent dictionary space * `here`: The pointer to the next available space in the dictionary |
On a fundamental level, milliFORTH the same FORTH as implemented by sectorFORTH, with a few modifications:
* All of the interpreter state words are bundled into a single struct (`s@`).
* Words don't get hidden while you are defining them. This doesn't really hinder your actual ability to write programs, but rather makes it possible to hang the interpreter if you do something wrong in this respect.
* There's no `tib` (terminal input buffer) word, because `tib` always starts at `0x0000`, so you can just use `>in` and don't need to add anything to it.
* In the small (production) version, the delete key doesn't work. I think this is fair since sectorLISP doesn't handle backspace either; even if you add it back, milliFORTH is still smaller by a few bytes.
* Error handling is even sparser. Successful input results in nothing (no familiar `ok.`). Erroneous input prints an extra blank line between the previous input and the next prompt.
## Use
sector.bin is an assembled binary of sector.asm. You can run it using `make emulate`, which invokes (and thus requires) `qemu-system-i386`, or by using any emulator of your choice.
Alternatively, `make` will reassemble sector.asm, then run the above qemu emulator.
Additionally, you can run an example file easily by running `make runfile file=SOURCE_CODE`. Try out `make runfile file=hello_world.FORTH` or `make runfile file=bf.FORTH`! *NOTE: Files run this way currently do not accept user input from stdin, as the file itself is being piped to qemu. Fix coming shortly.*
`make sizecheck` is a utility which assembles sector.asm into sector.bin and then lists out the size of sector.bin for you. Note that this automatically removes the padding from the .bin (as a working bootloader must be exactly 512 bytes).
## References
## Footnotes
1. The immensely inspirational sectorForth, to which much credit is due: <https://github.com/cesarblum/sectorforth/>. [](#user-content-fnref-1-d37e1f81f2eea8c6e7bde869760db32c) [↩2](#user-content-fnref-1-2-d37e1f81f2eea8c6e7bde869760db32c)
2. Mind-blowing sectorLISP: <https://justine.lol/sectorlisp2/>, <https://github.com/jart/sectorlisp>. [](#user-content-fnref-2-d37e1f81f2eea8c6e7bde869760db32c)
## About
A FORTH in 340 bytes — the smallest real programming language ever as of yet.
### Resources
[Readme](#readme-ov-file)
### License
[MIT license](#MIT-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/fuzzballcat/milliForth/activity)
### Stars
[**623**
stars](/fuzzballcat/milliForth/stargazers)
### Watchers
[**10**
watching](/fuzzballcat/milliForth/watchers)
### Forks
[**28**
forks](/fuzzballcat/milliForth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Ffuzzballcat%2FmilliForth&report=fuzzballcat+%28user%29)
## [Releases](/fuzzballcat/milliForth/releases)
No releases published
## [Packages 0](/users/fuzzballcat/packages?repo_name=milliForth)
No packages published
## [Contributors 2](/fuzzballcat/milliForth/graphs/contributors)
* [![@fuzzballcat](https://avatars.githubusercontent.com/u/57006511?s=64&v=4)](https://github.com/fuzzballcat)
[**fuzzballcat**](https://github.com/fuzzballcat)
* [![@peterferrie](https://avatars.githubusercontent.com/u/7152307?s=64&v=4)](https://github.com/peterferrie)
[**peterferrie**
Peter Ferrie](https://github.com/peterferrie)
## Languages
* [Forth
53.5%](/fuzzballcat/milliForth/search?l=forth)
* [Assembly
34.9%](/fuzzballcat/milliForth/search?l=assembly)
* [Makefile
6.8%](/fuzzballcat/milliForth/search?l=makefile)
* [Python
4.8%](/fuzzballcat/milliForth/search?l=python)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,543 @@
# pforth
**Source:** https://github.com/philburk/pforth
GitHub - philburk/pforth: Portable Forth in C
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fphilburk%2Fpforth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fphilburk%2Fpforth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=philburk%2Fpforth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[philburk](/philburk)
/
**[pforth](/philburk/pforth)**
Public
* [Notifications](/login?return_to=%2Fphilburk%2Fpforth) You must be signed in to change notification settings
* [Fork
114](/login?return_to=%2Fphilburk%2Fpforth)
* [Star
684](/login?return_to=%2Fphilburk%2Fpforth)
Portable Forth in C
### License
[0BSD license](/philburk/pforth/blob/master/license.txt)
[684
stars](/philburk/pforth/stargazers) [114
forks](/philburk/pforth/forks) [Branches](/philburk/pforth/branches) [Tags](/philburk/pforth/tags) [Activity](/philburk/pforth/activity)
[Star](/login?return_to=%2Fphilburk%2Fpforth)
[Notifications](/login?return_to=%2Fphilburk%2Fpforth) You must be signed in to change notification settings
* [Code](/philburk/pforth)
* [Issues
26](/philburk/pforth/issues)
* [Pull requests
5](/philburk/pforth/pulls)
* [Discussions](/philburk/pforth/discussions)
* [Actions](/philburk/pforth/actions)
* [Projects
0](/philburk/pforth/projects)
* [Wiki](/philburk/pforth/wiki)
* [Security
0](/philburk/pforth/security)
* [Insights](/philburk/pforth/pulse)
Additional navigation options
* [Code](/philburk/pforth)
* [Issues](/philburk/pforth/issues)
* [Pull requests](/philburk/pforth/pulls)
* [Discussions](/philburk/pforth/discussions)
* [Actions](/philburk/pforth/actions)
* [Projects](/philburk/pforth/projects)
* [Wiki](/philburk/pforth/wiki)
* [Security](/philburk/pforth/security)
* [Insights](/philburk/pforth/pulse)
# philburk/pforth
master
[Branches](/philburk/pforth/branches)[Tags](/philburk/pforth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[219 Commits](/philburk/pforth/commits/master/) 219 Commits | | |
| [.github/workflows](/philburk/pforth/tree/master/.github/workflows "This path skips through empty directories") | | [.github/workflows](/philburk/pforth/tree/master/.github/workflows "This path skips through empty directories") | | |
| [csrc](/philburk/pforth/tree/master/csrc "csrc") | | [csrc](/philburk/pforth/tree/master/csrc "csrc") | | |
| [fth](/philburk/pforth/tree/master/fth "fth") | | [fth](/philburk/pforth/tree/master/fth "fth") | | |
| [platforms](/philburk/pforth/tree/master/platforms "platforms") | | [platforms](/philburk/pforth/tree/master/platforms "platforms") | | |
| [.gitattributes](/philburk/pforth/blob/master/.gitattributes ".gitattributes") | | [.gitattributes](/philburk/pforth/blob/master/.gitattributes ".gitattributes") | | |
| [.gitignore](/philburk/pforth/blob/master/.gitignore ".gitignore") | | [.gitignore](/philburk/pforth/blob/master/.gitignore ".gitignore") | | |
| [.travis.yml](/philburk/pforth/blob/master/.travis.yml ".travis.yml") | | [.travis.yml](/philburk/pforth/blob/master/.travis.yml ".travis.yml") | | |
| [CMakeLists.txt](/philburk/pforth/blob/master/CMakeLists.txt "CMakeLists.txt") | | [CMakeLists.txt](/philburk/pforth/blob/master/CMakeLists.txt "CMakeLists.txt") | | |
| [README.md](/philburk/pforth/blob/master/README.md "README.md") | | [README.md](/philburk/pforth/blob/master/README.md "README.md") | | |
| [RELEASES.md](/philburk/pforth/blob/master/RELEASES.md "RELEASES.md") | | [RELEASES.md](/philburk/pforth/blob/master/RELEASES.md "RELEASES.md") | | |
| [license.txt](/philburk/pforth/blob/master/license.txt "license.txt") | | [license.txt](/philburk/pforth/blob/master/license.txt "license.txt") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [License](#)
# PForth - a Portable ANS-like Forth written in ANSI 'C'
by Phil Burk
with Larry Polansky, David Rosenboom and Darren Gibbs.
Support for 64-bit cells by Aleksej Saushev.
Portable Forth written in 'C' for most 32 and 64-bit platforms.
PForth is written in 'C' and can be easily ported to new 32 and 64-bit platforms.
It only needs character input and output functions to operate and, therefore, does not require an operating system.
This makes it handy for bringing up and testing embedded systems.
PForth also works on desktops including Windows, Mac and Linux and supports command line history.
This lets you develop hardware tests on a desktop before trying them on your embedded system.
But pForth is not a rich and friendly desktop programming environment.
There are no GUI tools for developing desktop applications. PForth is lean and mean and optimized for portability.
PForth has a tool for compiling code on a desktop, then exporting the dictionary in big or little endian format as 'C' source code.
This lets you compile tests for an embedded system that does not have file I/O.
PForth is based on ANSI-Forth but is not 100% compatible. <https://forth-standard.org/standard/words>
Code for pForth is maintained on GitHub at: <https://github.com/philburk/pforth>
Documentation for pForth at: <http://www.softsynth.com/pforth/>
To report bugs or request features please file a GitHub Issue.
For questions or general discussion please use the pForth forum at:
<http://groups.google.com/group/pforthdev>
## LEGAL NOTICE
Permission to use, copy, modify, and/or distribute this
software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
## Contents of SDK
```
platforms - tools for building pForth on various platforms
platforms/unix - Makefile for unix
csrc - pForth kernel in ANSI 'C'
csrc/pf_main.c - main() application for a standalone Forth
csrc/stdio - I/O code using basic stdio for generic platforms
csrc/posix - I/O code for Posix platform
csrc/win32 - I/O code for basic WIN32 platform
csrc/win32_console - I/O code for WIN32 console that supports command line history
fth - Forth code
fth/util - utility functions
```
## How to Build pForth
Building pForth involves two steps:
1. building the C based Forth kernel
2. building the Forth dictionary file using: ./pforth -i system.fth
3. optional build of standalone executable with built-in dictionary
We have provided build scripts to simplify this process.
On Unix and MacOS using Makefile:
```
cd platforms/unix
make all
./pforth_standalone
```
For more details, see the [Wiki](https://github.com/philburk/pforth/wiki/Compiling-on-Unix)
Please note that this can help with other platforms as well, see platforms/zig-crossbuild/ for an example.
Using CMake:
```
cmake .
make
cd fth
./pforth_standalone
```
For embedded systems, see the pForth reference manual at:
<http://www.softsynth.com/pforth/pf_ref.php>
## How to Run pForth
To run the all-in-one pForth enter:
```
./pforth_standalone
```
OR, to run using the dictionary file, enter:
```
./pforth
```
Quick check of Forth:
```
3 4 + .
words
bye
```
To compile source code files use:
```
INCLUDE filename
```
To create a custom dictionary enter in pForth:
```
c" newfilename.dic" SAVE-FORTH
```
The name must end in ".dic".
To run PForth with the new dictionary enter in the shell:
```
pforth -dnewfilename.dic
```
To run PForth and automatically include a forth file:
pforth myprogram.fth
## How to Test pForth
PForth comes with a small test suite. To test the Core words,
you can use the coretest developed by John Hayes.
On Unix and MacOS using Makefile:
```
cd platforms/unix
make test
```
Using CMake:
```
cmake .
make
cd fth
./pforth
include tester.fth
include coretest.fth
```
To run the other tests, enter:
```
pforth t_corex.fth
pforth t_strings.fth
pforth t_locals.fth
pforth t_alloc.fth
```
They will report the number of tests that pass or fail.
You can also test pForth kernel without loading a dictionary using option "-i".
Only the primitive words defined in C will be available.
This might be necessary if the dictionary can't be built.
```
./pforth -i
3 4 + .
23 77 swap .s
loadsys
```
## About
Portable Forth in C
### Topics
[c](/topics/c "Topic: c")
[forth](/topics/forth "Topic: forth")
### Resources
[Readme](#readme-ov-file)
### License
[0BSD license](#0BSD-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/philburk/pforth/activity)
### Stars
[**684**
stars](/philburk/pforth/stargazers)
### Watchers
[**42**
watching](/philburk/pforth/watchers)
### Forks
[**114**
forks](/philburk/pforth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fphilburk%2Fpforth&report=philburk+%28user%29)
## [Releases 2](/philburk/pforth/releases)
[v2.0.1
Latest
Jan 9, 2023](/philburk/pforth/releases/tag/v2.0.1)
[+ 1 release](/philburk/pforth/releases)
## [Packages 0](/users/philburk/packages?repo_name=pforth)
No packages published
### Uh oh!
There was an error while loading. Please reload this page.
## [Contributors 17](/philburk/pforth/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
[+ 3 contributors](/philburk/pforth/graphs/contributors)
## Languages
* [C
51.6%](/philburk/pforth/search?l=c)
* [Forth
43.7%](/philburk/pforth/search?l=forth)
* [Makefile
3.7%](/philburk/pforth/search?l=makefile)
* Other
1.0%
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,590 @@
# zForth
**Source:** https://github.com/zevv/zForth
GitHub - zevv/zForth: zForth: tiny, embeddable, flexible, compact Forth scripting language for embedded systems
[Skip to content](#start-of-content)
## Navigation Menu
Toggle navigation
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fzevv%2FzForth)
Appearance settings
* Platform
+ AI CODE CREATION
- [GitHub CopilotWrite better code with AI](https://github.com/features/copilot)
- [GitHub SparkBuild and deploy intelligent apps](https://github.com/features/spark)
- [GitHub ModelsManage and compare prompts](https://github.com/features/models)
- [MCP RegistryNewIntegrate external tools](https://github.com/mcp)
+ DEVELOPER WORKFLOWS
- [ActionsAutomate any workflow](https://github.com/features/actions)
- [CodespacesInstant dev environments](https://github.com/features/codespaces)
- [IssuesPlan and track work](https://github.com/features/issues)
- [Code ReviewManage code changes](https://github.com/features/code-review)
+ APPLICATION SECURITY
- [GitHub Advanced SecurityFind and fix vulnerabilities](https://github.com/security/advanced-security)
- [Code securitySecure your code as you build](https://github.com/security/advanced-security/code-security)
- [Secret protectionStop leaks before they start](https://github.com/security/advanced-security/secret-protection)
+ EXPLORE
- [Why GitHub](https://github.com/why-github)
- [Documentation](https://docs.github.com)
- [Blog](https://github.blog)
- [Changelog](https://github.blog/changelog)
- [Marketplace](https://github.com/marketplace)
[View all features](https://github.com/features)
* Solutions
+ BY COMPANY SIZE
- [Enterprises](https://github.com/enterprise)
- [Small and medium teams](https://github.com/team)
- [Startups](https://github.com/enterprise/startups)
- [Nonprofits](https://github.com/solutions/industry/nonprofits)
+ BY USE CASE
- [App Modernization](https://github.com/solutions/use-case/app-modernization)
- [DevSecOps](https://github.com/solutions/use-case/devsecops)
- [DevOps](https://github.com/solutions/use-case/devops)
- [CI/CD](https://github.com/solutions/use-case/ci-cd)
- [View all use cases](https://github.com/solutions/use-case)
+ BY INDUSTRY
- [Healthcare](https://github.com/solutions/industry/healthcare)
- [Financial services](https://github.com/solutions/industry/financial-services)
- [Manufacturing](https://github.com/solutions/industry/manufacturing)
- [Government](https://github.com/solutions/industry/government)
- [View all industries](https://github.com/solutions/industry)
[View all solutions](https://github.com/solutions)
* Resources
+ EXPLORE BY TOPIC
- [AI](https://github.com/resources/articles?topic=ai)
- [Software Development](https://github.com/resources/articles?topic=software-development)
- [DevOps](https://github.com/resources/articles?topic=devops)
- [Security](https://github.com/resources/articles?topic=security)
- [View all topics](https://github.com/resources/articles)
+ EXPLORE BY TYPE
- [Customer stories](https://github.com/customer-stories)
- [Events & webinars](https://github.com/resources/events)
- [Ebooks & reports](https://github.com/resources/whitepapers)
- [Business insights](https://github.com/solutions/executive-insights)
- [GitHub Skills](https://skills.github.com)
+ SUPPORT & SERVICES
- [Documentation](https://docs.github.com)
- [Customer support](https://support.github.com)
- [Community forum](https://github.com/orgs/community/discussions)
- [Trust center](https://github.com/trust-center)
- [Partners](https://github.com/partners)
* Open Source
+ COMMUNITY
- [GitHub SponsorsFund open source developers](https://github.com/sponsors)
+ PROGRAMS
- [Security Lab](https://securitylab.github.com)
- [Maintainer Community](https://maintainers.github.com)
- [Accelerator](https://github.com/accelerator)
- [Archive Program](https://archiveprogram.github.com)
+ REPOSITORIES
- [Topics](https://github.com/topics)
- [Trending](https://github.com/trending)
- [Collections](https://github.com/collections)
* Enterprise
+ ENTERPRISE SOLUTIONS
- [Enterprise platformAI-powered developer platform](https://github.com/enterprise)
+ AVAILABLE ADD-ONS
- [GitHub Advanced SecurityEnterprise-grade security features](https://github.com/security/advanced-security)
- [Copilot for BusinessEnterprise-grade AI features](https://github.com/features/copilot/copilot-business)
- [Premium SupportEnterprise-grade 24/7 support](https://github.com/premium-support)
* [Pricing](https://github.com/pricing)
Search or jump to...
# Search code, repositories, users, issues, pull requests...
Search
Clear
[Search syntax tips](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax)
# Provide feedback
We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
# Saved searches
## Use saved searches to filter your results more quickly
Name
Query
To see all available qualifiers, see our [documentation](https://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax).
Cancel
Create saved search
[Sign in](/login?return_to=https%3A%2F%2Fgithub.com%2Fzevv%2FzForth)
[Sign up](/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=zevv%2FzForth)
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
[zevv](/zevv)
/
**[zForth](/zevv/zForth)**
Public
* [Notifications](/login?return_to=%2Fzevv%2FzForth) You must be signed in to change notification settings
* [Fork
57](/login?return_to=%2Fzevv%2FzForth)
* [Star
408](/login?return_to=%2Fzevv%2FzForth)
zForth: tiny, embeddable, flexible, compact Forth scripting language for embedded systems
### License
[MIT license](/zevv/zForth/blob/master/LICENSE)
[408
stars](/zevv/zForth/stargazers) [57
forks](/zevv/zForth/forks) [Branches](/zevv/zForth/branches) [Tags](/zevv/zForth/tags) [Activity](/zevv/zForth/activity)
[Star](/login?return_to=%2Fzevv%2FzForth)
[Notifications](/login?return_to=%2Fzevv%2FzForth) You must be signed in to change notification settings
* [Code](/zevv/zForth)
* [Issues
1](/zevv/zForth/issues)
* [Pull requests
2](/zevv/zForth/pulls)
* [Actions](/zevv/zForth/actions)
* [Projects
0](/zevv/zForth/projects)
* [Security
0](/zevv/zForth/security)
* [Insights](/zevv/zForth/pulse)
Additional navigation options
* [Code](/zevv/zForth)
* [Issues](/zevv/zForth/issues)
* [Pull requests](/zevv/zForth/pulls)
* [Actions](/zevv/zForth/actions)
* [Projects](/zevv/zForth/projects)
* [Security](/zevv/zForth/security)
* [Insights](/zevv/zForth/pulse)
# zevv/zForth
master
[Branches](/zevv/zForth/branches)[Tags](/zevv/zForth/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | | Name | Last commit message | Last commit date |
| --- | --- | --- | --- | --- |
| Latest commit History[141 Commits](/zevv/zForth/commits/master/) 141 Commits | | |
| [.github/workflows](/zevv/zForth/tree/master/.github/workflows "This path skips through empty directories") | | [.github/workflows](/zevv/zForth/tree/master/.github/workflows "This path skips through empty directories") | | |
| [forth](/zevv/zForth/tree/master/forth "forth") | | [forth](/zevv/zForth/tree/master/forth "forth") | | |
| [src](/zevv/zForth/tree/master/src "src") | | [src](/zevv/zForth/tree/master/src "src") | | |
| [.gitattributes](/zevv/zForth/blob/master/.gitattributes ".gitattributes") | | [.gitattributes](/zevv/zForth/blob/master/.gitattributes ".gitattributes") | | |
| [.gitignore](/zevv/zForth/blob/master/.gitignore ".gitignore") | | [.gitignore](/zevv/zForth/blob/master/.gitignore ".gitignore") | | |
| [LICENSE](/zevv/zForth/blob/master/LICENSE "LICENSE") | | [LICENSE](/zevv/zForth/blob/master/LICENSE "LICENSE") | | |
| [Makefile](/zevv/zForth/blob/master/Makefile "Makefile") | | [Makefile](/zevv/zForth/blob/master/Makefile "Makefile") | | |
| [README.md](/zevv/zForth/blob/master/README.md "README.md") | | [README.md](/zevv/zForth/blob/master/README.md "README.md") | | |
| [zforth.png](/zevv/zForth/blob/master/zforth.png "zforth.png") | | [zforth.png](/zevv/zForth/blob/master/zforth.png "zforth.png") | | |
| View all files | | |
## Repository files navigation
* [README](#)
* [MIT license](#)
[![zForth](/zevv/zForth/raw/master/zforth.png)](/zevv/zForth/blob/master/zforth.png)
# zForth
From Wikipedia:
*A Forth environment combines the compiler with an interactive shell, where
the user defines and runs subroutines called words. Words can be tested,
redefined, and debugged as the source is entered without recompiling or
restarting the whole program. All syntactic elements, including variables
and basic operators are defined as words. Forth environments vary in how the
resulting program is stored, but ideally running the program has the same
effect as manually re-entering the source.*
zForth is yet another Forth, but with some special features not found in most
other forths. Note that zForth was written for engineers, not for language
purists or Forth aficionados. Its main intention is to be a lightweight
scripting language for extending embedded applications on small
microprocessors. It is not particularly fast, but should be easy to integrate
on any platform with a few kB's of ROM and RAM.
Also note that zForth is just *a* forth, but does not specifically implement or
care about any of the standards like ANS Forth - the kernel might or might not
behave as the standard, and the current standard library is rather limited.
For a lot of programmers Forth seems to belong to the domain of alien
languages: it does not look like any mainstream language most people encounter,
and is built on a number of philosophies that takes some time to get used to.
Still, it is one of the more efficient ways of bringing a interpreter and
compiler to a platform with restricted resources.
Some of zForth's highlights:
* **Small dictionary**: instead of relying on a fixed cell size, the dictionary is
written in variable length cells: small and common numbers take less space
then larger, resulting in 30% to 50% space saving
* **Portable**: zForth is written in 100% ANSI C, and runs on virtually all
operating systems and all architectures. Tested on x86 Linux/Win32/MS-DOS
(Turbo-C 1.0!), x86\_64, ARM, ARM thumb, MIPS, Atmel AVR and the 8051.
* **Small footprint**: the kernel C code compiles to about 3 or 4 kB of machine
code, depending on the architecture and chosen cell data types.
* **Support for multiple instances**: The compiler and VM state is stored in a
struct, allowing multiple instances of zForth to run in parallel.
* **Tracing**: zForth is able to show a nice trace of what it is doing under the
hood, see below for an example.
* **VM**: Implemented as a small virtual machine: not the fastest, but safe and
flexible. Instead of having direct access to host memory, the forth VM memory
is abstracted, allowing proper boundary checking on memory accesses and stack
operations.
* **Flexible data types**: at compile time the user is free to choose what C data
type should be used for the dictionary and the stacks. zForth supports signed
integer sizes from 16 to 128 bit, but also works seamlessly with floating point
types like float and double (or even the C99 'complex' type!)
* **Ease interfacing**: calling C code from forth is easy through a host system
call primitive, and code has access to the stack for exchanging data between
Forth and C. Calling forth from C is easy, just one function to evaluate forth
code.
# Source layout
```
./forth : core zforth library and various snippets and examples
./src/zforth : zfort core source; embed these into your program
./src/linux : example linux application
./src/atmega8 : example AVR atmega8 application
```
# Usage
zForth consists of only two files: zforth.c and zforth.h. Add both to your
project and call `zf_init()` and `zf_bootstrap()` during initialisation. Read
forth statements from a file or terminal and pass the strings to `zf_eval()` to
interpret, compile and run the code. Check the embedded documentation in
`zforth.h` for details.
`zforth.c` depends on a number preprocessor constants for configuration which
you can choose to fit your needs. Documentation is included in the file
`zfconf.h`.
A demo application for running zForth in linux is provided here, simply run `make`
to build.
To start zForth and load the core forth code, run:
```
./src/linux/zforth forth/core.zf
```
And zForth will welcome you with the startup message:
```
Welcome to zForth, 786 bytes used
```
zForth is now ready to use. Try some of the following:
Adding one and one or calculate the 144 squared:
```
1 1 + .
144 dup * .
```
Print the sine of 10 numbers between 0 and PI
```
: pi 3.141592654 ;
: demo pi 0 do i sin . pi 10 / loop+ ;
demo
```
Load and run the demo Mandelbrot fractal:
```
include forth/mandel.zf
.........................----.....................
.....................----+--......................
.......................--*-.......................
........................- --.....--...............
...........----........--%---------...............
............-------------#---------...............
.............------------ ---------...............
.............------------ ---------...............
..............---------o o--------..............
..............---------o =----------------------
.............----o-oo =o-=--------------..
...........-------# *------------.....
........--------=-= o-=--------.......
....--------------= =---------........
......-------------+ +---------.........
.......-------------=# %=-----------........
........--------=- -=--------.......
.......------= =------------
.....---o = = =-------
--------- --------
---------o+ +o--------
---------o =--------
---=#=# = = #=#=--
---= =--
-=- + + ==
o---oo*== -=*=o---
---------= =--------
---------#= =#--------
-----------% %------....
---...----= =% - #= =----.....
.......---=o----* =+*---------*+- *----o=----.....
........--------------------------------------....
```
# Tracing
zForth can write verbose traces of the code it is compiling and running. To enable
tracing, run `./zforth` with the `-t` argument. Tracing can be enabled at run time
by writing `1` in the `trace` variable:
```
1 trace !
```
Make sure the feature ZF\_ENABLE\_TRACING is enabled in zfconf.h to compile in
tracing support.
The following symbols are used:
* stack operations are prefixed with a double arrow, `«` means pop, `»` means push.
for operations on the return stack the arrow is prefixed with an `r`
* the current word being executed is shown in square brackets, the format
is `[<name>/<address>]`
* lines starting with a + show values being added to the dictionary
* lines starting with a space show the current line being executed, format
`<address> <data>`
* lines starting with `===` show the creation of a new word
```
: square dup * ;
: test 5 square . ;
test
```
Executing the word `test`:
```
test
r»0
[test/0326]
0326 0001 ┊ (lit) »5
0328 031c ┊ square/031c r»810
031c 000b ┊ ┊ (dup) «5 »5 »5
031d 0007 ┊ ┊ (*) «5 «5 »25
031e 0000 ┊ ┊ (exit) r«810
032a 0133 ┊ ./0133 r»812
0133 0001 ┊ ┊ (lit) »1
0135 0019 ┊ ┊ (sys) «1 «25
0136 0000 ┊ ┊ (exit) r«812
032c 0000 ┊ (exit) r«0 25
```
This is the trace of the definition of the `square` and `test` words
```
: square dup * ;
r»0
[:/002c]
002c 0003 ┊ (:)
002c 0003 ┊ (:)
=== create 'square'
+0313 0006 ¹
+0314 02eb ²
+0316 0000 s 'square'
===
002d 0000 ┊ (exit) r«0
+031c 000b ¹ +dup
+031d 0007 ¹ +*r»0
[;/0031]
0031 0004 ┊ (;)
+031e 0000 ¹ +exit
===
0032 0000 ┊ (exit) r«0
: test 5 square . ;
r»0
[:/002c]
002c 0003 ┊ (:)
002c 0003 ┊ (:)
=== create 'test'
+031f 0004 ¹
+0320 0313 ²
+0322 0000 s 'test'
===
002d 0000 ┊ (exit) r«0
+0326 0001 ¹ +lit
+0327 0005 ¹
+0328 031c ² +square
+032a 0133 ² +.r»0
[;/0031]
0031 0004 ┊ (;)
+032c 0000 ¹ +exit
===
0032 0000 ┊ (exit) r«0
```
### Dependencies
The zForth core itself has no external dependencies, the linux example depends on libreadline-dev.
## About
zForth: tiny, embeddable, flexible, compact Forth scripting language for embedded systems
### Topics
[scripting-language](/topics/scripting-language "Topic: scripting-language")
[forth](/topics/forth "Topic: forth")
### Resources
[Readme](#readme-ov-file)
### License
[MIT license](#MIT-1-ov-file)
### Uh oh!
There was an error while loading. Please reload this page.
[Activity](/zevv/zForth/activity)
### Stars
[**408**
stars](/zevv/zForth/stargazers)
### Watchers
[**21**
watching](/zevv/zForth/watchers)
### Forks
[**57**
forks](/zevv/zForth/forks)
[Report repository](/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fzevv%2FzForth&report=zevv+%28user%29)
## [Releases](/zevv/zForth/releases)
No releases published
## [Packages 0](/users/zevv/packages?repo_name=zForth)
No packages published
### Uh oh!
There was an error while loading. Please reload this page.
## [Contributors 14](/zevv/zForth/graphs/contributors)
### Uh oh!
There was an error while loading. Please reload this page.
## Languages
* [C
81.1%](/zevv/zForth/search?l=c)
* [Forth
15.7%](/zevv/zForth/search?l=forth)
* [Makefile
3.2%](/zevv/zForth/search?l=makefile)
## Footer
© 2026 GitHub, Inc.
### Footer navigation
* [Terms](https://docs.github.com/site-policy/github-terms/github-terms-of-service)
* [Privacy](https://docs.github.com/site-policy/privacy-policies/github-privacy-statement)
* [Security](https://github.com/security)
* [Status](https://www.githubstatus.com/)
* [Community](https://github.community/)
* [Docs](https://docs.github.com/)
* [Contact](https://support.github.com?tags=dotcom-footer)
* Manage cookies
* Do not share my personal information
You cant perform that action at this time.

View File

@@ -0,0 +1,684 @@
0:00
Welcome to fourth and beyond. My name is Timothy Lis and this is the Neoenographics channel. This talk will
0:05
not be covering standard fourth. Instead, this talk is going to start with the beyond fourth part. Let's
0:10
begin. What if we didn't actually need Visual Studio? What if we didn't need a separate debugger or even to C language?
0:17
Let's start with the first principle. Question everything until the problem is truly minimized. Begin by peeling the
0:22
onion of computing, passing through APIs, compilers, languages, code generation, and so on. Search the
0:28
alternative realities until greatness is found. And we'll start by rewinding time and learning from the past masters.
0:34
We'll start with the most basic interactive computer tool, the calculator. My favorite calculator was
0:39
the HP48. That's what I used. HP48 used reverse Polish notation. This made it
0:45
very easy to type in math and get answers. You didn't have to mess with parenthesis. The HP48 provided RPL. The
0:53
later machines provided system RPL which could even assemble machine code with offline tools for the HP48. People even
1:00
built games for these machines. Now what if we were to take that calculator and evolve it to something more forthlike?
1:06
We'll start with simple reverse polish notation calculator math. And next we'll introduce a dictionary. The dictionary
1:12
will point to positions on the data stack. For instance, in the second line here, we have a red word 4k. That 4k
1:19
word would be pointing to the next stack item. Next stack item we can do some evaluations to come up with the number
1:25
for. So we type in 1024 then type in four and then type in multiply. And now
1:30
we have 4096. So the 4k word would point to 4096. This is a basic way of doing a
1:37
variable. The next thing we could do is we could actually build numbers which represent op codes or multiple numbers
1:43
which represent op codes. Things that we could actually execute and have do an operation on the machine. So in this
1:50
case there's drop and drop points to a number on the data stack which disassembles to add ESI, -4 and then
1:59
returns. Drop would basically drop the top item from the data stack where ESI is pointing to the data stack. And now
2:06
once we have this in our dictionary, we can continue to do things on the stack and we can use drop if we want to. So
2:12
now we could write 4k which would pull that number 4096 that we had uh put in
2:18
the dictionary prior and then do one and then do two and then a plus which would create a three and then we execute drop
2:25
which will drop the three leaving 4096 on the stack and thus now we've created something quite powerful. So in this
2:31
context the gold numbers get pushed on the stack the gold words get its value in the dictionary pushed on the stack.
2:37
The green words are getting a value in the dictionary executed and the red word is putting a pointer to the top of stack
2:44
in the actual word in the dictionary. In some respects, you can see how this starts to create extremely powerful
2:49
system. So a fourthlike machine is really the ultimate form of tool building. The language is free form. The
2:55
dictionary defines words. These words become the language you program in. It enables any kind of factoring of a
3:01
problem. The language, the assembler, the compiler, the linker, the editor, the debugger, they're all defined in the
3:06
source itself. And these systems can be tiny. Tiny as in the whole thing fits in the cache. In my opinion, a fourthleike
3:13
machine would have been a better option than basic for a boot language. A lot of people learn basics cuz they could type
3:18
in a program from a book, say on the C64. But imagine if it was a fourth machine instead. You have something that
3:25
runs significantly faster and is significantly more powerful. The irony here is later Apple, IBM, and Sun, they
3:32
actually used a fourth-based open firmware, but few had programmed in it at the time. So, let's look back at
3:38
Fourth. Fourth was invented in 1986 by Chuck Moore or Charles Moore. Chuck
3:43
later focused on building multiple stackbased processors. He used his own VLSI CAD system, Okad for layout and
3:51
simulation, and these were written in his language. Early it was a sourceless language and later it got moved to color
3:57
forth from my understanding. The images below show some of the actual editor and simulation. These are from the ultra
4:04
technology site. What's impressive here is that these were dramatically small systems and yet they were used to do
4:10
some of the most complicated stuff that humans can do which is design chips that actually got fabricated and got used.
4:16
Chuck Moore's color forth I think is worth learning about. It's an example of real system minimization. 32-bit reverse
4:23
Polish notation language. It provides a data stack which gives you memory to work with and note code is compiled onto
4:30
the data stack too. It provides dictionaries which map a name to a value. The value is typically a 32-bit
4:36
number or 32-bit address to the source or data stack. The dictionaries are searched in a linear order from last to
4:42
first defined word. There are two main dictionaries. The fourth one which is used for words to call and macro which
4:49
is a secondary dictionary used for words that do code generation. Source is broken up into blocks. There is no file
4:56
system. Inside the source blocks are 32-bit tokens. These tokens contain 28
5:02
bits of compressed name or string and four bits of tag. The tag controls how
5:07
to interpret the source token. Let's go through some of the tags. The white tag means an ignored word. Yellow tag means
5:13
execute. If it's a number, we append the number on the data stack. If it's a word, we look up the word in the
5:20
dictionary and then we call the word. If it's a red word, we're doing a definition. We're setting the word in
5:26
the dictionary to the top of the stack or a pointer to the top of the stack. If it's green, we're compiling. If it's a
5:32
green number, we're appending a push number onto the stack. Effectively,
5:37
we're encoding the code, the machine language that would push that number. If
5:43
we compile a word, if we're in the macro dictionary, we're first going to look up the word in the macro dictionary, and if
5:50
it exists, we're going to call it. Otherwise, we look up the word in the fourth dictionary, and we append a call
5:56
to the word itself. Cyan or blue is used to defer words execution. So, we'll look
6:02
up the word in the macro dictionary, and we will append a call to the word. This way, we can make words that do code
6:09
generation, that call other words that do code generation. Next is the variable. Variable is used by magenta.
6:16
Variable sets the dictionary value to the word to it the pointer to the next source token in the source code as it's
6:23
being evaluated. And then anytime we have a yellow to green transition, we pop a number off the stack and then we
6:30
append a push number to the data stack, which basically means we're taking a number and we're turning it back into a
6:36
program, a program that pushes the number. So if we look at some of the blocks inside color forth and notice
6:43
this one here, block 18. This starts doing the code generation. So it'll push 24 and then it'll load which will take
6:50
block 24 and actually bring in all the code generation macros. And then the next one 26 load will bring in more
6:56
quote generation macros from block 26. If you look at block 24, it starts with
7:02
executing macro which moves us to making defines in the macro dictionary. The
7:07
first define is swap. Then it does 168B and then it does a two comma. The two
7:13
comma pushes two bytes onto the data stack. The next one is C28B
7:20
0689 followed by a comma. The comma pushes four bytes onto the data stack. So
7:26
effectively what we're doing is we're pushing some bytes to actually create code onto the data stack where swap is
7:33
defined. And if we disassemble these six bytes, we get move edx, dword ptr esi.
7:40
So effectively we're pulling from the stack into edx and the stack in this case is the data stack of fourth. The
7:46
next one is move dword ptr esi, eax. So we're pushing the existing cacheed value
7:53
of the top of the stack which is in eax. We're pushing that we're putting that on the stack. And then we move edx into eax
8:01
which is taking the old second value on the stack and pushing it into the cache value which is the top of the stack in
8:07
color fourth. So basically this whole block is defining op codes that are used for code generation. So let's fast way
8:14
forward now and let's just critique color forth. Perhaps one of the biggest critiques of color forth is that it's a
8:20
mismatch to hardware today. It's a stackbased machine and modern machines are register based. Modern machines have
8:26
really deep pipelines. They don't deal with branching well and fourth is extremely branch friendly. The
8:31
interpreter costs that you have to do per token are pretty high. We have to branch based on tag. Dictionaries are
8:38
searched from last added to first added with no hashing or any acceleration.
8:43
Most commonly every time you do an interpreting after branching on the tag you're going to branch again to another
8:49
thing which is going to be a mispredicted address. And note, you got an average of 16 clock stall on say Zen
8:55
2 for a branch misprediction. Of course, the logical response here is if you only have a tiny amount of code, there's no
9:01
reason it has to be super fast. After all, the most important optimization is doing less total work. For example, an
9:07
F1 car driving a,000 m is going to be substantially slower than a turtle walking one foot. Well, towards the end
9:14
of 2025, Chuck Moore said, "I think fate is trying to tell me it's time to move on."
9:20
And this is in response to Windows auto updating and then breaking his color forth. But I ask, should we actually
9:27
move on? The world did move on to mass hardware and software complexity, but
9:32
perhaps Chuck's way of thinking is actually exactly what is needed today. How about a localized reboot? We have a
9:38
lot of FBGA based systems showing up, and I'm hopeful that they're getting commercial success, but these are
9:44
effectively all emulators of prior hardware. What about doing something new? Maybe forthinking could be a part
9:49
of that. What about Neo vintage parallel machines? After all, forthinking is ideal for a fixed hardware platform.
9:56
FPGA based hardware emulators focus mostly on the serial thinking era. But this is actually a universal speed of
10:02
light barrier. These product lines are going to stop around N64 and so on because after that serial CPU clock
10:09
rates cannot be FPGA emulated. But FPGAAS have crazy parallel DSP capabilities. Perhaps we should design
10:16
for DSPs as the processors and then provide radically parallel but medium
10:21
clock machines and these are things we could actually drive with fourth style language. There is a challenge of
10:28
minimalism in a maximalism world. Software is a problem but the root is hardware complexity growth. For example,
10:34
our DNA4 ISA guide is almost 4 megabytes in itself. And try writing a modern USBC
10:40
controller driver yourself. And yet, even with all of today's hardware complexity, I still believe fourth
10:45
inspired software can be quite useful. I spent a lot of time exploring the permutation space around fourth,
10:51
specifically more around color fourth and seeing what variations could be made. One way I varied from fourth was
10:57
in an opin coding. I don't necessarily stick with a stackbased language. Sometimes I treat the register file more
11:03
like a closer highly aliased memory. Sometimes you use a stackbased language however as a macro language say for a
11:10
native hardware assembler and sometimes I mix a stackbased language with something that has arguments for
11:16
instance having a word have arguments after the word and still use it like a stackbased language. So I have used
11:22
forthlike things in commercial products. One example is I used to run a photography business and a software
11:28
development business and the old business website that I ran in my prior life doing landscape photography was
11:35
actually generated by a fourthlike language running server side which generated all the HTML pages. It made
11:41
managing a huge website actually practical. Now I had to use the wayback machine to find this. So sorry in
11:47
advance for the broken images. And of course, I had a different last name then from a broken marriage, but that's another story. But I did a lot more
11:54
forthlike things beyond this one. One of the things that got me right away was, of course, the lure to optimize. For
12:00
example, color forth uses this Huffman style encoding for its names and its tokens. Remember, a source token is a
12:08
T-bit tag, typically T is 4, with an S bit string where S is 28 bits. We could
12:14
do a better job of encoding the the 28 bits. For instance, we could split that full number range by some initial
12:20
probability table of the first character. And then we could split each of those ranges by say a one or two
12:27
character predictor. And then we train this thing on a giant dictionary. And of course, you're going to have to use
12:32
lookup tables. And of course, the memory used for the predictor is going to be greater than the rest of this whole
12:38
system combined. And yeah, it worked. It provided some very interesting stuff. You could put a number in and it would
12:45
basically BSU a string out which was pretty cool. This journey I think was
12:50
useful. I learned a lot of things in the process like where to optimize and where not to optimize. Next question is well
12:57
should we hash or should we not hash? It turns out that a compressed string like in the prior slide is actually a great
13:04
hash function. I can simply mask off some number of the least significant bits and that becomes my hash function.
13:10
or for hashing. I always dislike the issue of only part using cache lines. That's not very efficient. And of
13:16
course, we can try to fix that too. We can check a very tiny hash table first and size that hash table to stay in the
13:23
cache. And then if we miss on that, we can go to the fulls size one, the one that's going to have pretty poor
13:28
utilization on cache lines. And assuming lots of reuse, that tiny hash table is going to keep high cache utilization.
13:35
However, now we've done two stages of optimization. But we really should start asking why are we hashing and why are we
13:42
compressed? Why are we doing all this overhead? Why do we just not direct map? After all, if we're depending on an
13:48
editor, we could just direct map or perhaps just address into the dictionary directly. Then we can split off the T-
13:54
bit tag and the S bit string for editor use. And that can start simplifying things so we don't have all this
14:00
complexity in the first place. The next thing we can do if we're interpreting is we can solve the problem of branch
14:06
misses. Normally with an interpreter, you would evaluate the word and then you'd return back to the interpreter.
14:12
That interpreter would look up another word and do another branch. But that branch would always be mispredicted. One
14:17
option is we could just fold the interpreter back into the words themselves. But of course, we got to
14:23
make that interpreter really small, otherwise we're doing a lot of code duplication. Can imagine if you have a
14:28
thousand words, you're going to embed the interpreter a thousand times. So there's a lot of different ways we can
14:33
design an interpreter down into a few bytes. For instance, this one is a 8 byte interpreter. This is one I've never
14:40
used. Actually can do better than 8 bytes and I'll show you that towards the end. So of course the best way to learn
14:45
is to build stuff. So I built many color forth inspired things over the years. Some like the one to the right here. I
14:52
got distracted with editor graphics effectively making something extremely nice to use and very pretty. This one
14:58
was cool. The dictionary I moved into the source itself and I did a direct
15:03
binary editor. So this thing you'd actually see the cache lines and you're effectively doing a hex editor that uses
15:10
tags to tell you some contextual information and then each line of course
15:15
has uh a comment on the top followed by the data on the bottom. And of course I use different fonts because sometimes
15:22
I'm packing a full number with sometimes I'm packing characters and so on in comments. It was a relatively
15:28
complicated system, but actually simple when you think about it in the context of what we build today. One of the first
15:35
questions to ask yourself is whether you want to work with text source versus a binary editor. So sometimes I would work
15:41
with text source. In order to make this work well, I would have a prefix character in front of every word, which
15:47
basically would be the tag. And it would also enable me to use very simple syntax
15:52
coloring inside say nano. Most of these I built they were more like a fourth macro language that was used to create a
15:58
binary. So what I would do and for instance what you can see on the right is I would define something that would
16:03
enable me to build the ELF header and then after the ELF header was was built I would actually write the assembler in
16:10
the source code and then finish off the rest of the binary. These kind of languages are extremely small and the
16:16
whole thing is in a say a few kilobyte binary. The other thing I do with these is I bootstrap. So the first time I
16:23
might write the thing in C and then C would evaluate and then I'd run the interpreter in C and then later I would
16:30
write the rewrite the interpreter inside the source code and then compile that. Now I would be bootstrapped into the
16:36
language itself. And so by doing that I could actually compare my C code to the the code I wrote inside my own language.
16:43
And of course I'm faster inside my own language than in the C code. And of course, I'm a lot smaller in the binary
16:48
as well because I have a very very small ELF header in the binary that I generated compared to the one that say
16:55
GCC would generate. I built some custom x86 operating systems. It was fun to
17:00
build custom VGA fonts and of course mess with the pallet entries to improve the initial colors. I did lots of
17:07
different fourth variations, but typically these projects just got blocked in the mass complexity of
17:13
today's hardware. Meaning once you get down to the point where you want to say draw something on the screen other than
17:18
using say the old DOSs VGA frame buffer or if you want to start using input you start needing a USB driver and then all
17:26
of a sudden everything turns into a nightmare. One thing I mentioned before is it's very nice to use a forthlike language as a macro assembly language.
17:33
Traditional assembly language you do something like say add ecx edx and then
17:39
colon advanced pointer by stride. The later part here is heavily commented. In fact, typically assembly is mostly
17:47
comments otherwise a human can't really understand it. When you start using a fourthlike language as a macro
17:53
assembler, a lot of times what you do is instead of using the register number, you would just put the register number
17:59
inside another word and then use that word. So now you start self-documenting. And if you had common blocks of say
18:06
multiple instructions, you would start defining those in some other word and then you start factoring. And this way
18:11
you self-document everything and it becomes actually very easy to understand, a lot more easy to
18:17
understand than say assembler. And on top of this, of course, you can also put comments, but you don't typically need
18:22
as many. So if we were to look back at some of the lessons of all these projects, I think the key thing is that when your OS is an editor, is a hyper
18:30
calculator, is a debugger, is a hex editor, you end up with this interactive
18:35
instant iteration software development and that part is wonderful. The fourth style of thinking keeps source small
18:41
enough so that it's approachable by a single developer and that I think is very important. You basically build out
18:46
your own tools for the exactly the way you like to think and that's where its true beauty lies. Others like Onot have
18:53
built full systems, meaning he is running something that actually works
18:58
with Vulcan and generates Spear V. So there is another option and that is going sourceless. No language, no
19:05
assembler. The code is the data or the data is the code. Chuck's okay was a
19:10
source of inspiration. I've only read about this, but it did send me down a spiral of trying various ideas that are
19:17
related to what I read. So when we think about sourceless programming, it's best to just work from the opposite extreme.
19:24
Start with say a hex editor and then work towards what we would need to make that practical for code generation. So I
19:30
think of a binary as an array of say n 32-bit words and then we could have another thing which is an annotation
19:37
which is an array of n64-bit words. The annotation could provide a tag which gives context to the data or could
19:44
control how the editor manipulates the data. The annotation can also provide an 8 character text annotation for the
19:50
individual binary words which serves as documentation for what the word is for. So part of sourceless programming is how
19:56
do you generate code and with fourth hand assembling words is actually relatively easy because you don't have
20:02
that many you don't have that many low-level operations if you're doing a stackbased machine. I invented something
20:09
called x68 which I'm planning to do a separate talk on. It's a subset of x64
20:15
which works with op codes at 32-bit granularity only. Note that x664
20:21
supports ignored prefixes which can pad op codes out to 32-bit. And we also have
20:27
multibite noops which can align the ends too. And we can do things like adding in rex prefixes when we don't need it to
20:34
again pad out to 32-bit. So for instance, if we wanted to do a 32-bit instruction for return, we might put the
20:41
return, which is a C3, and then pad the rest of it with a three byte noop. And
20:47
once we've built this 32-bit return number, which we can an we annotate with, we can insert a return anywhere
20:55
just by copying and inserting this word in the source code. And later, if we built different op codes and say they
21:00
were multi-word, we can just use find and replace to change those. Effectively, we're removing compilation
21:05
into some edit time operations. One of the nice things about being at 32-bit
21:10
granularity for the instruction is that the 32-bit immediates are now at 32-bit granularity as well. And so now we can
21:18
just make it so that we have a tag which says this is an op code and a tag which says this is say an immediate hex value.
21:26
And we could show them separately with different colors. In this case, I have code for setting ESI to a 32-bit
21:32
immediate. And you'll notice that this one is using the 3E ignored DS segment
21:38
selector prefix to pad out the op code to 32-bit. And then after that, we have a silly number which we're setting into
21:45
ESI. That silly number is 1 2 3 4 5 6 7 8 in hex. So it's very easy to do inline
21:51
data this way. Of course, calls and jumps are another question. And we have an easy solution for that one as well.
21:57
In x8664, column jump uses a 32-bit relative immediate and that relative is
22:03
relative to the end of the op code, not the beginning. And so if we want to make an editor support this, we would just
22:09
tag the relative branch address as a word that is a relative address. And
22:15
then when we start editing text or say editing the words inside the binary and
22:21
say we move things around, we would just relink all of the words in the binary that have a relative address. So as code
22:27
changes, things just get fixed up. And so this effectively solves the call and the jump problem. It's very easy to make
22:34
an editor which repatches everything. Conditional branches, you might think those are complicated, but they're
22:40
actually not. Conditional branches is just an 8-bit relative branch address. And so when I make words on these, I
22:46
would say jump unequal minus two, which would jump unequal to the word that is
22:51
two words before this one or say j minus 4 for four words minus and so on. And so
22:58
I can just build a few of these constructs and change the op codes around whenever I need say a jump on
23:03
zero or so on. Nice thing about this is now you no longer have to label things because you just go and count and when
23:10
you move it around it's all relative. So you don't need to do any patching. If you want to add more stuff in your loop,
23:16
you just change, you know, the op code a little. Another option is the editor could have a built-in 32-bit word
23:22
assembly disassembly. Meaning I could use a shorthand for registers and op codes. And the shorthand that I would
23:28
use would be labeling the registers starting with G. So that zero through F
23:34
could be used for hex. So this is an example of how you might want to do it. So in this case I have h + at i08
23:42
which is going to disassemble to add rcx quadward pointer rdx + 0x8
23:51
which we can shorthand very easily and so I could have an editor that would show you either the disassembly or show
23:57
the shorthand instruction for it and that would aid in the understanding and ability to insert stuff without using
24:04
separate tools. So, I did build this sourceless system once in the real. It was back when I was building tiny
24:09
x86-based operating systems. I built the editor as a console program. So, this
24:15
would run in Linux and I would build binaries in that console program and
24:20
then I would use an x86 emulator running in Linux to actually test them. And this was a pretty liberating experience. I
24:27
learned a lot from there. On the right, I'm showing one of the boot sectors of one of the examples running in the
24:33
editor. Note with sourceless programming we could extend the annotation quite a bit. For instance, we could have tables
24:38
that map register numbers to strings and then for each cache line we could have an index of a table. In this way,
24:45
registers could be automatically annotated. For instance, if register 2 is set to position and register 4 is set
24:52
to velocity. If we had add R2, comma, R4, we could just put in add POSOS comma
24:58
velocity, right? And that would make it a lot easier to understand automatically. We could also extend and
25:04
have each cache line have a string as well. And this way we could automatically annotate say a label. The
25:10
first word maybe could be the label and the rest of the string could be used for a comment. So there's a lot of ways to
25:16
do sources programming where we just provide annotation tools to actually make it a practical experience. So let's
25:22
talk about some of the variations, the pros and cons. The easiest way to perhaps start this would be to work with
25:28
text source. And usually with text source, you're going to use prefix words for the tag. For instance, slash for
25:35
comment, colon for define, maybe tick for execute. This does have the slowest runtime, however, because you have a
25:41
character granularity loop. It does have a benefit in that for you to get started, there is no editor that you
25:47
have to write. You can use an external text editor and you can do easy custom syntax coloring. You're going to be very
25:53
easy to understand and to work in. However, I think you're missing a big piece if you go down this path, and that
25:58
is you don't get any live interaction or debugging. You're basically depending on the fast compile times of your custom
26:04
language and the fast load times of whatever program you're doing to try to get you in that iteration loop. And you
26:11
can work this way. I've done it many times, but the experience is nowhere near as good as doing the full
26:16
interactive one with a binary editor. I guess one of the other benefits here is you got very easy code portability.
26:23
There's no binary files, just text files. You can copy and paste as you will. Of course, the next jump up from
26:28
that is going to binary source. This would be middle performance runtime because now you're working at a word
26:34
granularity inside your interpreter. You have portability because you have code generation that can adapt to the system.
26:41
Meaning, as you interpret your code, you can look at what's underlying in the hardware and you can make changes to how
26:46
the code is generated at runtime. You can build just what bits of an assembler are needed. You don't need to build out
26:52
everything like you would with say a disassembler tool or an assembler tool. So for instance with x86 I don't
26:58
actually generate much of the ice. I only use a very very tiny subset. You do have to write the binary editor and that
27:04
can be a lot of work and sometimes that presents a problem with bootstrapping because you don't have the language to
27:10
write the editor in from the beginning. So you have to write the editor in some other language and then in that language
27:15
write the editor again and then you know complete the bootstrapping process. The
27:21
one benefit here is you get interactive development debug from the beginning and also now your source code shows how
27:28
constructs are built instead of just showing the result as you would get with say source free. One interesting thing
27:33
about fourth with binary source and this this concept that you can rebuild source
27:39
code at runtime at any point in execution is now you can start compiling things you load into machine code and
27:46
then you don't have to run all the overhead. Basically you can bake things into machine code anytime at edit time
27:52
and that's a very powerful feature. Now if we go and look at sourceless programming there's a bunch of pros and
27:58
cons. The one pro is that it's the fastest runtime. It's a true noop. You can build things that are highly tightly
28:04
optimized for a platform and they're as optimized as you could possibly get. You
28:09
do however lose capacity for showing how constants came to be and you lose the
28:15
capability of adapting to what the machine is. You can work around this however you can make smaller embedded
28:20
constants that you write into modified bit fields and instructions but it's
28:26
really taking a little too far in terms of complexity. You do need to write an editor which includes an opc code
28:31
assembler and disassembler potentially if you want to go down that route. And if you're going to do CPU and GPU,
28:37
that's a lot of work. It can be very complicated when systems include auto annotation. For instance, if you want to
28:44
type in say a string readable register and then have it go and figure out what register number that is. I guess the
28:50
primary disadvantage here is that there's no possibility for portability. You have a raw binary editor. And today
28:57
we have a problem with GPUs. Steam Deck is RDNA 2, Steam Machine's RDNA 3, and
29:04
who knows the future may be RDNA 4 or five or six. Problem with this is that when the ISA changes across those
29:10
chipsets, that can result in different instruction sizing. So you can't just do
29:16
simple source free. For example, Mimg in RDNA 2 has a different size than V image
29:22
in RDNA4. And that's all due to the ISA changes. So if you do sourceful
29:27
programming, you can port through a compile step. However, source list, you would need to do something else. And
29:33
perhaps that is just rewriting chipset specific versions of all the shaders, but that may be something that you don't
29:39
want to do. So thinking ahead on the Steam OS/ Linux project that I'm working on, effectively I'm building an AMD only
29:46
solution. I don't really have a name for this project, so I'm going to call it fifth. I think for fifth I want a mix of
29:52
various fourth style concepts and perhaps the best mix would be the best
29:57
of both worlds. A fast highle interpreter that's intent for doing GPU code generation where I need chipset
30:04
portability at runtime mixed with low-level sourceless words for the CPU
30:09
side for simple x664 where I don't need portability at this time. Since this is
30:15
for Linux, we should think about what we can do on Linux that we might not be able to do on Windows today. We first
30:21
start thinking about execution. The Linux x8664 ABI when you're running
30:26
without address space randomization, the execution starts at a fixed 4 megabytes
30:31
in and you can still do this today if you compile without FPIE. Also note,
30:37
even if you did get position independent execution, you could effectively just map the where you want your fixed
30:44
position to be and then just start execution there and just ignore the original mapping that they threw you at.
30:50
Another thing we can do is we can use page maps. And if we look at Steam Deck, we'll notice that dirty pages get
30:56
written about as fast as every 30 seconds, which is an important number. Means it won't be overwriting too fast.
31:03
So, let's look at something we can do on Linux that we're not allowed to do on Windows anymore. The self-modifying
31:08
binary. The idea here is that we have a cart file. The cart file represents the ROM. Actually, in this case, it's a RAM
31:15
because we're going to be modifying it. So, first we would execute the cart file. And when the cart file runs, it
31:21
would realize that it's not aback. And then it would copy itself to a backup file, cart.back, and then it would
31:28
launch cart. And then exit. This cart.back back would realize that it is the backup file and then it would map
31:35
the original file cart at say 6 megabytes in and it would provide that mapping and read write and execute and
31:42
then afterwards it would map an adjustable zero fill and that would be for when we're doing compilation or when
31:48
we have data that we don't want to be backed up all the time and after that it would jump to the interpreter and so if
31:54
we look at the memory mapping we'd have at 4 megabytes we would have say a 4 kilobyte boot loader section
32:01
And then we would have somewhere say at 6 megabytes we'd have the whole file and then after that we would have the zero
32:07
fill. And the nice thing about this is we automatically create a backup. We don't have to write any code to save the
32:13
file because it's going to autosave every 30 seconds. Also the data and code is together and we can make a new
32:19
version just by copying the file itself. Inside the binary we'd have a specific spot for the size of the file and the
32:25
size of the zero fill. So the process of doing this execution we can resize when
32:31
we build the cart.back file very easily. So for source code I'm thinking 32-bit
32:36
words for words they're going to be direct addresses into the binary and the binary is going to be the dictionary.
32:43
Makes it quite fast to interpret. The nice thing here is they can be direct addresses because we fix the position.
32:50
We're not using address base randomization. We'll just fix RSI to the interpreter source position and then all
32:56
the words will contain the next of the interpreter meaning all the words end in the interpreter itself or fold the
33:02
interpreter in whatever form they want into their own execution. And by doing this we enable lots of branch predictor
33:10
slots because each of these interpret end of word interpreters are going to be different branch predictors. So we can
33:17
actually get this down into five bytes if we want to. We can use the LODs to
33:22
basically load a word from RSI and then advance RSI and we can use two bytes to
33:29
look up the value in the dictionary and we can use two bytes later to jump to
33:34
the address for the next thing to run. So now we've gotten down to a five byte interpreter. Another thing I think I
33:40
would do for variation is I would make source more free form not strict reverse post notation. In other words, with
33:48
regular reverse pulse notation, you're going to have words that going to push values onto a stack and therefore your
33:53
granularity is at the word level. If instead we have arguments, we can fetch
33:59
a bunch of values off the stack right off the bat and we can look them up in the dictionary in parallel. And now our
34:05
branch granularity is dropping significantly. Maybe say a factor of maybe two or four depending on what our
34:12
common argument count is. I think this is a better compromise for when you're doing lots of code generation, which is
34:17
what we'll be doing on the CPU, mostly GPU code generation. So, for the editor, I'll just do an advanced 32-bit hex
34:24
editor. I'll split the source into blocks, and then each one of those blocks will be split into subblocks. And
34:31
the subblock will be source and then some annotation blocks. And so for every
34:37
source 32-bit source word, I'm going to have uh two I'm going to have say 64-bit
34:42
of annotation information split across two 32-bit words. And that'll give me eight characters. Each of those
34:49
characters will be 7 bit. And I'll have an 8bit tag for editor. And the tag will give me the format of the 32-bit value
34:56
in memory and give me whatever else I want in there. So I can adapt, you know,
35:01
for whatever I feel like doing in the future. And I can make this pretty uniform because I'll mostly have numbers
35:07
and then I'll have direct addresses to words inside this. So that's it for now. This is a late welcome to 2026. I used
35:15
the holiday for some deep thinking, but I think it's time now for some more building. Take care.

View File

@@ -0,0 +1,22 @@
"20070910 - 2 4th | !2 4th","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070910.html"
"20070912 - The Making of a Font","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070912.html"
"20070915 - Building the Chicken Without an Egg","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070915.html"
"20070919 - Editor Working","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070919.html"
"20070921 - Assembler in Atom4th","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070921.html"
"20140816 - Vintage Programming","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20140816.html"
"20141231 - Continued Notes on Custom Language","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20141231.html"
"20150414 - From Scratch Bug","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150414.html"
"20150420 - From Scratch Bug 2 : Source-Less Programming","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150420.html"
"20150422 - Source-Less Programming : 2","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150422.html"
"20150423 - Source-Less Programming : 3","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150423.html"
"20150424 - Source-Less Programming : 4","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150424.html"
"20150426 - Source-Less Programming : 5","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150426.html"
"20150710 - Inspiration Reboot","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150710.html"
"20150714 - 1536-1 : The Programmer Addiction = Feedback","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150714.html"
"20150715 - 1536-2 : Assembling From the Nothing","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150715.html"
"20150722 - 1536-3 : Simplify, Repeat","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150722.html"
"20150809 - 1536-4 : Coloring","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150809.html"
"20150810 - 1536-5 : Keys","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150810.html"
"20151113 - Rethinking the Symbolic Dictionary","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20151113.html"
"20151222 - Random Holiday 2015","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20151222.html"
"20161113 - Vintage Programming 2","https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20161113.html"
1 20070910 - 2 4th | !2 4th https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070910.html
2 20070912 - The Making of a Font https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070912.html
3 20070915 - Building the Chicken Without an Egg https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070915.html
4 20070919 - Editor Working https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070919.html
5 20070921 - Assembler in Atom4th https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070921.html
6 20140816 - Vintage Programming https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20140816.html
7 20141231 - Continued Notes on Custom Language https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20141231.html
8 20150414 - From Scratch Bug https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150414.html
9 20150420 - From Scratch Bug 2 : Source-Less Programming https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150420.html
10 20150422 - Source-Less Programming : 2 https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150422.html
11 20150423 - Source-Less Programming : 3 https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150423.html
12 20150424 - Source-Less Programming : 4 https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150424.html
13 20150426 - Source-Less Programming : 5 https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150426.html
14 20150710 - Inspiration Reboot https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150710.html
15 20150714 - 1536-1 : The Programmer Addiction = Feedback https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150714.html
16 20150715 - 1536-2 : Assembling From the Nothing https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150715.html
17 20150722 - 1536-3 : Simplify, Repeat https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150722.html
18 20150809 - 1536-4 : Coloring https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150809.html
19 20150810 - 1536-5 : Keys https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150810.html
20 20151113 - Rethinking the Symbolic Dictionary https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20151113.html
21 20151222 - Random Holiday 2015 https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20151222.html
22 20161113 - Vintage Programming 2 https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20161113.html

View File

@@ -0,0 +1,90 @@
# 20070910 - 2 4th | !2 4th
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070910.html
# 20070910 - 2 4th | !2 4th
![](20070910-A.jpg)
After just finishing up the last show of the season for my Photography Business (lighting shot above from Monument Valley),
I will again soon have time to really push to finish Atom.
Besides working on optimization of the engine, I've flushed out the scripting language I'm going to use as a rapid development tool to produce the game.
Since I'm going solo on this endeavor, I'm fully taking advantage of the fact that I can deviate from the common C/C++ standard which would be a practical requirement of working in a large team.
One notable, successful, and practical use of non-C like languages for game development is the [Game Object Assembly Lisp (GOAL)](http://www.gamasutra.com/features/20020710/white_02.htm)
used to build Jax and Daxter for the PS2. With inline assembly and runtime code generation,
looks like they found a perfect mix of both a very high and very low level programming language.
**Forth**
Similar in concept to GOAL, I've decided upon a Color Forth like rapid development programming tool for Atom which has the following advantages.
1. Run-time x86/x86-64 binary code generation. Can code the game from inside the game itself.
2. Ability to natively mix low level assembly, mid-level systems programming, and high level scripting all in the same source code.
Full forth like factoring of code at any level.
3. Compiler which has no need of lexical analysis, preprocessing, parsing, or semantic analysis.
Code is in a binary form with near direct factored translation to machine code.
So full re-compile of the entire source base in less than a second, from within the game itself.
4. Built-in in-game console, code/data editor, scripting, and debug tool. Editor works somewhat like a mix between a console, text editor, spreadsheet, and a debugger.
5. Data mixed in code in native binary form. No need for serialization code, simply save the program's code and the program's data is "serialized" as it is saved to disk.
6. Insane ease of use, code is color syntax highlighted, tab completion, multiple views, auto lookup and view of code/data definitions/values as cursor moves from word to word, and more.
7. And most importantly, it is amazingly simple. Current prototype of the built-in x86/SSE assembler is less than 4K of code/data.
I'll be posting more as I work on this production tool.
For those who know about Color Forth here is a quick preview. I've deviated quite far.
For instance my dictionary is embedded in the code itself, and as you edit (moving the memory locations of words around),
dictionary pointers are automatically re-linked. So the dictionary is direct, there is no need for hashing or searching to lookup a word.
My cell size is 16 bytes (supports SSE vectors) for the stacks and the dictionary, but source code is still in 32-bit tokens.
I'm supporting floating point single and double precision. Source code is similar to Color Forth, with many exceptions.
I've split the tag bits into 2 blocks. So code tokens still have a "color" tag, but data is embedded directly in code tokens without any tag bits.
In order to know if the source token is code or just raw data, the shadows blocks now contain extra tags fields which note code vs data and if data,
the type of the data (text, bytes, words, float, double, vector etc). So shadow blocks no longer contain comments,
instead they contain tag bits and are used to encode the dictionary directly (holding the strings to name words).
More later ... but for now, here is a shot as I was prototyping the language, prior to deciding to embed the dictionary in the source code.
**Of course, I've already changed all this but it will give you an idea.**
At this point in the development the colors were as follows,
1. DEFINE-TOKEN: Copy address of this token into dictionary word indexed by tag index field.
2. DEFINE-COMPILED: Copy memory stack top pointer into dictionary word indexed by tag index field.
3. DEFINE-VARIABLE: Copy data from token (or vector of 2 or 4 tokens based on tag type field) into dictionary word indexed by tag index field.
4. COMMENT: If tag is not set to define then tag index field is a comment.
5. JUMP: Dictionary word indexed by token is a pointer to a code token, jump interpreter to that point.
6. INTERPRET: Dictionary word indexed by token is a pointer to a code token, push current interpreter position on interpreter return stack,
then jump interpreter to that point.
7. EXECUTE: Dictionary word indexed by token is a function pointer, call that function.
8. COMPILE: Dictionary word indexed by token is a function pointer, compile a call to that function at the current memory stack top.
Advance the memory stack top to point to after the compiled CALL opcode.
9. PUSH-TOKEN: Push data from token (or vector of 2 or 4 tokens based on tag type field) into data stack.
10. PUSH-WORD: Push cell value from dictionary word indexed by token onto data stack.
11. POP-WORD: Pop cell top of data stack into dictionary word indexed by token.
12. IGNORE: Ignore token. Used for extra comments, and defining data.
The shot shows part of the assembler code block. If you read enough to decode it, you will notice that I was assembling with interpreted instead of compiled code.
Click on the image to see the full size version which is actually readable...
[![](20070910-B.jpg)](20070910-B.jpg)
**Interested in "Moore" Forth?**
Check out the evolution of Forth and the work of Chuck Moore (Forth's Inventor), specifically
[Color Forth](http://www.colorforth.com/cf.html) and
[Jeff Fox's](http://www.ultratechnology.com/dindex.htm) writings.
Moore's ideas are simply revolutionary, asynchronous massively multi-processing ultra-low power (24 billion operations / second at 450mW, yes thats mW!)
[18-bit forth based processor](http://www.intellasys.net/products/index.php?target=seaforth/SEAforth24A.txt)
designed for embedded DSP and more.

View File

@@ -0,0 +1,31 @@
# 20070912 - The Making of a Font
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070912.html
# 20070912 - The Making of a Font
Yes the font looks tiny on the web, but at its 640x480 target resolution it is 100% readable.
*(Lost Image)*
For the Atom Forth Editor I needed a raster font which met a very specific set of constraints.
* The font must work perfect at 640x480.* It must support 64 characters in 640 pixels wide.* It must also support 9 characters in 40 pixels wide.* It must be readable when drawn over the same color background.
The editor is displaying 16 32-bit tokens per line, with each line containing 2 sub-lines. The top sub-line shows 4 characters, and the bottom shows data, which can be formated with up to 9 characters. So the font was built exactly for these guidelines. I also went with lowercase as just smaller uppercase letters, in order to remove the need for any descending pixels, and thus pack in more lines per screen.
**Building the Font**
For the font texture I'm using the Red channel as a font shadow mask, and the Green channel as the font, hence the red background and green lettering at the top. The extra spacing is so that texture interpolation works correctly. In order to have anti-aliasing and font features on exact pixel boundaries for great readability, I started with drawing an aliased version of the font at its native size. Then nearest-up-sized to 4x its original size, and cleaned the bitmap. Then finally bilinear downsized to the native resolution to have perfect anti-aliasing and readability.
**Why 640x480?**
Ever watch a HDTV broadcast of a home Celtics basketball game? The MPEG artifacting during any motion is horrendous, especially on the wood grain of the court. It is so bad and distracting, I'd rather watch it on regular TV or even TV resolution DirectTV. The point? Technology is pushing huge resolution, but image quality is suffering. As like HDTV, what is the point of HD games with such bad aliasing problems? Personally I prefer a perfectly anti-aliased 640x480. So for Atom I am targeting 640x480 as the midrange resolution. Sure 1024 and larger if you have a fast GPU, and also 512 and smaller if you have a really slow GPU. But regardless of the resolution, Atom is always going to have perfect anti-aliasing.

View File

@@ -0,0 +1,32 @@
# 20070915 - Building the Chicken Without an Egg
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070915.html
# 20070915 - Building the Chicken Without an Egg
The classic Chicken and Egg problem, I really did want to write the editor for Atom Forth in the Atom Forth language, but atlas, it is hard to edit a binary source format without the editor. My solution was to get the editor up quickly using C, and add some "syscall" hooks in Atom Forth for controlling the editor. Later when I have the time, I will port the editor over to Atom Forth.
**Random Progress**
Just finished up the display code, screen shot below shows formatting of completely random data. Got the initial coloring somewhat where I want it. Already moved on to the editing code. Soon this will actually be usable. With the help of objdump -d and gas wrote the initial interpreter, using the dis-assembly to grab the byte stream for various interpreted opcodes like,
```
0000000000400745 SAdd:
400745: 48 03 47 00 :: add 0x0(%rdi),%rax
400749: 48 83 c7 f0 :: add $0xfffffffffffffff0,%rdi
40074d: c3 :: retq
```
Also this is my first time really getting into the binary opcode details of the 64bit extension to the x86 instruction set for my assembler and the differences between the C ABI between Linux and Windows for my C "syscall" interface. I've noticed Microsoft made a subtle but important optimization error in their C calling convention concerning how SSE values are saved and restored during function calls. The problem is that they have SSE regs xmm6-xmm15 as callee saved. Of course the callee doesn't know the type of data in the SSE regs, it could be scaler float, scaler double, vector float, vector double, and vector integer, all of which have separate load and store opcodes. On the Core Duo 2 and newer Intel processors, there is a performance penalty for using instructions which don't match the type of data currently in the SSE regs. This is caused by the processor having to do an extra internal conversion (probably because the register file is not stored in exact binary format, i.e. different radix between int and float for low latency ALU operations).

View File

@@ -0,0 +1,10 @@
# 20070919 - Editor Working
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070919.html
# 20070919 - Editor Working
![](20070919.jpg)
Got the editor fully working, 1800 lines of highly factored dense C code (I put multiple statements on one line). Now moving into incorporating the Atom Forth interpreter (which is only one page of assembly), followed by writing the assembler in Atom Forth, and lastly porting the editor and interpreter over to Atom Forth. Will then be able to edit the source code of the editor from within the editor itself, which is great for extending/modifying the editor when I need new keyboard shortcuts or other features!

View File

@@ -0,0 +1,26 @@
# 20070921 - Assembler in Atom4th
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20070921.html
# 20070921 - Assembler in Atom4th
![](20070921.jpg)
Nearly finished with writing a x86-32/64 bit assembler in the Atom4th language. The shot above shows about 50% of the code, excluding the opcode tables. In the process, I've changed a few things about the editor and fine-tuned the programming style. The final code for the assembler (which I still have to test) is nearly the same as what I had prototyped in Excel, see the screen shot from [20070910](20070910.html), except I've moved the assembler over to being fully compiled instead of interpreted.
**Again, Why Atom4th?**
The way I like to think about this is like the difference between your average bland front wheel drive car which might be able to do a one wheel burnout if you mash the gas pedal, and a raw striped down vintage road racing prototype race car.
99.99999% of people enjoy the comfort of knowing absolutely nothing about their car (after all, what the hell is a one wheel burn out anyway?), it gets good gas millage and goes from A to B. This front drive car is like C and other common languages. It is the work horse of near the entire world.
For the other 0.00001% there is the need for something different, something that requires intimate knowledge of the machine, purpose built to extract extreme performance, and yet simple enough to work on. This is the essence of vintage. To go back to simpler times, and have the freedom and access to do awesome things. Atom4th is that exotic vintage race car designed for those who get an adrenaline rush from the chest pounding 100+ decibel exhaust note and taste of ultra high octane leaded race gas.
**So What's Next**
Building this beast is taking longer than I expected, but with the assembler soon done, I'll be back onto the game engine, porting it to and optimizing it in Atom4th. I'm guessing the 4000 lines of C game engine code will factor out and simplify into about 32 Atom4th pages (at 32 line pairs per page). Porting the Atom4th editor into Atom4th is about 1800 lines of C code to port, so I'm going to skip that until way later, so I can get back to work on the actual game.

View File

@@ -0,0 +1,62 @@
# 20140816 - Vintage Programming
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20140816.html
# 20140816 - Vintage Programming
A photo (not a screenshot) of one of my home vintage development environments running on modern fast PCs. Shot shows colored syntax highlighted source to the compiler of the language I use most often (specifically the part which generates the ELF header for Linux). More on this below.
![](20140816-A.png)
This is running 640x480 on a small mid 90's VGA CRT which supports around 1000 lines. So no garbage double scan and no horrible squares for pixels. Instead a high quality analog display running at 85 Hz. The font is my 6x11 fixed size programming font.
![](20140816-B.png)
This specific compiler binary on x86-64 Linux is under 1700 bytes.
**A Language**
The language is ultra primitive, it does not include a linker, or anything to do code generation, there is no debugger (and it frankly is not needed as debuggers are slower than instant run-time recompile/reload style development). Instead the ELF (or platform) header for the binary, and the assembler or secondary language which actually describes the program, is written in the language itself.
Over the years I've been playing with either languages which are in classic text form, and languages which require custom editors and are in a binary form. This A language is the classic text source form. All the variations of languages I've been interested in are heavily influenced by [Color Forth](http://www.colorforth.com/).
This A compiler works in 2 passes, the first both parses and translates the source into x86-64 machine code. Think of this as factoring out the interpreter into the parser. The second pass simply calls the entry point of the source code to interpret the source (by running the existing generated machine code). After that whatever is written in the output buffer gets saved to a file.
Below is the syntax for the A language. A symbol is an untyped 64-bit value in memory. Like Forth there is a separate data and return stack.
\comment\
012345- \compile: push -0x12345 on the data stack\
,c3 \write a literal byte into the compile stream\
symbol \compile: call to symbol, symbol value is a pointer to function\
'symbol \compile: pop top of data stack, if value is true, call symbol\
`symbol \copy the symbol data into the compile stream, symbol is {32-bit pointer, 32-bit size}\
:symbol \compile: pop data stack into symbol value\
.symbol \compile: push symbol value onto data stack\
%symbol \compile: push address of symbol value onto data stack\
"string" \compile: push address of string, then push size of string on the data stack\
{ symbol ... } \define a function, symbol value set to head of compile stream\
And that is the A language. The closing "}" writes out the 32-bit size to the packed {32-bit pointer, 32-bit size} symbol value, and also adds an extra RET opcode to avoid needing to add one at the end of every define. There is one other convention missing in the above description, there is a hidden register used for the pointer to the output buffer.
**Writing Parts of the Language in the Language**
The first part of any source file is a collection of opcodes, like the *{ xor ,48 ... }* at the top of the image which is the raw x86-64 machine code to do the following in traditional assembly language (rax = top of data stack, rbx points to second data stack entry),
XOR rax, [rbx]
SUB rbx, 8
These collection of opcodes generate symbols which form the stack based language the interpreter uses. They would get used like *`xor* in the code (the copy symbol to compile stream syntax). For instance *`long* pops the top of the data stack and writes out 8-bytes to the output buffer, and *`asm* pushes the output buffer pointer onto the data stack.
I use this stack based language to then define an assembler (in the source code), and then I write code in the assembler using the stack based language as effectively the ultimate macro language. For instance if I was to describe the *`xor* command in the assembly it would look like follows,
{ xor .top .stk$ 0 X@^ .stk$ 8 #- }
Which is really hard to read without syntax coloring (sorry my HTML is lazy). For naming, the "X" = 64-bit extended, the "@" = load, and the "#" = immediate. So the "X@^" means assemble "XOR reg,[mem+imm]". The symbols "top" and "stk$" contain the numbers of the registers for the top of the stack and the pointer to the second item on the stack respectively.
**Compiler Parser**
The compiler parsing pass is quite easy, just a character jump table based on prefix character to a function which parses the {symbol, number, comment, white space, etc}. These functions don't return, they simply jump to the next thing to parse. As symbol strings are read they are hashed into a register and bit packed into two extra 64-bit registers (lower 4-bits/character in one register, upper 3-bits/character in another register). This packing makes string compare easy later when probing. Max symbol string is 16 characters. Hash table is a simple linear probing style, but with an array 2 of entries per hash value filling one cacheline. Each hash table entry has the following 8-byte values {lower bits of string, upper bits of string, pointer to symbol storage, unused}. The symbol storage is allocated from another stack (which only grows). Upon lookup, if a symbol isn't in the hash table it is added with new storage. Symbols never get deleted.

View File

@@ -0,0 +1,249 @@
# 20141231 - Continued Notes on Custom Language
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20141231.html
# 20141231 - Continued Notes on Custom Language
*Continuing notes on portable development for Linux and Windows using a custom language...*
Using [WINE](https://www.winehq.org/) on Linux for Windows development is working great: ability to use OpenGL 4.x in native 64-bit WIN32 binaries on Linux. Using the same compiler to build both Linux and Windows binaries which can both be run from the same Linux box.
**Forth-like Language as a Pre-Processor for Code-Generation**
My 1706 byte compiler takes a stream of prefixed text: mostly {optional prefix character, then word, then space} repeated...
\comment\
word \compile call to address at word\
:word \compile pop data stack into word\
.word \compile push 64-bit value at word onto data stack\
'word \compile conditional call to address at word if pop top of stack is non-zero\
`word \copy opcodes at word into compile stream\
%word \compile push address of word, still haven't used this\
{ word \define word, stores compile address in word, then at closing stores size (used for opcodes)\ }
34eb- \compile push hex number negated\
,c3 \write raw byte into compile stream, x86 ret opcode in this example\
"string" \compile push address of string, then push size of string\
Compiler strips whitespace and comments while converting the input words into machine code (using the conventions above), then executes the machine code.
There is no "interpreter" as would normally be used in a Forth based language.
The compiler does not even have the standard Forth opcodes,
these are instead just specified in the input source file. For example ADD,
{ add ,48 ,03 ,03 ,83 ,eb ,08 }
Which is the raw opcode stream for "MOV rax,[rbx]; ADD rbx,8" where "rax" is the top of the data stack, and "rbx" points to the 2nd item on the data stack. Since Forth opcodes are zero operand, it is trival to just write them in source code directly (language is easily extendable). I use under 30 forth style opcodes. After an opcode is defined, it can be used. For example,
10 20 `add
Which pushes 16 then 32 on the data stack (numbers are all in hex), then adds them. To do anything useful, words are added which pop a value from the data stack and write them to a buffer. For example write a byte,
{ byte ,40 ,88 ,07 ,83 ,c7 ,01 ,48 ,8b ,03 ,83 ,eb ,08 }
Once the compiler is finished executing the machine code generated by the source, which in turn is used to write a binary into a buffer, the compiler stores that buffer to disk and exits. In order to do anything useful the next step is to use the language and source opcodes which extend the language to build an assembler. Some bits of my assembler (enough for the ADD opcodes),
\setup words for integer registers\
0 :rax 1 :rcx 02 :rdx 03 :rbx 04 :rsp 05 :rbp 06 :rsi 07 :rdi
8 :r8 9 :r9 0a :r10 0b :r11 0c :r12 0d :r13 0e :r14 0f :r15
\words used to generate the opcode\
{ REXw 40 `add `byte }
{ REX .asmR 1 `shr 4 `and .asmRM 3 `shr `add `dup 'REXw `drp }
{ REXx .asmR 1 `shr 4 `and .asmRM 3 `shr `add 48 `add `byte }
{ MOD .asmR 7 `and 8 `mul .asmRM 7 `and `add .asmMOD `add `byte }
{ OP .asmOP 8 `shr 'OPh .asmOP `byte }
{ OP2 :asmOP :asmRM :asmR 0c0 :asmMOD REX OP MOD }
{ OP2x :asmOP :asmRM :asmR 0c0 :asmMOD REXx OP MOD }
\implementation of 32-bit and 64-bit ADD\
{ + 03 OP2 } { X+ 03 OP2x }
Afterwords it is possible to write assembly like,
.rax .rbx + \32-bit ADD eax,ebx\
.rax .rbx X+ \64-bit ADD rax,rbx\
Due to the complexity of x86-64 ISA, I used roughly 300 lines to get a full assembler (sans vector opcodes). With a majority of those opcodes not even getting used in practice. The [ref.x86asm.net/coder64.html](http://ref.x86asm.net/coder64.html) site is super useful as an opcode reference.
**Binary Header**
Next step is writing source to generate either a PE (Windows) or ELF (Linux) binary header. ELF with "dlsym" symbol used roughly 70 lines (mostly comments to describe the mess of structure required for an ELF). The PE header I generate for WIN32 binaries looks similar to [this example from Peter Ferrie](http://pferrie.host22.com/misc/pehdr.htm)
which is a rather minimal header with non-standard overlapping structures.
I added an import table for base Kernel32 functions like "LoadLibraryA",
because of fear that manual run-time "linking" via PEB would trigger virus warnings on real Windows boxes.
I'm not really attempting to hit a minimum size (like a 4KB demo), but rather just attempting to limit complexity.
WINE handles my non-standard PE with ease.
If I was to write an OS, I wouldn't have binary headers (PE/ELF complexity just goes away). Instead I would just load the binary at zero, with execution starting at 4 with no stack setup, with binary pages loaded with read+write+execute, and then some defined fixed address to grab any system related stuff (same page always mapped to all processes as read-only). This has an interesting side effect that JMP/CALL to zero would just restart the program (if nop filled) or do exception (if invalid opcode filled). Program start would map zero-fill and setup stack. I'd also implement thread local storage as page mapping specific to a thread (keeping it simple).
**ABI: Dealing With the Outside World**
Having your own language is awesome ... dealing with the C based Linux/Windows OS is a pain. I use a 8-byte stack alignment convention. The ABI uses a 16-byte stack alignment convention. The ABI for Linux Kernel, Linux C export libraries, and 64-bit Windows is different. Here is a rough breakdown of register usage,
\_ \_\_\_ \_ LXK LXU WIN
0 rax .
1 rcx . k0 a3 a0
2 rdx . a2 a2 a1
3 rbx . s0 s0 s0
4 rsp X
5 rbp X t0 t0 t0
6 rsi . a1 a1 a4 <- stored before call on WIN
7 rdi . a0 a0 a5 <- stored before call on WIN
8 r8\_ . a4 a4 a2
9 r9\_ . a5 a5 a3
a r10 . a3 k0 k0
b r11 . k1 k1 k1
c r12 X t1 t1 t1
d r13 X t2 t2 t2
e r14 . s1 s1 s1
f r15 . s2 s2 s2
rax = return value (or syscall index in Linux)
rsp = hardware stack
a# = register argument (where Windows 64-bit a4 and a5 are actually on the stack)
t# = temp register saved by callee, but register requires SIB byte for immediate indexed addressing
s# = register saved by callee, no SIB required for immediate indexed addressing
k# = register saved by caller if required (callee can kill the register)
I use a bunch of techniques to manage portability. Use a set of words {abi0, abi1, abi2 ... } and {os0, os1, os2 ... } (for things which map to Linux system calls) which map to different registers based on platform. Use word "ABI(" to store the stack into R13, then align the stack to 16-bytes, then setup a stack frame for the ABI safe for any amount of arguments. Words "ABI", "ABI5", "ABI6+" to do ABI based calls based on the number of integer arguments needed for the call. This is needed because Linux supports 6 arguments in registers, and Windows only supports 4. Then later ")ABI" to get my 8-byte aligned stack back,
{ ABI( .abiT2 .rsp X= .rsp 0fffffffffffffff0 X#& .rsp 50- X#+ }
{ ABI \imm\ #@CAL } \call with up to 4 arguments\
{ ABI5 \imm\ #@CAL } \call with 5 arguments\
{ ABI6+ \imm\ #@CAL } \call with 6 or more arguments\
{ )ABI .rsp .abiT2 X= }
With the following words overriding some of the above words on Windows (slighly more overhead on Windows),
{ ABI(.W .abiT2 .rsp X= .rsp 0fffffffffffffff0 X#& .rsp 80- X#+ }
{ ABI5.W .abi4 .abiW4 PSH! \imm\ #@CAL }
{ ABI6+.W .abi4 .abiW4 PSH! .abi5 .abiW5 PSH! \imm\ #@CAL }
So a C call to something like glMemoryBarrier would end up being something like,
ABI( .abi0 \GL\_BUFFER\_UPDATE\_BARRIER\_BIT\ 200 # .GlMemoryBarrier ABI )ABI
And in practice the "ABI(" and ")ABI" would be factored out to a much larger group of work. The "#@CAL" translates to call to "CALL [RIP+disp32]", since all ABI calls are manual dynamic linking the ".GlMemoryBarrier" is the address which holds the address to the external function (in practice I rename long functions into something smaller). Since both Windows and Linux lack any way to force libraries into the lower 32-bits of address space, and x86-64 has no "CALL [RIP+disp64]", I decided against run-time code modification patching due to complexity (would be possible via "MOV rax,imm64; CALL rax"). Both Windows and Linux require slightly different stack setup. Convention used for Linux (arg6 is the 7th argument),
-58 pushed return
-50 arg6 00 <---- aligned to 16-bytes, ABI base
-48 arg7 08
-40 arg8 10
-38 arg9 18
-30 argA 20
-28 argB 28
-20 argC 30
-18 argD 38
-10 argE 40
-08 argF 48
+00 aligned base
Convention used for Windows,
-88 pushed return
-80 .... 00 <---- aligned to 16-bytes, ABI base
-78 .... 08
-70 .... 10
-68 .... 18
-60 arg4 20
-58 arg5 28
-50 arg6 30
-48 arg7 38
-40 arg8 40
-38 arg9 48
-30 argA 50
-28 argB 58
-20 argC 60
-18 argD 68
-10 argE 70
-08 argF 78
+00 aligned base
The C based ABI and associated
"{{save state, call, ... nesting ..., return, load state} small amount of code} repeat ...}" pattern
forces inefficient code in the form of code bloat and constant shuffling around data between functional interfaces.
Some percentage of callee-save registers are often used to shadow arguments,
often data is loaded to register arguments
only to be saved in memory again for the next call,
caller saves happen even when the callee does not modify, etc.
I'd much rather be using a "have command structures in memory, fire-and-forget array of pointers to commands" model.
The fire-and-forget model is more parallel friendly (no return),
and provides ability for reuse of command data (patching).
The majority of system calls or ABI library calls could just be baked command data which exists in the binary.
Why do I need to generate complex code to do constant run-time generation and movement of mostly static data?
I conceptionally treat registers as a tiny fast compile-time immediate-indexed RAM (L0$).
Register allocation is a per-task process, not a per-function process.
There is no extra shuffling of data. No push/pop onto stack frames, etc.
For example register allocation is fixed purpose during the two passes
of the compiler,
\\_\_\_\_REGISTERS\_DURING\_COMPILE\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\
.rax :chr \input character\ .rax :dic \dictionary entry address\ .rax :str#
.rcx :hsh \hash value\ .rcx :jmp \jump address\ .rcx :num .rcx :str$
.rdx :pck1 \string packing 1\ .rdx :num- .rdx :siz
.rbx :pck2 \string packing 2\ .rbx :chr$1
.rbp :dic$ \dictionary top pointer, not addressed from\
.rsi :chr$ \input pointer\
.rdi :mem$ \memory stack, compile stack\
.r8 :def$ \define stack\
.r15 :zero \set to zero\
\\_\_\_\_REGISTERS\_DURING\_EXECUTE\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\
.rax :top \rax used for .dic only at launch\
.rcx :cnt \counter on text copy\
.rdx :fsk$ \float stack pointer, points to 2nd entry\
.rbx :stk$ \data stack pointer, points to 2nd entry\
.rsi :txt$ \used for source on text copy\
.rdi :out$ \output pointer, points to next empty byte\
**Debugging**
My dev environment is basically two side by side terminal windows per virtual desktop with a easy switch to different virtual desktops.
I'm using nano as a text editor and have some rather simple color syntax highlighting for my language.
No IDE no debugger. Proper late stone-age development.
To port to WIN32 I did have to fix some code generation bugs with regard to having a non-zero ORG.
On Linux I load the binary at zero, so file offset and loaded offsets are the same.
This is not possible in Windows.
IMO there is more utility in keeping it simple than having zero page fault.
When tracking down bugs in code generation or binary headers I just use "hexdump -C binary".
My language supports injection of any kind of data during code generation,
so it is trivial to just wrap an instruction or bit of code or data with something like "--------"
which is easy to find via "hexdump -C binary | less".
The Forth inspired language I use has only one possible error, attempting to call a word which has not been defined (which calls zero).
My compiler does not print any error messages, it simply crashes on that error.
Since in practice this effectively almost never happens, I've never bothered to have it write out an error message.
The last time I misspelled a word, it was a super quick manual log search (commenting out code) to find the error.
When compiling and testing is perceptually instant, lots of traditional complexity is just not needed.
As for regular development, I started programming when a bug would take down the entire machine (requiring reboot).
Being brought up in that era quickly instills a different kind of development process
(one that does not generate bugs often).
Most bugs I have are opcode mistakes (misspellings), like load "@" instead of store "!", or using a 32-bit form of an opcode instead of the 64-bit form.
The only pointers which are 64-bit in my binaries are pointers to library functions (Linux loads libraries outside the 32-bit address space),
the stack (I'm still using the OS default instead of moving to the lower 32-bit address space), or pointers returned by a library.
When dealing with bugs with an instant iteration cycle, "printf" style debug is the fast path.
I've built some basic constructs for debugging,
BUG( "message" )BUG \writes message to console\
.bugN .rax = 10 BUG# \example: prints the hex value in RAX to 16 digits to console\
Adding something to my "watch window" is just adding the code to output the value to the console.
This ends up being way better than a traditional debug tool because console output provides
both the history and timeline of everything being "watched".
**Misc**
In the past I had a practice of building a custom editor and run-time for each language.
The idea being that it was more efficient to compile from a binary representation,
which has a dictionary embedded in the source code (no parsing, no hashing).
Ultimately I moved away from that approach due to the complexity involved in building the editor that I wanted for the language.
Mostly due to the complexity of interfacing with the OS.
It is really easy to fall in the trap of building a tool which is many times more complex than the problem the tool is engineered to solve.
Decoupling from the dependency of a typical compiler and toolchain on modern systems has been a great learning experience.
If FPGA perf/$ was competitive with GPUs I'd probabably move on to building at the hardware level instead...

View File

@@ -0,0 +1,16 @@
# 20150414 - From Scratch Bug
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150414.html
# 20150414 - From Scratch Bug
Inspired by Jaymin's [JayStation2](http://jaystation2.maisonikkoku.com/JayStation2/JayStation2.html) effort and remembering a past life building custom OSs for early x86 machines, haven't been able to avoid the custom OS bug any longer. It starts easy with a harmless QEMU install, followed by a 512-byte bootloader switching to 80x50 text mode and installing a custom 48 character Forth font, then bring up of a Forth assembler/editor, then on to the pain of modern PCI and USB driver bring-up... with the eventual goal of a tiny bootable USB thumb system.
Amazingly refreshing to not have the OS telling you NO. Or the API telling you NO. Modern systems are all about the NO. Systems I grew up on were all about the YES.
Reworking my language from scratch, trying something new, replacing the Forth data stack with a new concept, but maintaining zero operand opcodes. Not sure if the idea will pan out. Dropping everything but 32-bit word support from the language, no need to interop with other software. No more 8/16/64-bit loads or stores (can still just inline machine code if required). Still running in x86-64 64-bit mode, so return stack PUSH/POP/CALL/RET is still a 64-bit stack operation, just don't need that 64-bit address space or 64-bit pointers anywhere else. Trying padding out all x86 opcodes to 32-bit alignment. This makes the 32-bit immediate 32-bit aligned. Wastes space, gives up some perf? Why would I care when most of the CPU side of the system fits in the L1 cache. Dropping paging, dropping interrupts, dropping everything, none of that stuff is needed.
Reworking an editor and binary source encoding. Switching to 32-bit tokens with 5 character max strings. 48 character character-set. Doing something horrible with font design: 1=I, 0=O, 2=Z, 5=S, etc. All caps font with no non-vertical or non-horizonal lines. Actually looks awesome. When you don't have to interop with the NO machine, long symbol names are not required. Color Forth like editors have almost no state. It is magical how they function simultaneously as an editor/assembler/console/debugger/UI/etc. Take the idea of "editor-time-words", words embedded in the source code which are evaluated when the block of source is drawn to the screen. Becomes possible to build out UI tools in the source. Can have an editor-time word read system data and draw in real-time updates in the source code itself. Editor-time words are just like any other word in the system, just color tagged to only be evaluated at draw time.
Minimal systems are a blessing, more so when you have only minimal free time to work on them.

View File

@@ -0,0 +1,40 @@
# 20150420 - From Scratch Bug 2 : Source-Less Programming
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150420.html
# 20150420 - From Scratch Bug 2 : Source-Less Programming
*This is a disruptive idea which comes back periodically: source-less programming.
Is it possible to efficiently program at a level even lower than an assembler?*
The general idea is that the editor is now something similar to an enhanced hex editor which edits a binary image directly.
Lowest memory is split into three parts {{running image, annotations for edit image}, edit image}.
The {running image, annotations for edit image} is the boot image.
The {edit image} is working space which gets snapshot replacement for {running image} on a safe transition zone.
The "annotation" section is what enables human understanding of the binary image.
**Words**
One way to keep the system very simple is to always work in 32-bit words.
A 32-bit word in memory is one of four things {data, opcode, absolute address, rip relative address}.
Data is easily handled by the hex editor part.
The annotation could provide a name for the data or a comment.
Opcodes in x86 can be complex but it is easy to simplify.
Start with something similar to forth zero-operand and one-operand operations (calls, etc).
Make all operations padded to 32-bit alignment (x86-64 can use the 2e ignored prefix to pad).
A call for instance becomes {32-bit opcode for call, 32-bit rip relative branch address}.
Or a global load becomes {32-bit opcode for load, 32-bit rip relative branch address}.
Annotation memory can provide a name for the opcode.
Annotation can provide a tag for each word in memory which marks
if the memory is a relative or absolute address (word gets a different color based on tag similar to color forth).
Addresses can be auto annotated by displaying the annotation associated with the destination.
Editor works on the {edit image},
with insert and delete of words automatically adjusting all the words tagged as address
(effectively relinking at edit time).
The {edit image} can also keep a mapping of original {running image} address
so that it is possible to view the live values of any data.
Editor provides something to easily be able to write an annotation
and have the associated opcode or address automatically get updated.
For example type the opcode name and the 32-bit value is automatically updated.
Very simple and yet powerful minimal tool.

View File

@@ -0,0 +1,72 @@
# 20150422 - Source-Less Programming : 2
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150422.html
# 20150422 - Source-Less Programming : 2
*Continuing with what will either be an insanely great or amazingly stupid project...*
Making slow progress with bits of free-time after work, far enough thinking through the full editor design to continue building. Decided to ditch 64-bit long mode for 32-bit protected mode. Not planning on using the CPU for much other than driving more parallel friendly hardware... so this is mostly a question of limiting complexity.
Don't need 16 registers and the REX prefix is too ugly for me to waste time on any more.
The 32-bit mode uses much more friendly mov reg,[imm32] absolute addressing,
also with ability to use [EBP+imm32] without an SIB byte (another thing I mostly avoid).
Unfortunately still need relative addresses for branching.
32-bit protected mode thankfully doesn't require page tables unlike 64-bit long mode.
Can still pad out instructions to 32-bits via reduntant segment selectors.
**Source-Less Analog to Compile-Time Math?**
Compile-time math is mostly for the purpose of self-documenting code:
"const uint32\_t willForgetHowICameUpWithThisNumber = startHere + 16 \* sizeof(lemons);".
The source-less analog is to write out the instructions to compute the value,
execute that code at edit time, then have anotations
for 32-bit data words which automatically pull from the result when building 32-bit words for opcode immediates for the new binary image.
**Reduced Register Usage Via Self Modifying Code**
Sure, kills the trace cache in two ways, what do I care.
Sometimes the easist way to do something complex is to
just modify the opcode immediates before calling into the function...
**What Will Annotations Look Like?**
The plan so far is for the editor to display a grid of 8x8 32-bit words.
Each word is colored according to a tag annotation
{data, absolute address, relative address, pull value}.
Each word has two extra associated annotations {LABEL, NOTE}.
Both are 5 6-bit character strings.
Words in grid get drawn showing {LABEL, HEX VALUE, NOTE} as follows,
LABEL
00000000
NOTE
The LABEL provides a name for an address in memory (data or branch address).
Words tagged with absolute or relative addresses or pull value show in the NOTE field
the LABEL of the memory address they reference.
Words tagged with data use NOTE to describe the opcode, or the immediate value.
Editor when inserting a NOTE can grab the data value from other words
with the same NOTE (so only need to manually assemble an opcode once).
Edit-time insert new words, delete words, and move blocks of words,
all just relink the entire edit copy of the binary image.
ESC key updates a version number in the edit copy,
which the excuting copy sees triggering it to replace itself
with the edit copy.
**Boot Strapping**
I'm bootstrapping the editor in NASM in a way that I'll be able
to see and edit later at run-time.
This is a time consuming process to get started
because instead of using NASM to assemble code,
I need to manually write the machine code to get the 32-bit padded opcodes.
Once enough of the editor is ready,
I need a very tiny IDE/PATA driver to be able to store to the disk image.
Then I can finish the rest of the editor in the editor.
Then I'll also be self hosted outside the emulator
and running directly on an old PC with a non-USB keyboard,
but with a proper PCIe slot...

View File

@@ -0,0 +1,34 @@
# 20150423 - Source-Less Programming : 3
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150423.html
# 20150423 - Source-Less Programming : 3
**Annotation Encoding**
Refined from last post, two 32-bit annotation words per binary image word,
FEDCBA9876543210FEDCBA9876543210
================================
00EEEEEEDDDDDDCCCCCCBBBBBBAAAAAA - LABEL : 5 6-bit chr string ABCDE
FEDCBA9876543210FEDCBA9876543210
================================
..............................00 - DAT : hex data
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA01 - GET : get word from address A\*4
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA02 - ABS : absolute address to A\*4
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA03 - REL : relative address to A\*4
Going to switch to just 2 lines per word displayed in the editor,
Only DAT annotations show hex value, other types show LABEL of referenced address
in the place of the hex value. So no need for an extra note.
In practice will be using some amount of binary image memory to build up
a dictionary of DAT words representing all the common somewhat forth like opcodes,
then GET words in the editor to build up source.
Need to redo the bootloader from floppy to harddrive usage,
and switch even the bootloader's 16-bit x86 code to 32-bit aligned
LABEL'ed stuff so the final editor can edit the bootloader.
Prior was avoiding manually assembling the 16-bit x86 code in the boot loader,
but might as well ditch NASM and use something else to bootstrap everything.

View File

@@ -0,0 +1,61 @@
# 20150424 - Source-Less Programming : 4
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150424.html
# 20150424 - Source-Less Programming : 4
*Still attempting to fully vet the design
before the bootstrap reboot...*
DAT words in the edit image need to maintain
their source address in the live image
This way on reload the live data can be copied over,
and persistent data gets saved to disk.
DAT annotations no longer have 30 bits of free space,
instead they have a live address.
When live address is zero. then DAT words
won't maintain live data.
This way read-only data can be self-repairing
(as long as the annotations don't get modified).
Going to use a different color for read-only DAT words.
New persistent data DAT words
will reference their edit-image hex value
before reload (then get updated to the live address).
REL words always get changed on reload (self repairing).
No need to keep the live address.
REL is only used for relative branching x86 opcodes.
Don't expect to have any run-time (non-edit-time)
self-modifying of relative branch addresses.
Given that branching to a relative branch opcode immedate
is not useful, the LABEL of a REL word is only useful
as a comment.
GET words also get changed on reload (self repairing).
GET is only designed for opcodes and labeled constants.
GET words will often be LABELed as a named branch/call target.
Been thinking about removing GET, and instead making a new
self-annotating word (display searches for a LABELed DAT
word with the same image value, then displays the
LABEL instead of HEX).
This opens up the implicit possibility of mis-annotations.
Would be rare for opcodes given they are large 32-bit values.
But for annotating things like data structure immediate offsets,
this will be a problem
(4 is the second word offset in any structure).
ABS words always get changed on reload (self repairing).
ABS words are targets for self-modifying code/data,
so they also need LABELs.
Reset on reload presents a problem in that
ABS cannot be used to setup persistent data
unless that persistent data is constant
or only built/changed in the editor.
But this limitation makes sense in the context
that ABS addresses in live data structures
can get invalidated by moving stuff around in memory.
The purpose of ABS is edit-time relinking.

View File

@@ -0,0 +1,84 @@
# 20150426 - Source-Less Programming : 5
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150426.html
# 20150426 - Source-Less Programming : 5
**Boot Loader Bring-up**
Managed to get the boot loader done, which includes the following steps,
(1.) Move the stack seg:pointer (since next step overwrites it).
(2.) Use BIOS to read the other 62 512-byte sectors for the first track.
(3.) Use BIOS to switch to 80x50 text mode and load custom character glyphs.
(4.) Use BIOS to set EGA text palette to 0-15 with 0 for overscan.
(5.) Program VGA palette registers for those 16 colors.
(6.) Use BIOS to enable A20.
(7.) Turn off interrupts, and relocate the image's 63 sectors to zero.
(8.) Load zero entry IDT, minimal 3 entry GDT.
(9.) Enable protected mode and jump to the 3rd sector.
The 2nd 512-byte sector contains the 8x8 character bitmaps for the first 64 characters.
The majority of the time was spent making a nice font,
getting colors the way I wanted,
and prototyping editor look and feel (without building it).
Didn't feel like fully hand assembling 16-bit x86 machine code for the boot loader,
so I used NASM and hexdump to accellerate the process
(to provide machine code I could pad out to 32-bit alignment).
Also wrote a quick C based tool to bootstrap the process of building the loader.
Something which would enable me to easily build out an annotated image,
and show a print out in the console of what I'd be seeing in the editor.
Here is a shot of a bit of the scratch C code I used to make the font,
![](20150426-A.png)
Here is a shot in QEMU of the loader displaying the font,
![](20150426-B.png)
And another shot from QEMU showing the pallet,
![](20150426-C.png)
**What the Current Annotated Image Looks Like**
Below is a shot captured from the terminal window output of the C tool.
I'm using 3 cache lines for the loader code.
![](20150426-D.png)
Grey lines separate the 512-byte sectors.
Memory address on the left in grey.
Each pair of lines shows half a x86 cacheline.
The blue to white shows the 5 character/word annotation strings
(now using the extra 2 bits of the label for color).
The red hex show the image data.
Not using {GET,ABS,REL} tagged words in this part,
so everything in the bootloader is just hand assembled 16-bit machine code,
and this is not representative of what the rest of the system will look like.
The rest of the system will have {GET opcode} followed by {HEX} or {ABS}
for opcode immediates (easy to write).
The 16-bit code is {HEX} mixed opcode and immediates, quite a bit different (hard to write).
Some hints on the annotations,
Everything is in base 16.
AX is TOP so I don't bother with "A=9000" (which wouldn't fit anyway),
instead I just write "9000" (the A= is implied).
The "!" means store so "SSSP!" is storing TOP (or AX) into both SS and SP.
The "B=200" means BX=200h.
In this 16-bit x86 case I use 3E to pad out opcodes to 32-bit.
The "X" = SI, "Y" = DI, "F" = BP.
**Next Step**
Ground work is done,
next step is to bring up the opcode dictionary for {GET} words,
then write a little IDE driver to get access to load the rest of the image,
and to be able to save in the editor.
After that, write the drawing code for the editor,
then a mini PS/2 driver for the input,
then write editor input handling.
Then I have a full OS ready to start on a real machine.

View File

@@ -0,0 +1,67 @@
# 20150710 - Inspiration Reboot
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150710.html
# 20150710 - Inspiration Reboot
*Quite inspired by the insane one still or video per day at [beeple.tumblr.com](http://beeple.tumblr.com/).
Attempting to get back in the grove of consistently taking a small amount of non-work time every day to reboot fun projects.
I'm on week 2 now of probably a three month process of healing from a torn lower back,
sitting in front of a computer is now low enough pain to have fun again...*
**1536**
Setting a new 1536-byte (3x 512-byte sector) constraint for a bootloader + source interpreter
which brings up a PC in 64-bit long-mode with a nice 8x8 pix VGA font
and with 30720-bytes (60 sectors, to fill out one track) of source text for editor and USB driver.
USB providing thumb drive access to load in more stuff.
Have 1st sector bringing up VGA and long mode,
2nd sector with 64-character font,
and last 512-byte sector currently in progress as the interpreter.
Went full circle back to something slow, but dead simple:
interpreter works on bytes as input.
The following selection of characters appends simultaneously to a 60-bit 10 6-bit/char word string,
and a 64-bit number,
```
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ#$@!+*-^&|=?<>_
```
Then giving a "color forth tag" like meaning to another fixed set of characters,
~ - Negate the 64-bit number.
. - Lookup word in dictionary, and push 64-bit value onto data stack.
, - Push 64-bit number on data stack.
: - Lookup word in dictionary, pop 64-bit value from data stack to word.
; - Write 32-bit number at compile position.
" - Lookup word in dictionary, interpret the string at address stored in word.
[ - Lookup word in dictionary, store compile position in word, append string from [ to ] compile position.
] - When un-matched with ], this ends interpretation via RET.
\ - Ignore text until the next \.
` - Lookup word in dictionary, call to address stored in word.
Those set of characters replace the "space" character in forth, and work like a post-fix tag working on either the string or number just parsed from input.
The set of tags is minimal but flexible enough to build up a forth style macro language assembler,
with everything defined in the source itself.
More on this next time.
One nice side effect of post-fix tags is that syntax highlight is trivial by reading characters backwards starting at the end of the block.
**Sony Wega CRT HDTVs**
The old Wega CRT HDTVs work quite well.
They apparently are nearly fixed frequency 1080 interlaced with around 540 lines (or fields) per ~60 Hz frame,
and unlike prior NTSC CRT TVs, they seem to not do any real progressive scanning.
Taking a working 1080i modeline and converting it to 540p and driving the CRT
results in the Wega initiating a "mode-reset" when it doesn't see the interlaced fields for the 2nd frame.
However 480p modes do work (perhaps with an internal conversion to 1080i).
Given that 1080i modes are totally useless as the 60Hz interlace flicker is horrible,
and 540p won't work, these HDTVs should be complete garbage.
However 720p works awesome as the TV's processing to re-sample to 1080i does not flicker any worse than 60Hz already does.
In theory the even and odd fields (in alternating frames) share around 75% of an input line (540/720),
and likely more if the re-sampling has some low-pass filtering.
Drop in a PS4 game which has aliasing problems, and the CRT HDTV works like magic.
These late model "hi-scan" Wega CRTs only had roughly 853 pixel width aperture grille:
853x540 from what was a 1920x1080 render is a good amount of super-sampling...

View File

@@ -0,0 +1,50 @@
# 20150714 - 1536-1 : The Programmer Addiction = Feedback
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150714.html
# 20150714 - 1536-1 : The Programmer Addiction = Feedback
Continuing on the 1536-byte loader based system.
Interpreter finished, under the 1536-byte goal.
Second major goal is to get to the instant feedback productivity addiction loop going: modify, get feedback, repeat.
Have simple ASCII to custom 64-character set encoding converter,
and way to include the converter source text starting at sector 3 in the boot loader.
First major test, getting an infinite loop or infinite reboot working.
Source without any syntax coloring,
```
\1536-1 --- BOOTUP INTO SPIN OR REBOOT LOOP\
800000, \PUSH BOOT-UP COMPILE POSITION\
BOOT: \STORE IN BOOT WHICH GETS CALLED TO RUN SYSTEM\
FEEBFEEB,/ \WRITE OPCODE TO JUMP TO SELF\
EAEAEAEA,/ \OR WRITE OPCODE TO CRASH ON INVALID INSTRUCTION\
] \END COMPILE - LOADER WILL THEN JMP TO BOOT WORD\
```
Loader sets up memory with dictionary at 1MB (2MB chunk with 1MB overflow), copies source to 4MB (4MB chunk maximum), then starts the compile position at 8MB (so 8MB and on is the rest of the memory on the system). Had one major bug getting the interpreter up, forgot that \ in NASM results in a line continuation even when in a comment, removing a line of a lookup table resulting in a crash.
Tracking down bugs is very easy, add "JMP $" or "db 0xEA" in NASM to hang or reboot respectively.
**Adjustments**
Adjusted the character syntax.
- - Negate the 64-bit number, add dash to the string.
. - Lookup word in dictionary, and push 64-bit value from word entry onto data stack.
, - Push 64-bit number on data stack.
: - Lookup word in dictionary, pop 64-bit value from data stack to word entry.
; - Lookup word in dictionary, interpret string starting at address stored in word entry.
[ - Lookup word in dictionary, store pointer to source after the [ in the word entry, skip past next ].
] - When un-matched with ], this ends interpretation via RET.

View File

@@ -0,0 +1,126 @@
# 20150715 - 1536-2 : Assembling From the Nothing
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150715.html
# 20150715 - 1536-2 : Assembling From the Nothing
*Started bringing up a limited subset x86-64 assembler.
The full x86-64 opcode encoding space is an unfortunate beast of complexity which I'd like to avoid.
So I did...*
**Compromises**
This prototype sticks to only exactly 4-byte or 8-byte instructions
(8-byte only if the instruction contains a 32-bit immediate/displacement).
The native x86-64 opcodes are prefix padded to fill the full 4-byte word.
Given that x86-64 CPUs work in chunks of 16-bytes of instruction fetch,
this makes it easy to maintain branch alignment visually in the code.
Since x86-64 float opcodes are natively 4-bytes without the REX prefix,
I'm self limiting to only 8 registers for this assembler,
which is good enough for the intended usage.
I'm not doing doubles and certainly not wasting time on vector instructions (have an attached GPU for that!).
Supported opcode forms in classic Intel syntax,
op;
op reg;
op reg,reg;
op reg,imm32;
op reg,[reg];
op reg,[reg+imm8];
op reg,[reg+imm32];
op reg,[imm32];
op reg,[reg+reg]; <- For LEA only.
This is a bloody ugly list
which needed translation into some kind of naming
in which "op" changes based on the form.
I borrowed some forthisms:
@ for load, ! for store.
Then added ' for imm8,
" for imm32, and # for RIP relative [imm32].
A 32-bit ADD and LEA ends up with this mess of options
(note . pushes word value on the stack, so A. pushes 0 for EAX in this context,
and , pushes a hex number, and / executes the opcode word which assembles the instruction to the current assembly write position),
A.B.+/ .......... add eax,ebx;
A.1234,"+/ ...... add eax,0x1234;
A.B.@+/ ......... add eax,[rbx];
A.B.12,'@+/ ..... add eax,[rbx+0x12];
A.B.1234,"@+/ ... add eax,[rbx+0x1234];
A.LABEL.#@+/ .... add eax,[LABEL]; <- RIP relative
A.B.12,'+=/ ..... lea eax,[rbx+0x12];
A.B.C.+=/ ....... lea eax,[rbx+rcx\*1];
Then using L to expand from 32-bit operand to 64-bit operand,
A.B.L+/ .......... add rax,rbx;
A.1234,L"+/ ...... add rax,0x1234;
A.B.L@+/ ......... add rax,[rbx];
A.B.12,L'@+/ ..... add rax,[rbx+0x12];
A.B.1234,L"@+/ ... add rax,[rbx+0x1234];
A.LABEL.L#@+/ .... add rax,[LABEL]; <- RIP relative
A.B.12,L'+=/ ..... lea rax,[rbx+0x12];
A.B.C.L+=/ ....... lea rax,[rbx+rcx\*1];
**Source Example With Google Docs Mockup Syntax Highlighting**
Font and colors are not what I'm going for, just enough to get to the next step.
This is an expanded example which starts building up enough of an assembler
to boot and clear the VGA text screen.
Some of this got copied from older projects in which I used "X" instead of "L" to mark the 64-bit operand
(just noticed I need to fix the shifts...).
I just currently copy from this to a text file which gets included into the boot loader on build.
*(Lost Image Here When Minus Went Down)*
**From Nothing to Something**
This starts by semi-self-documenting hand assembled x86 instructions via macros.
So "YB8-L'![F87B8948,/]" reads like this,
(1.) Y.B.8-,L'! packed to a word name YB8-L'! with tag characters removed.
(2.) [ which starts the macro.
(3.) F87B8948 which is {48 (REX 64-bit operand), 89 (store version of MOV), 79 (modrm byte: edi,[rbx+imm8]), F8 (-8)}.
(4.) , which pushes the number on the data stack.
(5.) / which after , executes the empty word, which pops the data stack and writes 32-bit to the asm position.
(6.) ] which ends the macro.
Later YB8-L'! with ; appended can be used to assemble that instruction by interpreting the macro.
The first assembled words are $ which pushes the current assembly position on the stack,
and $DRP (which is actually a bug which needs to be removed).
The $! pops an address from the data stack, and stores the current assembly position to given address.
This is later used for instruction build macros which do things like PSH` where the ` results in the dictionary address for the PSH word to be placed on the data stack.
The end game is getting to the point where given one of the opcode forms,
it is possible to write the following to produce a function which compiles an opcode,
C033403E,^`\_;
Which pushes the 4-byte opcode base 0xC033403E, then the opcode name ^ for XOR, then runs the \_ macro which assembles this into:
MOV eax,0xC033403E;
JMP X86-RM;
Immediately afterwards it is possible to execute the ^ word (call it) and assemble an XOR instruction.
The X86-RM expects to get the REG and RM operands from the data stack with base instruction opcode data in EAX.
**Making a Mess to Clean Up**
This about concludes the worst part of getting going from nothing,
except for the PTSD dreams where people only speak in mixed hex and x86 machine code: FUCOM! REX DA TEST JO.
When placed into final context there will be a few KB of source to build an assembler which covers all functionality I need for the rest of the system.
At this point I can easily add instructions and a few more of the opcode forms as they are they are needed.
And it becomes very easy to write assembly like this,
A.A.^/ Y.B8000,"/ C.1F40,"/ L!REP/
Which is this in Intel syntax,
xor eax,eax; <- set eax to zero
mov edi,0xB8000; <- VGA text memory start address
mov ecx,0x1F40; <- 80x50 times two bytes per character
cld;
rep storq; <- using old CISC style slow form to "do:mov [edi],rax;add rdi,8;dec rcx;jnz do;"

View File

@@ -0,0 +1,28 @@
# 20150722 - 1536-3 : Simplify, Repeat
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150722.html
# 20150722 - 1536-3 : Simplify, Repeat
Night 3 on the 1536 project, decided to make some changes before going full ahead with writing an editor.
(1.) Switched the boot loader to not relocate to zero.
Now leaving the BIOS areas alone, I doubt I'll ever go back to real mode after switching to long mode,
this ends up making the code easier, and provides room for the next change.
(2.) Switched the boot loader to fetch the first 15 tracks instead of just 1 track.
Now have a little over 472KB of source to work with on boot,
which is effectively infinite for this project.
The motivation for this change was the realization that x86-64 assembly source would get big.
Don't want to change this later. 472KB is close to the maximum without checking for things like EBA, or handling non-full-track reads.
(3.) Switched to an easier source model. Lines are now always 64 characters long.
Comments are switch to a single \ which functions like the C // style comment, ignoring the rest of the line.
Since lines are always 64 bytes (cacheline sized and aligned),
the interpreter can quickly skip over comments.
This is a trade in increased source size, for simplification of the editor:
fixed size lines makes everything trivial.
(4.) Making a convention that syntax highlighting with color only has a line of context.
Which translates into don't let things wrap. Easy.

View File

@@ -0,0 +1,41 @@
# 20150809 - 1536-4 : Coloring
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150809.html
# 20150809 - 1536-4 : Coloring
Night 4 on 1536.
Brought up most of the "x56-40" (x86-64 in hex) assembler now.
Also have majority of the forth-like words needed to assemble self-documenting constants {add,mul,neg,not,and,or,xor,...}.
*(Lost Image When Minus Went Down)*
Started on the editor.
Just enough of a quick prototype to render the text view in the editor (sans cursor for now).
All screens on this post are captured from the editor running in an x86-64 emulator.
Keeping the fixed 64 character lines makes everything very simple.
Syntax highlighting was carefully designed to only need one line of context.
Just a simple backward sweep to color, then a forward sweep to correct the color for comments (the \ marks rest of line as comment).
Adjusted the font, {\_,-,=} all now extend out full font cell width so they can double as lines.
Adjusted the colors closer to what I like for syntax highlighting.
Still experimenting with how to comment and arrange source.
![](20150809.png)
Have 16 characters to the right of the source window to use for real-time debug data.
Like viewing values of registers, memory, etc.
Thinking through details in the background.
Next step is to bring up the non-USB throw-away keyboard driver,
then get the editor functional.
**Bugs**
Still finding the no-errors, no-tools, know-everything path, easy to work with.
This time lost some time to an opcode assembly bug.
A full class of opcodes was broken, something never validated from last time, just forgot to make a RIP relative offset RIP relative for non-branch instructions.
Everything else working out of the box with no human errors.
When the mind can reason about the entire system,
and the edit/execute loop is near instant,
bugs normally are instant fix.
Quite satisfying to work this way.

View File

@@ -0,0 +1,15 @@
# 20150810 - 1536-5 : Keys
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20150810.html
# 20150810 - 1536-5 : Keys
Evening 5 on 1536. Wrote a mini PS/2 keyboard driver (source below) based on prior work. Ran out of time for testing, got distracted by SIGGRAPH slides.
Only supporting 64 keys (bit array in register), good enough to run arcade controllers which alias as keyboards.
Only supporting driver key release on {shift, control, alt}, allowing application to clear bits for release for other keys.
Had an interesting bug today: forgot to implement the "MOV REG,REG" opcode, surprised got this far in 1536 without register to register move.
Manually keeping 16-byte groupings for instructions has some interesting side effects on coding style...
![](20150810.png)

View File

@@ -0,0 +1,98 @@
# 20151113 - Rethinking the Symbolic Dictionary
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20151113.html
# 20151113 - Rethinking the Symbolic Dictionary
*Another permutation of dictionary implementation for forth like languages...*
**Source**
Exported source is composed of two parts,
(1.) Token array, where tokens can reference a local symbol by index into local hash table.
(2.) Local symbol hash table, has string for each entry.
Strings are 64-bits maximum and are stored in a reversible nearly pre-hashed form.
So hashing of a string is just an AND operation.
Tokens are 32-bits.
Local symbol hash is after the token array, so it can be trivially discarded after import.
**Global Dictionary**
Global dictionary maps 32-bit index to 32-bit value.
Each 32-bit index has an associated 64-bit string stored in the same reversible nearly pre-hashed form.
Dictionary entries are allocated by just taking the next entry in a line.
There is no deletion. Just two arrays (32-bit value array, and 32-bit string array), and an index for the top.
**Source Import**
Starts with loaded source in memory and allocated space for one extra array,
(1.) Source token array, gets translated to loaded-in-memory form.
(2.) Source local symbol hash table, with each entry being a 64-bit string.
(3.) Remap space, extra zeroed array with a 32-bit value per entry in local hash table.
Import streams through the global dictionary,
checking for a match in the source's local symbol hash table.
Upon finding a match, it writes the global index for the symbol into the associated remap space entry.
Import next streams through the source token array,
replacing the local symbol index
with the global index from the remap space entry.
When the remap space entry is zero,
a new symbol is allocated in the global dictionary
(this involves adding a symbol to the end of the dictionary,
and coping over the string from the local symbol hash table to the global dictionary string array).
After import the local symbol hash table and remap space are discarded.
This solves many of the core problems from a more conventional design where the global dictionary is a giant hash table.
That conventional design suffers from bad cache locality (because of the huge hash table).
This new design maintains a cache packed global dictionary (no gaps).
That conventional design can have worst case first load behavior,
each initial lookup of a new word in the dictionary on load would miss through to DRAM,
adding 100 ns per lookup.
This new design is composed of either linear streaming operations for big data
(global dictionary, source token array, etc) all of which get hardware auto-prefetch.
The source local symbol hash table is expected to be not too big and easily stay in cache (the only thing with random access).
Note with this new design, interpreting source at run-time no longer has any hash lookup,
just a direct lookup.
**First Source Import**
First source import (after machine reboot) has effectively an empty dictionary,
so import can be optimized.
**Editing**
Edit time operations, such as find the index for an existing symbol,
check if a symbol already exists,
or tab complete a symbol,
is done via a full stream through the global dictionary string table.
This is a linear operation with full auto-prefetch, so expected to be quite fast in practice.
Edit time operations are limited by human factors, so not a problem.
**Source Export**
Source export requires first checking how many unique symbols are in the chunk of source.
Use a bit array with one bit per global dictionary entry.
Zero the bit array.
Stream through the chunk of source tokens and check for a clear bit in the bit array.
For each clear bit, set the bit, and advance the count of unique words.
Setup space for the local symbol hash.
Scale up the unique symbol count to make sure the hashing is efficient.
Pad up to the next power of 2 in size.
Stream through the source tokens,
using the token index to get a global dictionary string,
hash the string into the local symbol hash, writing the associated string if new entry,
and remapping the source token index to the local hash.
Export is the most complex part of the design, but still quite simple.

View File

@@ -0,0 +1,189 @@
# 20151222 - Random Holiday 2015
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20151222.html
# 20151222 - Random Holiday 2015
**Google Photos = Actually Working (edit) Fail Great**
Minus has basically imploded loosing a lot of the image content on this blog,
unfortunately Google Photos is not a great alternative,
while it seems to support original quality, it does not, see the 2nd image (got low-passed)!
EDIT: turns out Blogger is the source of this problem, the preview sends back re-compressed images,
but after the initial posting, the original quality file is actually presented.
So Google Photos seems to be good, and it's a quality bug in Blogger Preview which was the source of the problem.
![](20151222-A.png)
**Vintage Interactive Realtime Operating System**
Taking part of my Christmas vacation time
to reboot my personal console x86-64 OS project.
I've rebooted this project more times than I'm willing to disclose on this blog.
Hopefully this reboot will stick long enough to build something real with it.
Otherwise it's been great practice, and the evolution of ideas has certainly been enlightening.
Here is a shot of the binary data for the boot sector in the editor,
![](20151222-B.png)
My goal is to rewind to the principals of the Commodore 64,
just applied to modern x86-64 hardware and evolved down a different path.
In my case to build a free OS with open source code which boots into a programming interface,
which fully exposes the machine, and provides some minimal interface to access hardware
including modern AMD GPUs.
With a feature list which is the inverse of a modern operating system:
single-user, single-tasking, no paging, no memory protection ...
the application gets total control over the machine,
free to use parallel CPU cores and GPU(s) for whatever it wants.
Ultimately manifesting as a thumb drive which can be plugged into a x86-64 machine
with compatible hardware and boot the OS to run 100% from RAM, to run software.
**A Tale of Two Languages**
C64 provided Basic at boot, I'm doing something vastly different.
Booting into an editor
which is a marriage
between
a spreadsheet, hex editor,
raw memory view, debugging tool,
interactive live programming environment,
annotated sourceless binary editor with automatic relink on edit,
and a forth-like language.
Effectively I've embedded a forth-like language in a sourceless binary framework.
The editor runs in a virtualized console
which can easily be embedded inside an application.
The editor shows 8 32-bit "cells" of memory per line (half cacheline),
with a pair of rows per cell.
Top row has a 10-character annotation (with automatic green highlight if the cell is referenced in the binary),
the botton row shows the data formatted based on a 4-bit tag stored in the annotation.
Note the screen shot showing the boot sector
was hand assembled 8086 (so is embedded data),
built from bits of NASM code chunks then disassembled
(it's not showing any of the embedded language source).
Tags are as follows,
unsigned 32-bit word
signed 32-bit word
four unsigned 8-bit bytes
32-bit floating point value
-----
unsigned 32-bit word with live update
signed 32-bit word with live update
four unsigned 8-bit bytes with live update
32-bit floating point value with live update
-----
32-bit absolute memory address
32-bit relative memory address [RIP+imm32]
toe language (subset of x86-64 with 32-bit padded opcodes)
ear language (forth-like language, encoded in binary form)
-----
5-character word (6-bits per character)
last 3 saved for GPU binary disassembly
Editor designed to edit an annotated copy of the live binary,
with a frameword designed to allow realtime update of the live binary as a snapshot of the edited copy.
The "with live update" tags
mean that the editor copy saves a 32-bit address to the live data
in it's copy of the binary (instead of the data itself).
This allows for direct edit and visualization of the live data,
with ability to still move bits of the binary around in memory.
The "toe" and "ear" tagged cells show editable disassembled x86-64 code
in the form of these languages.
The "ear" language is a zero-operand forth-like language.
Current design,
```
regs
----
rax = top
rcx = temp for shift
rbx = 2nd item on data stack, grows up
rbp = 4
rdi = points to last written 32-bit item on compile stack
bin word name x86-64 meaning
-------- ---- ----------------------------
0389dd03 , add ebx,ebp; mov [rbx],eax;
dd2b3e3e \ sub ebx,ebp;
c3f2c3f2 ; ret;
dd2b0303 add\ add eax,[rbx]; sub ebx,ebp;
dd2b0323 and\ and eax,[rbx]; sub ebx,ebp;
07c7fd0c dat# add edi,ebp; mov [rdi],imm;
d0ff3e3e cal call rax;
15ff3e3e cal# call [rip+imm];
058b3e3e get# mov eax,[rip+imm];
890fc085 jns# test eax,eax; jns imm;
850fc085 jnz# test eax,eax; jnz imm;
880fc085 js# test eax,eax; js imm;
840fc085 jz# test eax,eax; jz imm;
c0c73e3e lit# mov eax,imm;
03af0f3e mul imul eax,[rbx];
d8f73e3e neg neg eax;
00401f0f nop nop;
d0f73e3e not not eax;
dd2b030b or\ or eax,[rbx]; sub ebx,ebp;
05893e3e put# mov [rip+imm],eax;
f8d20b8b sar mov ecx,[rbx]; sar eax,cl;
e0d20b8b shl mov ecx,[rbx]; shl eax,cl;
e8d20b8b shr mov ecx,[rbx]; shr eax,cl;
dd2b032b sub\ sub eax,[rbx]; sub ebx,ebp;
dd2b0333 xor\ xor eax,[rbx]; sub ebx,ebp;
```
For symbols the immediate operands are all 32-bit
and use "absolute" or "relative" tagged cells following the "ear" tagged cell.
Likewise for "dat#" which pushes an immediate on the compile stack,
and "lit#" which pushes an immediate data on the data stack,
the following cell would have a data tag.
The dictionary is directly embedded in the binary,
using the edit-time relinking support.
No interpretation is done at run-time,
only edit-time,
as the language is kept in an executable form.
After building so many prototypes which "compile"
source to a binary form,

View File

@@ -0,0 +1,60 @@
# 20161113 - Vintage Programming 2
**Source:** https://refined-github-html-preview.kidonng.workers.dev/gomson/TimothyLottes.github.io/raw/refs/heads/master/20161113.html
# 20161113 - Vintage Programming 2
This is a follow-up to the [20140816 - Vintage Programming](20140816.html) post talking about this,
![](20140816-A.png)
**Retrospective**
Was thinking about resurecting the Atom project now that Vulkan supports what I would need to complete it,
and had to decide upon what language to write the reboot in.
Looking back at all my language and compiler experiments on PC over the years,
the A Language as described in that prior post from 2014 had the most utility
and was the easiest to be productive on in current PC style operating systems.
**Adjustments**
First implementation of compiler took ANSI text source file and output a binary.
The source had to build the ELF or PE header for the binary (similar to an assembler running without a linker).
This round, the compiler is the platform executable,
and programs will run directly from source (JITing themselves).
Compiler will be built around interactive run-time edit/recompile/retry loop which maintains existing program state in memory during the process.
* Start: Read the source file into the top of the memory stack.* Interpret the source into binary code.* Loop: Call the binary code entry point, if source file timestamp changed exit loop.* Jump to Start.
Source can thus be edited in the background in any text editor while the program runs.
Save the source file, and the program reloads itself while it runs.
Likewise the source could be edited inside the program itself.
Lots of flexibility.
**Portability and Distribution**
One source file for any platform, source adapts to the platform as it JITs itself into binary code at run-time.
Distribution is just pairing the platform specific compiler binary (which can be renamed to the program name),
and the source file (which will have a set name like "rom.a", so a double click of the renamed compiler runs the application without any arguments).
Platform specific compilers will be a few K executable depending on how minimal the ELF or PE is.
For a secondary option at some point I'll make something which can build a single executable with the compiler embedded with source.
**Open Source**
I'm going fully open-source for this project.
Compiler is being written in NASM assembly with embedded PE/ELF so there is no need for any kind of linker to build the compiler.
Thus far got a 1st draft on the PE done with all the Kernel32 symbols I believe I need,
with an executable which loads and then spins forever.
Will continue to bring up on Windows first to verify PE works on real Windows boxes,
before migrating back to Linux and Wine. More later as this project continues ...
Work in progress here: [github.com/TimothyLottes/A](https://github.com/TimothyLottes/A)

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 KiB

View File

@@ -0,0 +1,113 @@
# OCR Thread: X.com - Onat & Lottes Interaction 1.png
Post
OnatTurkcuoglu @onattØ • Apr 30
Reply
Forgot to mention in the heat of presentation, the initial textual language
was heavily influenced by one of your past forth-like languages.
Though I've built upon that foundation, I would have taken many wrong
turns without your guidance, thank you so much.
$4
NOTimothyLottes @NOTimothyLottes • Apr 28
Onat demos his radical language/editor/system for CPU+GPU
programming: youtube.com/watch?FJ9U_5t„.
01
NOTimothyLottes @NOTimothyLottes • Apr 30
Related thoughts/
253
[O] Having a low upper bound on the maximum complexity allowed in a
program enables so much simplification. One can always move complexity
into data, while keeping tight codebases.
01
NOTimothyLottes @NOTimothyLottes • Apr 30
[1] Seems like you group symbols into pages where each page can have a
string (shared with all symbols in the page), which when pared with limited
fixed maximum symbol string size, is an elegant way of effectively
supporting larger naming [I'll probably steal that idea next time]
02
NOTimothyLottes @NOTimothyLottes • Apr 30
[2] I'm also a big fan of how you used 16:9 aspect to auto render all the
debug info, symbol tables, disassembly, etc, alongside the source. I think
many people are probably lost in the speed at which you can manipulate
and test ideas while working on the source
01
NOTimothyLottes @NOTimothyLottes • Apr 30
[3] I got side tracked by building a language that could be assembled from
on the GPU in SIMD. However now I ask myself if that is just adding
"complexity", because if programs are bounded in size, why not just focus
on CPU non-parallel nested factoring (aka the forth-like way)
02
NOTimothyLottes @NOTimothyLottes • Apr 30
[4] 2-item data stack is an interesting compromise. Something I never
considered. I left off ripping out the data stack completely.
01
NOTimothyLottes @NOTimothyLottes • Apr 30
[5] Can do this instead,
a. Track a "top" register (number)
b. Use symbols to override top register
c. Have push (store) just advance top to next reg (in circular queue)
Gets to easy unnamed arguments
02
NOTimothyLottes @NOTimothyLottes • Apr 30
[6] You mentioned VK is most "form filling" which I think is an accurate
description. For most "C" like APIs I like to just lay out all the arguments in
memory like a tape drive in the order that functions get called and source
that tape at runtime for the calls
01
NOTimothyLottes @NOTimothyLottes • Apr 30
[7] They key concept here is that "common" arguments like the device are
pushed onto the tape using store duplication when they are known (after
device creation). So it's preemptive scatter, so later at call time there is no
argument gather.
01
NOTimothyLottes @NOTimothyLottes • Apr 30
[8] Likely the majority of C/C++/OOP/bloatware is just shuffling data
around in argument gather to support the concept of data stacks on HW
that has no physical data stack.
02
Onat Turkcuoglu
@onattØ
holy truthnuke - and people think C is the optimal state of possible
runtimes when it's a very limited runtime to have state mixed call/data-
stacks
not only you have to keep the whole stack around with replicated state,
it limits to serialized execution instead of parallel
2:53 PM Apr 30, 2025 57 Views
Post your reply
NOTimothyLottes @NOTimothyLottes • Apr 30
Reply
I laugh when people say C is like assembly, they are missing what we
actually did in assembly back then, which was all registers and globals and
gotos, no stacks. It's radically different than good assembly.
01
OnatTurkcuoglu @onattØ • Apr 30
when C became •the* execution model, it restricted all future hardware, HW
gets built with how the C compiler will compile to it instead of what's
ultimately a good design and a malleable macro-lang to map to HW
ofc a lot of people want portability so we went the boring route
01
NOTimothyLottes @NOTimothyLottes • Apr 30
The big industry mistake was factoring into thousands of functions in code,
instead of just baking all that into a "protocol" of data structures in memory.
Like OOP member functions to load or mutate one variable = vomit.
01
NOTimothyLottes @NOTimothyLottes • Apr 30
138
I do all my custom CPU side stuff more like treating the register file like a
"memory" of which the contents are aliased to different shared structures
for different purposes across time
01
NOTimothyLottes @NOTimothyLottes • Apr 30
So the register file is more like an aliased global namespace. And
"functions" are free of arguments and free of returns. This way of working
with the HW is way better and easier than the 'C' model.
01
NOTimothyLottes @NOTimothyLottes • Apr 30
In the few cases where you need to reuse small code patterns, those end
up a compile time macros that inline to different registers, larger pattems
are already better factored to data
01
OnatTurkcuoglu @onattØ • Apr 30
this is the galaxy-brain take on register-allocation right here - radically
simpler than what I had in mind:)
0

View File

@@ -0,0 +1,62 @@
Here is a curated list of **additional** highly relevant technical resources I scavenged (beyond the presentations, Twitter interactions, and Lottes blog archives you already OCRd/analyzed). I focused strictly on alignments with your paradigm: zero-overhead x86-64, sourceless ColorForth-derivative, 32-bit aligned token/opcode arrays, hex-editor IDEs (Lottes x68/Neokineogfx style), 2-item register stack (RAX/RDX + xchg, aliased globals per Onat), preemptive scatter/tape-drive args, instant <5 ms compilation/live reload, and no runtime data stack.
I prioritized deep architectural explanations, editor/token mechanics, and live machine-code manipulation. No public full code dumps or C-emitters for x68/KYRA were found (Onats repos are unrelated minimal C samples; Lottes keeps x68 details in talks). But the sources below give precise implementation blueprints, quotes, and diagrams-in-text that match your model exactly.
### 1. Lottes x68 / Neokineogfx (32-bit opcode padding, hex-editor frontend, token arrays)
- **"4th And Beyond" video (Neokineogfx / Timothy Lottes, uploaded Jan 14 2026)**
https://www.youtube.com/watch?v=Awkdt30Ruvk
Direct deep-dive on x68 as x64 subset using **only 32-bit granularity opcodes** (ignored prefixes + multibyte NOP padding for alignment).
Key excerpts (from auto-transcript):
- "x68 … subset of x64 which works with op codes at 32-bit granularity only. … x86-64 supports ignored prefixes which can pad op codes out to 32-bit. … if we wanted to do a 32-bit instruction for return, we might put the return, which is a C3, and then pad the rest of it with a three byte noop."
- "Source … 32-bit tokens. … 28 bits of compressed name or string and four bits of tag. The tag controls how to interpret the source token."
- Editor: "advanced 32-bit hex editor. … split the source into blocks … subblocks … source and then some annotation blocks. … for every … 32-bit source word, … 64-bit of annotation information … eight characters … 7 bit … 8bit tag for editor. And the tag will give me the format of the 32-bit value in memory."
- Dictionary: "32-bit words for words … direct addresses into the binary and the binary is going to be the dictionary. … fix the position … no address base randomization."
- Philosophy: "When your OS is an editor, is a hyper calculator, is a debugger, is a hex editor, you end up with this interactive instant iteration software development."
This is the strongest new source for your hex-frontend + annotation overlay + 32-bit padding helpers. He explicitly plans a separate x68 talk (not yet released as of Feb 2026).
- **Additional clarification from his archived "From Scratch Bug 2: Source-Less Programming" (20150420) and ": 2" (20150422)** (you have the raw HTML, but these sections align 1:1 with the 2026 video):
- Memory model: running image + parallel annotations + edit image; live swap at safe points.
- 32-bit word types: data / opcode / abs addr / RIP-rel addr.
- Editor grid: per-word LABEL (5×6-bit chars), HEX value, NOTE. Auto-relink on insert/delete for all address-tagged words. Version number in image triggers self-replacement.
- Padding example (x86-64): "Call = [32b call opcode] + [32b RIP-rel addr]".
These flesh out the exact visual editor mechanics you need for sourceless 32-bit token manipulation without string parsing.
- **"Scatter-Only Gather-Free Machines" (20161014 post title in archive)**
Direct match to your "preemptive scatter" for function arguments. (Thin content in the fetch, but the title + context from 1536 series points to static pre-placement of args in a linear memory "tape" arena before calls — no runtime stack ops.)
### 2. Onats KYRA/VAMP (global load/store, token dictionary indexing, 2-reg stack)
- **lang.html (Bit Test Complement)** https://onatto.github.io/lang.html
(You linked it before; here are the exact matching specs you asked for):
- 1800-byte x64 compiler, 192-line x64 asm (RIP-rel, heavy RAX/RDX + xchg for 2-item stack).
- Sub-5 ms SPIR-V, 1-2 ms total compile. Flat global namespace (aliased registers/memory).
- Binary encoding → direct machine code (no strings at runtime). Custom Vulkan IDE with instant feedback, 512 undo, crash-resilient.
Matches your model perfectly; no deeper public code/template dumps exist (his GitHub has only unrelated bare-metal C).
- **"Metaprogramming VAMP in KYRA" SVFIG talk (Apr 2025)** https://www.youtube.com/watch?v=J9U_5tjdegY
+ Forth Day 2020 preview (x64 + ColorForth + SPIR-V).
Covers binary token encoding, global namespace mapping, and the exact register/stack philosophy you described. No slides/code in meeting notes, but the video is the canonical deep-dive.
### 3. Ecosystem Parallels (minimalist zero-dep x86-64 machine code gen + instant live-reloaded sourceless)
- **Andreas Fredriksson "Hot Runtime Linking" (2012)** https://deplinenoise.wordpress.com/2012/02/11/hot-runtime-linking/
Exact match for instant compilation (<5 ms delta) + live-reloaded machine-code manipulation without restart.
Architecture:
- Linker daemon (host) does in-memory symbol resolution + relocations on changed .o files only.
- Target process parks at safe points (e.g., main loop), receives delta patches over socket.
- Conservative pointer scan + GC for old code blocks (retains if dangling refs).
- Zero-downtime atomic swap; handles function pointers via opt-in callback.
Quote: "The host garbage collects stale code and data … scanning the target process memory … If so, a warning is printed and the blocks are retained."
His Tundra build system (same author) is the zero-dep fast incremental piece. Perfect bridge to your sourceless live IDE.
- **Chuck Moore OKAD (sourceless precursor)** https://www.ultratechnology.com/okad.htm
Direct philosophical/technical ancestor:
- "Structure of the programs looks like Forth code, but there was no Forth compiler … Chuck himself [entered the kernel using a debugger]."
- Tools: hex memory editor + instruction decompiler/editor. All editing direct on bytecode (no source).
- "Collection of about a dozen 1K programs." Bootstrapped repeatedly without source.
Matches your bound-complexity + visual sourceless editor exactly.
### 4. Data Structures (tape-drive args + sourceless 32-bit token dictionary)
- Lottes model (synthesized from video + 2015 posts):
- **Token array**: flat 32-bit words in blocks (no filesystem). Each word = value + 4-bit tag (data/opcode/abs/rel/immediate).
- **Sourceless editor**: parallel annotation overlay (64-bit per token in 2026 design: 8×7-bit chars + 8-bit format tag). Editor reads/writes the token array directly; tags drive display (color/name/hex) with zero string parsing. Auto-relink addresses on edit.
- **Tape-drive / preemptive scatter**: Linear memory arena. Compiler statically scatters args into fixed slots before a call (gather-free). No data stack at runtime — registers + pre-placed tape slots only. (Explains your "memory tape-drive" for arguments + bound complexity forcing data structures.)

View File

@@ -0,0 +1,40 @@
Heres **more** highly relevant additions (scavenged fresh, strictly aligned to your zero-overhead sourceless x86-64 ColorForth-derivative: 32-bit token arrays, hex/sourceless editor, tape-drive scatter, 2-reg stack, instant compile/live reload). Strong focus on **WebAssembly** (binary format, linear memory tape parallels, dynamic emission, structured binary editors) plus other immediately useful tooling. No direct new Lottes/Onat Wasm material, but Wasm/SPIR-V binary parallels are explicit.
### WebAssembly Core Parallels & Tooling
Wasms binary section format + single growable linear memory (fixed-offset load/store, no runtime stack) is an almost 1:1 match for your 32-bit aligned tokens + preemptive scatter “tape drive” args. Decode/JIT is designed for <5 ms instantiation.
- **WAForth** (dynamic Forth-to-Wasm compiler written entirely in raw .wat)
https://github.com/remko/waforth
https://mko.re/waforth/ (live demo console)
~14 KB (7 KB gz) complete minimal Forth interpreter + **dynamic compiler** that emits new Wasm bytecode on-the-fly (LEB128 append, function table + indirect calls for words). Uses linear memory for 4-byte aligned stack/tape. CODE word for raw Wasm opcodes. Jonesforth-inspired. FOSDEM 2023 talk slides (hand-written minimal Wasm Forth system): https://archive.fosdem.org/2023/schedule/event/webassemblyforth/attachments/slides/5876/export/events/attachments/webassemblyforth/slides/5876/Exploring_WebAssembly_With_Forth.pdf
Direct blueprint for your token → machine-code emission loop and live reload.
- **ImHex** (star for your sourceless hex-editor frontend)
https://github.com/WerWolv/ImHex
https://web.imhex.werwolv.net/ (browser version runs via Wasm)
Professional hex editor with **Pattern Language** (.hexpat C-like DSL). Define custom 32-bit token structs (value + tag + annotation overlay) → automatic parse, highlight, tree view, colors, names, disassembly. Live patching, huge files, zero string parsing. Patterns repo: https://github.com/WerWolv/ImHex-Patterns (hundreds of examples).
Fork this for exact Lottes-style annotation overlay on your token array. Native + web versions both zero-dep.
Tiny example pattern snippet you can drop in (for a 32-bit token + 4-bit tag + 64-bit annotation block):
```c
struct Token {
u32 value;
u8 tag : 4;
u8 padding : 4;
char name[7]; // 7×7-bit compressed like Lottes
u64 annotation; // editor overlay (color/format)
};
Token tokens[$ / sizeof(Token)];
```
- **WABT / wasm-tools** (low-level binary manipulation)
https://github.com/WebAssembly/wabt
Official toolkit: wat2wasm / wasm2wat / disassembly / validation. Use for fast token-dictionary ↔ binary round-tripping or hex-patching prototypes. Pairs perfectly with ImHex.
- **Visual Wasm Structure Editor** (sourceless module building)
https://www.youtube.com/watch?v=liJg6rzXnPg
Visual (non-text) editor for adding instructions/sections directly to Wasm binary. Exact parallel to hex-editor + annotation for token arrays.
### Other Immediately Helpful
- **Wasm linear memory as tape-drive reference**
Wasms flat byte array with fixed-offset access is the cleanest public example of “preemptive scatter” without a runtime data stack. See practical buffer/tape examples: https://blog.jeremylikness.com/blog/2019-04-22_play-the-chaos-game-to-understand-webassembly-memory-management/ (passing pre-placed arrays between host and Wasm with zero copying).

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,859 @@
\ Part 2 of the JonesForth tutorial.
\ This one is added word-by-word as they are succesfully executed
\ Define / and MOD in terms of /MOD
: / /MOD SWAP DROP ;
: MOD /MOD DROP ;
\ Some char constant
: '\n' 10 ;
: BL 32 ; \ BL (blank) is standard FORTH word for space.
: CR '\n' EMIT ;
: SPACE BL EMIT ;
: NEGATE 0 SWAP - ;
: TRUE 1 ;
: FALSE 0 ;
: NOT 0= ;
\ LITERAL takes whatever on the stack and compiles LIT <foo>
: LITERAL IMMEDIATE
' LIT ,
,
;
: ':'
[
CHAR :
]
LITERAL
;
: ';' [ CHAR ; ] LITERAL ;
: '(' [ CHAR ( ] LITERAL ;
: ')' [ CHAR ) ] LITERAL ;
: '"' [ CHAR " ] LITERAL ;
: 'A' [ CHAR A ] LITERAL ;
: '0' [ CHAR 0 ] LITERAL ;
: '-' [ CHAR - ] LITERAL ;
: '.' [ CHAR . ] LITERAL ;
: [COMPILE] IMMEDIATE
WORD
FIND
>CFA
,
;
: RECURSE IMMEDIATE
LATEST @
>CFA
,
;
\ Conditionals Statements
: IF IMMEDIATE
' 0BRANCH ,
HERE @
0 ,
;
: THEN IMMEDIATE
DUP
HERE @ SWAP -
SWAP !
;
: ELSE IMMEDIATE
' BRANCH ,
HERE @
0 ,
SWAP
DUP
HERE @ SWAP -
SWAP !
;
: UNLESS IMMEDIATE
' NOT ,
[COMPILE] IF
;
\ Loop Construct
: BEGIN IMMEDIATE
HERE @
;
: UNTIL IMMEDIATE
' 0BRANCH ,
HERE @ -
,
;
: AGAIN IMMEDIATE
' BRANCH ,
HERE @ -
,
;
: WHILE IMMEDIATE
' 0BRANCH ,
HERE @
0 ,
;
: REPEAT IMMEDIATE
' BRANCH ,
SWAP
HERE @ - ,
DUP
HERE @ SWAP -
SWAP !
;
\ Comments
: ( IMMEDIATE
1
BEGIN
KEY
DUP '(' = IF
DROP
1+
ELSE
')' = IF
1-
THEN
THEN
DUP 0= UNTIL
DROP
;
( Now we can nest ( ... ) as much as we want )
\ Stack Manipulation
: NIP ( x y -- y ) SWAP DROP ;
: TUCK ( x y -- y x y ) SWAP OVER ;
: PICK ( x_u ... x_1 x_0 u -- x_u ... x_1 x_0 x_u )
1+
8 * ( multiply by the word size )
DSP@ +
@
;
\ Writes N spaces to stdout
: SPACES ( n -- )
BEGIN
DUP 0>
WHILE
SPACE
1-
REPEAT
DROP
;
\ EXTRA: Writes N zeroes to stdout
: ZEROES ( n -- )
BEGIN
DUP 0>
WHILE
'0' EMIT
1-
REPEAT
DROP
;
\ Standard word for manipulating BASE.
: DECIMAL ( -- ) 10 BASE ! ;
: HEX ( -- ) 16 BASE ! ;
( Printing Numbers )
: U. ( u -- )
BASE @ /MOD
?DUP IF ( if quotient <> 0 then )
RECURSE ( print the quotient )
THEN
( print the remainder )
DUP 10 < IF
'0'
ELSE
10 -
'A'
THEN
+
EMIT
;
( Printing the content of the stack )
: .S ( -- )
DSP@
BEGIN
DUP S0 @ <
WHILE
DUP @ U.
SPACE
8+
REPEAT
DROP
;
( Returns the width of an unsigned number (in characters) in the current base )
: UWIDTH
BASE @ /
?DUP IF
RECURSE 1+
ELSE
1
THEN
;
: U.R ( u width -- )
SWAP
DUP
UWIDTH
ROT
SWAP -
SPACES
U.
;
\ EXTRA, print zeroes padded unsigned number
: ZU.R ( u width -- )
SWAP
DUP
UWIDTH
ROT
SWAP -
ZEROES
U.
;
: .R ( n width -- )
SWAP ( width n )
DUP 0< IF
NEGATE ( width u )
1 ( save flag to remember that it was negative | width u 1 )
SWAP ( width 1 u )
ROT ( 1 u width )
1- ( 1 u width-1 )
ELSE
0 ( width u 0 )
SWAP ( width 0 u )
ROT ( 0 u width )
THEN
SWAP ( flag width u )
DUP ( flag width u u )
UWIDTH ( flag width u uwidth )
ROT ( flag u uwidth width )
SWAP - ( flag u width-uwidth )
SPACES ( flag u )
SWAP ( u flag )
IF
'-' EMIT
THEN
U.
;
( Finally )
: . 0 .R SPACE ;
( The real U. )
: U. U. SPACE ;
: ? ( addr -- ) @ . ;
: WITHIN ( c a b - f )
-ROT ( b c a )
OVER ( b c a c )
<= IF
> IF ( b c )
TRUE
ELSE
FALSE
THEN
ELSE
2DROP
FALSE
THEN
;
: DEPTH ( -- n )
S0 @ DSP@ -
8-
;
: ALIGNED ( addr -- addr )
7 + 7 INVERT AND
;
: ALIGN HERE @ ALIGNED HERE ! ;
: C,
HERE @ C!
1 HERE +!
;
: S" IMMEDIATE ( -- addr len )
STATE @ IF
' LITSTRING ,
HERE @
0 ,
BEGIN
KEY
DUP '"' <>
WHILE
C,
REPEAT
DROP
DUP
HERE @ SWAP -
8-
SWAP !
ALIGN
ELSE
HERE @
BEGIN
KEY
DUP '"' <>
WHILE
OVER C!
1+
REPEAT
DROP
HERE @ -
HERE @
SWAP
THEN
;
: ." IMMEDIATE
STATE @ IF
[COMPILE] S"
' TELL ,
ELSE
BEGIN
KEY
DUP '"' = IF
DROP
EXIT
THEN
EMIT
AGAIN
THEN
;
( Constant and Variables )
: CONSTANT
WORD
CREATE
DOCOL ,
' LIT ,
,
' EXIT ,
;
: ALLOT ( n -- addr )
HERE @ SWAP
HERE +!
;
: CELLS ( n -- n ) 8 * ;
: VARIABLE
1 CELLS ALLOT
WORD CREATE
DOCOL ,
' LIT ,
,
' EXIT ,
;
: VALUE ( n -- )
WORD CREATE
DOCOL ,
' LIT ,
,
' EXIT ,
;
: TO IMMEDIATE ( n -- )
WORD
FIND
>DFA
8+
STATE @ IF
' LIT ,
,
' ! ,
ELSE
!
THEN
;
: +TO IMMEDIATE
WORD
FIND
>DFA
8+
STATE @ IF
' LIT ,
,
' +! ,
ELSE
+!
THEN
;
: ID. ( addr -- )
8+
DUP C@
F_LENMASK AND
BEGIN
DUP 0>
WHILE
SWAP 1+
DUP C@
EMIT
SWAP 1-
REPEAT
2DROP ( len addr -- )
;
: ?HIDDEN
8+
C@
F_HIDDEN AND
;
: ?IMMEDIATE
8+
C@
F_IMMED AND
;
: WORDS
LATEST @
BEGIN
?DUP
WHILE
DUP ?HIDDEN NOT IF
DUP ID.
SPACE
THEN
@
REPEAT
CR
;
: FORGET
WORD FIND
DUP @ LATEST !
HERE !
;
: DUMP ( addr len -- )
BASE @ -ROT
HEX
BEGIN
?DUP ( while len > 0 )
WHILE
OVER 8 ZU.R ( print the address )
SPACE
( print up to 16 words on this line )
2DUP ( addr len addr len )
1- 15 AND 1+ ( addr len addr linelen )
BEGIN
?DUP ( while linelen > 0 )
WHILE
SWAP ( addr len linelen addr )
DUP C@ ( addr len linelen addr byte )
2 ZU.R SPACE ( print the byte )
1+ SWAP 1- ( addr len linelen addr -- addr len addr+1 linelen-1 )
REPEAT
DROP ( addr len )
( print the ASCII equivalents )
2DUP 1- 15 AND 1+ ( addr len addr linelen )
BEGIN
?DUP
WHILE
SWAP ( addr len linelen addr )
DUP C@ ( addr len linelen addr byte )
DUP 32 128 WITHIN IF ( 32 <= c < 128? )
EMIT
ELSE
DROP '.' EMIT
THEN
1+ SWAP 1-
REPEAT
DROP
CR
DUP 1- 15 AND 1+
TUCK
-
>R + R>
REPEAT
DROP
BASE !
;
: CASE IMMEDIATE
0
;
: OF IMMEDIATE
' OVER ,
' = ,
[COMPILE] IF
' DROP ,
;
: ENDOF IMMEDIATE
[COMPILE] ELSE
;
: ENDCASE IMMEDIATE
' DROP ,
BEGIN
?DUP
WHILE
[COMPILE] THEN
REPEAT
;
: CFA>
LATEST @
BEGIN
?DUP
WHILE
2DUP SWAP
< IF
NIP
EXIT
THEN
@
REPEAT
DROP
0
;
: SEE
WORD FIND
HERE @
LATEST @
BEGIN
2 PICK
OVER
<>
WHILE
NIP
DUP @
REPEAT
DROP
SWAP
':' EMIT SPACE DUP ID. SPACE
DUP ?IMMEDIATE IF ." IMMEDIATE " THEN
>DFA
BEGIN ( end start )
2DUP >
WHILE
DUP @ ( end start codeword )
CASE
' LIT OF ( is it LIT ? )
8 + DUP @ ( get next word )
. ( and print it )
ENDOF
' LITSTRING OF
[ CHAR S ] LITERAL EMIT '"' EMIT SPACE ( print S"<space> )
8 + DUP @ ( get the length )
SWAP 8 + SWAP ( end start+8 length )
2DUP TELL ( print the string )
'"' EMIT SPACE
+ ALIGNED ( end start+8+len, aligned )
8 - ( because we're about to add 8 below )
ENDOF
' 0BRANCH OF
." 0BRANCH ( "
8 + DUP @
.
." ) "
ENDOF
' BRANCH OF
." BRANCH ( "
8 + DUP @
.
." ) "
ENDOF
' ' OF
[ CHAR ' ] LITERAL EMIT SPACE
8 + DUP @
CFA>
ID. SPACE
ENDOF
' EXIT OF
2DUP
8 +
<> IF
." EXIT "
THEN
ENDOF
DUP
CFA>
ID. SPACE
ENDCASE
8 +
REPEAT
';' EMIT CR
2DROP
;
: :NONAME
0 0 CREATE
HERE @
DOCOL ,
]
;
: ['] IMMEDIATE
' LIT ,
;
( Exception )
: EXCEPTION-MARKER
RDROP
0
;
: CATCH
DSP@ 8+ >R
' EXCEPTION-MARKER 8+
>R
EXECUTE
;
: THROW
?DUP IF
RSP@
BEGIN
DUP R0 8- <
WHILE
DUP @
' EXCEPTION-MARKER 8+ = IF
8+
RSP!
DUP DUP DUP
R>
8-
SWAP OVER
!
DSP! EXIT
THEN
8+
REPEAT
DROP
CASE
0 1- OF ( ABORT )
." ABORTED" CR
ENDOF
." UNCAUGHT THROW "
DUP . CR
ENDCASE
QUIT
THEN
;
: ABORT
0 1- THROW
;
: PRINT-STACK-TACE
RSP@
BEGIN
DUP R0 8- <
WHILE
DUP @
CASE
' EXCEPTION-MARKER 8+ OF
." CATCH ( DSP="
8+ DUP @ U.
." ) "
ENDOF
DUP
CFA>
?DUP IF
2DUP
ID.
[ CHAR + ] LITERAL EMIT
SWAP >DFA 8+ - .
THEN
ENDCASE
8+
REPEAT
DROP
CR
;
( C String )
: Z" IMMEDIATE
STATE @ IF
' LITSTRING ,
HERE @
0 ,
BEGIN
KEY
DUP '"' <>
WHILE
HERE @ C!
1 HERE +!
REPEAT
0 HERE @ C!
1 HERE +!
DROP
DUP
HERE @ SWAP -
8-
SWAP !
ALIGN
' DROP ,
ELSE
HERE @
BEGIN
KEY
DUP '"' <>
WHILE
OVER C!
1+
REPEAT
DROP
0 SWAP C!
HERE @
THEN
;
: STRLEN
DUP
BEGIN
DUP C@ 0<>
WHILE
1+
REPEAT
SWAP -
;
: CSTRING
SWAP OVER
HERE @ SWAP
CMOVE
HERE @ +
0 SWAP C!
HERE @
;
( The Environment )
: ARGC S0 @ @ ;
: ARGV ( n -- str u )
1+ CELLS S0 @ +
@
DUP STRLEN
;
: ENVIRON
ARGC
2 +
CELLS
S0 @ +
;
: BYE 0 SYS_EXIT SYSCALL1 ;
: GET-BRK ( -- brkpoint ) 0 SYS_BRK SYSCALL1 ;
: UNUSED ( -- n ) GET-BRK HERE @ - 8 / ;
: BRK ( brkpoint -- ) SYS_BRK SYSCALL1 ;
: MORECORE ( cells -- ) CELLS GET-BRK + BRK ;
: R/O ( -- fam ) O_RDONLY ;
: R/W ( -- fam ) O_RDWR ;
: OPEN-FILE ( addr u fam -- fd 0 (if successful) | c-addr u fam -- fd errno (if there was an error) )
-ROT
CSTRING
SYS_OPEN SYSCALL2
DUP
DUP 0< IF
NEGATE
ELSE
DROP 0
THEN
;
: CREATE-FILE ( similar to OPEN-FILE )
O_CREAT OR
O_TRUNC OR
-ROT
CSTRING
420 -ROT
SYS_OPEN SYSCALL3
DUP
DUP 0< IF
NEGATE
ELSE
DROP 0
THEN
;
: CLOSE-FILE
SYS_CLOSE SYSCALL1
NEGATE
;
: READ-FILE
>R SWAP R>
SYS_READ SYSCALL3
DUP
DUP 0< IF
NEGATE
ELSE
DROP 0
THEN
;
: PERROR
TELL
':' EMIT SPACE
." ERRNO="
. CR
;
( TODO: translate jonesforth x86 assembler into x64 )
: WELCOME
S" TEST-MODE" FIND NOT IF
." Jombloforth version " VERSION . CR
UNUSED . ." cells remaining" CR
." ok " CR
THEN
;
WELCOME
HIDE WELCOME

File diff suppressed because it is too large Load Diff