!ARMForth32 on the Raspberry Pi

 
 
Home Page
 
 What is Forth?
 
 Why use Forth?
 
 !ARMForth32
 
Code Extensions
 
Examples
 
Downloads
 
More Information
 
 

What is Forth?

  
Forth is not so much a language as a complete programming system, including the operating system, assembler, compiler, multitasker and an interactive interpreter - all written in Forth. Some variants use their own editor as well. Forth is designed around a minimum of two stacks (for data and return addresses) and a linked list called a dictionary made up of words (or commands). The linked list may be "indirectly threaded", which requires some registers to be reserved to control the path flow when using the dictionary or running a program based on the words in the dictionary. A faster "directly threaded" system is based on linked assembler subroutine modules, and this is the sytem used by !ARMForth32. Each assembler routine is a reusable element (word) which generally does one thing well.
 
The use of the data stack to pass parameters between words is quick, so that there is little time penalty in factoring a computer program to its short, basic elements. This, in turn, makes the same elements (words) more reusable by other parts of the program, and can add to the elegance of the final result, or result in a bit of a dog's breakfast, depending on the skill of the programmer.
 
Forth can have a nucleus as small as 2K for a primitive system. As additional words are defined, the dictionary expands. Each application may have its own separate dictionary linked to the main Forth dictionary. The version of !ARMForth described here has a basic size of about 80K before the words from a particular application are added. It also makes extensive use of the SWI OS calls which come with RiscOS.
 
Forth was conceived in the 1970s by an American physicist Charles H. Moore working in astronomy, when he used it as a method of linking and interactively executing pre-tested routines. It is this ability to combine its interactivity (eg interrogating a peripheral's register contents using the keyboard, or trying a newly-defined word in isolation) with the ease of compilation of creating new words and structures that makes Forth so rewarding to use.