/r/Forth

Photograph via snooOG

"In particular you need to avoid writing code for situations that will never arise in practice. You need to avoid writing code to handle a general problem that you are never going to encounter. I don't need to solve the general problem when I only have to solve these specific cases." -- Chuck Moore

Why Forth?

  1. You can try things out interactively as you build your system. The compiling functionality is an exposed part of the language like everything else.

  2. It can be used to debug itself!

  3. Forth has no baked-in syntax or privileged data structures -- programming is done by extending the language to your application. Thus, it can become what ever you need it to be and fit the problem like a glove.

  4. Forth has a "low floor; high ceiling" approach to abstraction -- that is, it can be both low level, high level and anywhere in-between.

  5. You can do more with less. Forth fits in very small storage spaces.

  6. Forth is one of the few environments which is totally comprehensible by one person.


/r/Forth wiki


Tutorials

Starting Forth - A fun, illustrated introduction.

A Beginner's Guide to Forth - A faster-paced, somewhat less whimsical guide.

Forth Lessons

Jonesforth - How to write a Forth.


Documentation

ANS Forth standard

Forth 200x


Reading

Thinking Forth - A Language and Philosophy for Solving Problems

Forthwrite Magazine - From FIG UK.

Forth Dimensions - magazine archive.

The Journal of Forth Application and Research


Community

comp.lang.forth - Forth newsgroup.

#forth in irc.freenode.net

ForthHub community on GitHub


See also

/r/concatenative - Anything related to the use, theory, or implementation of concatenative programming languages.

/r/programbattles - Battle it out between likeminded coders to create the best code possible!

/r/Forth

3,505 Subscribers

7

Display text in the graphical environment for eForth Windows

The first thing we want to do, apart from graphical drawings, is to be able to display text in a Windows window. So, let's take a deep breath, then tackle this very vast subject, but also very rich in possibilities!

https://eforthwin.arduino-forth.com/article/graphic_ecrireTexte

: STR01 ( -- addr len )
    s" This is my first example.. I try to draw a very long text in this graphic window." ;

: FORMATTING ( -- n )
    DT_TOP          \ draw frop top
    DT_WORDBREAK OR \ break words
    DT_CENTER    OR \ center text
  ;

: DRAWtext  ( -- )
    10 10 200 120 LPRECT RECT!
    $ff0000 to color
    hdc STR01 LPRECT FORMATTING DrawTextA
  ;

https://preview.redd.it/jffuzoxlni1e1.jpg?width=388&format=pjpg&auto=webp&s=34312342aed0c1cad2417470c336050a353ca9da

1 Comment
2024/11/17
19:51 UTC

7

Displaying modal boxes with eForth Windows

Modal boxes are an integral part of the Windows environment. They are very useful for displaying information or issuing a warning. When closing the modal box, you can even recover certain choices caused by closing the modal box.

https://eforthwin.arduino-forth.com/article/api_afficherBoiteModale

z" Will you continue?" constant lpText
z" make a choice" constant lpCaption

: MSGbox ( -- )
NULL lpText lpCaption MB_YESNO MessageBoxA
?dup if
cr ." You have pressed: "
case
6 of ." Yes" endof
7 of ." No" endof
endcase
then
;

https://preview.redd.it/dozq9t2s951e1.jpg?width=883&format=pjpg&auto=webp&s=491b036a1d66972960d1671909f0bca4879f2e43

5 Comments
2024/11/15
22:50 UTC

11

zeptoforth 1.9.0 is out

This release:

  • adds hardware single-precision floating-point numerics support (except on the RP2040, due to lack of hardware floating point, and STM32F411, to save room of what little flash it has)
  • reworks the multitasker to be based on deadlines
  • optionally supports complex numbers on top of hardware single-precision floating-point numerics
  • adds a current directory concept
  • optionally supports FAT32 filesystems in PSRAM on RP2350 boards with PSRAM such as the Pimoroni Pico Plus 2
  • supports conveniently compiling string constants to the dictionary and storing them in buffers and reading them therefrom without the limitations of traditional counted strings or null-delimited strings
  • optimizes of/ofstr ... endof to collect all end branches to the end of case ... endcase/endcasestr blocks (except on the RP2040 and STM32L476, due to the limitations of these platforms)
  • fixes a bug where double-cell local variables would not be properly updated with constants due to an issue with the code generator
  • fixes a bug introduced in the last beta release 1.9.0-beta.3 where due to an issue with the multitasker zeptoforth would sometimes crash on boot and would not properly update the deadlines of tasks.

You can get it from https://github.com/tabemann/zeptoforth/releases/tag/v1.9.0.

0 Comments
2024/11/15
03:06 UTC

0

Forth as a mobile app

I did a thing that you may find interesting

Download our app and start programming on your phone right now. RIGHT NOW!

apps.apple.com/gb/app/hencefo…

9 Comments
2024/11/13
10:00 UTC

7

ANSI Sequences for Z79Forth

Here, ANSI Sequences for emulated VT terminals:

https://github.com/MPETREMANN11/Z79Forth/blob/master/VT525/vt525.4th

The content of this file has been tested with the Tera Term terminal in VT 525 emulation. Its content allows:

* position the display

* color the text and the background

* memorize and restore the cursor position

* a real screen erase

And above, a photo in 3D (anaglyphe) from the Z79Forth card:

https://preview.redd.it/jemc54wl3n0e1.jpg?width=1024&format=pjpg&auto=webp&s=3d0773f70edb5923ca508c0dcad23dbd60e42374

1 Comment
2024/11/13
09:42 UTC

7

zeptoforth 1.9.0-beta.3 is out

This release adds string constants not limited to 255 characters, optimizes of ... endof blocks (except on the RP2040 and STM32L476), allows direct control over task deadlines with the deadline scheduler, optimizes zeptoIP using the deadline scheduler, and fixes a bug where if a task were blocked long enough its deadline would "wrap around" resulting in it being incorrectly scheduled. You can get it from https://github.com/tabemann/zeptoforth/releases/tag/v1.9.0-beta.3.

0 Comments
2024/11/12
04:16 UTC

6

The first facts of our expert system

An expert system evaluates rules based on facts. We will study in detail how to define facts. To do this, we will enter into the mechanics of how the FORTH language works to describe facts, whether predefined or not.

https://eforthwin.arduino-forth.com/article/flog_premiersFaits

https://preview.redd.it/729sl61b3c0e1.jpg?width=600&format=pjpg&auto=webp&s=6a343732988cacda714deb1109e7f3320863c00a

0 Comments
2024/11/11
20:41 UTC

10

Beginnings of an expert system

In this first chapter devoted to an elementary expert system, we will approach the beginnings of the construction of such a system. Each new chapter will unfold the design of such a system in detail.

https://eforthwin.arduino-forth.com/article/flog_premices

https://preview.redd.it/le2wt2aqu40e1.jpg?width=600&format=pjpg&auto=webp&s=b207e4ea977b2585722788c476871173ee526f25

3 Comments
2024/11/10
20:21 UTC

7

Datas Structures for eFORTH windows

In this article, we will explore a few cases of data structures. The goal is to give ideas for your own structures, starting with one- and two-dimensional arrays. This article ends with the use of the structures vocabulary.

https://eforthwin.arduino-forth.com/article/elements_dataStructures

https://preview.redd.it/2p4kwvjj1yzd1.png?width=459&format=png&auto=webp&s=82ffdeaca216df7c16963b267cb1f03c81e64288

3 Comments
2024/11/09
21:26 UTC

6

flashforth i2c driver for LCD2004 display

I am looking for a [flashforth driver for the 20 x 4 character display LCD2040 with I²C interface. I²C address $25. Any suggestions?

2 Comments
2024/11/08
09:40 UTC

19

What I'm working on

It has been a while since I posed. I wanted to show off what I'm working on these days.

The screenshot below is QEMU running a Forth bare metal.

If you notice, I can see the address of the frame buffer and could write Forth words to render to it.

The Forth is STC. I must say the line between forth and assembly is really blurred.

You may also notice that I wrote the bulk of a disassembler (in assembly) for the SEE word.

The Forth is time slice interrupt driven, too. The tasking is fully round-robin and priority based (tasks at highest priority will run round robin). I implemented a wait list so Tasks can truly sleep and not be involved in the round-robin scheme until they awake. Waking a task is done by sending it a signal - so a key ready or disk block ready might signal a waiting task which moves it to the active list and it then gets to run.

It's still very early in development. Most of the hardware stuff is done - like MMU/page tables, RTC (real time clock), mouse pointer, keyboard, regular timer, IDT (interrupt table), GDT, and all the rest of the usual OSDev type stuff.

It requires BIOS to boot and has no support for NVME yet. I bought a $200 laptop to run this on, but until it supports UEFI and NVME, it's not going to boot.

It does support block I/O for ATA/IDE disks. Maybe I have a really old laptop that might boot and run this.

I haven't made the repo public yet. Once I am satisfied with the stability of the code, I will do that and post here.

My current "task" in the issues board is local variables. Once I have those, I can rewrite a lot of the assembly in pure forth.

BTW, I still haven't figured out create/does> yet. I haven't given it enough thought, though I did pick your brains here a while back.

Cheers

In action

Pseudo File System (readonly in RAM)

17 Comments
2024/11/07
21:26 UTC

13

A milliForth for 6502

A minimal Forth for 6502, based on sectorforth and milliforth, https://github.com/agsb/milliForth-6502, bare-bones in less than 1200 bytes

2 Comments
2024/11/07
19:16 UTC

8

Creating the SDL2 vocabulary in eForth Windows

0 Comments
2024/11/07
16:23 UTC

3

HowTo create a list of float numbers?

Hello,

I would like to create a list (or 1D array) of float numbers and access them later.

It sould be something like this..

CREATION

400 SIZEFL REG44 -> creates a list named REG44 of 400 float numbers

READING

100 REG44 F@ -> read the indice 100 of the float list REG44 and put it into the float stack

STORAGE

100 REG44 2.0 F! -> stores the number 2.0 into the float list REG44 of indice 100

Any advice where to find words doing that job are welcome (I was trying till now to reserve n cells and then to read/write directly into the cell address but so far not successfull).

5 Comments
2024/11/07
16:13 UTC

7

Display BMP images with SDL2 and eForth Windows

SDL2, in its base configuration, natively supports only the BMP format. This means that you can load and display BMP images directly without the need for a third-party library like SDL_image.

https://eforthwin.arduino-forth.com/article/SDL2_images

https://preview.redd.it/2ed8iaiksazd1.png?width=1007&format=png&auto=webp&s=0818dbb508febdd10229e4d2006a858feae16d78

0 Comments
2024/11/06
15:15 UTC

14

zeptoforth 1.9.0-beta.1 is out

I could have just decided to release zeptoforth 1.9.0, but I decided to add some more features first. Consequently, zeptoforth 1.9.0-beta.1 is out, which adds a current directory concept which I should have added ages ago, optional support for FAT32 filesystems in PSRAM on RP2350 boards with PSRAM such as the Pimoroni Pico Plus 2 (essentially a large, by microcontroller standards, RAM disk), and an optional utility for copying files between filesystems. You can get it from https://github.com/tabemann/zeptoforth/releases/tag/v1.9.0-beta.1.

1 Comment
2024/11/02
22:52 UTC

10

zeptoforth 1.9.0-beta.0 is out

This beta release adds, on top of the new support for single-precision hardware floating point for the RP2350, the STM32F407, the STM32F746, and the STM32L476, support for complex numbers using single-precision hardware floating point, including string conversions and literals (specified as ({+,-})x{+,-}yi where x and y can have the form ({+,-})a(.b)(e({+,-})c)). You can get it from https://github.com/tabemann/zeptoforth/releases/tag/v1.9.0-beta.0.

0 Comments
2024/10/27
20:39 UTC

10

new project: SDL2 library for eForth Windows

Hi,

I started a new project: Implement and use the SDL2 library with eForth Windows.

The project is at its beginning. Because at the same time as I develop this library, I write its documentation and usage examples.

Any help or comments are welcome on this project.

SDL2 is the library used by many video game developers.

Link to the project: https://github.com/MPETREMANN11/SDL2-eForth-windows

https://preview.redd.it/mpv0s1sc0axd1.jpg?width=800&format=pjpg&auto=webp&s=59fe028148e1effa3a55d486b98670ec75f2c571

3 Comments
2024/10/27
10:29 UTC

0 Comments
2024/10/26
10:33 UTC

9

Forth assemblers for 64-bit ARM

Does anyone know of a forth assembler for 64-bit ARM? I assumed gforth would have one, but not that I can tell. I've done a couple, but while they aren't hard, they are tedious.

5 Comments
2024/10/26
04:47 UTC

12

8th ver 24.07 released

Very much a bug fix release, and updating major libraries. Some optimization, reduced startup time, etc.

Full details on the forum

0 Comments
2024/10/22
14:11 UTC

6

Minor changes to embrace a larger audience

It seems to me with some minor changes forth might be embraced by a larger audience.

Changing THEN to ENDIF is one example.

I would also use { } to define anonymous words. This could change control structures to a more readable and less polymorphic design.

It would mean IF,ELSE,DO could now operate on single words and have the same behavior in both run and compile time.

23 Comments
2024/10/19
15:48 UTC

9

zeptoforth 1.9.0-alpha.0, now with hardware floating point support, is out

zeptoforth 1.9.0-alpha.0, which introduces hardware single-precision floating point support on the RP2350, STM32F407, STM32L476, and STM32F746 is out. Note that its string conversion routines could potentially be improved on; they are not quite ideal at this point in my view. (Suggestions for improvements which do not require bignums or black magic are welcome.) This release also fixes a major bug in the code generator where assigning a literal to a double-cell local variable would be compiled incorrectly. You can get it from https://github.com/tabemann/zeptoforth/releases/tag/v1.9.0-alpha.0.

1 Comment
2024/10/17
04:08 UTC

Back To Top