Diff for /gforth/Attic/gforth.ds between versions 1.42 and 1.43

version 1.42, 1997/01/14 16:30:50 version 1.43, 1997/02/01 14:59:30
Line 7 Line 7
 @comment %**end of header (This is for running Texinfo on a region.)  @comment %**end of header (This is for running Texinfo on a region.)
   
 @ifinfo  @ifinfo
 This file documents Gforth 0.2  This file documents Gforth 0.3
   
 Copyright @copyright{} 1995,1996 Free Software Foundation, Inc.  Copyright @copyright{} 1995-1997 Free Software Foundation, Inc.
   
      Permission is granted to make and distribute verbatim copies of       Permission is granted to make and distribute verbatim copies of
      this manual provided the copyright notice and this permission notice       this manual provided the copyright notice and this permission notice
Line 41  Copyright @copyright{} 1995,1996 Free So Line 41  Copyright @copyright{} 1995,1996 Free So
 @sp 10  @sp 10
 @center @titlefont{Gforth Manual}  @center @titlefont{Gforth Manual}
 @sp 2  @sp 2
 @center for version 0.2  @center for version 0.3
 @sp 2  @sp 2
 @center Anton Ertl  @center Anton Ertl
 @center Bernd Paysan  @center Bernd Paysan
Line 51  Copyright @copyright{} 1995,1996 Free So Line 51  Copyright @copyright{} 1995,1996 Free So
 @comment  The following two commands start the copyright page.  @comment  The following two commands start the copyright page.
 @page  @page
 @vskip 0pt plus 1filll  @vskip 0pt plus 1filll
 Copyright @copyright{} 1995,1996 Free Software Foundation, Inc.  Copyright @copyright{} 1995--1997 Free Software Foundation, Inc.
   
 @comment !! Published by ... or You can get a copy of this manual ...  @comment !! Published by ... or You can get a copy of this manual ...
   
Line 77  Copyright @copyright{} 1995,1996 Free So Line 77  Copyright @copyright{} 1995,1996 Free So
 @node Top, License, (dir), (dir)  @node Top, License, (dir), (dir)
 @ifinfo  @ifinfo
 Gforth is a free implementation of ANS Forth available on many  Gforth is a free implementation of ANS Forth available on many
 personal machines. This manual corresponds to version 0.2.  personal machines. This manual corresponds to version 0.3.
 @end ifinfo  @end ifinfo
   
 @menu  @menu
 * License::                       * License::                     
 * Goals::                       About the Gforth Project  * Goals::                       About the Gforth Project
 * Other Books::                 Things you might want to read  * Other Books::                 Things you might want to read
 * Invocation::                  Starting Gforth  * Invoking Gforth::             Starting Gforth
 * Words::                       Forth words available in Gforth  * Words::                       Forth words available in Gforth
 * Tools::                       Programming tools  * Tools::                       Programming tools
 * ANS conformance::             Implementation-defined options etc.  * ANS conformance::             Implementation-defined options etc.
 * Model::                       The abstract machine of Gforth  * Model::                       The abstract machine of Gforth
 * Integrating Gforth::          Forth as scripting language for applications.  * Integrating Gforth::          Forth as scripting language for applications
 * Emacs and Gforth::            The Gforth Mode  * Emacs and Gforth::            The Gforth Mode
 * Internals::                   Implementation details  * Image Files::                 @code{.fi} files contain compiled code
   * Engine::                      The inner interpreter and the primitives
 * Bugs::                        How to report them  * Bugs::                        How to report them
 * Origin::                      Authors and ancestors of Gforth  * Origin::                      Authors and ancestors of Gforth
 * Word Index::                  An item for each Forth word  * Word Index::                  An item for each Forth word
 * Node Index::                  An item for each node  * Concept Index::               A menu covering many topics
 @end menu  @end menu
   
 @node License, Goals, Top, Top  @node License, Preface, Top, Top
 @unnumbered GNU GENERAL PUBLIC LICENSE  @unnumbered GNU GENERAL PUBLIC LICENSE
 @center Version 2, June 1991  @center Version 2, June 1991
   
Line 491  library.  If this is what you want to do Line 492  library.  If this is what you want to do
 Public License instead of this License.  Public License instead of this License.
   
 @iftex  @iftex
 @node    Preface  @node    Preface, Goals, License, Top
 @comment node-name,     next,           previous, up  @comment node-name,     next,           previous, up
 @unnumbered Preface  @unnumbered Preface
 @cindex Preface  @cindex Preface
Line 500  Forth. This manual is primarily a refere Line 501  Forth. This manual is primarily a refere
 for introductory material.  for introductory material.
 @end iftex  @end iftex
   
 @node    Goals, Other Books, License, Top  @node    Goals, Other Books, Preface, Top
 @comment node-name,     next,           previous, up  @comment node-name,     next,           previous, up
 @chapter Goals of Gforth  @chapter Goals of Gforth
 @cindex Goals  @cindex Goals
 The goal of the Gforth Project is to develop a standard model for  The goal of the Gforth Project is to develop a standard model for
 ANSI Forth. This can be split into several subgoals:  ANS Forth. This can be split into several subgoals:
   
 @itemize @bullet  @itemize @bullet
 @item  @item
 Gforth should conform to the ANSI Forth standard.  Gforth should conform to the Forth standard (ANS Forth).
 @item  @item
 It should be a model, i.e. it should define all the  It should be a model, i.e. it should define all the
 implementation-dependent things.  implementation-dependent things.
Line 543  powerful features, but not yet everythin Line 544  powerful features, but not yet everythin
 certainly have achieved our execution speed goals (@pxref{Performance}).  certainly have achieved our execution speed goals (@pxref{Performance}).
 It is free and available on many machines.  It is free and available on many machines.
   
 @node Other Books, Invocation, Goals, Top  @node Other Books, Invoking Gforth, Goals, Top
 @chapter Other books on ANS Forth  @chapter Other books on ANS Forth
   @cindex books on Forth
   
 As the standard is relatively new, there are not many books out yet. It  As the standard is relatively new, there are not many books out yet. It
 is not recommended to learn Forth by using Gforth and a book that is  is not recommended to learn Forth by using Gforth and a book that is
 not written for ANS Forth, as you will not know your mistakes from the  not written for ANS Forth, as you will not know your mistakes from the
 deviations of the book.  deviations of the book.
   
   @cindex standard document for ANS Forth
   @cindex ANS Forth document
 There is, of course, the standard, the definite reference if you want to  There is, of course, the standard, the definite reference if you want to
 write ANS Forth programs. It is available in printed form from the  write ANS Forth programs. It is available in printed form from the
 National Standards Institute Sales Department (Tel.: USA (212) 642-4900;  National Standards Institute Sales Department (Tel.: USA (212) 642-4900;
Line 564  format, and it has been converted to HTM Line 568  format, and it has been converted to HTM
 versions can be found through  versions can be found through
 @*@file{http://www.complang.tuwien.ac.at/projects/forth.html}.  @*@file{http://www.complang.tuwien.ac.at/projects/forth.html}.
   
 @cite{Forth: The new model} by Jack Woehr (Prentice-Hall, 1993) is an  @cindex introductory book
   @cindex book, introductory
   @cindex Woehr, Jack: @cite{Forth: The New Model}
   @cindex @cite{Forth: The new model} (book)
   @cite{Forth: The New Model} by Jack Woehr (Prentice-Hall, 1993) is an
 introductory book based on a draft version of the standard. It does not  introductory book based on a draft version of the standard. It does not
 cover the whole standard. It also contains interesting background  cover the whole standard. It also contains interesting background
 information (Jack Woehr was in the ANS Forth Technical Committee). It is  information (Jack Woehr was in the ANS Forth Technical Committee). It is
 not appropriate for complete newbies, but programmers experienced in  not appropriate for complete newbies, but programmers experienced in
 other languages should find it ok.  other languages should find it ok.
   
 @node Invocation, Words, Other Books, Top  @node Invoking Gforth, Words, Other Books, Top
 @chapter Invocation  @chapter Invoking Gforth
   @cindex invoking Gforth
   @cindex running Gforth
   @cindex command-line options
   @cindex options on the command line
   @cindex flags on the command line
   
 You will usually just say @code{gforth}. In many other cases the default  You will usually just say @code{gforth}. In many other cases the default
 Gforth image will be invoked like this:  Gforth image will be invoked like this:
Line 594  The initialization options must come bef Line 607  The initialization options must come bef
 line. They are:  line. They are:
   
 @table @code  @table @code
   @cindex -i, command-line option
   @cindex --image-file, command-line option
 @item --image-file @var{file}  @item --image-file @var{file}
 @item -i @var{file}  @itemx -i @var{file}
 Loads the Forth image @var{file} instead of the default  Loads the Forth image @var{file} instead of the default
 @file{gforth.fi}.  @file{gforth.fi} (@pxref{Image Files}).
   
   @cindex --path, command-line option
   @cindex -p, command-line option
 @item --path @var{path}  @item --path @var{path}
 @item -p @var{path}  @itemx -p @var{path}
 Uses @var{path} for searching the image file and Forth source code files  Uses @var{path} for searching the image file and Forth source code files
 instead of the default in the environment variable @code{GFORTHPATH} or  instead of the default in the environment variable @code{GFORTHPATH} or
 the path specified at installation time (e.g.,  the path specified at installation time (e.g.,
 @file{/usr/local/share/gforth/0.2.0:.}). A path is given as a list of  @file{/usr/local/share/gforth/0.2.0:.}). A path is given as a list of
 directories, separated by @samp{:} (on Unix) or @samp{;} (on other OSs).  directories, separated by @samp{:} (on Unix) or @samp{;} (on other OSs).
   
   @cindex --dictionary-size, command-line option
   @cindex -m, command-line option
   @cindex @var{size} parameters for command-line options
   @cindex size of the dictionary and the stacks
 @item --dictionary-size @var{size}  @item --dictionary-size @var{size}
 @item -m @var{size}  @itemx -m @var{size}
 Allocate @var{size} space for the Forth dictionary space instead of  Allocate @var{size} space for the Forth dictionary space instead of
 using the default specified in the image (typically 256K). The  using the default specified in the image (typically 256K). The
 @var{size} specification consists of an integer and a unit (e.g.,  @var{size} specification consists of an integer and a unit (e.g.,
Line 616  using the default specified in the image Line 637  using the default specified in the image
 size, in this case Cells), @code{k} (kilobytes), and @code{M}  size, in this case Cells), @code{k} (kilobytes), and @code{M}
 (Megabytes). If no unit is specified, @code{e} is used.  (Megabytes). If no unit is specified, @code{e} is used.
   
   @cindex --data-stack-size, command-line option
   @cindex -d, command-line option
 @item --data-stack-size @var{size}  @item --data-stack-size @var{size}
 @item -d @var{size}  @itemx -d @var{size}
 Allocate @var{size} space for the data stack instead of using the  Allocate @var{size} space for the data stack instead of using the
 default specified in the image (typically 16K).  default specified in the image (typically 16K).
   
   @cindex --return-stack-size, command-line option
   @cindex -r, command-line option
 @item --return-stack-size @var{size}  @item --return-stack-size @var{size}
 @item -r @var{size}  @itemx -r @var{size}
 Allocate @var{size} space for the return stack instead of using the  Allocate @var{size} space for the return stack instead of using the
 default specified in the image (typically 16K).  default specified in the image (typically 15K).
   
   @cindex --fp-stack-size, command-line option
   @cindex -f, command-line option
 @item --fp-stack-size @var{size}  @item --fp-stack-size @var{size}
 @item -f @var{size}  @itemx -f @var{size}
 Allocate @var{size} space for the floating point stack instead of  Allocate @var{size} space for the floating point stack instead of
 using the default specified in the image (typically 16K). In this case  using the default specified in the image (typically 15.5K). In this case
 the unit specifier @code{e} refers to floating point numbers.  the unit specifier @code{e} refers to floating point numbers.
   
   @cindex --locals-stack-size, command-line option
   @cindex -l, command-line option
 @item --locals-stack-size @var{size}  @item --locals-stack-size @var{size}
 @item -l @var{size}  @itemx -l @var{size}
 Allocate @var{size} space for the locals stack instead of using the  Allocate @var{size} space for the locals stack instead of using the
 default specified in the image (typically 16K).  default specified in the image (typically 14.5K).
   
   @cindex -h, command-line option
   @cindex --help, command-line option
   @item --help
   @itemx -h
   Print a message about the command-line options
   
   @cindex -v, command-line option
   @cindex --version, command-line option
   @item --version
   @itemx -v
   Print version and exit
   
   @cindex --debug, command-line option
   @item --debug
   Print some information useful for debugging on startup.
   
   @cindex --offset-image, command-line option
   @item --offset-image
   Start the dictionary at a slightly different position than would be used
   otherwise (useful for creating data-relocatable images,
   @pxref{Data-Relocatable Image Files}).
   
   @cindex --clear-dictionary, command-line option
   @item --clear-dictionary
   Initialize all bytes in the dictionary to 0 before loading the image
   (@pxref{Data-Relocatable Image Files}).
 @end table  @end table
   
   @cindex loading files at startup
   @cindex executing code on startup
   @cindex batch processing with Gforth
 As explained above, the image-specific command-line arguments for the  As explained above, the image-specific command-line arguments for the
 default image @file{gforth.fi} consist of a sequence of filenames and  default image @file{gforth.fi} consist of a sequence of filenames and
 @code{-e @var{forth-code}} options that are interpreted in the sequence  @code{-e @var{forth-code}} options that are interpreted in the sequence
Line 649  Forth words, you have to quote them or u Line 707  Forth words, you have to quote them or u
 after processing the command line (instead of entering interactive mode)  after processing the command line (instead of entering interactive mode)
 append @code{-e bye} to the command line.  append @code{-e bye} to the command line.
   
   @cindex versions, invoking other versions of Gforth
 If you have several versions of Gforth installed, @code{gforth} will  If you have several versions of Gforth installed, @code{gforth} will
 invoke the version that was installed last. @code{gforth-@var{version}}  invoke the version that was installed last. @code{gforth-@var{version}}
 invokes a specific version. You may want to use the option  invokes a specific version. You may want to use the option
Line 663  the user initialization file @file{.gfor Line 722  the user initialization file @file{.gfor
 option @code{--no-rc} is given; this file is first searched in @file{.},  option @code{--no-rc} is given; this file is first searched in @file{.},
 then in @file{~}, then in the normal path (see above).  then in @file{~}, then in the normal path (see above).
   
 @node Words, Tools, Invocation, Top  @node Words, Tools, Invoking Gforth, Top
 @chapter Forth Words  @chapter Forth Words
   @cindex Words
   
 @menu  @menu
 * Notation::                      * Notation::                    
 * Arithmetic::                    * Arithmetic::                  
 * Stack Manipulation::            * Stack Manipulation::          
 * Memory access::                 * Memory::               
 * Control Structures::            * Control Structures::          
 * Locals::                        * Locals::                      
 * Defining Words::                * Defining Words::              
Line 686  then in @file{~}, then in the normal pat Line 746  then in @file{~}, then in the normal pat
   
 @node Notation, Arithmetic, Words, Words  @node Notation, Arithmetic, Words, Words
 @section Notation  @section Notation
   @cindex notation of glossary entries
   @cindex format of glossary entries
   @cindex glossary notation format
   @cindex word glossary entry format
   
 The Forth words are described in this section in the glossary notation  The Forth words are described in this section in the glossary notation
 that has become a de-facto standard for Forth texts, i.e.  that has become a de-facto standard for Forth texts, i.e.,
   
 @format  @format
 @var{word}     @var{Stack effect}   @var{wordset}   @var{pronunciation}  @var{word}     @var{Stack effect}   @var{wordset}   @var{pronunciation}
Line 697  that has become a de-facto standard for Line 761  that has become a de-facto standard for
   
 @table @var  @table @var
 @item word  @item word
   @cindex case insensitivity
 The name of the word. BTW, Gforth is case insensitive, so you can  The name of the word. BTW, Gforth is case insensitive, so you can
 type the words in in lower case (However, @pxref{core-idef}).  type the words in in lower case (However, @pxref{core-idef}).
   
 @item Stack effect  @item Stack effect
   @cindex stack effect
 The stack effect is written in the notation @code{@var{before} --  The stack effect is written in the notation @code{@var{before} --
 @var{after}}, where @var{before} and @var{after} describe the top of  @var{after}}, where @var{before} and @var{after} describe the top of
 stack entries before and after the execution of the word. The rest of  stack entries before and after the execution of the word. The rest of
Line 719  this standard behaviour, or the word doe Line 785  this standard behaviour, or the word doe
 compile time, both stack effects are shown; otherwise only the run-time  compile time, both stack effects are shown; otherwise only the run-time
 stack effect is shown.  stack effect is shown.
   
   @cindex pronounciation of words
 @item pronunciation  @item pronunciation
 How the word is pronounced  How the word is pronounced.
   
   @cindex wordset
 @item wordset  @item wordset
 The ANS Forth standard is divided into several wordsets. A standard  The ANS Forth standard is divided into several wordsets. A standard
 system need not support all of them. So, the fewer wordsets your program  system need not support all of them. So, the fewer wordsets your program
Line 738  strings are also displayed like words; y Line 806  strings are also displayed like words; y
 A description of the behaviour of the word.  A description of the behaviour of the word.
 @end table  @end table
   
   @cindex types of stack items
   @cindex stack item types
 The type of a stack item is specified by the character(s) the name  The type of a stack item is specified by the character(s) the name
 starts with:  starts with:
   
 @table @code  @table @code
 @item f  @item f
 Bool, i.e. @code{false} or @code{true}.  @cindex @code{f}, stack item type
   Boolean flags, i.e. @code{false} or @code{true}.
 @item c  @item c
   @cindex @code{c}, stack item type
 Char  Char
 @item w  @item w
   @cindex @code{w}, stack item type
 Cell, can contain an integer or an address  Cell, can contain an integer or an address
 @item n  @item n
   @cindex @code{n}, stack item type
 signed integer  signed integer
 @item u  @item u
   @cindex @code{u}, stack item type
 unsigned integer  unsigned integer
 @item d  @item d
   @cindex @code{d}, stack item type
 double sized signed integer  double sized signed integer
 @item ud  @item ud
   @cindex @code{ud}, stack item type
 double sized unsigned integer  double sized unsigned integer
 @item r  @item r
   @cindex @code{r}, stack item type
 Float (on the FP stack)  Float (on the FP stack)
 @item a_  @item a_
   @cindex @code{a_}, stack item type
 Cell-aligned address  Cell-aligned address
 @item c_  @item c_
   @cindex @code{c_}, stack item type
 Char-aligned address (note that a Char may have two bytes in Windows NT)  Char-aligned address (note that a Char may have two bytes in Windows NT)
 @item f_  @item f_
   @cindex @code{f_}, stack item type
 Float-aligned address  Float-aligned address
 @item df_  @item df_
   @cindex @code{df_}, stack item type
 Address aligned for IEEE double precision float  Address aligned for IEEE double precision float
 @item sf_  @item sf_
   @cindex @code{sf_}, stack item type
 Address aligned for IEEE single precision float  Address aligned for IEEE single precision float
 @item xt  @item xt
   @cindex @code{xt}, stack item type
 Execution token, same size as Cell  Execution token, same size as Cell
 @item wid  @item wid
   @cindex @code{wid}, stack item type
 Wordlist ID, same size as Cell  Wordlist ID, same size as Cell
 @item f83name  @item f83name
   @cindex @code{f83name}, stack item type
 Pointer to a name structure  Pointer to a name structure
 @item "  @item "
   @cindex @code{"}, stack item type
 string in the input stream (not the stack). The terminating character is  string in the input stream (not the stack). The terminating character is
 a blank by default. If it is not a blank, it is shown in @code{<>}  a blank by default. If it is not a blank, it is shown in @code{<>}
 quotes.  quotes.
   
 @end table  @end table
   
 @node Arithmetic, Stack Manipulation, Notation, Words  @node Arithmetic, Stack Manipulation, Notation, Words
 @section Arithmetic  @section Arithmetic
   @cindex arithmetic words
   
   @cindex division with potentially negative operands
 Forth arithmetic is not checked, i.e., you will not hear about integer  Forth arithmetic is not checked, i.e., you will not hear about integer
 overflow on addition or multiplication, you may hear about division by  overflow on addition or multiplication, you may hear about division by
 zero if you are lucky. The operator is written after the operands, but  zero if you are lucky. The operator is written after the operands, but
Line 803  former, @pxref{Mixed precision}). Line 892  former, @pxref{Mixed precision}).
   
 @node Single precision, Bitwise operations, Arithmetic, Arithmetic  @node Single precision, Bitwise operations, Arithmetic, Arithmetic
 @subsection Single precision  @subsection Single precision
   @cindex single precision arithmetic words
   
 doc-+  doc-+
 doc--  doc--
 doc-*  doc-*
Line 816  doc-max Line 907  doc-max
   
 @node Bitwise operations, Mixed precision, Single precision, Arithmetic  @node Bitwise operations, Mixed precision, Single precision, Arithmetic
 @subsection Bitwise operations  @subsection Bitwise operations
   @cindex bitwise operation words
   
 doc-and  doc-and
 doc-or  doc-or
 doc-xor  doc-xor
Line 825  doc-2/ Line 918  doc-2/
   
 @node Mixed precision, Double precision, Bitwise operations, Arithmetic  @node Mixed precision, Double precision, Bitwise operations, Arithmetic
 @subsection Mixed precision  @subsection Mixed precision
   @cindex mixed precision arithmetic words
   
 doc-m+  doc-m+
 doc-*/  doc-*/
 doc-*/mod  doc-*/mod
Line 837  doc-sm/rem Line 932  doc-sm/rem
   
 @node Double precision, Floating Point, Mixed precision, Arithmetic  @node Double precision, Floating Point, Mixed precision, Arithmetic
 @subsection Double precision  @subsection Double precision
   @cindex double precision arithmetic words
   
   @cindex double-cell numbers, input format
   @cindex input format for double-cell numbers
 The outer (aka text) interpreter converts numbers containing a dot into  The outer (aka text) interpreter converts numbers containing a dot into
 a double precision number. Note that only numbers with the dot as last  a double precision number. Note that only numbers with the dot as last
 character are standard-conforming.  character are standard-conforming.
Line 851  doc-dmax Line 949  doc-dmax
   
 @node Floating Point,  , Double precision, Arithmetic  @node Floating Point,  , Double precision, Arithmetic
 @subsection Floating Point  @subsection Floating Point
   @cindex floating point arithmetic words
   
   @cindex floating-point numbers, input format
   @cindex input format for floating-point numbers
 The format of floating point numbers recognized by the outer (aka text)  The format of floating point numbers recognized by the outer (aka text)
 interpreter is: a signed decimal number, possibly containing a decimal  interpreter is: a signed decimal number, possibly containing a decimal
 point (@code{.}), followed by @code{E} or @code{e}, optionally followed  point (@code{.}), followed by @code{E} or @code{e}, optionally followed
Line 865  value greater then 14, the @code{E} may Line 966  value greater then 14, the @code{E} may
 number will be interpreted as integer, unless it has a signed exponent  number will be interpreted as integer, unless it has a signed exponent
 (both @code{+} and @code{-} are allowed as signs).  (both @code{+} and @code{-} are allowed as signs).
   
   @cindex angles in trigonometric operations
   @cindex trigonometric operations
 Angles in floating point operations are given in radians (a full circle  Angles in floating point operations are given in radians (a full circle
 has 2 pi radians). Note, that Gforth has a separate floating point  has 2 pi radians). Note, that Gforth has a separate floating point
 stack, but we use the unified notation.  stack, but we use the unified notation.
   
   @cindex floating-point arithmetic, pitfalls
 Floating point numbers have a number of unpleasant surprises for the  Floating point numbers have a number of unpleasant surprises for the
 unwary (e.g., floating point addition is not associative) and even a few  unwary (e.g., floating point addition is not associative) and even a few
 for the wary. You should not use them unless you know what you are doing  for the wary. You should not use them unless you know what you are doing
Line 911  doc-fasinh Line 1015  doc-fasinh
 doc-facosh  doc-facosh
 doc-fatanh  doc-fatanh
   
 @node Stack Manipulation, Memory access, Arithmetic, Words  @node Stack Manipulation, Memory, Arithmetic, Words
 @section Stack Manipulation  @section Stack Manipulation
   @cindex stack manipulation words
   
   @cindex floating-point stack in the standard
 Gforth has a data stack (aka parameter stack) for characters, cells,  Gforth has a data stack (aka parameter stack) for characters, cells,
 addresses, and double cells, a floating point stack for floating point  addresses, and double cells, a floating point stack for floating point
 numbers, a return stack for storing the return addresses of colon  numbers, a return stack for storing the return addresses of colon
Line 927  they work also for a unified stack model Line 1033  they work also for a unified stack model
 it. Instead, just say that your program has an environmental dependency  it. Instead, just say that your program has an environmental dependency
 on a separate FP stack.  on a separate FP stack.
   
   @cindex return stack and locals
   @cindex locals and return stack
 Also, a Forth system is allowed to keep the local variables on the  Also, a Forth system is allowed to keep the local variables on the
 return stack. This is reasonable, as local variables usually eliminate  return stack. This is reasonable, as local variables usually eliminate
 the need to use the return stack explicitly. So, if you want to produce  the need to use the return stack explicitly. So, if you want to produce
Line 944  standard document for the exact rules). Line 1052  standard document for the exact rules).
   
 @node Data stack, Floating point stack, Stack Manipulation, Stack Manipulation  @node Data stack, Floating point stack, Stack Manipulation, Stack Manipulation
 @subsection Data stack  @subsection Data stack
   @cindex data stack manipulation words
   @cindex stack manipulations words, data stack
   
 doc-drop  doc-drop
 doc-nip  doc-nip
 doc-dup  doc-dup
Line 965  doc-2rot Line 1076  doc-2rot
   
 @node Floating point stack, Return stack, Data stack, Stack Manipulation  @node Floating point stack, Return stack, Data stack, Stack Manipulation
 @subsection Floating point stack  @subsection Floating point stack
   @cindex floating-point stack manipulation words
   @cindex stack manipulation words, floating-point stack
   
 doc-fdrop  doc-fdrop
 doc-fnip  doc-fnip
 doc-fdup  doc-fdup
Line 975  doc-frot Line 1089  doc-frot
   
 @node Return stack, Locals stack, Floating point stack, Stack Manipulation  @node Return stack, Locals stack, Floating point stack, Stack Manipulation
 @subsection Return stack  @subsection Return stack
   @cindex return stack manipulation words
   @cindex stack manipulation words, return stack
   
 doc->r  doc->r
 doc-r>  doc-r>
 doc-r@  doc-r@
Line 989  doc-2rdrop Line 1106  doc-2rdrop
   
 @node Stack pointer manipulation,  , Locals stack, Stack Manipulation  @node Stack pointer manipulation,  , Locals stack, Stack Manipulation
 @subsection Stack pointer manipulation  @subsection Stack pointer manipulation
   @cindex stack pointer manipulation words
   
 doc-sp@  doc-sp@
 doc-sp!  doc-sp!
 doc-fp@  doc-fp@
Line 998  doc-rp! Line 1117  doc-rp!
 doc-lp@  doc-lp@
 doc-lp!  doc-lp!
   
 @node Memory access, Control Structures, Stack Manipulation, Words  @node Memory, Control Structures, Stack Manipulation, Words
 @section Memory access  @section Memory
   @cindex Memory words
   
 @menu  @menu
 * Stack-Memory transfers::        * Memory Access::      
 * Address arithmetic::            * Address arithmetic::          
 * Memory block access::           * Memory Blocks::         
 @end menu  @end menu
   
 @node Stack-Memory transfers, Address arithmetic, Memory access, Memory access  @node Memory Access, Address arithmetic, Memory, Memory
 @subsection Stack-Memory transfers  @subsection Memory Access
   @cindex memory access words
   
 doc-@  doc-@
 doc-!  doc-!
Line 1024  doc-sf! Line 1145  doc-sf!
 doc-df@  doc-df@
 doc-df!  doc-df!
   
 @node Address arithmetic, Memory block access, Stack-Memory transfers, Memory access  @node Address arithmetic, Memory Blocks, Memory Access, Memory
 @subsection Address arithmetic  @subsection Address arithmetic
   @cindex address arithmetic words
   
 ANS Forth does not specify the sizes of the data types. Instead, it  ANS Forth does not specify the sizes of the data types. Instead, it
 offers a number of words for computing sizes and doing address  offers a number of words for computing sizes and doing address
Line 1034  address units (aus); on most systems the Line 1156  address units (aus); on most systems the
 that a character may have more than one au, so @code{chars} is no noop  that a character may have more than one au, so @code{chars} is no noop
 (on systems where it is a noop, it compiles to nothing).  (on systems where it is a noop, it compiles to nothing).
   
   @cindex alignment of addresses for types
 ANS Forth also defines words for aligning addresses for specific  ANS Forth also defines words for aligning addresses for specific
 addresses. Many computers require that accesses to specific data types  types. Many computers require that accesses to specific data types
 must only occur at specific addresses; e.g., that cells may only be  must only occur at specific addresses; e.g., that cells may only be
 accessed at addresses divisible by 4. Even if a machine allows unaligned  accessed at addresses divisible by 4. Even if a machine allows unaligned
 accesses, it can usually perform aligned accesses faster.   accesses, it can usually perform aligned accesses faster. 
Line 1049  an oversight, but reflects the fact that Line 1172  an oversight, but reflects the fact that
 char-aligned have no use in the standard and therefore will not be  char-aligned have no use in the standard and therefore will not be
 created.  created.
   
   @cindex @code{CREATE} and alignment
 The standard guarantees that addresses returned by @code{CREATE}d words  The standard guarantees that addresses returned by @code{CREATE}d words
 are cell-aligned; in addition, Gforth guarantees that these addresses  are cell-aligned; in addition, Gforth guarantees that these addresses
 are aligned for all purposes.  are aligned for all purposes.
Line 1060  doc-chars Line 1184  doc-chars
 doc-char+  doc-char+
 doc-cells  doc-cells
 doc-cell+  doc-cell+
   doc-cell
 doc-align  doc-align
 doc-aligned  doc-aligned
 doc-floats  doc-floats
 doc-float+  doc-float+
   doc-float
 doc-falign  doc-falign
 doc-faligned  doc-faligned
 doc-sfloats  doc-sfloats
Line 1080  doc-cfalign Line 1206  doc-cfalign
 doc-cfaligned  doc-cfaligned
 doc-address-unit-bits  doc-address-unit-bits
   
 @node Memory block access,  , Address arithmetic, Memory access  @node Memory Blocks,  , Address arithmetic, Memory
 @subsection Memory block access  @subsection Memory Blocks
   @cindex memory block words
   
 doc-move  doc-move
 doc-erase  doc-erase
Line 1094  doc-cmove> Line 1221  doc-cmove>
 doc-fill  doc-fill
 doc-blank  doc-blank
   
 @node Control Structures, Locals, Memory access, Words  @node Control Structures, Locals, Memory, Words
 @section Control Structures  @section Control Structures
   @cindex control structures
   
 Control structures in Forth cannot be used in interpret state, only in  Control structures in Forth cannot be used in interpret state, only in
 compile state, i.e., in a colon definition. We do not like this  compile state@footnote{More precisely, they have no interpretation
 limitation, but have not seen a satisfying way around it yet, although  semantics (@pxref{Interpretation and Compilation Semantics})}, i.e., in
 many schemes have been proposed.  a colon definition. We do not like this limitation, but have not seen a
   satisfying way around it yet, although many schemes have been proposed.
   
 @menu  @menu
 * Selection::                     * Selection::                   
Line 1113  many schemes have been proposed. Line 1242  many schemes have been proposed.
   
 @node Selection, Simple Loops, Control Structures, Control Structures  @node Selection, Simple Loops, Control Structures, Control Structures
 @subsection Selection  @subsection Selection
   @cindex selection control structures
   @cindex control structures for selection
   
   @cindex @code{IF} control structure
 @example  @example
 @var{flag}  @var{flag}
 IF  IF
Line 1155  efficient than using @code{?dup}. Defini Line 1287  efficient than using @code{?dup}. Defini
 for @code{ENDIF}, @code{?DUP-IF} and @code{?DUP-0=-IF} are provided in  for @code{ENDIF}, @code{?DUP-IF} and @code{?DUP-0=-IF} are provided in
 @file{compat/control.fs}.  @file{compat/control.fs}.
   
   @cindex @code{CASE} control structure
 @example  @example
 @var{n}  @var{n}
 CASE  CASE
Line 1171  but must not consume it. Line 1304  but must not consume it.
   
 @node Simple Loops, Counted Loops, Selection, Control Structures  @node Simple Loops, Counted Loops, Selection, Control Structures
 @subsection Simple Loops  @subsection Simple Loops
   @cindex simple loops
   @cindex loops without count 
   
   @cindex @code{WHILE} loop
 @example  @example
 BEGIN  BEGIN
   @var{code1}    @var{code1}
Line 1182  REPEAT Line 1318  REPEAT
 @end example  @end example
   
 @var{code1} is executed and @var{flag} is computed. If it is true,  @var{code1} is executed and @var{flag} is computed. If it is true,
 @var{code2} is executed and the loop is restarted; If @var{flag} is false, execution continues after the @code{REPEAT}.  @var{code2} is executed and the loop is restarted; If @var{flag} is
   false, execution continues after the @code{REPEAT}.
   
   @cindex @code{UNTIL} loop
 @example  @example
 BEGIN  BEGIN
   @var{code}    @var{code}
Line 1193  UNTIL Line 1331  UNTIL
   
 @var{code} is executed. The loop is restarted if @code{flag} is false.  @var{code} is executed. The loop is restarted if @code{flag} is false.
   
   @cindex endless loop
   @cindex loops, endless
 @example  @example
 BEGIN  BEGIN
   @var{code}    @var{code}
Line 1203  This is an endless loop. Line 1343  This is an endless loop.
   
 @node Counted Loops, Arbitrary control structures, Simple Loops, Control Structures  @node Counted Loops, Arbitrary control structures, Simple Loops, Control Structures
 @subsection Counted Loops  @subsection Counted Loops
   @cindex counted loops
   @cindex loops, counted
   @cindex @code{DO} loops
   
 The basic counted loop is:  The basic counted loop is:
 @example  @example
Line 1255  between @var{limit-1} and @var{limit} is Line 1398  between @var{limit-1} and @var{limit} is
   
 @code{4 1 +DO  i .  2 +LOOP}   prints @code{1 3}  @code{4 1 +DO  i .  2 +LOOP}   prints @code{1 3}
   
   @cindex negative increment for counted loops
   @cindex counted loops with negative increment
 The behaviour of @code{@var{n} +LOOP} is peculiar when @var{n} is negative:  The behaviour of @code{@var{n} +LOOP} is peculiar when @var{n} is negative:
   
 @code{-1 0 ?DO  i .  -1 +LOOP}  prints @code{0 -1}  @code{-1 0 ?DO  i .  -1 +LOOP}  prints @code{0 -1}
Line 1288  to become invalid during maintenance of Line 1433  to become invalid during maintenance of
 @code{EXIT}. @code{UNLOOP} removes the loop control parameters from the  @code{EXIT}. @code{UNLOOP} removes the loop control parameters from the
 return stack so @code{EXIT} can get to its return address.  return stack so @code{EXIT} can get to its return address.
   
   @cindex @code{FOR} loops
 Another counted loop is  Another counted loop is
 @example  @example
 @var{n}  @var{n}
Line 1304  loops. Line 1450  loops.
   
 @node Arbitrary control structures, Calls and returns, Counted Loops, Control Structures  @node Arbitrary control structures, Calls and returns, Counted Loops, Control Structures
 @subsection Arbitrary control structures  @subsection Arbitrary control structures
   @cindex control structures, user-defined
   
   @cindex control-flow stack
 ANS Forth permits and supports using control structures in a non-nested  ANS Forth permits and supports using control structures in a non-nested
 way. Information about incomplete control structures is stored on the  way. Information about incomplete control structures is stored on the
 control-flow stack. This stack may be implemented on the Forth data  control-flow stack. This stack may be implemented on the Forth data
 stack, and this is what we have done in Gforth.  stack, and this is what we have done in Gforth.
   
   @cindex @code{orig}, control-flow stack item
   @cindex @code{dest}, control-flow stack item
 An @i{orig} entry represents an unresolved forward branch, a @i{dest}  An @i{orig} entry represents an unresolved forward branch, a @i{dest}
 entry represents a backward branch target. A few words are the basis for  entry represents a backward branch target. A few words are the basis for
 building any control structure possible (except control structures that  building any control structure possible (except control structures that
Line 1422  necessary to define them. Line 1572  necessary to define them.
   
 @node Calls and returns, Exception Handling, Arbitrary control structures, Control Structures  @node Calls and returns, Exception Handling, Arbitrary control structures, Control Structures
 @subsection Calls and returns  @subsection Calls and returns
   @cindex calling a definition
   @cindex returning from a definition
   
 A definition can be called simply be writing the name of the  A definition can be called simply be writing the name of the
 definition. When the end of the definition is reached, it returns. An  definition. When the end of the definition is reached, it returns. An
Line 1437  doc-;s Line 1589  doc-;s
   
 @node Exception Handling,  , Calls and returns, Control Structures  @node Exception Handling,  , Calls and returns, Control Structures
 @subsection Exception Handling  @subsection Exception Handling
   @cindex Exceptions
   
 doc-catch  doc-catch
 doc-throw  doc-throw
   
 @node Locals, Defining Words, Control Structures, Words  @node Locals, Defining Words, Control Structures, Words
 @section Locals  @section Locals
   @cindex locals
   
 Local variables can make Forth programming more enjoyable and Forth  Local variables can make Forth programming more enjoyable and Forth
 programs easier to read. Unfortunately, the locals of ANS Forth are  programs easier to read. Unfortunately, the locals of ANS Forth are
Line 1462  at EuroForth '94; it is available at Line 1616  at EuroForth '94; it is available at
   
 @node Gforth locals, ANS Forth locals, Locals, Locals  @node Gforth locals, ANS Forth locals, Locals, Locals
 @subsection Gforth locals  @subsection Gforth locals
   @cindex Gforth locals
   @cindex locals, Gforth style
   
 Locals can be defined with  Locals can be defined with
   
Line 1494  find. However, this problem can be avoid Line 1650  find. However, this problem can be avoid
 conventions: Do not use both notations in the same program. If you do,  conventions: Do not use both notations in the same program. If you do,
 they should be distinguished using additional means, e.g. by position.  they should be distinguished using additional means, e.g. by position.
   
   @cindex types of locals
   @cindex locals types
 The name of the local may be preceded by a type specifier, e.g.,  The name of the local may be preceded by a type specifier, e.g.,
 @code{F:} for a floating point value:  @code{F:} for a floating point value:
   
Line 1504  The name of the local may be preceded by Line 1662  The name of the local may be preceded by
  Ar Bi f* Ai Br f* f+ ;   Ar Bi f* Ai Br f* f+ ;
 @end example  @end example
   
   @cindex flavours of locals
   @cindex locals flavours
   @cindex value-flavoured locals
   @cindex variable-flavoured locals
 Gforth currently supports cells (@code{W:}, @code{W^}), doubles  Gforth currently supports cells (@code{W:}, @code{W^}), doubles
 (@code{D:}, @code{D^}), floats (@code{F:}, @code{F^}) and characters  (@code{D:}, @code{D^}), floats (@code{F:}, @code{F^}) and characters
 (@code{C:}, @code{C^}) in two flavours: a value-flavoured local (defined  (@code{C:}, @code{C^}) in two flavours: a value-flavoured local (defined
Line 1518  left). E.g., the standard word @code{emi Line 1680  left). E.g., the standard word @code{emi
     char* 1 type ;      char* 1 type ;
 @end example  @end example
   
   @cindex default type of locals
   @cindex locals, default type
 A local without type specifier is a @code{W:} local. Both flavours of  A local without type specifier is a @code{W:} local. Both flavours of
 locals are initialized with values from the data or FP stack.  locals are initialized with values from the data or FP stack.
   
Line 1536  poses the following questions: Line 1700  poses the following questions:
   
 @node Where are locals visible by name?, How long do locals live?, Gforth locals, Gforth locals  @node Where are locals visible by name?, How long do locals live?, Gforth locals, Gforth locals
 @subsubsection Where are locals visible by name?  @subsubsection Where are locals visible by name?
   @cindex locals visibility
   @cindex visibility of locals
   @cindex scope of locals
   
 Basically, the answer is that locals are visible where you would expect  Basically, the answer is that locals are visible where you would expect
 it in block-structured languages, and sometimes a little longer. If you  it in block-structured languages, and sometimes a little longer. If you
Line 1582  that the visibility of some locals is mo Line 1749  that the visibility of some locals is mo
 says. If @code{UNREACHABLE} is used where it should not (i.e., if you  says. If @code{UNREACHABLE} is used where it should not (i.e., if you
 lie to the compiler), buggy code will be produced.  lie to the compiler), buggy code will be produced.
   
   doc-unreachable
   
 Another problem with this rule is that at @code{BEGIN}, the compiler  Another problem with this rule is that at @code{BEGIN}, the compiler
 does not know which locals will be visible on the incoming  does not know which locals will be visible on the incoming
 back-edge. All problems discussed in the following are due to this  back-edge. All problems discussed in the following are due to this
Line 1695  REPEAT Line 1864  REPEAT
   
 @node How long do locals live?, Programming Style, Where are locals visible by name?, Gforth locals  @node How long do locals live?, Programming Style, Where are locals visible by name?, Gforth locals
 @subsubsection How long do locals live?  @subsubsection How long do locals live?
   @cindex locals lifetime
   @cindex lifetime of locals
   
 The right answer for the lifetime question would be: A local lives at  The right answer for the lifetime question would be: A local lives at
 least as long as it can be accessed. For a value-flavoured local this  least as long as it can be accessed. For a value-flavoured local this
Line 1709  afterwards are erroneous). Line 1880  afterwards are erroneous).
   
 @node Programming Style, Implementation, How long do locals live?, Gforth locals  @node Programming Style, Implementation, How long do locals live?, Gforth locals
 @subsubsection Programming Style  @subsubsection Programming Style
   @cindex locals programming style
   @cindex programming style, locals
   
 The freedom to define locals anywhere has the potential to change  The freedom to define locals anywhere has the potential to change
 programming styles dramatically. In particular, the need to use the  programming styles dramatically. In particular, the need to use the
Line 1729  readable. Of course, this benefit will o Line 1902  readable. Of course, this benefit will o
 programmers continue to honour the principle of factoring instead of  programmers continue to honour the principle of factoring instead of
 using the added latitude to make the words longer.  using the added latitude to make the words longer.
   
   @cindex single-assignment style for locals
 Using @code{TO} can and should be avoided.  Without @code{TO},  Using @code{TO} can and should be avoided.  Without @code{TO},
 every value-flavoured local has only a single assignment and many  every value-flavoured local has only a single assignment and many
 advantages of functional languages apply to Forth. I.e., programs are  advantages of functional languages apply to Forth. I.e., programs are
Line 1778  in every loop iteration. Line 1952  in every loop iteration.
   
 @node Implementation,  , Programming Style, Gforth locals  @node Implementation,  , Programming Style, Gforth locals
 @subsubsection Implementation  @subsubsection Implementation
   @cindex locals implementation
   @cindex implementation of locals
   
   @cindex locals stack
 Gforth uses an extra locals stack. The most compelling reason for  Gforth uses an extra locals stack. The most compelling reason for
 this is that the return stack is not float-aligned; using an extra stack  this is that the return stack is not float-aligned; using an extra stack
 also eliminates the problems and restrictions of using the return stack  also eliminates the problems and restrictions of using the return stack
Line 1814  area and @code{@}} switches it back and Line 1991  area and @code{@}} switches it back and
 initializing code. @code{W:} etc.@ are normal defining words. This  initializing code. @code{W:} etc.@ are normal defining words. This
 special area is cleared at the start of every colon definition.  special area is cleared at the start of every colon definition.
   
   @cindex wordlist for defining locals
 A special feature of Gforth's dictionary is used to implement the  A special feature of Gforth's dictionary is used to implement the
 definition of locals without type specifiers: every wordlist (aka  definition of locals without type specifiers: every wordlist (aka
 vocabulary) has its own methods for searching  vocabulary) has its own methods for searching
Line 1860  level to the level at the orig point, so Line 2038  level to the level at the orig point, so
 adjustment from the current level to the right level after the  adjustment from the current level to the right level after the
 @code{THEN}.  @code{THEN}.
   
   @cindex locals information on the control-flow stack
   @cindex control-flow stack items, locals information
 In a conventional Forth implementation a dest control-flow stack entry  In a conventional Forth implementation a dest control-flow stack entry
 is just the target address and an orig entry is just the address to be  is just the target address and an orig entry is just the address to be
 patched. Our locals implementation adds a wordlist to every orig or dest  patched. Our locals implementation adds a wordlist to every orig or dest
Line 1906  usually less than reclaiming this space Line 2086  usually less than reclaiming this space
   
 @node ANS Forth locals,  , Gforth locals, Locals  @node ANS Forth locals,  , Gforth locals, Locals
 @subsection ANS Forth locals  @subsection ANS Forth locals
   @cindex locals, ANS Forth style
   
 The ANS Forth locals wordset does not define a syntax for locals, but  The ANS Forth locals wordset does not define a syntax for locals, but
 words that make it possible to define various syntaxes. One of the  words that make it possible to define various syntaxes. One of the
Line 1966  locals wordset. Line 2147  locals wordset.
   
 @node Defining Words, Tokens for Words, Locals, Words  @node Defining Words, Tokens for Words, Locals, Words
 @section Defining Words  @section Defining Words
   @cindex defining words
   
 @menu  @menu
 * Simple Defining Words::         * Simple Defining Words::       
Line 1977  locals wordset. Line 2159  locals wordset.
   
 @node Simple Defining Words, Colon Definitions, Defining Words, Defining Words  @node Simple Defining Words, Colon Definitions, Defining Words, Defining Words
 @subsection Simple Defining Words  @subsection Simple Defining Words
   @cindex simple defining words
   @cindex defining words, simple
   
 doc-constant  doc-constant
 doc-2constant  doc-2constant
Line 1993  doc-is Line 2177  doc-is
   
 @node Colon Definitions, User-defined Defining Words, Simple Defining Words, Defining Words  @node Colon Definitions, User-defined Defining Words, Simple Defining Words, Defining Words
 @subsection Colon Definitions  @subsection Colon Definitions
   @cindex colon definitions
   
 @example  @example
 : name ( ... -- ... )  : name ( ... -- ... )
Line 2011  doc-; Line 2196  doc-;
   
 @node User-defined Defining Words, Supplying names, Colon Definitions, Defining Words  @node User-defined Defining Words, Supplying names, Colon Definitions, Defining Words
 @subsection User-defined Defining Words  @subsection User-defined Defining Words
   @cindex user-defined defining words
   @cindex defining words, user-defined
   
 You can create new defining words simply by wrapping defining-time code  You can create new defining words simply by wrapping defining-time code
 around existing defining words and putting the sequence in a colon  around existing defining words and putting the sequence in a colon
 definition.  definition.
   
   @cindex @code{CREATE} ... @code{DOES>}
 If you want the words defined with your defining words to behave  If you want the words defined with your defining words to behave
 differently from words defined with standard defining words, you can  differently from words defined with standard defining words, you can
 write your defining word like this:  write your defining word like this:
Line 2063  When you create a constant with @code{5 Line 2251  When you create a constant with @code{5
 @code{five} with @code{,}. When @code{five} is invoked, the address of  @code{five} with @code{,}. When @code{five} is invoked, the address of
 the body is put on the stack, and @code{@@} retrieves the value 5.  the body is put on the stack, and @code{@@} retrieves the value 5.
   
   @cindex stack effect of @code{DOES>}-parts
   @cindex @code{DOES>}-parts, stack effect
 In the example above the stack comment after the @code{DOES>} specifies  In the example above the stack comment after the @code{DOES>} specifies
 the stack effect of the defined words, not the stack effect of the  the stack effect of the defined words, not the stack effect of the
 following code (the following code expects the address of the body on  following code (the following code expects the address of the body on
Line 2071  the convention that I use and recommend Line 2261  the convention that I use and recommend
 locals declarations for stack effect specification, though).  locals declarations for stack effect specification, though).
   
 @subsubsection Applications of @code{CREATE..DOES>}  @subsubsection Applications of @code{CREATE..DOES>}
   @cindex @code{CREATE} ... @code{DOES>}, applications
   
 You may wonder how to use this feature. Here are some usage patterns:  You may wonder how to use this feature. Here are some usage patterns:
   
   @cindex factoring similar colon definitions
 When you see a sequence of code occurring several times, and you can  When you see a sequence of code occurring several times, and you can
 identify a meaning, you will factor it out as a colon definition. When  identify a meaning, you will factor it out as a colon definition. When
 you see similar colon definitions, you can factor them using  you see similar colon definitions, you can factor them using
Line 2097  DOES> ( reg-target reg-source n -- ) Line 2289  DOES> ( reg-target reg-source n -- )
 1 reg-reg-imm andi,  1 reg-reg-imm andi,
 @end example  @end example
   
   @cindex currying
 Another view of @code{CREATE..DOES>} is to consider it as a crude way to  Another view of @code{CREATE..DOES>} is to consider it as a crude way to
 supply a part of the parameters for a word (known as @dfn{currying} in  supply a part of the parameters for a word (known as @dfn{currying} in
 the functional language community). E.g., @code{+} needs two  the functional language community). E.g., @code{+} needs two
Line 2113  DOES> ( n2 -- n1+n2 ) Line 2306  DOES> ( n2 -- n1+n2 )
 @end example  @end example
   
 @subsubsection The gory details of @code{CREATE..DOES>}  @subsubsection The gory details of @code{CREATE..DOES>}
   @cindex @code{CREATE} ... @code{DOES>}, details
   
 doc-does>  doc-does>
   
   @cindex @code{DOES>} in a separate definition
 This means that you need not use @code{CREATE} and @code{DOES>} in the  This means that you need not use @code{CREATE} and @code{DOES>} in the
 same definition; E.g., you can put the @code{DOES>}-part in a separate  same definition; E.g., you can put the @code{DOES>}-part in a separate
 definition. This allows us to, e.g., select among different DOES>-parts:  definition. This allows us to, e.g., select among different DOES>-parts:
Line 2137  DOES> ( ... -- ... ) Line 2332  DOES> ( ... -- ... )
     ENDIF ;      ENDIF ;
 @end example  @end example
   
   @cindex @code{DOES>} in interpretation state
 In a standard program you can apply a @code{DOES>}-part only if the last  In a standard program you can apply a @code{DOES>}-part only if the last
 word was defined with @code{CREATE}. In Gforth, the @code{DOES>}-part  word was defined with @code{CREATE}. In Gforth, the @code{DOES>}-part
 will override the behaviour of the last word defined in any case. In a  will override the behaviour of the last word defined in any case. In a
Line 2164  doc->body Line 2360  doc->body
   
 @node Supplying names, Interpretation and Compilation Semantics, User-defined Defining Words, Defining Words  @node Supplying names, Interpretation and Compilation Semantics, User-defined Defining Words, Defining Words
 @subsection Supplying names for the defined words  @subsection Supplying names for the defined words
   @cindex names for defined words
   @cindex defining words, name parameter
   
   @cindex defining words, name given in a string
 By default, defining words take the names for the defined words from the  By default, defining words take the names for the defined words from the
 input stream. Sometimes you want to supply the name from a string. You  input stream. Sometimes you want to supply the name from a string. You
 can do this with  can do this with
Line 2181  is equivalent to Line 2380  is equivalent to
 create foo  create foo
 @end example  @end example
   
   @cindex defining words without name
 Sometimes you want to define a word without a name. You can do this with  Sometimes you want to define a word without a name. You can do this with
   
 doc-noname  doc-noname
   
   @cindex execution token of last defined word
 To make any use of the newly defined word, you need its execution  To make any use of the newly defined word, you need its execution
 token. You can get it with  token. You can get it with
   
Line 2218  IS deferred Line 2419  IS deferred
   
 @node Interpretation and Compilation Semantics,  , Supplying names, Defining Words  @node Interpretation and Compilation Semantics,  , Supplying names, Defining Words
 @subsection Interpretation and Compilation Semantics  @subsection Interpretation and Compilation Semantics
   @cindex semantics, interpretation and compilation
   
   @cindex interpretation semantics
 The @dfn{interpretation semantics} of a word are what the text  The @dfn{interpretation semantics} of a word are what the text
 interpreter does when it encounters the word in interpret state. It also  interpreter does when it encounters the word in interpret state. It also
 appears in some other contexts, e.g., the execution token returned by  appears in some other contexts, e.g., the execution token returned by
Line 2226  appears in some other contexts, e.g., th Line 2429  appears in some other contexts, e.g., th
 @var{word} (in other words, @code{' @var{word} execute} is equivalent to  @var{word} (in other words, @code{' @var{word} execute} is equivalent to
 interpret-state text interpretation of @code{@var{word}}).  interpret-state text interpretation of @code{@var{word}}).
   
   @cindex compilation semantics
 The @dfn{compilation semantics} of a word are what the text interpreter  The @dfn{compilation semantics} of a word are what the text interpreter
 does when it encounters the word in compile state. It also appears in  does when it encounters the word in compile state. It also appears in
 other contexts, e.g, @code{POSTPONE @var{word}} compiles@footnote{In  other contexts, e.g, @code{POSTPONE @var{word}} compiles@footnote{In
 standard terminology, ``appends to the current definition''.} the  standard terminology, ``appends to the current definition''.} the
 compilation semantics of @var{word}.  compilation semantics of @var{word}.
   
   @cindex execution semantics
 The standard also talks about @dfn{execution semantics}. They are used  The standard also talks about @dfn{execution semantics}. They are used
 only for defining the interpretation and compilation semantics of many  only for defining the interpretation and compilation semantics of many
 words. By default, the interpretation semantics of a word are to  words. By default, the interpretation semantics of a word are to
Line 2242  execution semantics; the default compila Line 2447  execution semantics; the default compila
 execution semantics to the execution semantics of the current  execution semantics to the execution semantics of the current
 definition.}  definition.}
   
   @cindex immediate words
 You can change the compilation semantics into @code{execute}ing the  You can change the compilation semantics into @code{execute}ing the
 execution semantics with  execution semantics with
   
 doc-immediate  doc-immediate
   
   @cindex compile-only words
 You can remove the interpretation semantics of a word with  You can remove the interpretation semantics of a word with
   
 doc-compile-only  doc-compile-only
Line 2295  the same compilation semantics as the si Line 2502  the same compilation semantics as the si
 @code{foobar}, but the implementation of the compilation semantics is  @code{foobar}, but the implementation of the compilation semantics is
 more efficient with respect to run-time.  more efficient with respect to run-time.
   
   @cindex state-smart words are a bad idea
 Some people try to use state-smart words to emulate the feature provided  Some people try to use state-smart words to emulate the feature provided
 by @code{interpret/compile:} (words are state-smart if they check  by @code{interpret/compile:} (words are state-smart if they check
 @code{STATE} during execution). E.g., they would try to code  @code{STATE} during execution). E.g., they would try to code
Line 2320  state, the result will not be what you e Line 2528  state, the result will not be what you e
 perform @code{foo bar}). State-smart words are a bad idea. Simply don't  perform @code{foo bar}). State-smart words are a bad idea. Simply don't
 write them!  write them!
   
   @cindex defining words with arbitrary semantics combinations
 It is also possible to write defining words that define words with  It is also possible to write defining words that define words with
 arbitrary combinations of interpretation and compilation semantics (or,  arbitrary combinations of interpretation and compilation semantics (or,
 preferably, arbitrary combinations of implementations of the default  preferably, arbitrary combinations of implementations of the default
Line 2371  accessing the header structure usually k Line 2580  accessing the header structure usually k
   
 @node Tokens for Words, Wordlists, Defining Words, Words  @node Tokens for Words, Wordlists, Defining Words, Words
 @section Tokens for Words  @section Tokens for Words
   @cindex tokens for words
   
 This chapter describes the creation and use of tokens that represent  This chapter describes the creation and use of tokens that represent
 words on the stack (and in data space).  words on the stack (and in data space).
Line 2378  words on the stack (and in data space). Line 2588  words on the stack (and in data space).
 Named words have interpretation and compilation semantics. Unnamed words  Named words have interpretation and compilation semantics. Unnamed words
 just have execution semantics.  just have execution semantics.
   
   @cindex execution token
 An @dfn{execution token} represents the execution semantics of an  An @dfn{execution token} represents the execution semantics of an
 unnamed word. An execution token occupies one cell. As explained in  unnamed word. An execution token occupies one cell. As explained in
 section @ref{Supplying names}, the execution token of the last words  section @ref{Supplying names}, the execution token of the last words
Line 2390  doc-execute Line 2601  doc-execute
 You can compile the word with  You can compile the word with
 doc-compile,  doc-compile,
   
   @cindex code field address
   @cindex CFA
 In Gforth, the abstract data type @emph{execution token} is implemented  In Gforth, the abstract data type @emph{execution token} is implemented
 as CFA (code field address).  as CFA (code field address).
   
Line 2405  by complaining about compile-only words. Line 2618  by complaining about compile-only words.
 compiling word @var{X}, use @code{COMP' @var{X} drop} or @code{[COMP']  compiling word @var{X}, use @code{COMP' @var{X} drop} or @code{[COMP']
 @var{X} drop}.  @var{X} drop}.
   
   @cindex compilation token
 The compilation semantics are represented by a @dfn{compilation token}  The compilation semantics are represented by a @dfn{compilation token}
 consisting of two cells: @var{w xt}. The top cell @var{xt} is an  consisting of two cells: @var{w xt}. The top cell @var{xt} is an
 execution token. The compilation semantics represented by the  execution token. The compilation semantics represented by the
Line 2427  token, and the @var{xt} part represents Line 2641  token, and the @var{xt} part represents
 we may introduce unusual compilation tokens in the future (e.g.,  we may introduce unusual compilation tokens in the future (e.g.,
 compilation tokens representing the compilation semantics of literals).  compilation tokens representing the compilation semantics of literals).
   
   @cindex name token
   @cindex name field address
   @cindex NFA
 Named words are also represented by the @dfn{name token}. The abstract  Named words are also represented by the @dfn{name token}. The abstract
 data type @emph{name token} is implemented as NFA (name field address).  data type @emph{name token} is implemented as NFA (name field address).
   
Line 2450  doc-name>string Line 2667  doc-name>string
   
 @node Programming Tools, Assembler and Code words, Other I/O, Words  @node Programming Tools, Assembler and Code words, Other I/O, Words
 @section Programming Tools  @section Programming Tools
   @cindex programming tools
   
 @menu  @menu
 * Debugging::                   Simple and quick.  * Debugging::                   Simple and quick.
Line 2458  doc-name>string Line 2676  doc-name>string
   
 @node Debugging, Assertions, Programming Tools, Programming Tools  @node Debugging, Assertions, Programming Tools, Programming Tools
 @subsection Debugging  @subsection Debugging
   @cindex debugging
   
 The simple debugging aids provided in @file{debugging.fs}  The simple debugging aids provided in @file{debugging.fs}
 are meant to support a different style of debugging than the  are meant to support a different style of debugging than the
Line 2490  doc-printdebugline Line 2709  doc-printdebugline
   
 @node Assertions,  , Debugging, Programming Tools  @node Assertions,  , Debugging, Programming Tools
 @subsection Assertions  @subsection Assertions
   @cindex assertions
   
 It is a good idea to make your programs self-checking, in particular, if  It is a good idea to make your programs self-checking, in particular, if
 you use an assumption (e.g., that a certain field of a data structure is  you use an assumption (e.g., that a certain field of a data structure is
Line 2549  probably more appropriate than an assert Line 2769  probably more appropriate than an assert
   
 @node Assembler and Code words, Threading Words, Programming Tools, Words  @node Assembler and Code words, Threading Words, Programming Tools, Words
 @section Assembler and Code words  @section Assembler and Code words
   @cindex assembler
   @cindex code words
   
 Gforth provides some words for defining primitives (words written in  Gforth provides some words for defining primitives (words written in
 machine code), and for defining the the machine-code equivalent of  machine code), and for defining the the machine-code equivalent of
Line 2576  These words are rarely used. Therefore t Line 2798  These words are rarely used. Therefore t
 which is usually not loaded (except @code{flush-icache}, which is always  which is usually not loaded (except @code{flush-icache}, which is always
 present). You can load them with @code{require code.fs}.  present). You can load them with @code{require code.fs}.
   
   @cindex registers of the inner interpreter
 In the assembly code you will want to refer to the inner interpreter's  In the assembly code you will want to refer to the inner interpreter's
 registers (e.g., the data stack pointer) and you may want to use other  registers (e.g., the data stack pointer) and you may want to use other
 registers for temporary storage. Unfortunately, the register allocation  registers for temporary storage. Unfortunately, the register allocation
Line 2608  actual register allocation. E.g., if the Line 2831  actual register allocation. E.g., if the
 register @code{$17}, create an alias for this register called @code{sp},  register @code{$17}, create an alias for this register called @code{sp},
 and use that in your assembly code.  and use that in your assembly code.
   
   @cindex code words, portable
 Another option for implementing normal and defining words efficiently  Another option for implementing normal and defining words efficiently
 is: adding the wanted functionality to the source of Gforth. For normal  is: adding the wanted functionality to the source of Gforth. For normal
 words you just have to edit @file{primitives} (@pxref{Automatic  words you just have to edit @file{primitives} (@pxref{Automatic
Line 2618  defined words) may require changes in @f Line 2842  defined words) may require changes in @f
   
 @node Threading Words,  , Assembler and Code words, Words  @node Threading Words,  , Assembler and Code words, Words
 @section Threading Words  @section Threading Words
   @cindex threading words
   
   @cindex code address
 These words provide access to code addresses and other threading stuff  These words provide access to code addresses and other threading stuff
 in Gforth (and, possibly, other interpretive Forths). It more or less  in Gforth (and, possibly, other interpretive Forths). It more or less
 abstracts away the differences between direct and indirect threading  abstracts away the differences between direct and indirect threading
 (and, for direct threading, the machine dependences). However, at  (and, for direct threading, the machine dependences). However, at
 present this wordset is still inclomplete. It is also pretty low-level;  present this wordset is still incomplete. It is also pretty low-level;
 some day it will hopefully be made unnecessary by an internals words set  some day it will hopefully be made unnecessary by an internals wordset
 that abstracts implementation details away completely.  that abstracts implementation details away completely.
   
 doc->code-address  doc->code-address
Line 2653  defining word. Line 2879  defining word.
 @chapter Tools  @chapter Tools
   
 @menu  @menu
 * ANS Report::                  Report the words used, sorted by wordset  * ANS Report::                  Report the words used, sorted by wordset.
 @end menu  @end menu
   
 See also @ref{Emacs and Gforth}.  See also @ref{Emacs and Gforth}.
   
 @node ANS Report,  , Tools, Tools  @node ANS Report,  , Tools, Tools
 @section @file{ans-report.fs}: Report the words used, sorted by wordset  @section @file{ans-report.fs}: Report the words used, sorted by wordset
   @cindex @file{ans-report.fs}
   @cindex report the words used in your program
   @cindex words used in your program
   
 If you want to label a Forth program as ANS Forth Program, you must  If you want to label a Forth program as ANS Forth Program, you must
 document which wordsets the program uses; for extension wordsets, it is  document which wordsets the program uses; for extension wordsets, it is
Line 2699  which wordset is the right one to specif Line 2928  which wordset is the right one to specif
 compilation semantics of @code{S"}, it is a Core word; if you also use  compilation semantics of @code{S"}, it is a Core word; if you also use
 its interpretation semantics, it is a File word.  its interpretation semantics, it is a File word.
   
   @c ******************************************************************
 @node ANS conformance, Model, Tools, Top  @node ANS conformance, Model, Tools, Top
 @chapter ANS conformance  @chapter ANS conformance
   @cindex ANS conformance of Gforth
   
 To the best of our knowledge, Gforth is an  To the best of our knowledge, Gforth is an
   
Line 2732  ANS Forth System Line 2962  ANS Forth System
 @item providing the String Extensions word set (another easy one)  @item providing the String Extensions word set (another easy one)
 @end itemize  @end itemize
   
   @cindex system documentation
 In addition, ANS Forth systems are required to document certain  In addition, ANS Forth systems are required to document certain
 implementation choices. This chapter tries to meet these  implementation choices. This chapter tries to meet these
 requirements. In many cases it gives a way to ask the system for the  requirements. In many cases it gives a way to ask the system for the
Line 2762  change during the maintenance of Gforth. Line 2993  change during the maintenance of Gforth.
 @comment  node-name,  next,  previous,  up  @comment  node-name,  next,  previous,  up
 @section The Core Words  @section The Core Words
 @c =====================================================================  @c =====================================================================
   @cindex core words, system documentation
   @cindex system documentation, core words
   
 @menu  @menu
 * core-idef::                   Implementation Defined Options                     * core-idef::                   Implementation Defined Options                   
Line 2773  change during the maintenance of Gforth. Line 3006  change during the maintenance of Gforth.
 @node core-idef, core-ambcond, The Core Words, The Core Words  @node core-idef, core-ambcond, The Core Words, The Core Words
 @subsection Implementation Defined Options  @subsection Implementation Defined Options
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex core words, implementation-defined options
   @cindex implementation-defined options, core words
   
 @table @i  
   
   @table @i
 @item (Cell) aligned addresses:  @item (Cell) aligned addresses:
   @cindex cell-aligned addresses
   @cindex aligned addresses
 processor-dependent. Gforth's alignment words perform natural alignment  processor-dependent. Gforth's alignment words perform natural alignment
 (e.g., an address aligned for a datum of size 8 is divisible by  (e.g., an address aligned for a datum of size 8 is divisible by
 8). Unaligned accesses usually result in a @code{-23 THROW}.  8). Unaligned accesses usually result in a @code{-23 THROW}.
   
 @item @code{EMIT} and non-graphic characters:  @item @code{EMIT} and non-graphic characters:
   @cindex @code{EMIT} and non-graphic characters
   @cindex non-graphic characters and @code{EMIT}
 The character is output using the C library function (actually, macro)  The character is output using the C library function (actually, macro)
 @code{putc}.  @code{putc}.
   
 @item character editing of @code{ACCEPT} and @code{EXPECT}:  @item character editing of @code{ACCEPT} and @code{EXPECT}:
   @cindex character editing of @code{ACCEPT} and @code{EXPECT}
   @cindex editing in @code{ACCEPT} and @code{EXPECT}
   @cindex @code{ACCEPT}, editing
   @cindex @code{EXPECT}, editing
 This is modeled on the GNU readline library (@pxref{Readline  This is modeled on the GNU readline library (@pxref{Readline
 Interaction, , Command Line Editing, readline, The GNU Readline  Interaction, , Command Line Editing, readline, The GNU Readline
 Library}) with Emacs-like key bindings. @kbd{Tab} deviates a little by  Library}) with Emacs-like key bindings. @kbd{Tab} deviates a little by
Line 2793  producing a full word completion every t Line 3036  producing a full word completion every t
 producing the common prefix of all completions).  producing the common prefix of all completions).
   
 @item character set:  @item character set:
   @cindex character set
 The character set of your computer and display device. Gforth is  The character set of your computer and display device. Gforth is
 8-bit-clean (but some other component in your system may make trouble).  8-bit-clean (but some other component in your system may make trouble).
   
 @item Character-aligned address requirements:  @item Character-aligned address requirements:
   @cindex character-aligned address requirements
 installation-dependent. Currently a character is represented by a C  installation-dependent. Currently a character is represented by a C
 @code{unsigned char}; in the future we might switch to @code{wchar_t}  @code{unsigned char}; in the future we might switch to @code{wchar_t}
 (Comments on that requested).  (Comments on that requested).
   
 @item character-set extensions and matching of names:  @item character-set extensions and matching of names:
   @cindex character-set extensions and matching of names
   @cindex case sensitivity for name lookup
   @cindex name lookup, case sensitivity
   @cindex locale and case sensitivity
 Any character except the ASCII NUL charcter can be used in a  Any character except the ASCII NUL charcter can be used in a
 name. Matching is case-insensitive (except in @code{TABLE}s. The  name. Matching is case-insensitive (except in @code{TABLE}s). The
 matching is performed using the C function @code{strncasecmp}, whose  matching is performed using the C function @code{strncasecmp}, whose
 function is probably influenced by the locale. E.g., the @code{C} locale  function is probably influenced by the locale. E.g., the @code{C} locale
 does not know about accents and umlauts, so they are matched  does not know about accents and umlauts, so they are matched
Line 2817  are using)). Also, the locale you prefer Line 3066  are using)). Also, the locale you prefer
 operating systems. Hopefully, Unicode will solve these problems one day.  operating systems. Hopefully, Unicode will solve these problems one day.
   
 @item conditions under which control characters match a space delimiter:  @item conditions under which control characters match a space delimiter:
   @cindex space delimiters
   @cindex control characters as delimiters
 If @code{WORD} is called with the space character as a delimiter, all  If @code{WORD} is called with the space character as a delimiter, all
 white-space characters (as identified by the C macro @code{isspace()})  white-space characters (as identified by the C macro @code{isspace()})
 are delimiters. @code{PARSE}, on the other hand, treats space like other  are delimiters. @code{PARSE}, on the other hand, treats space like other
Line 2826  interpreter (aka text interpreter) by de Line 3077  interpreter (aka text interpreter) by de
 characters as delimiters.  characters as delimiters.
   
 @item format of the control flow stack:  @item format of the control flow stack:
   @cindex control flow stack, format
 The data stack is used as control flow stack. The size of a control flow  The data stack is used as control flow stack. The size of a control flow
 stack item in cells is given by the constant @code{cs-item-size}. At the  stack item in cells is given by the constant @code{cs-item-size}. At the
 time of this writing, an item consists of a (pointer to a) locals list  time of this writing, an item consists of a (pointer to a) locals list
Line 2835  item (TOS). The following tags are used: Line 3087  item (TOS). The following tags are used:
 @code{scopestart}.  @code{scopestart}.
   
 @item conversion of digits > 35  @item conversion of digits > 35
   @cindex digits > 35
 The characters @code{[\]^_'} are the digits with the decimal value  The characters @code{[\]^_'} are the digits with the decimal value
 36@minus{}41. There is no way to input many of the larger digits.  36@minus{}41. There is no way to input many of the larger digits.
   
 @item display after input terminates in @code{ACCEPT} and @code{EXPECT}:  @item display after input terminates in @code{ACCEPT} and @code{EXPECT}:
   @cindex @code{EXPECT}, display after end of input
   @cindex @code{ACCEPT}, display after end of input
 The cursor is moved to the end of the entered string. If the input is  The cursor is moved to the end of the entered string. If the input is
 terminated using the @kbd{Return} key, a space is typed.  terminated using the @kbd{Return} key, a space is typed.
   
 @item exception abort sequence of @code{ABORT"}:  @item exception abort sequence of @code{ABORT"}:
   @cindex exception abort sequence of @code{ABORT"}
   @cindex @code{ABORT"}, exception abort sequence
 The error string is stored into the variable @code{"error} and a  The error string is stored into the variable @code{"error} and a
 @code{-2 throw} is performed.  @code{-2 throw} is performed.
   
 @item input line terminator:  @item input line terminator:
   @cindex input line terminator
   @cindex line terminator on input
   @cindex newline charcter on input
 For interactive input, @kbd{C-m} (CR) and @kbd{C-j} (LF) terminate  For interactive input, @kbd{C-m} (CR) and @kbd{C-j} (LF) terminate
 lines. One of these characters is typically produced when you type the  lines. One of these characters is typically produced when you type the
 @kbd{Enter} or @kbd{Return} key.  @kbd{Enter} or @kbd{Return} key.
   
 @item maximum size of a counted string:  @item maximum size of a counted string:
   @cindex maximum size of a counted string
   @cindex counted string, maximum size
 @code{s" /counted-string" environment? drop .}. Currently 255 characters  @code{s" /counted-string" environment? drop .}. Currently 255 characters
 on all ports, but this may change.  on all ports, but this may change.
   
 @item maximum size of a parsed string:  @item maximum size of a parsed string:
   @cindex maximum size of a parsed string
   @cindex parsed string, maximum size
 Given by the constant @code{/line}. Currently 255 characters.  Given by the constant @code{/line}. Currently 255 characters.
   
 @item maximum size of a definition name, in characters:  @item maximum size of a definition name, in characters:
   @cindex maximum size of a definition name, in characters
   @cindex name, maximum length
 31  31
   
 @item maximum string length for @code{ENVIRONMENT?}, in characters:  @item maximum string length for @code{ENVIRONMENT?}, in characters:
   @cindex maximum string length for @code{ENVIRONMENT?}, in characters
   @cindex @code{ENVIRONMENT?} string length, maximum
 31  31
   
 @item method of selecting the user input device:  @item method of selecting the user input device:
   @cindex user input device, method of selecting
 The user input device is the standard input. There is currently no way to  The user input device is the standard input. There is currently no way to
 change it from within Gforth. However, the input can typically be  change it from within Gforth. However, the input can typically be
 redirected in the command line that starts Gforth.  redirected in the command line that starts Gforth.
   
 @item method of selecting the user output device:  @item method of selecting the user output device:
   @cindex user output device, method of selecting
 @code{EMIT} and @code{TYPE} output to the file-id stored in the value  @code{EMIT} and @code{TYPE} output to the file-id stored in the value
 @code{outfile-id} (@code{stdout} by default). Gforth uses buffered  @code{outfile-id} (@code{stdout} by default). Gforth uses buffered
 output, so output on a terminal does not become visible before the next  output, so output on a terminal does not become visible before the next
Line 2880  the buffer overflows. Line 3150  the buffer overflows.
 What are we expected to document here?  What are we expected to document here?
   
 @item number of bits in one address unit:  @item number of bits in one address unit:
   @cindex number of bits in one address unit
   @cindex address unit, size in bits
 @code{s" address-units-bits" environment? drop .}. 8 in all current  @code{s" address-units-bits" environment? drop .}. 8 in all current
 ports.  ports.
   
 @item number representation and arithmetic:  @item number representation and arithmetic:
   @cindex number representation and arithmetic
 Processor-dependent. Binary two's complement on all current ports.  Processor-dependent. Binary two's complement on all current ports.
   
 @item ranges for integer types:  @item ranges for integer types:
   @cindex ranges for integer types
   @cindex integer types, ranges
 Installation-dependent. Make environmental queries for @code{MAX-N},  Installation-dependent. Make environmental queries for @code{MAX-N},
 @code{MAX-U}, @code{MAX-D} and @code{MAX-UD}. The lower bounds for  @code{MAX-U}, @code{MAX-D} and @code{MAX-UD}. The lower bounds for
 unsigned (and positive) types is 0. The lower bound for signed types on  unsigned (and positive) types is 0. The lower bound for signed types on
Line 2894  two's complement and one's complement ma Line 3169  two's complement and one's complement ma
 by adding 1 to the upper bound.  by adding 1 to the upper bound.
   
 @item read-only data space regions:  @item read-only data space regions:
   @cindex read-only data space regions
   @cindex data-space, read-only regions
 The whole Forth data space is writable.  The whole Forth data space is writable.
   
 @item size of buffer at @code{WORD}:  @item size of buffer at @code{WORD}:
   @cindex size of buffer at @code{WORD}
   @cindex @code{WORD} buffer size
 @code{PAD HERE - .}. 104 characters on 32-bit machines. The buffer is  @code{PAD HERE - .}. 104 characters on 32-bit machines. The buffer is
 shared with the pictured numeric output string. If overwriting  shared with the pictured numeric output string. If overwriting
 @code{PAD} is acceptable, it is as large as the remaining dictionary  @code{PAD} is acceptable, it is as large as the remaining dictionary
Line 2904  space, although only as much can be sens Line 3183  space, although only as much can be sens
 string.  string.
   
 @item size of one cell in address units:  @item size of one cell in address units:
   @cindex cell size
 @code{1 cells .}.  @code{1 cells .}.
   
 @item size of one character in address units:  @item size of one character in address units:
   @cindex char size
 @code{1 chars .}. 1 on all current ports.  @code{1 chars .}. 1 on all current ports.
   
 @item size of the keyboard terminal buffer:  @item size of the keyboard terminal buffer:
   @cindex size of the keyboard terminal buffer
   @cindex terminal buffer, size
 Varies. You can determine the size at a specific time using @code{lp@@  Varies. You can determine the size at a specific time using @code{lp@@
 tib - .}. It is shared with the locals stack and TIBs of files that  tib - .}. It is shared with the locals stack and TIBs of files that
 include the current file. You can change the amount of space for TIBs  include the current file. You can change the amount of space for TIBs
Line 2917  and locals stack at Gforth startup with Line 3200  and locals stack at Gforth startup with
 @code{-l}.  @code{-l}.
   
 @item size of the pictured numeric output buffer:  @item size of the pictured numeric output buffer:
   @cindex size of the pictured numeric output buffer
   @cindex pictured numeric output buffer, size
 @code{PAD HERE - .}. 104 characters on 32-bit machines. The buffer is  @code{PAD HERE - .}. 104 characters on 32-bit machines. The buffer is
 shared with @code{WORD}.  shared with @code{WORD}.
   
 @item size of the scratch area returned by @code{PAD}:  @item size of the scratch area returned by @code{PAD}:
 The remainder of dictionary space. You can even use the unused part of  @cindex size of the scratch area returned by @code{PAD}
 the data stack space. The current size can be computed with @code{sp@@  @cindex @code{PAD} size
 pad - .}.  The remainder of dictionary space. @code{unused pad here - - .}.
   
 @item system case-sensitivity characteristics:  @item system case-sensitivity characteristics:
   @cindex case-sensitivity characteristics
 Dictionary searches are case insensitive (except in  Dictionary searches are case insensitive (except in
 @code{TABLE}s). However, as explained above under @i{character-set  @code{TABLE}s). However, as explained above under @i{character-set
 extensions}, the matching for non-ASCII characters is determined by the  extensions}, the matching for non-ASCII characters is determined by the
Line 2933  locale you are using. In the default @co Line 3219  locale you are using. In the default @co
 characters are matched case-sensitively.  characters are matched case-sensitively.
   
 @item system prompt:  @item system prompt:
   @cindex system prompt
   @cindex prompt
 @code{ ok} in interpret state, @code{ compiled} in compile state.  @code{ ok} in interpret state, @code{ compiled} in compile state.
   
 @item division rounding:  @item division rounding:
   @cindex division rounding
 installation dependent. @code{s" floored" environment? drop .}. We leave  installation dependent. @code{s" floored" environment? drop .}. We leave
 the choice to @code{gcc} (what to use for @code{/}) and to you (whether to use  the choice to @code{gcc} (what to use for @code{/}) and to you (whether
 @code{fm/mod}, @code{sm/rem} or simply @code{/}).  to use @code{fm/mod}, @code{sm/rem} or simply @code{/}).
   
 @item values of @code{STATE} when true:  @item values of @code{STATE} when true:
   @cindex @code{STATE} values
 -1.  -1.
   
 @item values returned after arithmetic overflow:  @item values returned after arithmetic overflow:
Line 2952  fault), although a @code{-10 throw} (div Line 3242  fault), although a @code{-10 throw} (div
 appropriate.  appropriate.
   
 @item whether the current definition can be found after @t{DOES>}:  @item whether the current definition can be found after @t{DOES>}:
   @cindex @t{DOES>}, visibility of current definition
 No.  No.
   
 @end table  @end table
Line 2960  No. Line 3251  No.
 @node core-ambcond, core-other, core-idef, The Core Words  @node core-ambcond, core-other, core-idef, The Core Words
 @subsection Ambiguous conditions  @subsection Ambiguous conditions
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex core words, ambiguous conditions
   @cindex ambiguous conditions, core words
   
 @table @i  @table @i
   
 @item a name is neither a word nor a number:  @item a name is neither a word nor a number:
   @cindex name not found
   @cindex Undefined word
 @code{-13 throw} (Undefined word). Actually, @code{-13 bounce}, which  @code{-13 throw} (Undefined word). Actually, @code{-13 bounce}, which
 preserves the data and FP stack, so you don't lose more work than  preserves the data and FP stack, so you don't lose more work than
 necessary.  necessary.
   
 @item a definition name exceeds the maximum length allowed:  @item a definition name exceeds the maximum length allowed:
   @cindex Word name too long
 @code{-19 throw} (Word name too long)  @code{-19 throw} (Word name too long)
   
 @item addressing a region not inside the various data spaces of the forth system:  @item addressing a region not inside the various data spaces of the forth system:
   @cindex Invalid memory address
 The stacks, code space and name space are accessible. Machine code space is  The stacks, code space and name space are accessible. Machine code space is
 typically readable. Accessing other addresses gives results dependent on  typically readable. Accessing other addresses gives results dependent on
 the operating system. On decent systems: @code{-9 throw} (Invalid memory  the operating system. On decent systems: @code{-9 throw} (Invalid memory
 address).  address).
   
 @item argument type incompatible with parameter:  @item argument type incompatible with parameter:
   @cindex Argument type mismatch
 This is usually not caught. Some words perform checks, e.g., the control  This is usually not caught. Some words perform checks, e.g., the control
 flow words, and issue a @code{ABORT"} or @code{-12 THROW} (Argument type  flow words, and issue a @code{ABORT"} or @code{-12 THROW} (Argument type
 mismatch).  mismatch).
   
 @item attempting to obtain the execution token of a word with undefined execution semantics:  @item attempting to obtain the execution token of a word with undefined execution semantics:
   @cindex Interpreting a compile-only word, for @code{'} etc.
   @cindex execution token of words with undefined execution semantics
 @code{-14 throw} (Interpreting a compile-only word). In some cases, you  @code{-14 throw} (Interpreting a compile-only word). In some cases, you
 get an execution token for @code{compile-only-error} (which performs a  get an execution token for @code{compile-only-error} (which performs a
 @code{-14 throw} when executed).  @code{-14 throw} when executed).
   
 @item dividing by zero:  @item dividing by zero:
   @cindex dividing by zero
   @cindex floating point unidentified fault, integer division
   @cindex divide by zero
 typically results in a @code{-55 throw} (floating point unidentified  typically results in a @code{-55 throw} (floating point unidentified
 fault), although a @code{-10 throw} (divide by zero) would be more  fault), although a @code{-10 throw} (divide by zero) would be more
 appropriate.  appropriate.
   
 @item insufficient data stack or return stack space:  @item insufficient data stack or return stack space:
 Not checked. This typically results in mysterious illegal memory  @cindex insufficient data stack or return stack space
 accesses, producing @code{-9 throw} (Invalid memory address) or  @cindex stack overflow
 @code{-23 throw} (Address alignment exception).  @cindex Address alignment exception, stack overflow
   @cindex Invalid memory address, stack overflow
   Depending on the operating system, the installation, and the invocation
   of Gforth, this is either checked by the memory management hardware, or
   it is not checked. If it is checked, you typically get a @code{-9 throw}
   (Invalid memory address) as soon as the overflow happens. If it is not
   check, overflows typically result in mysterious illegal memory accesses,
   producing @code{-9 throw} (Invalid memory address) or @code{-23 throw}
   (Address alignment exception); they might also destroy the internal data
   structure of @code{ALLOCATE} and friends, resulting in various errors in
   these words.
   
 @item insufficient space for loop control parameters:  @item insufficient space for loop control parameters:
   @cindex insufficient space for loop control parameters
 like other return stack overflows.  like other return stack overflows.
   
 @item insufficient space in the dictionary:  @item insufficient space in the dictionary:
 Not checked. Similar results as stack overflows. However, typically the  @cindex insufficient space in the dictionary
 error appears at a different place when one inserts or removes code.  @cindex dictionary overflow
   Depending on the operating system, the installation, and the invocation
   of Gforth, this is either checked by the memory management hardware, or
   it is not checked. Similar results as stack overflows. However,
   typically the error appears at a different place when one inserts or
   removes code. Also, the @code{THROW} does not relieve the situation (it
   does for stack overflows).
   
 @item interpreting a word with undefined interpretation semantics:  @item interpreting a word with undefined interpretation semantics:
 For some words, we defined interpretation semantics. For the others:  @cindex interpreting a word with undefined interpretation semantics
 @code{-14 throw} (Interpreting a compile-only word).  @cindex Interpreting a compile-only word
   For some words, we have defined interpretation semantics. For the
   others: @code{-14 throw} (Interpreting a compile-only word).
   
 @item modifying the contents of the input buffer or a string literal:  @item modifying the contents of the input buffer or a string literal:
   @cindex modifying the contents of the input buffer or a string literal
 These are located in writable memory and can be modified.  These are located in writable memory and can be modified.
   
 @item overflow of the pictured numeric output string:  @item overflow of the pictured numeric output string:
 Not checked.  @cindex overflow of the pictured numeric output string
   @cindex pictured numeric output string, overflow
   Not checked. Runs into the dictionary and destroys it (at least,
   partially).
   
 @item parsed string overflow:  @item parsed string overflow:
   @cindex parsed string overflow
 @code{PARSE} cannot overflow. @code{WORD} does not check for overflow.  @code{PARSE} cannot overflow. @code{WORD} does not check for overflow.
   
 @item producing a result out of range:  @item producing a result out of range:
   @cindex result out of range
 On two's complement machines, arithmetic is performed modulo  On two's complement machines, arithmetic is performed modulo
 2**bits-per-cell for single arithmetic and 4**bits-per-cell for double  2**bits-per-cell for single arithmetic and 4**bits-per-cell for double
 arithmetic (with appropriate mapping for signed types). Division by zero  arithmetic (with appropriate mapping for signed types). Division by zero
Line 3027  appropriate. @code{convert} and @code{>n Line 3355  appropriate. @code{convert} and @code{>n
 silently.  silently.
   
 @item reading from an empty data or return stack:  @item reading from an empty data or return stack:
   @cindex stack empty
   @cindex stack underflow
 The data stack is checked by the outer (aka text) interpreter after  The data stack is checked by the outer (aka text) interpreter after
 every word executed. If it has underflowed, a @code{-4 throw} (Stack  every word executed. If it has underflowed, a @code{-4 throw} (Stack
 underflow) is performed. Apart from that, the stacks are not checked and  underflow) is performed. Apart from that, stacks may be checked or not,
 underflows can result in similar behaviour as overflows (of adjacent  depending on operating system, installation, and invocation. The
 stacks).  consequences of stack underflows are similar to the consequences of
   stack overflows. Note that even if the system uses checking (through the
   MMU), your program may have to underflow by a significant number of
   stack items to trigger the reaction (the reason for this is that the
   MMU, and therefore the checking, works with a page-size granularity).
   
 @item unexpected end of the input buffer, resulting in an attempt to use a zero-length string as a name:  @item unexpected end of the input buffer, resulting in an attempt to use a zero-length string as a name:
   @cindex unexpected end of the input buffer
   @cindex zero-length string as a name
   @cindex Attempt to use zero-length string as a name
 @code{Create} and its descendants perform a @code{-16 throw} (Attempt to  @code{Create} and its descendants perform a @code{-16 throw} (Attempt to
 use zero-length string as a name). Words like @code{'} probably will not  use zero-length string as a name). Words like @code{'} probably will not
 find what they search. Note that it is possible to create zero-length  find what they search. Note that it is possible to create zero-length
 names with @code{nextname} (should it not?).  names with @code{nextname} (should it not?).
   
 @item @code{>IN} greater than input buffer:  @item @code{>IN} greater than input buffer:
   @cindex @code{>IN} greater than input buffer
 The next invocation of a parsing word returns a string with length 0.  The next invocation of a parsing word returns a string with length 0.
   
 @item @code{RECURSE} appears after @code{DOES>}:  @item @code{RECURSE} appears after @code{DOES>}:
   @cindex @code{RECURSE} appears after @code{DOES>}
 Compiles a recursive call to the defining word, not to the defined word.  Compiles a recursive call to the defining word, not to the defined word.
   
 @item argument input source different than current input source for @code{RESTORE-INPUT}:  @item argument input source different than current input source for @code{RESTORE-INPUT}:
   @cindex argument input source different than current input source for @code{RESTORE-INPUT}
   @cindex Argument type mismatch, @code{RESTORE-INPUT}
   @cindex @code{RESTORE-INPUT}, Argument type mismatch
 @code{-12 THROW}. Note that, once an input file is closed (e.g., because  @code{-12 THROW}. Note that, once an input file is closed (e.g., because
 the end of the file was reached), its source-id may be  the end of the file was reached), its source-id may be
 reused. Therefore, restoring an input source specification referencing a  reused. Therefore, restoring an input source specification referencing a
Line 3056  In the future, Gforth may be able to res Line 3398  In the future, Gforth may be able to res
 from other than the current input source.  from other than the current input source.
   
 @item data space containing definitions gets de-allocated:  @item data space containing definitions gets de-allocated:
   @cindex data space containing definitions gets de-allocated
 Deallocation with @code{allot} is not checked. This typically results in  Deallocation with @code{allot} is not checked. This typically results in
 memory access faults or execution of illegal instructions.  memory access faults or execution of illegal instructions.
   
 @item data space read/write with incorrect alignment:  @item data space read/write with incorrect alignment:
   @cindex data space read/write with incorrect alignment
   @cindex alignment faults
   @cindex Address alignment exception
 Processor-dependent. Typically results in a @code{-23 throw} (Address  Processor-dependent. Typically results in a @code{-23 throw} (Address
 alignment exception). Under Linux on a 486 or later processor with  alignment exception). Under Linux on a 486 or later processor with
 alignment turned on, incorrect alignment results in a @code{-9 throw}  alignment turned on, incorrect alignment results in a @code{-9 throw}
Line 3067  alignment turned on, incorrect alignment Line 3413  alignment turned on, incorrect alignment
 alignment restrictions that do not report them.  alignment restrictions that do not report them.
   
 @item data space pointer not properly aligned, @code{,}, @code{C,}:  @item data space pointer not properly aligned, @code{,}, @code{C,}:
   @cindex data space pointer not properly aligned, @code{,}, @code{C,}
 Like other alignment errors.  Like other alignment errors.
   
 @item less than u+2 stack items (@code{PICK} and @code{ROLL}):  @item less than u+2 stack items (@code{PICK} and @code{ROLL}):
 Not checked. May cause an illegal memory access.  Like other stack underflows.
   
 @item loop control parameters not available:  @item loop control parameters not available:
   @cindex loop control parameters not available
 Not checked. The counted loop words simply assume that the top of return  Not checked. The counted loop words simply assume that the top of return
 stack items are loop control parameters and behave accordingly.  stack items are loop control parameters and behave accordingly.
   
 @item most recent definition does not have a name (@code{IMMEDIATE}):  @item most recent definition does not have a name (@code{IMMEDIATE}):
   @cindex most recent definition does not have a name (@code{IMMEDIATE})
   @cindex last word was headerless
 @code{abort" last word was headerless"}.  @code{abort" last word was headerless"}.
   
 @item name not defined by @code{VALUE} used by @code{TO}:  @item name not defined by @code{VALUE} used by @code{TO}:
 @code{-32 throw} (Invalid name argument) (unless name was defined by  @cindex name not defined by @code{VALUE} used by @code{TO}
 @code{CONSTANT}; then it just changes the constant).  @cindex @code{TO} on non-@code{VALUE}s
   @cindex Invalid name argument, @code{TO}
   @code{-32 throw} (Invalid name argument) (unless name is a local or was
   defined by @code{CONSTANT}; in the latter case it just changes the constant).
   
 @item name not found (@code{'}, @code{POSTPONE}, @code{[']}, @code{[COMPILE]}):  @item name not found (@code{'}, @code{POSTPONE}, @code{[']}, @code{[COMPILE]}):
   @cindex name not found (@code{'}, @code{POSTPONE}, @code{[']}, @code{[COMPILE]})
   @cindex Undefined word, @code{'}, @code{POSTPONE}, @code{[']}, @code{[COMPILE]}
 @code{-13 throw} (Undefined word)  @code{-13 throw} (Undefined word)
   
 @item parameters are not of the same type (@code{DO}, @code{?DO}, @code{WITHIN}):  @item parameters are not of the same type (@code{DO}, @code{?DO}, @code{WITHIN}):
   @cindex parameters are not of the same type (@code{DO}, @code{?DO}, @code{WITHIN})
 Gforth behaves as if they were of the same type. I.e., you can predict  Gforth behaves as if they were of the same type. I.e., you can predict
 the behaviour by interpreting all parameters as, e.g., signed.  the behaviour by interpreting all parameters as, e.g., signed.
   
 @item @code{POSTPONE} or @code{[COMPILE]} applied to @code{TO}:  @item @code{POSTPONE} or @code{[COMPILE]} applied to @code{TO}:
   @cindex @code{POSTPONE} or @code{[COMPILE]} applied to @code{TO}
 Assume @code{: X POSTPONE TO ; IMMEDIATE}. @code{X} performs the  Assume @code{: X POSTPONE TO ; IMMEDIATE}. @code{X} performs the
 compilation semantics of @code{TO}.  compilation semantics of @code{TO}.
   
 @item String longer than a counted string returned by @code{WORD}:  @item String longer than a counted string returned by @code{WORD}:
   @cindex String longer than a counted string returned by @code{WORD}
   @cindex @code{WORD}, string overflow
 Not checked. The string will be ok, but the count will, of course,  Not checked. The string will be ok, but the count will, of course,
 contain only the least significant bits of the length.  contain only the least significant bits of the length.
   
 @item u greater than or equal to the number of bits in a cell (@code{LSHIFT}, @code{RSHIFT}):  @item u greater than or equal to the number of bits in a cell (@code{LSHIFT}, @code{RSHIFT}):
   @cindex @code{LSHIFT}, large shift counts
   @cindex @code{RSHIFT}, large shift counts
 Processor-dependent. Typical behaviours are returning 0 and using only  Processor-dependent. Typical behaviours are returning 0 and using only
 the low bits of the shift count.  the low bits of the shift count.
   
 @item word not defined via @code{CREATE}:  @item word not defined via @code{CREATE}:
   @cindex @code{>BODY} of non-@code{CREATE}d words
 @code{>BODY} produces the PFA of the word no matter how it was defined.  @code{>BODY} produces the PFA of the word no matter how it was defined.
   
   @cindex @code{DOES>} of non-@code{CREATE}d words
 @code{DOES>} changes the execution semantics of the last defined word no  @code{DOES>} changes the execution semantics of the last defined word no
 matter how it was defined. E.g., @code{CONSTANT DOES>} is equivalent to  matter how it was defined. E.g., @code{CONSTANT DOES>} is equivalent to
 @code{CREATE , DOES>}.  @code{CREATE , DOES>}.
Line 3119  Not checked. As usual, you can expect me Line 3482  Not checked. As usual, you can expect me
 @node core-other,  , core-ambcond, The Core Words  @node core-other,  , core-ambcond, The Core Words
 @subsection Other system documentation  @subsection Other system documentation
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex other system documentation, core words
   @cindex core words, other system documentation
   
 @table @i  @table @i
   
 @item nonstandard words using @code{PAD}:  @item nonstandard words using @code{PAD}:
   @cindex @code{PAD} use by nonstandard words
 None.  None.
   
 @item operator's terminal facilities available:  @item operator's terminal facilities available:
   @cindex operator's terminal facilities available
 After processing the command line, Gforth goes into interactive mode,  After processing the command line, Gforth goes into interactive mode,
 and you can give commands to Gforth interactively. The actual facilities  and you can give commands to Gforth interactively. The actual facilities
 available depend on how you invoke Gforth.  available depend on how you invoke Gforth.
   
 @item program data space available:  @item program data space available:
   @cindex program data space available
   @cindex data space available
 @code{UNUSED .} gives the remaining dictionary space. The total  @code{UNUSED .} gives the remaining dictionary space. The total
 dictionary space can be specified with the @code{-m} switch  dictionary space can be specified with the @code{-m} switch
 (@pxref{Invocation}) when Gforth starts up.  (@pxref{Invoking Gforth}) when Gforth starts up.
   
 @item return stack space available:  @item return stack space available:
   @cindex return stack space available
 You can compute the total return stack space in cells with  You can compute the total return stack space in cells with
 @code{s" RETURN-STACK-CELLS" environment? drop .}. You can specify it at  @code{s" RETURN-STACK-CELLS" environment? drop .}. You can specify it at
 startup time with the @code{-r} switch (@pxref{Invocation}).  startup time with the @code{-r} switch (@pxref{Invoking Gforth}).
   
 @item stack space available:  @item stack space available:
   @cindex stack space available
 You can compute the total data stack space in cells with  You can compute the total data stack space in cells with
 @code{s" STACK-CELLS" environment? drop .}. You can specify it at  @code{s" STACK-CELLS" environment? drop .}. You can specify it at
 startup time with the @code{-d} switch (@pxref{Invocation}).  startup time with the @code{-d} switch (@pxref{Invoking Gforth}).
   
 @item system dictionary space required, in address units:  @item system dictionary space required, in address units:
   @cindex system dictionary space required, in address units
 Type @code{here forthstart - .} after startup. At the time of this  Type @code{here forthstart - .} after startup. At the time of this
 writing, this gives 80080 (bytes) on a 32-bit system.  writing, this gives 80080 (bytes) on a 32-bit system.
 @end table  @end table
Line 3155  writing, this gives 80080 (bytes) on a 3 Line 3526  writing, this gives 80080 (bytes) on a 3
 @node The optional Block word set, The optional Double Number word set, The Core Words, ANS conformance  @node The optional Block word set, The optional Double Number word set, The Core Words, ANS conformance
 @section The optional Block word set  @section The optional Block word set
 @c =====================================================================  @c =====================================================================
   @cindex system documentation, block words
   @cindex block words, system documentation
   
 @menu  @menu
 * block-idef::                  Implementation Defined Options                    * block-idef::                  Implementation Defined Options
 * block-ambcond::               Ambiguous Conditions                 * block-ambcond::               Ambiguous Conditions               
 * block-other::                 Other System Documentation                   * block-other::                 Other System Documentation                 
 @end menu  @end menu
Line 3167  writing, this gives 80080 (bytes) on a 3 Line 3540  writing, this gives 80080 (bytes) on a 3
 @node block-idef, block-ambcond, The optional Block word set, The optional Block word set  @node block-idef, block-ambcond, The optional Block word set, The optional Block word set
 @subsection Implementation Defined Options  @subsection Implementation Defined Options
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex implementation-defined options, block words
   @cindex block words, implementation-defined options
   
 @table @i  @table @i
   
 @item the format for display by @code{LIST}:  @item the format for display by @code{LIST}:
   @cindex @code{LIST} display format
 First the screen number is displayed, then 16 lines of 64 characters,  First the screen number is displayed, then 16 lines of 64 characters,
 each line preceded by the line number.  each line preceded by the line number.
   
 @item the length of a line affected by @code{\}:  @item the length of a line affected by @code{\}:
   @cindex length of a line affected by @code{\}
   @cindex @code{\}, line length in blocks
 64 characters.  64 characters.
 @end table  @end table
   
Line 3183  each line preceded by the line number. Line 3560  each line preceded by the line number.
 @node block-ambcond, block-other, block-idef, The optional Block word set  @node block-ambcond, block-other, block-idef, The optional Block word set
 @subsection Ambiguous conditions  @subsection Ambiguous conditions
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex block words, ambiguous conditions
   @cindex ambiguous conditions, block words
   
 @table @i  @table @i
   
 @item correct block read was not possible:  @item correct block read was not possible:
   @cindex block read not possible
 Typically results in a @code{throw} of some OS-derived value (between  Typically results in a @code{throw} of some OS-derived value (between
 -512 and -2048). If the blocks file was just not long enough, blanks are  -512 and -2048). If the blocks file was just not long enough, blanks are
 supplied for the missing portion.  supplied for the missing portion.
   
 @item I/O exception in block transfer:  @item I/O exception in block transfer:
   @cindex I/O exception in block transfer
   @cindex block transfer, I/O exception
 Typically results in a @code{throw} of some OS-derived value (between  Typically results in a @code{throw} of some OS-derived value (between
 -512 and -2048).  -512 and -2048).
   
 @item invalid block number:  @item invalid block number:
   @cindex invalid block number
   @cindex block number invalid
 @code{-35 throw} (Invalid block number)  @code{-35 throw} (Invalid block number)
   
 @item a program directly alters the contents of @code{BLK}:  @item a program directly alters the contents of @code{BLK}:
   @cindex @code{BLK}, altering @code{BLK}
 The input stream is switched to that other block, at the same  The input stream is switched to that other block, at the same
 position. If the storing to @code{BLK} happens when interpreting  position. If the storing to @code{BLK} happens when interpreting
 non-block input, the system will get quite confused when the block ends.  non-block input, the system will get quite confused when the block ends.
   
 @item no current block buffer for @code{UPDATE}:  @item no current block buffer for @code{UPDATE}:
   @cindex @code{UPDATE}, no current block buffer
 @code{UPDATE} has no effect.  @code{UPDATE} has no effect.
   
 @end table  @end table
   
   
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
 @node block-other,  , block-ambcond, The optional Block word set  @node block-other,  , block-ambcond, The optional Block word set
 @subsection Other system documentation  @subsection Other system documentation
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex other system documentation, block words
   @cindex block words, other system documentation
   
 @table @i  @table @i
   
 @item any restrictions a multiprogramming system places on the use of buffer addresses:  @item any restrictions a multiprogramming system places on the use of buffer addresses:
 No restrictions (yet).  No restrictions (yet).
   
Line 3229  depends on your disk space. Line 3614  depends on your disk space.
 @node The optional Double Number word set, The optional Exception word set, The optional Block word set, ANS conformance  @node The optional Double Number word set, The optional Exception word set, The optional Block word set, ANS conformance
 @section The optional Double Number word set  @section The optional Double Number word set
 @c =====================================================================  @c =====================================================================
   @cindex system documentation, double words
   @cindex double words, system documentation
   
 @menu  @menu
 * double-ambcond::              Ambiguous Conditions                * double-ambcond::              Ambiguous Conditions              
Line 3239  depends on your disk space. Line 3626  depends on your disk space.
 @node double-ambcond,  , The optional Double Number word set, The optional Double Number word set  @node double-ambcond,  , The optional Double Number word set, The optional Double Number word set
 @subsection Ambiguous conditions  @subsection Ambiguous conditions
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex double words, ambiguous conditions
   @cindex ambiguous conditions, double words
   
 @table @i  @table @i
   
 @item @var{d} outside of range of @var{n} in @code{D>S}:  @item @var{d} outside of range of @var{n} in @code{D>S}:
   @cindex @code{D>S}, @var{d} out of range of @var{n} 
 The least significant cell of @var{d} is produced.  The least significant cell of @var{d} is produced.
   
 @end table  @end table
Line 3252  The least significant cell of @var{d} is Line 3641  The least significant cell of @var{d} is
 @node The optional Exception word set, The optional Facility word set, The optional Double Number word set, ANS conformance  @node The optional Exception word set, The optional Facility word set, The optional Double Number word set, ANS conformance
 @section The optional Exception word set  @section The optional Exception word set
 @c =====================================================================  @c =====================================================================
   @cindex system documentation, exception words
   @cindex exception words, system documentation
   
 @menu  @menu
 * exception-idef::              Implementation Defined Options                * exception-idef::              Implementation Defined Options              
Line 3262  The least significant cell of @var{d} is Line 3653  The least significant cell of @var{d} is
 @node exception-idef,  , The optional Exception word set, The optional Exception word set  @node exception-idef,  , The optional Exception word set, The optional Exception word set
 @subsection Implementation Defined Options  @subsection Implementation Defined Options
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex implementation-defined options, exception words
   @cindex exception words, implementation-defined options
   
 @table @i  @table @i
 @item @code{THROW}-codes used in the system:  @item @code{THROW}-codes used in the system:
 The codes -256@minus{}-511 are used for reporting signals (see  @cindex @code{THROW}-codes used in the system
 @file{errore.fs}). The codes -512@minus{}-2047 are used for OS errors  The codes -256@minus{}-511 are used for reporting signals. The mapping
 (for file and memory allocation operations). The mapping from OS error  from OS signal numbers to throw codes is -256@minus{}@var{signal}. The
 numbers to throw code is -512@minus{}@code{errno}. One side effect of  codes -512@minus{}-2047 are used for OS errors (for file and memory
 this mapping is that undefined OS errors produce a message with a  allocation operations). The mapping from OS error numbers to throw codes
 strange number; e.g., @code{-1000 THROW} results in @code{Unknown error  is -512@minus{}@code{errno}. One side effect of this mapping is that
 488} on my system.  undefined OS errors produce a message with a strange number; e.g.,
   @code{-1000 THROW} results in @code{Unknown error 488} on my system.
 @end table  @end table
   
 @c =====================================================================  @c =====================================================================
 @node The optional Facility word set, The optional File-Access word set, The optional Exception word set, ANS conformance  @node The optional Facility word set, The optional File-Access word set, The optional Exception word set, ANS conformance
 @section The optional Facility word set  @section The optional Facility word set
 @c =====================================================================  @c =====================================================================
   @cindex system documentation, facility words
   @cindex facility words, system documentation
   
 @menu  @menu
 * facility-idef::               Implementation Defined Options                 * facility-idef::               Implementation Defined Options               
Line 3289  strange number; e.g., @code{-1000 THROW} Line 3685  strange number; e.g., @code{-1000 THROW}
 @node facility-idef, facility-ambcond, The optional Facility word set, The optional Facility word set  @node facility-idef, facility-ambcond, The optional Facility word set, The optional Facility word set
 @subsection Implementation Defined Options  @subsection Implementation Defined Options
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex implementation-defined options, facility words
   @cindex facility words, implementation-defined options
   
 @table @i  @table @i
   
 @item encoding of keyboard events (@code{EKEY}):  @item encoding of keyboard events (@code{EKEY}):
   @cindex keyboard events, encoding in @code{EKEY}
   @cindex @code{EKEY}, encoding of keyboard events
 Not yet implemented.  Not yet implemented.
   
 @item duration of a system clock tick  @item duration of a system clock tick:
   @cindex duration of a system clock tick
   @cindex clock tick duration
 System dependent. With respect to @code{MS}, the time is specified in  System dependent. With respect to @code{MS}, the time is specified in
 microseconds. How well the OS and the hardware implement this, is  microseconds. How well the OS and the hardware implement this, is
 another question.  another question.
   
 @item repeatability to be expected from the execution of @code{MS}:  @item repeatability to be expected from the execution of @code{MS}:
   @cindex repeatability to be expected from the execution of @code{MS}
   @cindex @code{MS}, repeatability to be expected
 System dependent. On Unix, a lot depends on load. If the system is  System dependent. On Unix, a lot depends on load. If the system is
 lightly loaded, and the delay is short enough that Gforth does not get  lightly loaded, and the delay is short enough that Gforth does not get
 swapped out, the performance should be acceptable. Under MS-DOS and  swapped out, the performance should be acceptable. Under MS-DOS and
Line 3313  other single-tasking systems, it should Line 3716  other single-tasking systems, it should
 @node facility-ambcond,  , facility-idef, The optional Facility word set  @node facility-ambcond,  , facility-idef, The optional Facility word set
 @subsection Ambiguous conditions  @subsection Ambiguous conditions
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex facility words, ambiguous conditions
   @cindex ambiguous conditions, facility words
   
 @table @i  @table @i
   
 @item @code{AT-XY} can't be performed on user output device:  @item @code{AT-XY} can't be performed on user output device:
   @cindex @code{AT-XY} can't be performed on user output device
 Largely terminal dependent. No range checks are done on the arguments.  Largely terminal dependent. No range checks are done on the arguments.
 No errors are reported. You may see some garbage appearing, you may see  No errors are reported. You may see some garbage appearing, you may see
 simply nothing happen.  simply nothing happen.
Line 3328  simply nothing happen. Line 3733  simply nothing happen.
 @node The optional File-Access word set, The optional Floating-Point word set, The optional Facility word set, ANS conformance  @node The optional File-Access word set, The optional Floating-Point word set, The optional Facility word set, ANS conformance
 @section The optional File-Access word set  @section The optional File-Access word set
 @c =====================================================================  @c =====================================================================
   @cindex system documentation, file words
   @cindex file words, system documentation
   
 @menu  @menu
 * file-idef::                   Implementation Defined Options                     * file-idef::                   Implementation Defined Options
 * file-ambcond::                Ambiguous Conditions                  * file-ambcond::                Ambiguous Conditions                
 @end menu  @end menu
   
   
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
 @node file-idef, file-ambcond, The optional File-Access word set, The optional File-Access word set  @node file-idef, file-ambcond, The optional File-Access word set, The optional File-Access word set
 @subsection Implementation Defined Options  @subsection Implementation Defined Options
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex implementation-defined options, file words
   @cindex file words, implementation-defined options
   
 @table @i  @table @i
   @item file access methods used:
 @item File access methods used:  @cindex file access methods used
 @code{R/O}, @code{R/W} and @code{BIN} work as you would  @code{R/O}, @code{R/W} and @code{BIN} work as you would
 expect. @code{W/O} translates into the C file opening mode @code{w} (or  expect. @code{W/O} translates into the C file opening mode @code{w} (or
 @code{wb}): The file is cleared, if it exists, and created, if it does  @code{wb}): The file is cleared, if it exists, and created, if it does
 not (both with @code{open-file} and @code{create-file}).  Under Unix  not (with both @code{open-file} and @code{create-file}).  Under Unix
 @code{create-file} creates a file with 666 permissions modified by your  @code{create-file} creates a file with 666 permissions modified by your
 umask.  umask.
   
 @item file exceptions:  @item file exceptions:
   @cindex file exceptions
 The file words do not raise exceptions (except, perhaps, memory access  The file words do not raise exceptions (except, perhaps, memory access
 faults when you pass illegal addresses or file-ids).  faults when you pass illegal addresses or file-ids).
   
 @item file line terminator:  @item file line terminator:
   @cindex file line terminator
 System-dependent. Gforth uses C's newline character as line  System-dependent. Gforth uses C's newline character as line
 terminator. What the actual character code(s) of this are is  terminator. What the actual character code(s) of this are is
 system-dependent.  system-dependent.
   
 @item file name format  @item file name format:
   @cindex file name format
 System dependent. Gforth just uses the file name format of your OS.  System dependent. Gforth just uses the file name format of your OS.
   
 @item information returned by @code{FILE-STATUS}:  @item information returned by @code{FILE-STATUS}:
   @cindex @code{FILE-STATUS}, returned information
 @code{FILE-STATUS} returns the most powerful file access mode allowed  @code{FILE-STATUS} returns the most powerful file access mode allowed
 for the file: Either @code{R/O}, @code{W/O} or @code{R/W}. If the file  for the file: Either @code{R/O}, @code{W/O} or @code{R/W}. If the file
 cannot be accessed, @code{R/O BIN} is returned. @code{BIN} is applicable  cannot be accessed, @code{R/O BIN} is returned. @code{BIN} is applicable
 along with the returned mode.  along with the returned mode.
   
 @item input file state after an exception when including source:  @item input file state after an exception when including source:
   @cindex exception when including source
 All files that are left via the exception are closed.  All files that are left via the exception are closed.
   
 @item @var{ior} values and meaning:  @item @var{ior} values and meaning:
   @cindex @var{ior} values and meaning
 The @var{ior}s returned by the file and memory allocation words are  The @var{ior}s returned by the file and memory allocation words are
 intended as throw codes. They typically are in the range  intended as throw codes. They typically are in the range
 -512@minus{}-2047 of OS errors.  The mapping from OS error numbers to  -512@minus{}-2047 of OS errors.  The mapping from OS error numbers to
 @var{ior}s is -512@minus{}@var{errno}.  @var{ior}s is -512@minus{}@var{errno}.
   
 @item maximum depth of file input nesting:  @item maximum depth of file input nesting:
   @cindex maximum depth of file input nesting
   @cindex file input nesting, maximum depth
 limited by the amount of return stack, locals/TIB stack, and the number  limited by the amount of return stack, locals/TIB stack, and the number
 of open files available. This should not give you troubles.  of open files available. This should not give you troubles.
   
 @item maximum size of input line:  @item maximum size of input line:
   @cindex maximum size of input line
   @cindex input line size, maximum
 @code{/line}. Currently 255.  @code{/line}. Currently 255.
   
 @item methods of mapping block ranges to files:  @item methods of mapping block ranges to files:
   @cindex mapping block ranges to files
   @cindex files containing blocks
   @cindex blocks in files
 By default, blocks are accessed in the file @file{blocks.fb} in the  By default, blocks are accessed in the file @file{blocks.fb} in the
 current working directory. The file can be switched with @code{USE}.  current working directory. The file can be switched with @code{USE}.
   
 @item number of string buffers provided by @code{S"}:  @item number of string buffers provided by @code{S"}:
   @cindex @code{S"}, number of string buffers
 1  1
   
 @item size of string buffer used by @code{S"}:  @item size of string buffer used by @code{S"}:
   @cindex @code{S"}, size of string buffer
 @code{/line}. currently 255.  @code{/line}. currently 255.
   
 @end table  @end table
Line 3400  current working directory. The file can Line 3823  current working directory. The file can
 @node file-ambcond,  , file-idef, The optional File-Access word set  @node file-ambcond,  , file-idef, The optional File-Access word set
 @subsection Ambiguous conditions  @subsection Ambiguous conditions
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex file words, ambiguous conditions
   @cindex ambiguous conditions, file words
   
 @table @i  @table @i
   @item attempting to position a file outside its boundaries:
 @item attempting to position a file outside it's boundaries:  @cindex @code{REPOSITION-FILE}, outside the file's boundaries
 @code{REPOSITION-FILE} is performed as usual: Afterwards,  @code{REPOSITION-FILE} is performed as usual: Afterwards,
 @code{FILE-POSITION} returns the value given to @code{REPOSITION-FILE}.  @code{FILE-POSITION} returns the value given to @code{REPOSITION-FILE}.
   
 @item attempting to read from file positions not yet written:  @item attempting to read from file positions not yet written:
   @cindex reading from file positions not yet written
 End-of-file, i.e., zero characters are read and no error is reported.  End-of-file, i.e., zero characters are read and no error is reported.
   
 @item @var{file-id} is invalid (@code{INCLUDE-FILE}):  @item @var{file-id} is invalid (@code{INCLUDE-FILE}):
   @cindex @code{INCLUDE-FILE}, @var{file-id} is invalid 
 An appropriate exception may be thrown, but a memory fault or other  An appropriate exception may be thrown, but a memory fault or other
 problem is more probable.  problem is more probable.
   
 @item I/O exception reading or closing @var{file-id} (@code{include-file}, @code{included}):  @item I/O exception reading or closing @var{file-id} (@code{INCLUDE-FILE}, @code{INCLUDED}):
   @cindex @code{INCLUDE-FILE}, I/O exception reading or closing @var{file-id}
   @cindex @code{INCLUDED}, I/O exception reading or closing @var{file-id}
 The @var{ior} produced by the operation, that discovered the problem, is  The @var{ior} produced by the operation, that discovered the problem, is
 thrown.  thrown.
   
 @item named file cannot be opened (@code{included}):  @item named file cannot be opened (@code{INCLUDED}):
   @cindex @code{INCLUDED}, named file cannot be opened
 The @var{ior} produced by @code{open-file} is thrown.  The @var{ior} produced by @code{open-file} is thrown.
   
 @item requesting an unmapped block number:  @item requesting an unmapped block number:
   @cindex unmapped block numbers
 There are no unmapped legal block numbers. On some operating systems,  There are no unmapped legal block numbers. On some operating systems,
 writing a block with a large number may overflow the file system and  writing a block with a large number may overflow the file system and
 have an error message as consequence.  have an error message as consequence.
   
 @item using @code{source-id} when @code{blk} is non-zero:  @item using @code{source-id} when @code{blk} is non-zero:
   @cindex @code{SOURCE-ID}, behaviour when @code{BLK} is non-zero
 @code{source-id} performs its function. Typically it will give the id of  @code{source-id} performs its function. Typically it will give the id of
 the source which loaded the block. (Better ideas?)  the source which loaded the block. (Better ideas?)
   
Line 3437  the source which loaded the block. (Bett Line 3869  the source which loaded the block. (Bett
 @node  The optional Floating-Point word set, The optional Locals word set, The optional File-Access word set, ANS conformance  @node  The optional Floating-Point word set, The optional Locals word set, The optional File-Access word set, ANS conformance
 @section The optional Floating-Point word set  @section The optional Floating-Point word set
 @c =====================================================================  @c =====================================================================
   @cindex system documentation, floating-point words
   @cindex floating-point words, system documentation
   
 @menu  @menu
 * floating-idef::               Implementation Defined Options  * floating-idef::               Implementation Defined Options
Line 3448  the source which loaded the block. (Bett Line 3882  the source which loaded the block. (Bett
 @node floating-idef, floating-ambcond, The optional Floating-Point word set, The optional Floating-Point word set  @node floating-idef, floating-ambcond, The optional Floating-Point word set, The optional Floating-Point word set
 @subsection Implementation Defined Options  @subsection Implementation Defined Options
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex implementation-defined options, floating-point words
   @cindex floating-point words, implementation-defined options
   
 @table @i  @table @i
   
 @item format and range of floating point numbers:  @item format and range of floating point numbers:
   @cindex format and range of floating point numbers
   @cindex floating point numbers, format and range
 System-dependent; the @code{double} type of C.  System-dependent; the @code{double} type of C.
   
 @item results of @code{REPRESENT} when @var{float} is out of range:  @item results of @code{REPRESENT} when @var{float} is out of range:
   @cindex  @code{REPRESENT}, results when @var{float} is out of range
 System dependent; @code{REPRESENT} is implemented using the C library  System dependent; @code{REPRESENT} is implemented using the C library
 function @code{ecvt()} and inherits its behaviour in this respect.  function @code{ecvt()} and inherits its behaviour in this respect.
   
 @item rounding or truncation of floating-point numbers:  @item rounding or truncation of floating-point numbers:
   @cindex rounding of floating-point numbers
   @cindex truncation of floating-point numbers
   @cindex floating-point numbers, rounding or truncation
 System dependent; the rounding behaviour is inherited from the hosting C  System dependent; the rounding behaviour is inherited from the hosting C
 compiler. IEEE-FP-based (i.e., most) systems by default round to  compiler. IEEE-FP-based (i.e., most) systems by default round to
 nearest, and break ties by rounding to even (i.e., such that the last  nearest, and break ties by rounding to even (i.e., such that the last
 bit of the mantissa is 0).  bit of the mantissa is 0).
   
 @item size of floating-point stack:  @item size of floating-point stack:
   @cindex floating-point stack size
 @code{s" FLOATING-STACK" environment? drop .} gives the total size of  @code{s" FLOATING-STACK" environment? drop .} gives the total size of
 the floating-point stack (in floats). You can specify this on startup  the floating-point stack (in floats). You can specify this on startup
 with the command-line option @code{-f} (@pxref{Invocation}).  with the command-line option @code{-f} (@pxref{Invoking Gforth}).
   
 @item width of floating-point stack:  @item width of floating-point stack:
   @cindex floating-point stack width 
 @code{1 floats}.  @code{1 floats}.
   
 @end table  @end table
Line 3479  with the command-line option @code{-f} ( Line 3922  with the command-line option @code{-f} (
 @node floating-ambcond,  , floating-idef, The optional Floating-Point word set  @node floating-ambcond,  , floating-idef, The optional Floating-Point word set
 @subsection Ambiguous conditions  @subsection Ambiguous conditions
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex floating-point words, ambiguous conditions
   @cindex ambiguous conditions, floating-point words
   
 @table @i  @table @i
   
 @item @code{df@@} or @code{df!} used with an address that is not double-float  aligned:  @item @code{df@@} or @code{df!} used with an address that is not double-float  aligned:
   @cindex @code{df@@} or @code{df!} used with an address that is not double-float  aligned
 System-dependent. Typically results in a @code{-23 THROW} like other  System-dependent. Typically results in a @code{-23 THROW} like other
 alignment violations.  alignment violations.
   
 @item @code{f@@} or @code{f!} used with an address that is not float  aligned:  @item @code{f@@} or @code{f!} used with an address that is not float  aligned:
   @cindex @code{f@@} used with an address that is not float aligned
   @cindex @code{f!} used with an address that is not float aligned
 System-dependent. Typically results in a @code{-23 THROW} like other  System-dependent. Typically results in a @code{-23 THROW} like other
 alignment violations.  alignment violations.
   
 @item Floating-point result out of range:  @item floating-point result out of range:
   @cindex floating-point result out of range
 System-dependent. Can result in a @code{-55 THROW} (Floating-point  System-dependent. Can result in a @code{-55 THROW} (Floating-point
 unidentified fault), or can produce a special value representing, e.g.,  unidentified fault), or can produce a special value representing, e.g.,
 Infinity.  Infinity.
   
 @item @code{sf@@} or @code{sf!} used with an address that is not single-float  aligned:  @item @code{sf@@} or @code{sf!} used with an address that is not single-float  aligned:
   @cindex @code{sf@@} or @code{sf!} used with an address that is not single-float  aligned
 System-dependent. Typically results in an alignment fault like other  System-dependent. Typically results in an alignment fault like other
 alignment violations.  alignment violations.
   
 @item BASE is not decimal (@code{REPRESENT}, @code{F.}, @code{FE.}, @code{FS.}):  @item @code{BASE} is not decimal (@code{REPRESENT}, @code{F.}, @code{FE.}, @code{FS.}):
   @cindex @code{BASE} is not decimal (@code{REPRESENT}, @code{F.}, @code{FE.}, @code{FS.})
 The floating-point number is converted into decimal nonetheless.  The floating-point number is converted into decimal nonetheless.
   
 @item Both arguments are equal to zero (@code{FATAN2}):  @item Both arguments are equal to zero (@code{FATAN2}):
   @cindex @code{FATAN2}, both arguments are equal to zero
 System-dependent. @code{FATAN2} is implemented using the C library  System-dependent. @code{FATAN2} is implemented using the C library
 function @code{atan2()}.  function @code{atan2()}.
   
 @item Using ftan on an argument @var{r1} where cos(@var{r1}) is zero:  @item Using @code{FTAN} on an argument @var{r1} where cos(@var{r1}) is zero:
   @cindex @code{FTAN} on an argument @var{r1} where cos(@var{r1}) is zero
 System-dependent. Anyway, typically the cos of @var{r1} will not be zero  System-dependent. Anyway, typically the cos of @var{r1} will not be zero
 because of small errors and the tan will be a very large (or very small)  because of small errors and the tan will be a very large (or very small)
 but finite number.  but finite number.
   
 @item @var{d} cannot be presented precisely as a float in @code{D>F}:  @item @var{d} cannot be presented precisely as a float in @code{D>F}:
   @cindex @code{D>F}, @var{d} cannot be presented precisely as a float
 The result is rounded to the nearest float.  The result is rounded to the nearest float.
   
 @item dividing by zero:  @item dividing by zero:
   @cindex dividing by zero, floating-point
   @cindex floating-point dividing by zero
   @cindex floating-point unidentified fault, FP divide-by-zero
 @code{-55 throw} (Floating-point unidentified fault)  @code{-55 throw} (Floating-point unidentified fault)
   
 @item exponent too big for conversion (@code{DF!}, @code{DF@@}, @code{SF!}, @code{SF@@}):  @item exponent too big for conversion (@code{DF!}, @code{DF@@}, @code{SF!}, @code{SF@@}):
   @cindex exponent too big for conversion (@code{DF!}, @code{DF@@}, @code{SF!}, @code{SF@@})
 System dependent. On IEEE-FP based systems the number is converted into  System dependent. On IEEE-FP based systems the number is converted into
 an infinity.  an infinity.
   
 @item @var{float}<1 (@code{facosh}):  @item @var{float}<1 (@code{FACOSH}):
   @cindex @code{FACOSH}, @var{float}<1
   @cindex floating-point unidentified fault, @code{FACOSH}
 @code{-55 throw} (Floating-point unidentified fault)  @code{-55 throw} (Floating-point unidentified fault)
   
 @item @var{float}=<-1 (@code{flnp1}):  @item @var{float}=<-1 (@code{FLNP1}):
   @cindex @code{FLNP1}, @var{float}=<-1
   @cindex floating-point unidentified fault, @code{FLNP1}
 @code{-55 throw} (Floating-point unidentified fault). On IEEE-FP systems  @code{-55 throw} (Floating-point unidentified fault). On IEEE-FP systems
 negative infinity is typically produced for @var{float}=-1.  negative infinity is typically produced for @var{float}=-1.
   
 @item @var{float}=<0 (@code{fln}, @code{flog}):  @item @var{float}=<0 (@code{FLN}, @code{FLOG}):
   @cindex @code{FLN}, @var{float}=<0
   @cindex @code{FLOG}, @var{float}=<0
   @cindex floating-point unidentified fault, @code{FLN} or @code{FLOG}
 @code{-55 throw} (Floating-point unidentified fault). On IEEE-FP systems  @code{-55 throw} (Floating-point unidentified fault). On IEEE-FP systems
 negative infinity is typically produced for @var{float}=0.  negative infinity is typically produced for @var{float}=0.
   
 @item @var{float}<0 (@code{fasinh}, @code{fsqrt}):  @item @var{float}<0 (@code{FASINH}, @code{FSQRT}):
   @cindex @code{FASINH}, @var{float}<0
   @cindex @code{FSQRT}, @var{float}<0
   @cindex floating-point unidentified fault, @code{FASINH} or @code{FSQRT}
 @code{-55 throw} (Floating-point unidentified fault). @code{fasinh}  @code{-55 throw} (Floating-point unidentified fault). @code{fasinh}
 produces values for these inputs on my Linux box (Bug in the C library?)  produces values for these inputs on my Linux box (Bug in the C library?)
   
 @item |@var{float}|>1 (@code{facos}, @code{fasin}, @code{fatanh}):  @item |@var{float}|>1 (@code{FACOS}, @code{FASIN}, @code{FATANH}):
   @cindex @code{FACOS}, |@var{float}|>1
   @cindex @code{FASIN}, |@var{float}|>1
   @cindex @code{FATANH}, |@var{float}|>1
   @cindex floating-point unidentified fault, @code{FACOS}, @code{FASIN} or @code{FATANH}
 @code{-55 throw} (Floating-point unidentified fault).  @code{-55 throw} (Floating-point unidentified fault).
   
 @item integer part of float cannot be represented by @var{d} in @code{f>d}:  @item integer part of float cannot be represented by @var{d} in @code{F>D}:
   @cindex @code{F>D}, integer part of float cannot be represented by @var{d}
   @cindex floating-point unidentified fault, @code{F>D}
 @code{-55 throw} (Floating-point unidentified fault).  @code{-55 throw} (Floating-point unidentified fault).
   
 @item string larger than pictured numeric output area (@code{f.}, @code{fe.}, @code{fs.}):  @item string larger than pictured numeric output area (@code{f.}, @code{fe.}, @code{fs.}):
   @cindex string larger than pictured numeric output area (@code{f.}, @code{fe.}, @code{fs.})
 This does not happen.  This does not happen.
 @end table  @end table
   
   
   
 @c =====================================================================  @c =====================================================================
 @node  The optional Locals word set, The optional Memory-Allocation word set, The optional Floating-Point word set, ANS conformance  @node  The optional Locals word set, The optional Memory-Allocation word set, The optional Floating-Point word set, ANS conformance
 @section The optional Locals word set  @section The optional Locals word set
 @c =====================================================================  @c =====================================================================
   @cindex system documentation, locals words
   @cindex locals words, system documentation
   
 @menu  @menu
 * locals-idef::                 Implementation Defined Options                   * locals-idef::                 Implementation Defined Options                 
Line 3563  This does not happen. Line 4037  This does not happen.
 @node locals-idef, locals-ambcond, The optional Locals word set, The optional Locals word set  @node locals-idef, locals-ambcond, The optional Locals word set, The optional Locals word set
 @subsection Implementation Defined Options  @subsection Implementation Defined Options
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex implementation-defined options, locals words
   @cindex locals words, implementation-defined options
   
 @table @i  @table @i
   
 @item maximum number of locals in a definition:  @item maximum number of locals in a definition:
   @cindex maximum number of locals in a definition
   @cindex locals, maximum number in a definition
 @code{s" #locals" environment? drop .}. Currently 15. This is a lower  @code{s" #locals" environment? drop .}. Currently 15. This is a lower
 bound, e.g., on a 32-bit machine there can be 41 locals of up to 8  bound, e.g., on a 32-bit machine there can be 41 locals of up to 8
 characters. The number of locals in a definition is bounded by the size  characters. The number of locals in a definition is bounded by the size
Line 3579  of locals-buffer, which contains the nam Line 4056  of locals-buffer, which contains the nam
 @node locals-ambcond,  , locals-idef, The optional Locals word set  @node locals-ambcond,  , locals-idef, The optional Locals word set
 @subsection Ambiguous conditions  @subsection Ambiguous conditions
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex locals words, ambiguous conditions
   @cindex ambiguous conditions, locals words
   
 @table @i  @table @i
   
 @item executing a named local in interpretation state:  @item executing a named local in interpretation state:
 @code{-14 throw} (Interpreting a compile-only word).  @cindex local in interpretation state
   @cindex Interpreting a compile-only word, for a local
   Locals have no interpretation semantics. If you try to perform the
   interpretation semantics, you will get a @code{-14 throw} somewhere
   (Interpreting a compile-only word). If you perform the compilation
   semantics, the locals access will be compiled (irrespective of state).
   
 @item @var{name} not defined by @code{VALUE} or @code{(LOCAL)} (@code{TO}):  @item @var{name} not defined by @code{VALUE} or @code{(LOCAL)} (@code{TO}):
   @cindex name not defined by @code{VALUE} or @code{(LOCAL)} used by @code{TO}
   @cindex @code{TO} on non-@code{VALUE}s and non-locals
   @cindex Invalid name argument, @code{TO}
 @code{-32 throw} (Invalid name argument)  @code{-32 throw} (Invalid name argument)
   
 @end table  @end table
Line 3595  of locals-buffer, which contains the nam Line 4081  of locals-buffer, which contains the nam
 @node  The optional Memory-Allocation word set, The optional Programming-Tools word set, The optional Locals word set, ANS conformance  @node  The optional Memory-Allocation word set, The optional Programming-Tools word set, The optional Locals word set, ANS conformance
 @section The optional Memory-Allocation word set  @section The optional Memory-Allocation word set
 @c =====================================================================  @c =====================================================================
   @cindex system documentation, memory-allocation words
   @cindex memory-allocation words, system documentation
   
 @menu  @menu
 * memory-idef::                 Implementation Defined Options                   * memory-idef::                 Implementation Defined Options                 
Line 3605  of locals-buffer, which contains the nam Line 4093  of locals-buffer, which contains the nam
 @node memory-idef,  , The optional Memory-Allocation word set, The optional Memory-Allocation word set  @node memory-idef,  , The optional Memory-Allocation word set, The optional Memory-Allocation word set
 @subsection Implementation Defined Options  @subsection Implementation Defined Options
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex implementation-defined options, memory-allocation words
   @cindex memory-allocation words, implementation-defined options
   
 @table @i  @table @i
   
 @item values and meaning of @var{ior}:  @item values and meaning of @var{ior}:
   @cindex  @var{ior} values and meaning
 The @var{ior}s returned by the file and memory allocation words are  The @var{ior}s returned by the file and memory allocation words are
 intended as throw codes. They typically are in the range  intended as throw codes. They typically are in the range
 -512@minus{}-2047 of OS errors.  The mapping from OS error numbers to  -512@minus{}-2047 of OS errors.  The mapping from OS error numbers to
Line 3620  intended as throw codes. They typically Line 4110  intended as throw codes. They typically
 @node  The optional Programming-Tools word set, The optional Search-Order word set, The optional Memory-Allocation word set, ANS conformance  @node  The optional Programming-Tools word set, The optional Search-Order word set, The optional Memory-Allocation word set, ANS conformance
 @section The optional Programming-Tools word set  @section The optional Programming-Tools word set
 @c =====================================================================  @c =====================================================================
   @cindex system documentation, programming-tools words
   @cindex programming-tools words, system documentation
   
 @menu  @menu
 * programming-idef::            Implementation Defined Options              * programming-idef::            Implementation Defined Options            
Line 3631  intended as throw codes. They typically Line 4123  intended as throw codes. They typically
 @node programming-idef, programming-ambcond, The optional Programming-Tools word set, The optional Programming-Tools word set  @node programming-idef, programming-ambcond, The optional Programming-Tools word set, The optional Programming-Tools word set
 @subsection Implementation Defined Options  @subsection Implementation Defined Options
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex implementation-defined options, programming-tools words
   @cindex programming-tools words, implementation-defined options
   
 @table @i  @table @i
   @item ending sequence for input following @code{;CODE} and @code{CODE}:
 @item ending sequence for input following @code{;code} and @code{code}:  @cindex @code{;CODE} ending sequence
 @code{end-code}  @cindex @code{CODE} ending sequence
   @code{END-CODE}
 @item manner of processing input following @code{;code} and @code{code}:  
 The @code{assembler} vocabulary is pushed on the search order stack, and  @item manner of processing input following @code{;CODE} and @code{CODE}:
   @cindex @code{;CODE}, processing input
   @cindex @code{CODE}, processing input
   The @code{ASSEMBLER} vocabulary is pushed on the search order stack, and
 the input is processed by the text interpreter, (starting) in interpret  the input is processed by the text interpreter, (starting) in interpret
 state.  state.
   
 @item search order capability for @code{EDITOR} and @code{ASSEMBLER}:  @item search order capability for @code{EDITOR} and @code{ASSEMBLER}:
   @cindex @code{ASSEMBLER}, search order capability
 The ANS Forth search order word set.  The ANS Forth search order word set.
   
 @item source and format of display by @code{SEE}:  @item source and format of display by @code{SEE}:
   @cindex @code{SEE}, source and format of output
 The source for @code{see} is the intermediate code used by the inner  The source for @code{see} is the intermediate code used by the inner
 interpreter.  The current @code{see} tries to output Forth source code  interpreter.  The current @code{see} tries to output Forth source code
 as well as possible.  as well as possible.
Line 3656  as well as possible. Line 4155  as well as possible.
 @node programming-ambcond,  , programming-idef, The optional Programming-Tools word set  @node programming-ambcond,  , programming-idef, The optional Programming-Tools word set
 @subsection Ambiguous conditions  @subsection Ambiguous conditions
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex programming-tools words, ambiguous conditions
   @cindex ambiguous conditions, programming-tools words
   
 @table @i  @table @i
   
 @item deleting the compilation wordlist (@code{FORGET}):  @item deleting the compilation wordlist (@code{FORGET}):
   @cindex @code{FORGET}, deleting the compilation wordlist
 Not implemented (yet).  Not implemented (yet).
   
 @item fewer than @var{u}+1 items on the control flow stack (@code{CS-PICK}, @code{CS-ROLL}):  @item fewer than @var{u}+1 items on the control flow stack (@code{CS-PICK}, @code{CS-ROLL}):
   @cindex @code{CS-PICK}, fewer than @var{u}+1 items on the control flow stack
   @cindex @code{CS-ROLL}, fewer than @var{u}+1 items on the control flow stack
   @cindex control-flow stack underflow
 This typically results in an @code{abort"} with a descriptive error  This typically results in an @code{abort"} with a descriptive error
 message (may change into a @code{-22 throw} (Control structure mismatch)  message (may change into a @code{-22 throw} (Control structure mismatch)
 in the future). You may also get a memory access error. If you are  in the future). You may also get a memory access error. If you are
 unlucky, this ambiguous condition is not caught.  unlucky, this ambiguous condition is not caught.
   
 @item @var{name} can't be found (@code{forget}):  @item @var{name} can't be found (@code{FORGET}):
   @cindex @code{FORGET}, @var{name} can't be found
 Not implemented (yet).  Not implemented (yet).
   
 @item @var{name} not defined via @code{CREATE}:  @item @var{name} not defined via @code{CREATE}:
 @code{;code} behaves like @code{DOES>} in this respect, i.e., it changes  @cindex @code{;CODE}, @var{name} not defined via @code{CREATE}
   @code{;CODE} behaves like @code{DOES>} in this respect, i.e., it changes
 the execution semantics of the last defined word no matter how it was  the execution semantics of the last defined word no matter how it was
 defined.  defined.
   
 @item @code{POSTPONE} applied to @code{[IF]}:  @item @code{POSTPONE} applied to @code{[IF]}:
   @cindex @code{POSTPONE} applied to @code{[IF]}
   @cindex @code{[IF]} and @code{POSTPONE}
 After defining @code{: X POSTPONE [IF] ; IMMEDIATE}. @code{X} is  After defining @code{: X POSTPONE [IF] ; IMMEDIATE}. @code{X} is
 equivalent to @code{[IF]}.  equivalent to @code{[IF]}.
   
 @item reaching the end of the input source before matching @code{[ELSE]} or @code{[THEN]}:  @item reaching the end of the input source before matching @code{[ELSE]} or @code{[THEN]}:
   @cindex @code{[IF]}, end of the input source before matching @code{[ELSE]} or @code{[THEN]}
 Continue in the same state of conditional compilation in the next outer  Continue in the same state of conditional compilation in the next outer
 input source. Currently there is no warning to the user about this.  input source. Currently there is no warning to the user about this.
   
 @item removing a needed definition (@code{FORGET}):  @item removing a needed definition (@code{FORGET}):
   @cindex @code{FORGET}, removing a needed definition
 Not implemented (yet).  Not implemented (yet).
   
 @end table  @end table
Line 3694  Not implemented (yet). Line 4205  Not implemented (yet).
 @node  The optional Search-Order word set,  , The optional Programming-Tools word set, ANS conformance  @node  The optional Search-Order word set,  , The optional Programming-Tools word set, ANS conformance
 @section The optional Search-Order word set  @section The optional Search-Order word set
 @c =====================================================================  @c =====================================================================
   @cindex system documentation, search-order words
   @cindex search-order words, system documentation
   
 @menu  @menu
 * search-idef::                 Implementation Defined Options                   * search-idef::                 Implementation Defined Options                 
Line 3705  Not implemented (yet). Line 4218  Not implemented (yet).
 @node search-idef, search-ambcond, The optional Search-Order word set, The optional Search-Order word set  @node search-idef, search-ambcond, The optional Search-Order word set, The optional Search-Order word set
 @subsection Implementation Defined Options  @subsection Implementation Defined Options
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex implementation-defined options, search-order words
   @cindex search-order words, implementation-defined options
   
 @table @i  @table @i
   
 @item maximum number of word lists in search order:  @item maximum number of word lists in search order:
   @cindex maximum number of word lists in search order
   @cindex search order, maximum depth
 @code{s" wordlists" environment? drop .}. Currently 16.  @code{s" wordlists" environment? drop .}. Currently 16.
   
 @item minimum search order:  @item minimum search order:
   @cindex minimum search order
   @cindex search order, minimum
 @code{root root}.  @code{root root}.
   
 @end table  @end table
Line 3720  Not implemented (yet). Line 4238  Not implemented (yet).
 @node search-ambcond,  , search-idef, The optional Search-Order word set  @node search-ambcond,  , search-idef, The optional Search-Order word set
 @subsection Ambiguous conditions  @subsection Ambiguous conditions
 @c ---------------------------------------------------------------------  @c ---------------------------------------------------------------------
   @cindex search-order words, ambiguous conditions
   @cindex ambiguous conditions, search-order words
   
 @table @i  @table @i
   
 @item changing the compilation wordlist (during compilation):  @item changing the compilation wordlist (during compilation):
   @cindex changing the compilation wordlist (during compilation)
   @cindex compilation wordlist, change before definition ends
 The word is entered into the wordlist that was the compilation wordlist  The word is entered into the wordlist that was the compilation wordlist
 at the start of the definition. Any changes to the name field (e.g.,  at the start of the definition. Any changes to the name field (e.g.,
 @code{immediate}) or the code field (e.g., when executing @code{DOES>})  @code{immediate}) or the code field (e.g., when executing @code{DOES>})
Line 3731  are applied to the latest defined word ( Line 4252  are applied to the latest defined word (
 @code{lastxt}), if possible, irrespective of the compilation wordlist.  @code{lastxt}), if possible, irrespective of the compilation wordlist.
   
 @item search order empty (@code{previous}):  @item search order empty (@code{previous}):
   @cindex @code{previous}, search order empty
   @cindex Vocstack empty, @code{previous}
 @code{abort" Vocstack empty"}.  @code{abort" Vocstack empty"}.
   
 @item too many word lists in search order (@code{also}):  @item too many word lists in search order (@code{also}):
   @cindex @code{also}, too many word lists in search order
   @cindex Vocstack full, @code{also}
 @code{abort" Vocstack full"}.  @code{abort" Vocstack full"}.
   
 @end table  @end table
   
   @c ***************************************************************
 @node Model, Integrating Gforth, ANS conformance, Top  @node Model, Integrating Gforth, ANS conformance, Top
 @chapter Model  @chapter Model
   
 This chapter has yet to be written. It will contain information, on  This chapter has yet to be written. It will contain information, on
 which internal structures you can rely.  which internal structures you can rely.
   
   @c ***************************************************************
 @node Integrating Gforth, Emacs and Gforth, Model, Top  @node Integrating Gforth, Emacs and Gforth, Model, Top
 @chapter Integrating Gforth into C programs  @chapter Integrating Gforth into C programs
   
Line 3794  Signals? Line 4321  Signals?
   
 Accessing the Stacks  Accessing the Stacks
   
 @node Emacs and Gforth, Internals, Integrating Gforth, Top  @node Emacs and Gforth, Image Files, Integrating Gforth, Top
 @chapter Emacs and Gforth  @chapter Emacs and Gforth
   @cindex Emacs and Gforth
   
   @cindex @file{gforth.el}
   @cindex @file{forth.el}
   @cindex Rydqvist, Goran
   @cindex comment editing commands
   @cindex @code{\}, editing with Emacs
   @cindex debug tracer editing commands
   @cindex @code{~~}, removal with Emacs
   @cindex Forth mode in Emacs
 Gforth comes with @file{gforth.el}, an improved version of  Gforth comes with @file{gforth.el}, an improved version of
 @file{forth.el} by Goran Rydqvist (included in the TILE package). The  @file{forth.el} by Goran Rydqvist (included in the TILE package). The
 improvements are a better (but still not perfect) handling of  improvements are a better (but still not perfect) handling of
Line 3807  stuff I do not use alone, even though so Line 4343  stuff I do not use alone, even though so
 TILE. To get a description of these features, enter Forth mode and type  TILE. To get a description of these features, enter Forth mode and type
 @kbd{C-h m}.  @kbd{C-h m}.
   
   @cindex source location of error or debugging output in Emacs
   @cindex error output, finding the source location in Emacs
   @cindex debugging output, finding the source location in Emacs
 In addition, Gforth supports Emacs quite well: The source code locations  In addition, Gforth supports Emacs quite well: The source code locations
 given in error messages, debugging output (from @code{~~}) and failed  given in error messages, debugging output (from @code{~~}) and failed
 assertion messages are in the right format for Emacs' compilation mode  assertion messages are in the right format for Emacs' compilation mode
Line 3815  Manual}) so the source location correspo Line 4354  Manual}) so the source location correspo
 message is only a few keystrokes away (@kbd{C-x `} for the next error,  message is only a few keystrokes away (@kbd{C-x `} for the next error,
 @kbd{C-c C-c} for the error under the cursor).  @kbd{C-c C-c} for the error under the cursor).
   
   @cindex @file{TAGS} file
   @cindex @file{etags.fs}
   @cindex viewing the source of a word in Emacs
 Also, if you @code{include} @file{etags.fs}, a new @file{TAGS} file  Also, if you @code{include} @file{etags.fs}, a new @file{TAGS} file
 (@pxref{Tags, , Tags Tables, emacs, Emacs Manual}) will be produced that  (@pxref{Tags, , Tags Tables, emacs, Emacs Manual}) will be produced that
 contains the definitions of all words defined afterwards. You can then  contains the definitions of all words defined afterwards. You can then
Line 3825  Table,emacs, Emacs Manual}). The TAGS fi Line 4367  Table,emacs, Emacs Manual}). The TAGS fi
 @file{$(datadir)/gforth/$(VERSION)/TAGS} (e.g.,  @file{$(datadir)/gforth/$(VERSION)/TAGS} (e.g.,
 @file{/usr/local/share/gforth/0.2.0/TAGS}).  @file{/usr/local/share/gforth/0.2.0/TAGS}).
   
   @cindex @file{.emacs}
 To get all these benefits, add the following lines to your @file{.emacs}  To get all these benefits, add the following lines to your @file{.emacs}
 file:  file:
   
Line 3833  file: Line 4376  file:
 (setq auto-mode-alist (cons '("\\.fs\\'" . forth-mode) auto-mode-alist))  (setq auto-mode-alist (cons '("\\.fs\\'" . forth-mode) auto-mode-alist))
 @end example  @end example
   
 @node Internals, Bugs, Emacs and Gforth, Top  @node Image Files, Engine, Emacs and Gforth, Top
 @chapter Internals  @chapter Image Files
   @cindex image files
   @cindex @code{.fi} files
   @cindex precompiled Forth code
   @cindex dictionary in persistent form
   @cindex persistent form of dictionary
   
   An image file is a file containing an image of the Forth dictionary,
   i.e., compiled Forth code and data residing in the dictionary.  By
   convention, we use the extension @code{.fi} for image files.
   
   @menu
   * Image File Background::          Why have image files?
   * Non-Relocatable Image Files::    don't always work.
   * Data-Relocatable Image Files::   are better.
   * Fully Relocatable Image Files::  are hard to create.
   * Stack and Dictionary Sizes::     Setting the default sizes for an image.
   * Running Image Files::            @code{gforth -i @var{file}} or @var{file}.
   * Modifying the Startup Sequence:: and turnkey applications.
   @end menu
   
   @node Image File Background, Non-Relocatable Image Files, Image Files, Image Files
   @section Image File Background
   @cindex image file background
   
   Our Forth system consists not only of primitives, but also of
   definitions written in Forth. Since the Forth compiler itself belongs
   to those definitions, it is not possible to start the system with the
   primitives and the Forth source alone. Therefore we provide the Forth
   code as an image file in nearly executable form. At the start of the
   system a C routine loads the image file into memory, sets up the
   memory (stacks etc.) according to information in the image file, and
   starts executing Forth code.
   
   The image file variants represent different compromises between the
   goals of making it easy to generate image files and making them
   portable.
   
   @cindex relocation at run-time
   Win32Forth 3.4 and Mitch Bradleys @code{cforth} use relocation at
   run-time. This avoids many of the complications discussed below (image
   files are data relocatable without further ado), but costs performance
   (one addition per memory access).
   
   @cindex relocation at load-time
   Our loader performs relocation at image load time. The loader also has
   to replace tokens standing for primitive calls with the appropriate
   code-field addresses (or code addresses in the case of direct
   threading).
   
   There are three kinds of image files, with different degrees of
   relocatability: non-relocatable, data-relocatable, and fully relocatable
   image files.
   
   @cindex image file loader
   @cindex relocating loader
   @cindex loader for image files
   These image file variants have several restrictions in common; they are
   caused by the design of the image file loader:
   
   @itemize @bullet
   @item
   There is only one segment; in particular, this means, that an image file
   cannot represent @code{ALLOCATE}d memory chunks (and pointers to
   them). And the contents of the stacks are not represented, either.
   
   @item
   The only kinds of relocation supported are: the addition of the same
   offset to all cells that represent data addresses; and the replacement of
   special tokens with code addresses.
   
   If any complex computations involving addresses are performed, the
   results cannot be represented in the image file. Several applications that
   use such computations come to mind:
   @itemize @minus
   @item
   Hashing addresses (or data structures which contain addresses) for table
   lookup. If you use Gforth's @code{table}s or @code{wordlist}s for this
   purpose, you will have no problem, because the hash tables are
   recomputed automatically when the system is started. If you use your own
   hash tables, you will have to do something similar.
   
   @item
   There's a cute implementation of doubly-linked lists that uses
   @code{XOR}ed addresses. You could represent such lists as singly-linked
   in the image file, and restore the doubly-linked representation on
   startup.@footnote{In my opinion, though, you should think thrice before
   using a doubly-linked list (whatever implementation).}
   
   @item
   On many architectures addresses are represented in machine code in some
   shifted or mangled form. You cannot put @code{CODE} words that contain
   absolute addresses in this form in a relocatable image file. Workarounds
   are representing the address in some relative form (e.g., relative to
   the CFA, which is present in some register), or loading the address from
   a place where it is stored in a non-mangled form.
   @end itemize
   @end itemize
   
   @node  Non-Relocatable Image Files, Data-Relocatable Image Files, Image File Background, Image Files
   @section Non-Relocatable Image Files
   @cindex non-relocatable image files
   @cindex image files, non-relocatable
   
   These files are simple memory dumps of the dictionary. They are specific
   to the executable (i.e., @file{gforth} file) they were created
   with. What's worse, they are specific to the place on which the
   dictionary resided when the image was created. Now, there is no
   guarantee that the dictionary will reside at the same place the next
   time you start Gforth, so there's no guarantee that a non-relocatable
   image will work the next time (Gforth will complain instead of crashing,
   though).
   
   You can create a non-relocatable image file with
   
   doc-savesystem
   
   @node Data-Relocatable Image Files, Fully Relocatable Image Files, Non-Relocatable Image Files, Image Files
   @section Data-Relocatable Image Files
   @cindex data-relocatable image files
   @cindex image files, data-relocatable
   
   @cindex @file{gforth.fi}, relocatability
   These files contain relocatable data addresses, but fixed code addresses
   (instead of tokens). They are specific to the executable (i.e.,
   @file{gforth} file) they were created with. E.g., the image
   @code{gforth.fi} is a data-relocatable image file.
   
   @cindex @file{comp-image.fs}
   You can create a data-relocatable image file by creating two
   non-relocatable image files for different base addresses and processing
   them with @file{comp-image.fs}, which generates the relocation
   information by comparing the images.
   
   After loading @file{comp-image.fs}, you can invoke the word
   @code{comp-image}, which reads the names of the two input files and the
   name of the output file from the input stream. This program also
   produces some output on the standard output: It displays the offset
   (i.e., the difference between the base addresses of the images);
   moreover, for each cell that cannot be represented correctly in the
   image files, it displays a line like the following one:
   
   @example
        78DC         BFFFFA50         BFFFFA40
   @end example
   
   This means that at offset $78dc from @code{forthstart}, one input image
   contains $bffffa50, and the other contains $bffffa40. Since these cells
   cannot be represented correctly in the output image, you should examine
   these places in the dictionary and verify that these cells are dead
   (i.e., not read before they are written).
   
   E.g., if you want to create an image @file{asm.fi} that has the file
   @file{asm.fs} loaded in addition to the usual stuff, you could do it
   like this:
   
   @example
   gforth --clear-dictionary asm.fs "savesystem asm.fi1 bye"
   gforth --clear-dictionary --offset-image asm.fs "savesystem asm.fi2 bye"
   gforth -m 100000 comp-image.fs -e "comp-image asm.fi1 asm.fi2 asm.fi bye"
   @end example
   
   @cindex --clear-dictionary, creating image files
   @cindex --offset-image, creating image files
   The flag @code{--clear-dictionary} ensures that the dictionary memory is
   cleared at the start (so you won't see @code{comp-image} messages about
   spurious differences). The flag @code{--offset-image} loads the image at
   a small offset from its normal position, ensuring that the resulting
   nonrelocatable images have different bases (otherwise @code{comp-image}
   cannot work).
   
   @node Fully Relocatable Image Files, Stack and Dictionary Sizes, Data-Relocatable Image Files, Image Files
   @section Fully Relocatable Image Files
   @cindex fully relocatable image files
   @cindex image files, fully relocatable
   
   @cindex @file{kern*.fi}, relocatability
   These image files have relocatable data addresses, and tokens for code
   addresses. They are still a bit machine dependent with respect to the
   size and format (byte order, floating point format) of their data. The
   @file{kernlxxx.fi} files are fully relocatable.
   
   @cindex cross-compiler
   @cindex metacompiler
   At present a fully relocatable image file can only be produced by
   @code{cross}, a batch compiler that accepts a Forth-like programming
   language. This @code{cross} language has to be documented
   yet.
   
   @cindex target compiler
   @code{cross} not only allows the programmer to create fully relocatable
   image files, but also to create image files for machines with different
   data sizes and data formats than the one used for generating the image
   file. This convenience is bought with restrictions and inconveniences in
   programming. E.g., addresses have to be stored in memory with special
   words (@code{A!}, @code{A,}, etc.) in order to make the code
   relocatable.
   
   @node Stack and Dictionary Sizes, Running Image Files, Fully Relocatable Image Files, Image Files
   @section Stack and Dictionary Sizes
   @cindex image file, stack and dictionary sizes
   @cindex dictionary size default
   @cindex stack size default
   
   If you invoke Gforth with a command line flag for the size
   (@pxref{Invoking Gforth}), the size you specify is stored in the
   dictionary. If you save the dictionary with @code{savesystem}, this size
   will become the default for the resulting image file. E.g., the
   following will create a non-relocatable version of gforth.fi with a 1MB
   dictionary:
   
   @example
   gforth -m 1M -e "savesystem gforth1M.fi bye"
   @end example
   
   In other words, if you want to set the default size for the dictionary
   and the stacks of an image, just invoke Gforth with the appropriate
   options when creating the image. When creating a data-relocatable image,
   you have to use the same size options for both @code{savesystem}s.
   
   @cindex stack size, cache-friendly
   Note: For cache-friendly behaviour (i.e., good performance), you should
   make the sizes of the stacks modulo, say, 2K, somewhat different. E.g.,
   the default stack sizes are: data: 16k (mod 2k=0); fp: 15.5k (mod
   2k=1.5k); return: 15k(mod 2k=1k); locals: 14.5k (mod 2k=0.5k).
   
   @node Running Image Files, Modifying the Startup Sequence, Stack and Dictionary Sizes, Image Files
   @section Running Image Files
   @cindex running image files
   @cindex invoking image files
   @cindex image file invocation
   
   @cindex -i, invoke image file
   @cindex --image file, invoke image file
   You can invoke Gforth with an image file @var{image} instead of the
   default @file{gforth.fi} with the @code{-i} flag (@pxref{Invoking Gforth}):
   @example
   gforth -i @var{image}
   @end example
   
   @cindex executable image file
   @cindex image files, executable
   If your operating system supports starting scripts with a line of the
   form @code{#! ...}, you can make your image file executable, and you'll
   just have to type the image file name to start Gforth with this image
   file (note that the file extension @code{.fi} is just a convention).
   
   I.e., in most Unix systems, you just have to make the image file
   @var{image} executable with
   
   @example
   chmod +x @var{image}
   @end example
   
   and then you can invoke it by simply typing @var{image} instead of
   @code{gforth -i @var{image}}.
   
   @node Modifying the Startup Sequence,  , Running Image Files, Image Files
   @section Modifying the Startup Sequence
   @cindex startup sequence for image file
   @cindex image file initialization sequence
   @cindex initialization sequence of image file
   
   You can add your own initialization to the startup sequence through the
   deferred word
   
   doc-'cold
   
   @code{'cold} is invoked just before the image-specific command line
   processing (by default, loading files and evaluating (@code{-e}) strings
   starts.
   
   A sequence for adding your initialization usually looks like this:
   
   @example
   :noname
       Defers 'cold \ do other initialization stuff (e.g., rehashing wordlists)
       ... \ your stuff
   ; IS 'cold
   @end example
   
   @cindex turnkey image files
   @cindex image files, turnkey applications
   You can make a turnkey image by letting @code{'cold} execute a word
   (your turnkey application) that never returns; instead, it exits Gforth
   via @code{bye} or @code{throw}.
   
   @c ******************************************************************
   @node Engine, Bugs, Image Files, Top
   @chapter Engine
   @cindex engine
   @cindex virtual machine
   
 Reading this section is not necessary for programming with Gforth. It  Reading this section is not necessary for programming with Gforth. It
 should be helpful for finding your way in the Gforth sources.  may be helpful for finding your way in the Gforth sources.
   
 The ideas in this section have also been published in the papers  The ideas in this section have also been published in the papers
 @cite{ANS fig/GNU/??? Forth} (in German) by Bernd Paysan, presented at  @cite{ANS fig/GNU/??? Forth} (in German) by Bernd Paysan, presented at
Line 3849  Ertl, presented at EuroForth '93; the la Line 4683  Ertl, presented at EuroForth '93; the la
 * Portability::                   * Portability::                 
 * Threading::                     * Threading::                   
 * Primitives::                    * Primitives::                  
 * System Architecture::           
 * Performance::                   * Performance::                 
 @end menu  @end menu
   
 @node Portability, Threading, Internals, Internals  @node Portability, Threading, Engine, Engine
 @section Portability  @section Portability
   @cindex engine portability
   
 One of the main goals of the effort is availability across a wide range  One of the main goals of the effort is availability across a wide range
 of personal machines. fig-Forth, and, to a lesser extent, F83, achieved  of personal machines. fig-Forth, and, to a lesser extent, F83, achieved
Line 3862  this goal by manually coding the engine Line 4696  this goal by manually coding the engine
 then-popular processors. This approach is very labor-intensive and the  then-popular processors. This approach is very labor-intensive and the
 results are short-lived due to progress in computer architecture.  results are short-lived due to progress in computer architecture.
   
   @cindex C, using C for the engine
 Others have avoided this problem by coding in C, e.g., Mitch Bradley  Others have avoided this problem by coding in C, e.g., Mitch Bradley
 (cforth), Mikael Patel (TILE) and Dirk Zoller (pfe). This approach is  (cforth), Mikael Patel (TILE) and Dirk Zoller (pfe). This approach is
 particularly popular for UNIX-based Forths due to the large variety of  particularly popular for UNIX-based Forths due to the large variety of
Line 3869  architectures of UNIX machines. Unfortun Line 4704  architectures of UNIX machines. Unfortun
 does not mix well with the goals of efficiency and with using  does not mix well with the goals of efficiency and with using
 traditional techniques: Indirect or direct threading cannot be expressed  traditional techniques: Indirect or direct threading cannot be expressed
 in C, and switch threading, the fastest technique available in C, is  in C, and switch threading, the fastest technique available in C, is
 significantly slower. Another problem with C is that it's very  significantly slower. Another problem with C is that it is very
 cumbersome to express double integer arithmetic.  cumbersome to express double integer arithmetic.
   
   @cindex GNU C for the engine
   @cindex long long
 Fortunately, there is a portable language that does not have these  Fortunately, there is a portable language that does not have these
 limitations: GNU C, the version of C processed by the GNU C compiler  limitations: GNU C, the version of C processed by the GNU C compiler
 (@pxref{C Extensions, , Extensions to the C Language Family, gcc.info,  (@pxref{C Extensions, , Extensions to the C Language Family, gcc.info,
Line 3893  on all these machines. Line 4730  on all these machines.
 Writing in a portable language has the reputation of producing code that  Writing in a portable language has the reputation of producing code that
 is slower than assembly. For our Forth engine we repeatedly looked at  is slower than assembly. For our Forth engine we repeatedly looked at
 the code produced by the compiler and eliminated most compiler-induced  the code produced by the compiler and eliminated most compiler-induced
 inefficiencies by appropriate changes in the source-code.  inefficiencies by appropriate changes in the source code.
   
   @cindex explicit register declarations
   @cindex --enable-force-reg, configuration flag
   @cindex -DFORCE_REG
 However, register allocation cannot be portably influenced by the  However, register allocation cannot be portably influenced by the
 programmer, leading to some inefficiencies on register-starved  programmer, leading to some inefficiencies on register-starved
 machines. We use explicit register declarations (@pxref{Explicit Reg  machines. We use explicit register declarations (@pxref{Explicit Reg
 Vars, , Variables in Specified Registers, gcc.info, GNU C Manual}) to  Vars, , Variables in Specified Registers, gcc.info, GNU C Manual}) to
 improve the speed on some machines. They are turned on by using the  improve the speed on some machines. They are turned on by using the
 @code{gcc} switch @code{-DFORCE_REG}. Unfortunately, this feature not  configuration flag @code{--enable-force-reg} (@code{gcc} switch
 only depends on the machine, but also on the compiler version: On some  @code{-DFORCE_REG}). Unfortunately, this feature not only depends on the
 machines some compiler versions produce incorrect code when certain  machine, but also on the compiler version: On some machines some
 explicit register declarations are used. So by default  compiler versions produce incorrect code when certain explicit register
 @code{-DFORCE_REG} is not used.  declarations are used. So by default @code{-DFORCE_REG} is not used.
   
 @node Threading, Primitives, Portability, Internals  @node Threading, Primitives, Portability, Engine
 @section Threading  @section Threading
   @cindex inner interpreter implementation
   @cindex threaded code implementation
   
   @cindex labels as values
 GNU C's labels as values extension (available since @code{gcc-2.0},  GNU C's labels as values extension (available since @code{gcc-2.0},
 @pxref{Labels as Values, , Labels as Values, gcc.info, GNU C Manual})  @pxref{Labels as Values, , Labels as Values, gcc.info, GNU C Manual})
 makes it possible to take the address of @var{label} by writing  makes it possible to take the address of @var{label} by writing
Line 3916  makes it possible to take the address of Line 4759  makes it possible to take the address of
 @code{goto *@var{address}}. I.e., @code{goto *&&x} is the same as  @code{goto *@var{address}}. I.e., @code{goto *&&x} is the same as
 @code{goto x}.  @code{goto x}.
   
   @cindex NEXT, indirect threaded
   @cindex indirect threaded inner interpreter
   @cindex inner interpreter, indirect threaded
 With this feature an indirect threaded NEXT looks like:  With this feature an indirect threaded NEXT looks like:
 @example  @example
 cfa = *ip++;  cfa = *ip++;
 ca = *cfa;  ca = *cfa;
 goto *ca;  goto *ca;
 @end example  @end example
   @cindex instruction pointer
 For those unfamiliar with the names: @code{ip} is the Forth instruction  For those unfamiliar with the names: @code{ip} is the Forth instruction
 pointer; the @code{cfa} (code-field address) corresponds to ANS Forths  pointer; the @code{cfa} (code-field address) corresponds to ANS Forths
 execution token and points to the code field of the next word to be  execution token and points to the code field of the next word to be
Line 3929  executed; The @code{ca} (code address) f Line 4776  executed; The @code{ca} (code address) f
 executable code, e.g., a primitive or the colon definition handler  executable code, e.g., a primitive or the colon definition handler
 @code{docol}.  @code{docol}.
   
   @cindex NEXT, direct threaded
   @cindex direct threaded inner interpreter
   @cindex inner interpreter, direct threaded
 Direct threading is even simpler:  Direct threading is even simpler:
 @example  @example
 ca = *ip++;  ca = *ip++;
Line 3946  Of course we have packaged the whole thi Line 4796  Of course we have packaged the whole thi
   
 @node Scheduling, Direct or Indirect Threaded?, Threading, Threading  @node Scheduling, Direct or Indirect Threaded?, Threading, Threading
 @subsection Scheduling  @subsection Scheduling
   @cindex inner interpreter optimization
   
 There is a little complication: Pipelined and superscalar processors,  There is a little complication: Pipelined and superscalar processors,
 i.e., RISC and some modern CISC machines can process independent  i.e., RISC and some modern CISC machines can process independent
Line 3985  switch is on by default on machines that Line 4836  switch is on by default on machines that
   
 @node Direct or Indirect Threaded?, DOES>, Scheduling, Threading  @node Direct or Indirect Threaded?, DOES>, Scheduling, Threading
 @subsection Direct or Indirect Threaded?  @subsection Direct or Indirect Threaded?
   @cindex threading, direct or indirect?
   
   @cindex -DDIRECT_THREADED
 Both! After packaging the nasty details in macro definitions we  Both! After packaging the nasty details in macro definitions we
 realized that we could switch between direct and indirect threading by  realized that we could switch between direct and indirect threading by
 simply setting a compilation flag (@code{-DDIRECT_THREADED}) and  simply setting a compilation flag (@code{-DDIRECT_THREADED}) and
Line 3993  defining a few machine-specific macros f Line 4846  defining a few machine-specific macros f
 On the Forth level we also offer access words that hide the  On the Forth level we also offer access words that hide the
 differences between the threading methods (@pxref{Threading Words}).  differences between the threading methods (@pxref{Threading Words}).
   
 Indirect threading is implemented completely  Indirect threading is implemented completely machine-independently.
 machine-independently. Direct threading needs routines for creating  Direct threading needs routines for creating jumps to the executable
 jumps to the executable code (e.g. to docol or dodoes). These routines  code (e.g. to docol or dodoes). These routines are inherently
 are inherently machine-dependent, but they do not amount to many source  machine-dependent, but they do not amount to many source lines. I.e.,
 lines. I.e., even porting direct threading to a new machine is a small  even porting direct threading to a new machine is a small effort.
 effort.  
   @cindex --enable-indirect-threaded, configuration flag
   @cindex --enable-direct-threaded, configuration flag
   The default threading method is machine-dependent. You can enforce a
   specific threading method when building Gforth with the configuration
   flag @code{--enable-direct-threaded} or
   @code{--enable-indirect-threaded}. Note that direct threading is not
   supported on all machines.
   
 @node DOES>,  , Direct or Indirect Threaded?, Threading  @node DOES>,  , Direct or Indirect Threaded?, Threading
 @subsection DOES>  @subsection DOES>
   @cindex @code{DOES>} implementation
   
   @cindex dodoes routine
   @cindex DOES-code
 One of the most complex parts of a Forth engine is @code{dodoes}, i.e.,  One of the most complex parts of a Forth engine is @code{dodoes}, i.e.,
 the chunk of code executed by every word defined by a  the chunk of code executed by every word defined by a
 @code{CREATE}...@code{DOES>} pair. The main problem here is: How to find  @code{CREATE}...@code{DOES>} pair. The main problem here is: How to find
 the Forth code to be executed, i.e. the code after the @code{DOES>} (the  the Forth code to be executed, i.e. the code after the
 DOES-code)? There are two solutions:  @code{DOES>} (the DOES-code)? There are two solutions:
   
 In fig-Forth the code field points directly to the dodoes and the  In fig-Forth the code field points directly to the dodoes and the
 DOES-code address is stored in the cell after the code address  DOES-code address is stored in the cell after the code address (i.e. at
 (i.e. at cfa cell+). It may seem that this solution is illegal in the  @code{@var{cfa} cell+}). It may seem that this solution is illegal in
 Forth-79 and all later standards, because in fig-Forth this address  the Forth-79 and all later standards, because in fig-Forth this address
 lies in the body (which is illegal in these standards). However, by  lies in the body (which is illegal in these standards). However, by
 making the code field larger for all words this solution becomes legal  making the code field larger for all words this solution becomes legal
 again. We use this approach for the indirect threaded version. Leaving  again. We use this approach for the indirect threaded version and for
 a cell unused in most words is a bit wasteful, but on the machines we  direct threading on some machines. Leaving a cell unused in most words
 are targeting this is hardly a problem. The other reason for having a  is a bit wasteful, but on the machines we are targeting this is hardly a
 code field size of two cells is to avoid having different image files  problem. The other reason for having a code field size of two cells is
 for direct and indirect threaded systems (@pxref{System Architecture}).  to avoid having different image files for direct and indirect threaded
   systems (direct threaded systems require two-cell code fields on many
   machines).
   
   @cindex DOES-handler
 The other approach is that the code field points or jumps to the cell  The other approach is that the code field points or jumps to the cell
 after @code{DOES}. In this variant there is a jump to @code{dodoes} at  after @code{DOES}. In this variant there is a jump to @code{dodoes} at
 this address. @code{dodoes} can then get the DOES-code address by  this address (the DOES-handler). @code{dodoes} can then get the
 computing the code address, i.e., the address of the jump to dodoes,  DOES-code address by computing the code address, i.e., the address of
 and add the length of that jump field. A variant of this is to have a  the jump to dodoes, and add the length of that jump field. A variant of
 call to @code{dodoes} after the @code{DOES>}; then the return address  this is to have a call to @code{dodoes} after the @code{DOES>}; then the
 (which can be found in the return register on RISCs) is the DOES-code  return address (which can be found in the return register on RISCs) is
 address. Since the two cells available in the code field are usually  the DOES-code address. Since the two cells available in the code field
 used up by the jump to the code address in direct threading, we use  are used up by the jump to the code address in direct threading on many
 this approach for direct threading. We did not want to add another  architectures, we use this approach for direct threading on these
 cell to the code field.  architectures. We did not want to add another cell to the code field.
   
 @node Primitives, System Architecture, Threading, Internals  @node Primitives, Performance, Threading, Engine
 @section Primitives  @section Primitives
   @cindex primitives, implementation
   @cindex virtual machine instructions, implementation
   
 @menu  @menu
 * Automatic Generation::          * Automatic Generation::        
Line 4043  cell to the code field. Line 4912  cell to the code field.
   
 @node Automatic Generation, TOS Optimization, Primitives, Primitives  @node Automatic Generation, TOS Optimization, Primitives, Primitives
 @subsection Automatic Generation  @subsection Automatic Generation
   @cindex primitives, automatic generation
   
   @cindex @file{prims2x.fs}
 Since the primitives are implemented in a portable language, there is no  Since the primitives are implemented in a portable language, there is no
 longer any need to minimize the number of primitives. On the contrary,  longer any need to minimize the number of primitives. On the contrary,
 having many primitives is an advantage: speed. In order to reduce the  having many primitives has an advantage: speed. In order to reduce the
 number of errors in primitives and to make programming them easier, we  number of errors in primitives and to make programming them easier, we
 provide a tool, the primitive generator (@file{prims2x.fs}), that  provide a tool, the primitive generator (@file{prims2x.fs}), that
 automatically generates most (and sometimes all) of the C code for a  automatically generates most (and sometimes all) of the C code for a
 primitive from the stack effect notation.  The source for a primitive  primitive from the stack effect notation.  The source for a primitive
 has the following form:  has the following form:
   
   @cindex primitive source format
 @format  @format
 @var{Forth-name}        @var{stack-effect}      @var{category}  [@var{pronounc.}]  @var{Forth-name}        @var{stack-effect}      @var{category}  [@var{pronounc.}]
 [@code{""}@var{glossary entry}@code{""}]  [@code{""}@var{glossary entry}@code{""}]
Line 4122  fall through to NEXT. Line 4994  fall through to NEXT.
   
 @node TOS Optimization, Produced code, Automatic Generation, Primitives  @node TOS Optimization, Produced code, Automatic Generation, Primitives
 @subsection TOS Optimization  @subsection TOS Optimization
   @cindex TOS optimization for primitives
   @cindex primitives, keeping the TOS in a register
   
 An important optimization for stack machine emulators, e.g., Forth  An important optimization for stack machine emulators, e.g., Forth
 engines, is keeping  one or more of the top stack items in  engines, is keeping  one or more of the top stack items in
Line 4135  due to fewer loads from and stores to th Line 5009  due to fewer loads from and stores to th
 @var{y<n}, due to additional moves between registers.  @var{y<n}, due to additional moves between registers.
 @end itemize  @end itemize
   
   @cindex -DUSE_TOS
   @cindex -DUSE_NO_TOS
 In particular, keeping one item in a register is never a disadvantage,  In particular, keeping one item in a register is never a disadvantage,
 if there are enough registers. Keeping two items in registers is a  if there are enough registers. Keeping two items in registers is a
 disadvantage for frequent words like @code{?branch}, constants,  disadvantage for frequent words like @code{?branch}, constants,
Line 4147  otherwise it is a macro that expands int Line 5023  otherwise it is a macro that expands int
 GNU C compiler tries to keep simple variables like @code{TOS} in  GNU C compiler tries to keep simple variables like @code{TOS} in
 registers, and it usually succeeds, if there are enough registers.  registers, and it usually succeeds, if there are enough registers.
   
   @cindex -DUSE_FTOS
   @cindex -DUSE_NO_FTOS
 The primitive generator performs the TOS optimization for the  The primitive generator performs the TOS optimization for the
 floating-point stack, too (@code{-DUSE_FTOS}). For floating-point  floating-point stack, too (@code{-DUSE_FTOS}). For floating-point
 operations the benefit of this optimization is even larger:  operations the benefit of this optimization is even larger:
Line 4174  effect @code{--} no stores or loads shou Line 5052  effect @code{--} no stores or loads shou
   
 @node Produced code,  , TOS Optimization, Primitives  @node Produced code,  , TOS Optimization, Primitives
 @subsection Produced code  @subsection Produced code
   @cindex primitives, assembly code listing
   
   @cindex @file{engine.s}
 To see what assembly code is produced for the primitives on your machine  To see what assembly code is produced for the primitives on your machine
 with your compiler and your flag settings, type @code{make engine.s} and  with your compiler and your flag settings, type @code{make engine.s} and
 look at the resulting file @file{engine.s}.  look at the resulting file @file{engine.s}.
   
 @node System Architecture, Performance, Primitives, Internals  @node  Performance,  , Primitives, Engine
 @section System Architecture  
   
 Our Forth system consists not only of primitives, but also of  
 definitions written in Forth. Since the Forth compiler itself belongs  
 to those definitions, it is not possible to start the system with the  
 primitives and the Forth source alone. Therefore we provide the Forth  
 code as an image file in nearly executable form. At the start of the  
 system a C routine loads the image file into memory, sets up the  
 memory (stacks etc.) according to information in the image file, and  
 starts executing Forth code.  
   
 The image file format is a compromise between the goals of making it  
 easy to generate image files and making them portable. The easiest way  
 to generate an image file is to just generate a memory dump. However,  
 this kind of image file cannot be used on a different machine, or on  
 the next version of the engine on the same machine, it even might not  
 work with the same engine compiled by a different version of the C  
 compiler. We would like to have as few versions of the image file as  
 possible, because we do not want to distribute many versions of the  
 same image file, and to make it easy for the users to use their image  
 files on many machines. We currently need to create a different image  
 file for machines with different cell sizes and different byte order  
 (little- or big-endian)@footnote{We are considering adding information to the  
 image file that enables the loader to change the byte order.}.  
   
 Forth code that is going to end up in a portable image file has to  
 comply to some restrictions: addresses have to be stored in memory with  
 special words (@code{A!}, @code{A,}, etc.) in order to make the code  
 relocatable. Cells, floats, etc., have to be stored at the natural  
 alignment boundaries@footnote{E.g., store floats (8 bytes) at an address  
 divisible by~8. This happens automatically in our system when you use  
 the ANS Forth alignment words.}, in order to avoid alignment faults on  
 machines with stricter alignment. The image file is produced by a  
 metacompiler (@file{cross.fs}).  
   
 So, unlike the image file of Mitch Bradleys @code{cforth}, our image  
 file is not directly executable, but has to undergo some manipulations  
 during loading. Address relocation is performed at image load-time, not  
 at run-time. The loader also has to replace tokens standing for  
 primitive calls with the appropriate code-field addresses (or code  
 addresses in the case of direct threading).  
   
 @node  Performance,  , System Architecture, Internals  
 @section Performance  @section Performance
   @cindex performance of some Forth interpreters
   @cindex engine performance
   @cindex benchmarking Forth systems
   @cindex Gforth performance
   
 On RISCs the Gforth engine is very close to optimal; i.e., it is usually  On RISCs the Gforth engine is very close to optimal; i.e., it is usually
 impossible to write a significantly faster engine.  impossible to write a significantly faster engine.
Line 4236  and hand-tuned it for the 486; this syst Line 5077  and hand-tuned it for the 486; this syst
 Sieve benchmark on a 486DX2/66 than Gforth compiled with  Sieve benchmark on a 486DX2/66 than Gforth compiled with
 @code{gcc-2.6.3} with @code{-DFORCE_REG}.  @code{gcc-2.6.3} with @code{-DFORCE_REG}.
   
   @cindex Win32Forth performance
   @cindex NT Forth performance
   @cindex eforth performance
   @cindex ThisForth performance
   @cindex PFE performance
   @cindex TILE performance
 However, this potential advantage of assembly language implementations  However, this potential advantage of assembly language implementations
 is not necessarily realized in complete Forth systems: We compared  is not necessarily realized in complete Forth systems: We compared
 Gforth (direct threaded, compiled with @code{gcc-2.6.3} and  Gforth (direct threaded, compiled with @code{gcc-2.6.3} and
Line 4280  not written optimally for the 486 (e.g., Line 5127  not written optimally for the 486 (e.g.,
 instruction). In addition, Win32Forth uses a comfortable, but costly  instruction). In addition, Win32Forth uses a comfortable, but costly
 method for relocating the Forth image: like @code{cforth}, it computes  method for relocating the Forth image: like @code{cforth}, it computes
 the actual addresses at run time, resulting in two address computations  the actual addresses at run time, resulting in two address computations
 per NEXT (@pxref{System Architecture}).  per NEXT (@pxref{Image File Background}).
   
 Only Eforth with the peephole optimizer performs comparable to  Only Eforth with the peephole optimizer performs comparable to
 Gforth. The speedups achieved with peephole optimization of threaded  Gforth. The speedups achieved with peephole optimization of threaded
Line 4288  code are quite remarkable. Adding a peep Line 5135  code are quite remarkable. Adding a peep
 cause similar speedups.  cause similar speedups.
   
 The speedup of Gforth over PFE, ThisForth and TILE can be easily  The speedup of Gforth over PFE, ThisForth and TILE can be easily
 explained with the self-imposed restriction to standard C, which makes  explained with the self-imposed restriction of the latter systems to
 efficient threading impossible (however, the measured implementation of  standard C, which makes efficient threading impossible (however, the
 PFE uses a GNU C extension: @ref{Global Reg Vars, , Defining Global  measured implementation of PFE uses a GNU C extension: @ref{Global Reg
 Register Variables, gcc.info, GNU C Manual}).  Moreover, current C  Vars, , Defining Global Register Variables, gcc.info, GNU C Manual}).
 compilers have a hard time optimizing other aspects of the ThisForth  Moreover, current C compilers have a hard time optimizing other aspects
 and the TILE source.  of the ThisForth and the TILE source.
   
 Note that the performance of Gforth on 386 architecture processors  Note that the performance of Gforth on 386 architecture processors
 varies widely with the version of @code{gcc} used. E.g., @code{gcc-2.5.8}  varies widely with the version of @code{gcc} used. E.g., @code{gcc-2.5.8}
Line 4302  machine registers by itself and would no Line 5149  machine registers by itself and would no
 register declarations, giving a 1.3 times slower engine (on a 486DX2/66  register declarations, giving a 1.3 times slower engine (on a 486DX2/66
 running the Sieve) than the one measured above.  running the Sieve) than the one measured above.
   
   Note also that there have been several releases of Win32Forth since the
   release presented here, so the results presented here may have little
   predictive value for the performance of Win32Forth today.
   
   @cindex @file{Benchres}
 In @cite{Translating Forth to Efficient C} by M. Anton Ertl and Martin  In @cite{Translating Forth to Efficient C} by M. Anton Ertl and Martin
 Maierhofer (presented at EuroForth '95), an indirect threaded version of  Maierhofer (presented at EuroForth '95), an indirect threaded version of
 Gforth is compared with Win32Forth, NT Forth, PFE, and ThisForth; that  Gforth is compared with Win32Forth, NT Forth, PFE, and ThisForth; that
 version of Gforth is 2\%@minus{}8\% slower on a 486 than the version  version of Gforth is 2\%@minus{}8\% slower on a 486 than the version
 used here. The paper available at  used here. The paper available at
 @*@file{http://www.complang.tuwien.ac.at/papers/ertl&maierhofer95.ps.gz};  @*@file{http://www.complang.tuwien.ac.at/papers/ertl&maierhofer95.ps.gz};
 it also contains numbers for some native code systems. You can find  it also contains numbers for some native code systems. You can find a
 numbers for Gforth on various machines in @file{Benchres}.  newer version of these measurements at
   @file{http://www.complang.tuwien.ac.at/forth/performance.html}. You can
   find numbers for Gforth on various machines in @file{Benchres}.
   
 @node Bugs, Origin, Internals, Top  @node Bugs, Origin, Engine, Top
 @chapter Bugs  @chapter Bugs
   @cindex bug reporting
   
 Known bugs are described in the file BUGS in the Gforth distribution.  Known bugs are described in the file BUGS in the Gforth distribution.
   
Line 4321  If you find a bug, please send a bug rep Line 5176  If you find a bug, please send a bug rep
 describe the Gforth version used (it is announced at the start of an  describe the Gforth version used (it is announced at the start of an
 interactive Gforth session), the machine and operating system (on Unix  interactive Gforth session), the machine and operating system (on Unix
 systems you can use @code{uname -a} to produce this information), the  systems you can use @code{uname -a} to produce this information), the
 installation options (send the @code{config.status} file), and a  installation options (send the @file{config.status} file), and a
 complete list of changes you (or your installer) have made to the Gforth  complete list of changes you (or your installer) have made to the Gforth
 sources (if any); it should contain a program (or a sequence of keyboard  sources (if any); it should contain a program (or a sequence of keyboard
 commands) that reproduces the bug and a description of what you think  commands) that reproduces the bug and a description of what you think
Line 4335  to Report Bugs, gcc.info, GNU C Manual}. Line 5190  to Report Bugs, gcc.info, GNU C Manual}.
 @chapter Authors and Ancestors of Gforth  @chapter Authors and Ancestors of Gforth
   
 @section Authors and Contributors  @section Authors and Contributors
   @cindex authors of Gforth
   @cindex contributors to Gforth
   
 The Gforth project was started in mid-1992 by Bernd Paysan and Anton  The Gforth project was started in mid-1992 by Bernd Paysan and Anton
 Ertl. The third major author was Jens Wilke.  Lennart Benschop (who was  Ertl. The third major author was Jens Wilke.  Lennart Benschop (who was
Line 4351  was developed across the Internet, and i Line 5208  was developed across the Internet, and i
 physically yet.  physically yet.
   
 @section Pedigree  @section Pedigree
   @cindex Pedigree of Gforth
   
 Gforth descends from BigForth (1993) and fig-Forth. Gforth and PFE (by  Gforth descends from BigForth (1993) and fig-Forth. Gforth and PFE (by
 Dirk Zoller) will cross-fertilize each other. Of course, a significant  Dirk Zoller) will cross-fertilize each other. Of course, a significant
Line 4386  H. Moore, presented at the HOPL-II confe Line 5244  H. Moore, presented at the HOPL-II confe
 Notices 28(3), 1993.  You can find more historical and genealogical  Notices 28(3), 1993.  You can find more historical and genealogical
 information about Forth there.  information about Forth there.
   
 @node Word Index, Node Index, Origin, Top  @node Word Index, Concept Index, Origin, Top
 @chapter Word Index  @unnumbered Word Index
   
 This index is as incomplete as the manual. Each word is listed with  This index is as incomplete as the manual. Each word is listed with
 stack effect and wordset.  stack effect and wordset.
   
 @printindex fn  @printindex fn
   
 @node Node Index,  , Word Index, Top  @node Concept Index,  , Word Index, Top
 @chapter Node Index  @unnumbered Concept and Word Index
   
   This index is as incomplete as the manual. Not all entries listed are
   present verbatim in the text. Only the names are listed for the words
   here.
   
 This index is even less complete than the manual.  @printindex cp
   
 @contents  @contents
 @bye  @bye

Removed from v.1.42  
changed lines
  Added in v.1.43


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>