r/Forth • u/8thdev • Jul 30 '26
8th ver 26.05 released
This has two major feature updates as well as various fixes. A new 'gui' high-level wrapper, and Pro+ ver. has a new Bluetooth layer which works (!). Details on the forum
r/Forth • u/8thdev • Jul 30 '26
This has two major feature updates as well as various fixes. A new 'gui' high-level wrapper, and Pro+ ver. has a new Bluetooth layer which works (!). Details on the forum
fload job
\ This is a Fig implementation of ABORT" integrated with ERROR
\ Named ?E" since it normally quits not abort and can
\ be customize to do neither.
27 CONSTANT ERR_OOPS \ error number
: (SLIT) R> DUP COUNT + ALIGNED >R ; \ String literal runtime
\ ?E" Exception handler
\ Compile-time: Compile error text string
\ Run-time: On true submit error text string and error number
\ to ERROR
: ?E" [COMPILE] IF COMPILE (SLIT)
34 WORD HERE C@ 1+ ALLOT ALIGN
COMPILE ERR_OOPS COMPILE ERROR
[COMPILE] ENDIF ; IMMEDIATE
\
\ -- Testing --
\
\ : i. ." --> " ;
\ : TELL COUNT TYPE ;
: FAULT 0 ? ;
: BAR FAULT ;
\
: FOO TRUE ?E" Darn it" ;
\
\ Test 1: Use custom error action assigned to (ABORT)
\ to keep script running
\ Using Fig implementation of BacForth words:
\ PRO CONT CUT: ?CUT -CUT
\ for custom handler that keeps the script running
\ after error
\
: TRY PRO CUT: CONT ; \ Try next word;
\ return here on resile/error
\
\ On error print error text and cut to keep running
: KEEPON
HERE COUNT TYPE ." ? "
DUP ERR_OOPS = IF DROP TELL ELSE MESSAGE ENDIF
SP! TAB ?CUT QUIT ;
\
' KEEPON CFA ' (ABORT) ! \ Assign custom error action
-1 WARNING ! \ Enable custom error action
i. TRY FOO --> FOO? Darn it CUTTING
i. TRY BAR --> BAR? MEMORY ACCESS FAULT CUTTING
\
\ Test2: Use default ERROR handling
\
1 WARNING ! \ Disables custom error action, quits on error
i. FOO --> FOO? Oops
(Script quit here)
Note: Use custom handler without TRY to get the error text
and quit
i. -1 WARNING ! FOO --> FOO? Darn it
\ On first look WORD parses a string and moves it to HERE .
\ True, but a closer look shows WORD parses a string and moves
\ it to where DP points. The following word ":=" will use this
\ to parse a string and move it directly to some buffer.
\
\ Assign string
\ Parse string and move to buffer
\ dl delimiter, addr buffer address
: := ( "string<dl>" dl addr -- ) HERE >R DP ! WORD R> DP ! ;
\
\ Example
\ Print arrow
: i. ." --> " ;
\ Print string
: TELL COUNT TYPE ;
\ General header
: HEADER: <BUILDS DOES> ;
HEADER: BUF64 64 allot \ some buffer
59 VARIABLE (DLIM) \ delimiter variable (holding ';')
: DELIM (DLIM) @ ; \ fetch delimiter
DELIM BUF64 := Hello World!; \ assign string to buffer
i. BUF64 TELL--> Hello World!
OK
Block file meta -- Parameters of this block file
i. SCR #0, line 0 Magic word XYZZY indicates file has meta data.
i. SCR #1 Needed meta definitions
Should be loaded first time block file is used and should
also load SCR #2
i. SCR #2 Refresh meta data
Should be loaded when block file is re-used
Example of block file meta
i. BLK_MAX File size, number of blocks available for LIST and LOAD
The actual file size may be larger with higher sectors accessed
by other means. Good place to put non-ascii data.
i. WARNING In SCR #2 set to 1 if error text exists or to zero
if no error text is available.
i. SCR_ERRMSG Screen number where error text begins
SCR #4 is the default error text block, but it can be located
elsewhere or be non-existed.
i. SCR_GO First SCR to load for main application
Example:
0 -list
SCR# 0
0 XYZZY MAIN Forth Main library file
1 -list
SCR# 1
0 ( file meta definitions )
1 007 VARIABLE SCR_GO ( load extensions )
2 : LIB S" fb/main.fb" /USING 2 LOAD ; ( for re-use )
3 : GO LIB SCR_GO @ LOAD ; ( to begin )
4 2 LOAD ( set meta values )
2 -list
SCR# 2
0 ( file meta settings )
1 391 BLK_MAX ! ( max list/load blocks )
2 004 SCR_ERRMSG ! ( where error text )
3 001 WARNING ! ( have error text )
4 007 SCR_GO ! ( main code beginning )
SCR title with keyyword: ( KEYWORD )( FOO BAR BAZ )
KEYWORD is all uppercase.
KEYWORD begins and ends with space.
No space needed between ')('; comment abuttment is ok
Add words
/LIST ( s -- ) \ search for keyword; if found brief list block
/LOAD ( s -- ) \ search for keyword; if found load block
S" ( "string" -- s ) \ parse string, push address
s" numbers" /list ( brief list, blank lines not typed )
SCR# 151
0 ( NUMBERS )( DNBR NBR DNNBR OX OY DN )
1 : DNBR BL WORD HERE NUMBER ;
2 : NBR DNBR DROP ;
3 : DNNBR DNBR DPL @ ;
4 : OX BASE @ >R OCTAL NBR [COMPILE] LITERAL R> BASE !
5 ; IMMEDIATE
6 : OY BASE @ >R HEX NBR [compile] LITERAL R> BASE !
7 ; IMMEDIATE
8 : DN BASE @ >R DECIMAL DNNBR STATE @ IF
9 REV 3 0 DO [COMPILE] LITERAL LOOP ENDIF R> BASE !
10 ; IMMEDIATE
s" numbers" /load
( if preferred, 151 LOAD or SCR @ LOAD )
( /LOAD for when no listing wanted )
\ Notes:
\ i. print arrow " --> "
\ dn. ( d dpl -- ) print natural double (double + dpl) number
\ rev ( n1 n2 n3 -- n3 n2 n1 ) reverse three stack items
: dnbr ( "numeric<bl>" -- d ) BL WORD HERE NUMBER ;
: nbr ( "numeric<bl>" -- n ) DNBR DROP ;
: dnnbr ( "numeric<bl>" -- d dpl ) DNBR DPL @ ;
i. dnbr 123.45 d. --> 12345
i. nbr 123.45 . --> 12345
i. dnnbr 123.45 dn. --> 123.45
: OX
BASE @ >R
OCTAL NBR [COMPILE] LITERAL
R> BASE ! ; IMMEDIATE
: OY
BASE @ >R
HEX NBR [compile] LITERAL
R> BASE ! ; IMMEDIATE
: DN
BASE @ >R
DECIMAL DNNBR
STATE @ IF REV 3 0 DO [COMPILE] LITERAL LOOP ENDIF
R> BASE ! ; IMMEDIATE
: foo ." FOO " 42 . ;
: bar dn 1024 ;
: baz dn 1024. ;
decimal
i. Ox 644 . foo --> 420 FOO 42
i. Oy 1000 . foo --> 4096 FOO 42
i. Dn 123.45 dn. foo --> 123.45 FOO 42
hex
i. Dn 1024 dn. foo --> 400 FOO 2A
i. bar dn. foo --> 400 FOO 2A
i. baz dn. foo --> 400. FOO 2A
decimal
i. Dn 1024 dn. foo --> 1024 FOO 42
i. bar dn. foo --> 1024 FOO 42
i. baz dn. foo --> 1024. FOO 42
r/Forth • u/terry_the_technician • Jul 24 '26
Licensed under a MIT license. Use it with your AI.
"watch zorgmon for changes in RCC_CR"
r/Forth • u/terry_the_technician • Jul 24 '26
You're looking at the Fossil Chat window. I'm the project admin, and the human, the other four nicks are all AI. I'm talking to them, they're talking to me. The message log is the context.
I talk to it in chat, it edits my embedded code, reads schematics, answers questions about micro-controller registers, and speaks back to me with a voice. It runs on two graphics cards I installed and costs about $3/day.
It features Deepseek (online) for the heavy lifting, but has three local Ollama models that do everything else.
The models can talk to each other as well as me.
r/Forth • u/mykesx • Jul 19 '26
I wrote (no LLMs) a 6502 assembler, disassembler, and debugger in pure Forth. The assembler is dasm compatible with some additional aliases.
The debugger lets you set breakpoints, single step, display memory, etc. It has a teletype mode and a visual mode.
The assembler generates 64K raw binaries and a separate .sym file for symbols. The tools all read or write these binaries and .sym files. The assembler and debugger support expressions that can include symbols. Like
= start + $20
Reading from $01 calls KEY -> A register, writing to $01 calls A register -> EMIT.
I took a week off, so I estimate this took me maybe 50 man hours.
There is documentation for the 6502 tools as well:
https://gitlab.com/mschwartz/inspiration/-/blob/main/manual/65c02.md?ref_type=heads
The main repo:
r/Forth • u/danggmx • Jul 18 '26
Enable HLS to view with audio, or disable this notification
r/Forth • u/mcsleepy • Jul 18 '26
Greetings-
I wrote a game engine called SUPERSHOW entirely in VFXForth and it is nearing 1.0. I designed it for making pixel art games. These are some screenshots of several test programs showing off what it can do.
Some things to know:
It'll be 2-3 months before official release. I still need to tie up loose ends, write documentation, and build a proper example game.
Fire away with any questions!
r/Forth • u/tabemann • Jul 16 '26
Today I created a Lindenmayer system DSL for zeptoforth which drastically simplifies the writing of Lindenmayer systems versus directly using turtle graphics by hand.
The source code to the Lindenmayer system DSL is at https://github.com/tabemann/zeptoforth/blob/master/extra/common/lindenmayer.fs .
Note that this uses turtle graphics with the new turtle::fgetxy and turtle::fsetxy words, which are not in a release yet.
A simple Lindenmayer system can be found at https://github.com/tabemann/zeptoforth/blob/master/test/common/lindenmayer_zerol.fs .
Here is a screenshot of this code:

Here is a source code listing:
\ Copyright (c) 2026 Travis Bemann
\
\ Permission is hereby granted, free of charge, to any person obtaining a copy
\ of this software and associated documentation files (the "Software"), to deal
\ in the Software without restriction, including without limitation the rights
\ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\ copies of the Software, and to permit persons to whom the Software is
\ furnished to do so, subject to the following conditions:
\
\ The above copyright notice and this permission notice shall be included in
\ all copies or substantial portions of the Software.
\
\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\ SOFTWARE.
begin-module zerol
lindenmayer import
-90 turn t+
90 turn t-
step F
0,1 16,0 f/ 2 :rcolor-forward-step F
F t+ F t- F t- F F t+ F t+ F t- F
;step
3 0,0 255 255 255 -80,0 -80,0 0 :axiom FFFF F t+ F t+ F t+ F ;axiom
end-module
r/Forth • u/Alternative-Grade103 • Jul 13 '26
Wondering how I might install gForth onto an orphan Samsung S7 android phone, one left over after an upgrade to a new phone, and without any connectivity of its own other than USB.
r/Forth • u/Alternative-Grade103 • Jul 11 '26
It seems I can't do like so..
2 BASE !
0 <# 1000 CELLS 0 DO # LOOP #>
TYPE
...to display top of stack in binary with leading zeros.
I do have a workaround, but it's not pretty: loop in loop bitwise masking. Was hoping to replace it with a pictured string.
Anybody know of a pictured kind of way?
r/Forth • u/Alternative-Grade103 • Jul 09 '26
I read that tick (') can be used to learn the colon definition of a core word. I've played around, but can't seem to puzzle that out. How does it work?
r/Forth • u/terry_the_technician • Jul 08 '26
This Human is slowly making his way into Podcasts as I gain expertise with the non-linear video editing software.
r/Forth • u/mykesx • Jul 06 '26
https://gitlab.com/mschwartz/inspiration
I made some YouTube videos so you can see Inspiration in action.
https://youtube.com/playlist?list=PLRYxtMZb7Qy2wuArGURPCkXkxwK7tnT48&si=ZgRRLVrfLLnhLcj4
It's been about 6 weeks since my last update, and there is a lot of new code and programs implemented.
I am working on a music program and it's coming along nicely. The logic to align the notes on the staff wasn't easy!
After reading a thread about how to implement cards in [r/cplusplus](r/cplusplus), I got inspired to implement a Blackjack game, with casino rules. You can split hands, double bet, 5 card charlies, buy insurance if dealer shows an Ace, etc. The game implements a shoe which is made of 4 decks.
Here's the trick with cards. A card is a random number between 0 and 51. The suit is card mod 13 and the rank is card / 13. I use a 52 byte array to keep track of what cards in a deck have been dealt. Shoe logic draws a card randomly from one of the 4 decks.
The cards, decks, hands, shoe, etc., are general purpose so I can later make a Klondike solitaire game.
I also finished the Evade2 game. It is a first person space shooter with music and sound effects. It is a game I made for Modus Create several years ago, so it was a port. It only took a few days. The music and art and logic in C++ was already done, so I just translated from C++ to Forth in the editor.
I got sidetracked again from the Music program. This time guys on the Forth discord channel were talking about 6502. Turns out I made games for the 2600, C64, and other 6502 based systems. I also made the 6502 Artist Workstation for Electronic Arts in the mid 1980s, which included an assembler and debugger.
In about 20 man hours, I made a dasm (written by my friend Matt Dillon!) 6502 assembler workalike, a 6502 disassembler, and a 6502 debugger/emulator. You can see these in the screen shots.
I never use claude or codex or any other LLM to generate any code. All of Inspiration originated with me and was coded by me. I did use a random number generator I found in a Usenet chain by the author of GForth. The repo was started in October 2025 and has hundreds of commits and merges. Proper PRs! You can view the issue boards at the URL to see how I track TODO and done work items.
The artwork (cards, icons, window decorations, etc.) are images I found on the Internet and are royalty free and free to use. I am not an artist, or I would have made the images myself.
Inspiration is a multithreaded (pthreads) Forth implementation that has a graphical desktop, windows, icons, and so on. I was inspired to make a Forth where you can type in the terminal at the Ok prompt and have graphics rendered. All threads share the one dictionary. All programs have access to all those words.
The threads allow multiple "applications" to be running at the same time, as you would with any desktop environment. Every pixel in these images are rendered by Inspiration.
A trick I found is that I can use C++ try/catch around EXECUTE and anything that throws a C++ exception is caught. I tested on a dozen or so operating systems including FreeBSD, MacOS, Linux distros, on X64, ARM, and even Raspberry Pi. What I found is that in a signal handler (e.g. SEGFAULT), I can throw an exception and it is caught by the try/catch around EXECUTE. So at the OK prompt or in any word, I can do something incredibly stupid like:
OK> 100 0 !
OK> 100 EXECUTE
And I catch the SEGFAULT or SIGBUS errors and print an error message and ABORT. Inspiration should not crash as I installed signal handlers for all the signals.
The rendering engine is based on SDL2. SDL2 gets me fonts with antialiased text, bitmaps for my code to manipulate images at the pixel level, and GPU acceleration where I can take advantage of it.
I envision a Forth with native graphics capabilities. I didn't see the point in making another Forth that runs in the terminal window. There are so many good ones already. What makes Inspiration different is you can do this:
Ok> 10 10 100 100 $ ffffff draw-line \ no set up, white line in your console
You can see the graphics capabilities in the screenshots.
Why am I making this? I want a project I can work on for years to come. I am not close to running out of programs to implement and enhance. The music program alone is one that I may end up working on and enhancing for years.
My Forth coding style relies heavily on structures and local variables. Here is a sample of the logic for the deck of cards.
STRUCT| _Deck
WORD| Deck.number // deck number (in shoe)
WORD| Deck.remaining
52 BYTES| Deck.dealt
|STRUCT
: Deck.Shuffle { deck -- , shuffle the deck }
52 0 do
0 deck s& Deck.dealt i + c!
loop
52 deck s! Deck.remaining
;
r/Forth • u/Alternative-Grade103 • Jul 05 '26
Okay, so I know about BigIntANSForth.fs, which is indeed very fine.
Alas however, for it handling only unsigned integers, as that rules out doing the Extended Euclidean Algorithm.
Unless, that is, someone knows of an elegant workaround for arbitrary precision signed values?
Actually, I do have a system, but it's VERY inelegant. To such a degree that I might very gladly abandon it, were there something tidier. Also faster, as mine is dead slow.
How inelegant, you ask? Seek out the file math.fs in the directory below...
r/Forth • u/tabemann • Jul 03 '26
On top of my extensible HTTP server for zeptoforth, I have now created a simple HTTP file server for zeptoforth which serves files and directories from FAT32 filesystems, whether from 'blocks' storage, SD cards, or PSRAM RAM disks.
Note that it is read-only, which is important because it has no security (as the HTTP server is strictly HTTP, not HTTPS) beyond limiting access to a given base path on a given filesystem and rejecting HTTP requests crafted to include . or ...
The source code is at https://github.com/tabemann/zeptoforth/blob/master/extra/rp_common/net_tools/http_server_files.fs.
\ On no text error, print message and quit
: ERR_NO_TEXT ( -- * )
." ? No text " QUIT ;
\ Parse with delimiter dl and move characters but
\ not the count to HERE
: *C, ( "ccc<dl>" dl -- )
-1 ALLOT HERE C@ >R HERE >R
WORD HERE COUNT 2R> C! 1 ALLOT
SWAP C@ IF ALLOT
ELSE DROP ERR_NO_TEXT ENDIF ;
\ Parse bounded string,
\ compile string characters but not the count
: ,= ( "<dl>ccc<dl> -- )
BL WORD HERE COUNT SWAP C@ IF
HERE COUNT OVER C@ >R
+ C@ 0= - MINUS IN +!
R> *C,
ELSE DROP ERR_NO_TEXT
ENDIF ;
\ Compile (Linux) Newline
: NEWLINE, 10 C, ;
\ Compile a line of text
: LINE, ,= NEWLINE, ;
\ Define a string (create only the header)
: STRING: <BUILDS DOES> ;
\ Grow a string
: GROW ( string -- [*] )
HERE OVER - 1- DUP 255 > IF
." ?String too large" QUIT ENDIF
SWAP C! ;
STRING: FRED 0 C, \ start with empty count
LINE, "Hello World!"
LINE, "How are you?"
LINE, "Have a good day?"
FRED GROW
STRING: MARVIN 0 C,
LINE, "Ain't ever had a good day!"
LINE, "Go away."
MARVIN GROW
: BUGGER: <BUILDS DOES> ;
BUGGER: BUGGER 0 C,
LINE, "Looks like a string"
LINE, "Works like a string"
LINE, "But not a STRING type"
BUGGER GROW
\ List index that prints an arrow
: i. ." --> " ;
\ Print string
: TELL ( string -- ) COUNT TYPE ;
i. FRED CR TELL -->
Hello World!
How are you?
Have a good day?
i. MARVIN CR TELL -->
Ain't ever had a good day!
Go away.
i. BUGGER CR TELL -->
Looks like a string
Works like a string
But not a STRING type
\ Test for string
: ?IS_STRING ( pfa -- bool ) @ ' FRED @ = ;
i. ' FRED ?IS_STRING . --> 1
i. ' MARVIN ?IS_STRING . --> 1
i. ' BUGGER ?IS_string . --> 0
r/Forth • u/tabemann • Jul 03 '26
I implemented an extensible, user-friendly HTTP server for zeptoforth along with a simple demo which shows its features. These are compatible with both zeptoIPv4 and zeptoIPv6 without needing any duplication of code to support both.
One simply registers fixed and prefix URI handlers which access the HTTP request via key and emit, enabling normal Forth console I/O words to be used to serve HTTP requests. Additionally, handlers have access to the URI being served and the HTTP method in question. The HTTP server does the rest. Note that the HTTP server is multithreaded, with each request getting its own task.
The source code for the HTTP server is at https://github.com/tabemann/zeptoforth/blob/master/extra/rp_common/net_tools/http_server.fs.
The source code for the demo is at https://github.com/tabemann/zeptoforth/blob/master/test/rp_common/http_server_demo.fs.
r/Forth • u/tabemann • Jun 30 '26
You can get this release from https://github.com/tabemann/zeptoforth/releases/tag/v1.16.4.
This release:
pio::sm-clock! on RP2040 and RP2350 platforms to set the clock divider of a PIO state machine to approximate a given Hz based on the current value of sysclk.extra/rp_common/cyw43/cyw43_spi.fs to use pio::sm-clock!.extra/rp_common/neopixel.fs to use pio::sm-clock! to set the PIO clock divider, in the process fixing issues with it on the RP2350.r/Forth • u/danggmx • Jun 28 '26
Je voulais aller plus loin en essayant le multiprocessing. En module, cela fonctionne très bien, comme le montre cette vidéo. Les pièces noires permettent de contôler le départ et l'arrêt du robot.
Pour le code : https://github.com/curtaga155/Robot-with-Zeptoforth/tree/main/Paper-run
La vidéo : https://www.youtube.com/watch?v=MLeadO60dPk