Forth
1. Forth
properties
ID: ffb8be57-d874-4540-9fe0-9efea6559185CREATED: <2025-01-18 Sat 20:44>
- Factor is a cool concatenative lang but unfortunately the C interface (vm/master.h) no longer exists on the master branch.
- Real Programmers Don't Use Pascal
- Assembly and Machine Code Interfacing in Forth Programming - PiEmbSysTech
- Annex F: Test Suite
notes
implementation/
- data stack - one-cell wide
- control-flow stack
return stack - one or more cells
rules:
A program shall not access values on the return stack (using R@, R>, 2R@, 2R> or NR>) that it did not place there using >R, 2>R or N>R;
A program shall not access from within a do-loop values placed on the return stack before the loop was entered;
All values placed on the return stack within a do-loop shall be removed before I, J, LOOP, +LOOP, UNLOOP, or LEAVE is executed;
All values placed on the return stack within a definition shall be removed before the definition is terminated or before EXIT is executed.
Forth words are organized into a structure called the dictionary. While the form of this structure is not specified by the standard, it can be described as consisting of three logical parts: a name space, a code space, and a data space. The logical separation of these parts does not require their physical separation.
A program shall not fetch from or store into locations outside data space. An ambiguous condition exists if a program addresses name space or code spac
names = 1-31 chars
The relationship between code space and data space is implementation dependent.
Data space is the only logical area of the dictionary for which standard words are provided to allocate and access regions of memory. These regions are: contiguous regions, variables, text-literal regions, input buffers, and other transient regions, each of which is described in the following sections. A program may read from or write into these regions unless otherwise specified.
- text-interpreter (repl) = 3.4
- syntax
Forth has a simple, operator-ordered syntax. The phrase A B C returns values as if A were executed first, then B and finally C. Words that cause deviations from this linear flow of control are called control-flow words. Combinations of control-flow words whose stack effects are compatible form control-flow structures. Examples of typical use are given for each control-flow word in Annex A.
Forth syntax is extensible; for example, new control-flow words can be defined in terms of existing ones. This standard does not require a syntax or program-construct checker.
1.1. gforth
1.2. avrforth
properties
ID: 8263ab5f-ced9-4bc6-b22c-2d1f319394eeCREATED: <2025-08-08 Fri 21:38>
- overview
avrforth is a 16-bit subroutine threaded forth kernel for atmel's avr series of microcontrollers. Current development is done for the at90can128 (my cansynth board, to be exact), but it will run on most any mega device with minimal adjustments.
avrforth borrows some ideas from Terry Loveall's 4word. It is a colorless colorforth. The interpreter only interprets. Words must be compiled explicitly using the ] operator. Numeric input is handled by $, which parses the next word as a hexidecimal number.
avrforth uses null-terminated strings internally against tradition. I may switch to counted strings if they prove easier to deal with.
avrforth supports using the entire 128k instruction address space of the atmega128 and at90can128 for code.
avrforth has an interactive interpreter. It interprets input from the uart and compiles directly to flash. avrforth does not require separate memory to store program tokens.
avrforth has an integrated assembler. Assembly code words can be added without recompiling the kernel.
avrforth is public domain.
- requirements
You need a host forth system to assemble avrforth. Development is done with gforth. You also need a utility to program the flash and a terminal program to communicate with the kernel through the avr's uart. I use avrdude and picocom for those tasks.
1.3. flashforth
properties
ID: 3f65cfc7-f3b0-4b50-b20a-d775936ad08fCREATED: <2025-08-08 Fri 21:39>
1.4. colorforth
properties
ID: 2a285bbe-715d-49a5-8fcb-df9921c3352bCREATED: <2025-08-08 Fri 21:40>
1.5. Books
properties
ID: 35de6467-e9fc-49f4-b46b-0e05029f9f48CREATED: <2025-02-13 Thu 22:32>
2. Factor
properties
CREATED: <2025-01-18 Sat 20:44>ID: b0f61b51-fbd8-4b45-a8cd-0a2e08864fed
3. Joy
properties
CREATED: <2025-01-18 Sat 20:44>ID: 39af0f8f-aff7-40f3-a139-e1338a6bb966