www.delorie.com/gnu/docs/gforth/gforth.html   search  
 
Buy GNU books!


Gforth Manual

[Top] [Contents] [Index] [ ? ]

Gforth Manual

Gforth is a free implementation of ANS Forth available on many personal machines. This manual corresponds to version 0.5.0.

GNU GENERAL PUBLIC LICENSE  The GPL
1. Goals of Gforth  About the Gforth Project
2. Gforth Environment  Starting (and exiting) Gforth
3. Forth Tutorial  Hands-on Forth Tutorial
4. An Introduction to ANS Forth  An introduction to ANS Forth
5. Forth Words  Forth words available in Gforth
6. Error messages  How to interpret them
7. Tools  Programming tools
8. ANS conformance  Implementation-defined options etc.
9. Should I use Gforth extensions?  Should I use extensions?
10. Model  The abstract machine of Gforth
11. Integrating Gforth into C programs  Forth as scripting language for applications
12. Emacs and Gforth  The Gforth Mode
13. Image Files  .fi files contain compiled code
14. Engine  The inner interpreter and the primitives
15. Binding to System Library  
16. Cross Compiler  The Cross Compiler
A. Bugs  How to report them
B. Authors and Ancestors of Gforth  Authors and ancestors of Gforth
C. Other Forth-related information  Books and places to look on the WWW
Word Index  An item for each Forth word
Concept and Word Index  A menu covering many topics

Gforth Environment

2.1 Invoking Gforth  Getting in
2.2 Leaving Gforth  Getting out
2.3 Command-line editing  
2.4 Environment variables  that affect how Gforth starts up
2.5 Gforth files  What gets installed and where
2.6 Startup speed  When 35ms is not fast enough ...

Forth Tutorial

3.1 Starting Gforth  
3.2 Syntax  
3.3 Crash Course  
3.4 Stack  
3.5 Arithmetics  
3.6 Stack Manipulation  
3.7 Using files for Forth code  
3.8 Comments  
3.9 Colon Definitions  
3.10 Decompilation  
3.11 Stack-Effect Comments  
3.12 Types  
3.13 Factoring  
3.14 Designing the stack effect  
3.15 Local Variables  
3.16 Conditional execution  
3.17 Flags and Comparisons  
3.18 General Loops  
3.19 Counted loops  
3.20 Recursion  
3.21 Leaving definitions or loops  
3.22 Return Stack  
3.23 Memory  
3.24 Characters and Strings  
3.25 Alignment  
3.26 Files  
3.27 Interpretation and Compilation Semantics and Immediacy  
3.28 Execution Tokens  
3.29 Exceptions  
3.30 Defining Words  
3.31 Arrays and Records  
3.32 POSTPONE  
3.33 Literal  
3.34 Advanced macros  
3.35 Compilation Tokens  
3.36 Wordlists and Search Order  

An Introduction to ANS Forth

4.1 Introducing the Text Interpreter  
4.2 Stacks, postfix notation and parameter passing  
4.3 Your first Forth definition  
4.4 How does that work?  
4.5 Forth is written in Forth  
4.6 Review - elements of a Forth system  
4.7 Where To Go Next  
4.8 Exercises  

Forth Words

5.1 Notation  
5.2 Case insensitivity  
5.3 Comments  
5.4 Boolean Flags  
5.5 Arithmetic  
5.6 Stack Manipulation  
5.7 Memory  
5.8 Control Structures  
5.9 Defining Words  
5.10 Interpretation and Compilation Semantics  
5.11 Tokens for Words  
5.12 Compiling words  
5.13 The Text Interpreter  
5.14 Word Lists  
5.15 Environmental Queries  
5.16 Files  
5.17 Blocks  
5.18 Other I/O  
5.19 Locals  
5.20 Structures  
5.21 Object-oriented Forth  
5.22 Programming Tools  
5.23 Assembler and Code Words  
5.24 Threading Words  
5.25 Passing Commands to the Operating System  
5.26 Keeping track of Time  
5.27 Miscellaneous Words  

Arithmetic

5.5.1 Single precision  
5.5.2 Double precision  Double-cell integer arithmetic
5.5.3 Bitwise operations  
5.5.4 Numeric comparison  
5.5.5 Mixed precision  Operations with single and double-cell integers
5.5.6 Floating Point  

Stack Manipulation

5.6.1 Data stack  
5.6.2 Floating point stack  
5.6.3 Return stack  
5.6.4 Locals stack  
5.6.5 Stack pointer manipulation  

Memory

5.7.1 ANS Forth and Gforth memory models  
5.7.2 Dictionary allocation  
5.7.3 Heap allocation  
5.7.4 Memory Access  
5.7.5 Address arithmetic  
5.7.6 Memory Blocks  

Control Structures

5.8.1 Selection  IF ... ELSE ... ENDIF
5.8.2 Simple Loops  BEGIN ...
5.8.3 Counted Loops  DO
5.8.4 Arbitrary control structures  
5.8.5 Calls and returns  
5.8.6 Exception Handling  

Defining Words

5.9.1 CREATE  
5.9.2 Variables  Variables and user variables
5.9.3 Constants  
5.9.4 Values  Initialised variables
5.9.5 Colon Definitions  
5.9.6 Anonymous Definitions  Definitions without names
5.9.7 Supplying the name of a defined word  Passing definition names as strings
5.9.8 User-defined Defining Words  
5.9.9 Deferred words  Allow forward references
5.9.10 Aliases  

User-defined Defining Words

5.9.8.1 Applications of CREATE..DOES>  
5.9.8.2 The gory details of CREATE..DOES>  
5.9.8.3 Advanced does> usage example  

Interpretation and Compilation Semantics

5.10.1 Combined Words  

Tokens for Words

5.11.1 Execution token  represents execution/interpretation semantics
5.11.2 Compilation token  represents compilation semantics
5.11.3 Name token  represents named words

Compiling words

5.12.1 Literals  Compiling data values
5.12.2 Macros  Compiling words

The Text Interpreter

5.13.1 Input Sources  
5.13.2 Number Conversion  
5.13.3 Interpret/Compile states  
5.13.4 Interpreter Directives  

Word Lists

5.14.1 Vocabularies  
5.14.2 Why use word lists?  
5.14.3 Word list example  

Files

5.16.1 Forth source files  
5.16.2 General files  
5.16.3 Search Paths  

Search Paths

5.16.3.1 Source Search Paths  
5.16.3.2 General Search Paths  

Other I/O

5.18.1 Simple numeric output  Predefined formats
5.18.2 Formatted numeric output  Formatted (pictured) output
5.18.3 String Formats  How Forth stores strings in memory
5.18.4 Displaying characters and strings  Other stuff
5.18.5 Input  

Locals

5.19.1 Gforth locals  
5.19.2 ANS Forth locals  

Gforth locals

5.19.1.1 Where are locals visible by name?  
5.19.1.2 How long do locals live?  
5.19.1.3 Locals programming style  
5.19.1.4 Locals implementation  

Structures

5.20.1 Why explicit structure support?  
5.20.2 Structure Usage  
5.20.3 Structure Naming Convention  
5.20.4 Structure Implementation  
5.20.5 Structure Glossary  

Object-oriented Forth

5.21.1 Why object-oriented programming?  
5.21.2 Object-Oriented Terminology  
5.21.3 The `objects.fs' model  
5.21.4 The `oof.fs' model  
5.21.5 The `mini-oof.fs' model  
5.21.6 Comparison with other object models  

The `objects.fs' model

5.21.3.1 Properties of the `objects.fs' model  
5.21.3.2 Basic `objects.fs' Usage  
5.21.3.3 The `object.fs' base class  
5.21.3.4 Creating objects  
5.21.3.5 Object-Oriented Programming Style  
5.21.3.6 Class Binding  
5.21.3.7 Method conveniences  
5.21.3.8 Classes and Scoping  
5.21.3.9 Dividing classes  
5.21.3.10 Object Interfaces  
5.21.3.11 `objects.fs' Implementation  
5.21.3.12 `objects.fs' Glossary  

The `oof.fs' model

5.21.4.1 Properties of the `oof.fs' model  
5.21.4.2 Basic `oof.fs' Usage  
5.21.4.3 The `oof.fs' base class  
5.21.4.4 Class Declaration  
5.21.4.5 Class Implementation  

The `mini-oof.fs' model

5.21.5.1 Basic `mini-oof.fs' Usage  
5.21.5.2 Mini-OOF Example  
5.21.5.3 `mini-oof.fs' Implementation  

Programming Tools

5.22.1 Examining data and code  
5.22.2 Forgetting words  
5.22.3 Debugging  Simple and quick.
5.22.4 Assertions  Making your programs self-checking.
5.22.5 Singlestep Debugger  Executing your program word by word.

Assembler and Code Words

5.23.1 Code and ;code  
5.23.2 Common Assembler  Assembler Syntax
5.23.3 Common Disassembler  
5.23.4 386 Assembler  Deviations and special cases
5.23.5 Alpha Assembler  Deviations and special cases
5.23.6 MIPS assembler  Deviations and special cases
5.23.7 Other assemblers  How to write them

Tools

7.1 `ans-report.fs': Report the words used, sorted by wordset  Report the words used, sorted by wordset.

ANS conformance

8.1 The Core Words  
8.2 The optional Block word set  
8.3 The optional Double Number word set  
8.4 The optional Exception word set  
8.5 The optional Facility word set  
8.6 The optional File-Access word set  
8.7 The optional Floating-Point word set  
8.8 The optional Locals word set  
8.9 The optional Memory-Allocation word set  
8.10 The optional Programming-Tools word set  
8.11 The optional Search-Order word set  

The Core Words

8.1.1 Implementation Defined Options  
8.1.2 Ambiguous conditions  Ambiguous Conditions
8.1.3 Other system documentation  Other System Documentation

The optional Block word set

8.2.1 Implementation Defined Options  
8.2.2 Ambiguous conditions  Ambiguous Conditions
8.2.3 Other system documentation  Other System Documentation

The optional Double Number word set

8.3.1 Ambiguous conditions  Ambiguous Conditions

The optional Exception word set

8.4.1 Implementation Defined Options  

The optional Facility word set

8.5.1 Implementation Defined Options  
8.5.2 Ambiguous conditions  Ambiguous Conditions

The optional File-Access word set

8.6.1 Implementation Defined Options  
8.6.2 Ambiguous conditions  Ambiguous Conditions

The optional Floating-Point word set

8.7.1 Implementation Defined Options  
8.7.2 Ambiguous conditions  Ambiguous Conditions

The optional Locals word set

8.8.1 Implementation Defined Options  
8.8.2 Ambiguous conditions  Ambiguous Conditions

The optional Memory-Allocation word set

8.9.1 Implementation Defined Options  

The optional Programming-Tools word set

8.10.1 Implementation Defined Options  
8.10.2 Ambiguous conditions  Ambiguous Conditions

The optional Search-Order word set

8.11.1 Implementation Defined Options  
8.11.2 Ambiguous conditions  Ambiguous Conditions

Image Files

13.1 Image Licensing Issues  Distribution terms for images.
13.2 Image File Background  Why have image files?
13.3 Non-Relocatable Image Files  don't always work.
13.4 Data-Relocatable Image Files  are better.
13.5 Fully Relocatable Image Files  better yet.
13.6 Stack and Dictionary Sizes  Setting the default sizes for an image.
13.7 Running Image Files  gforth -i file or file.
13.8 Modifying the Startup Sequence  and turnkey applications.

Fully Relocatable Image Files

13.5.1 `gforthmi'  The normal way
13.5.2 `cross.fs'  The hard way

Engine

14.1 Portability  
14.2 Threading  
14.3 Primitives  
14.4 Performance  

Threading

14.2.1 Scheduling  
14.2.2 Direct or Indirect Threaded?  
14.2.3 DOES>  

Primitives

14.3.1 Automatic Generation  
14.3.2 TOS Optimization  
14.3.3 Produced code  

Cross Compiler

16.1 Using the Cross Compiler  
16.2 How the Cross Compiler Works  


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003