Diff for /gforth/Attic/gforth.ds between versions 1.30 and 1.34

version 1.30, 1996/01/25 16:45:50 version 1.34, 1996/08/21 14:58:40
Line 9 Line 9
 @ifinfo  @ifinfo
 This file documents Gforth 0.2  This file documents Gforth 0.2
   
 Copyright @copyright{} 1995 Free Software Foundation, Inc.  Copyright @copyright{} 1995,1996 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 51  Copyright @copyright{} 1995 Free Softwar Line 51  Copyright @copyright{} 1995 Free Softwar
 @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 Free Software Foundation, Inc.  Copyright @copyright{} 1995,1996 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 88  personal machines. This manual correspon Line 88  personal machines. This manual correspon
 * Words::                       Forth words available in Gforth  * Words::                       Forth words available in Gforth
 * 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.
 * Emacs and Gforth::            The Gforth Mode  * Emacs and Gforth::            The Gforth Mode
 * Internals::                   Implementation details  * Internals::                   Implementation details
 * Bugs::                        How to report them  * Bugs::                        How to report them
Line 1141  system that only supplies @code{THEN} is Line 1142  system that only supplies @code{THEN} is
 Forth's @code{THEN} has the meaning 2b, whereas @code{THEN} in Pascal  Forth's @code{THEN} has the meaning 2b, whereas @code{THEN} in Pascal
 and many other programming languages has the meaning 3d.]  and many other programming languages has the meaning 3d.]
   
 We also provide the words @code{?dup-if} and @code{?dup-0=-if}, so you  Gforth also provides the words @code{?dup-if} and @code{?dup-0=-if}, so
 can avoid using @code{?dup}.  you can avoid using @code{?dup}. Using these alternatives is also more
   efficient than using @code{?dup}. Definitions in plain standard Forth
   for @code{ENDIF}, @code{?DUP-IF} and @code{?DUP-0=-IF} are provided in
   @file{compat/control.fs}.
   
 @example  @example
 @var{n}  @var{n}
Line 1325  doc-else Line 1329  doc-else
 doc-while  doc-while
 doc-repeat  doc-repeat
   
   Gforth adds some more control-structure words:
   
   doc-endif
   doc-?dup-if
   doc-?dup-0=-if
   
 Counted loop words constitute a separate group of words:  Counted loop words constitute a separate group of words:
   
 doc-?do  doc-?do
Line 1724  E.g., a definition using @code{TO} might Line 1734  E.g., a definition using @code{TO} might
 : strcmp @{ addr1 u1 addr2 u2 -- n @}  : strcmp @{ addr1 u1 addr2 u2 -- n @}
  u1 u2 min 0   u1 u2 min 0
  ?do   ?do
    addr1 c@ addr2 c@ - ?dup     addr1 c@ addr2 c@ -
    if     ?dup-if
      unloop exit       unloop exit
    then     then
    addr1 char+ TO addr1     addr1 char+ TO addr1
Line 1747  are initialized with the right value for Line 1757  are initialized with the right value for
  addr1 addr2   addr1 addr2
  u1 u2 min 0    u1 u2 min 0 
  ?do @{ s1 s2 @}   ?do @{ s1 s2 @}
    s1 c@ s2 c@ - ?dup      s1 c@ s2 c@ -
    if     ?dup-if
      unloop exit       unloop exit
    then     then
    s1 char+ s2 char+     s1 char+ s2 char+
Line 2175  use @code{>DOES-CODE}. Line 2185  use @code{>DOES-CODE}.
 To the best of our knowledge, Gforth is an  To the best of our knowledge, Gforth is an
   
 ANS Forth System  ANS Forth System
 @itemize  @itemize @bullet
 @item providing the Core Extensions word set  @item providing the Core Extensions word set
 @item providing the Block word set  @item providing the Block word set
 @item providing the Block Extensions word set  @item providing the Block Extensions word set
Line 2194  ANS Forth System Line 2204  ANS Forth System
 @item providing the Memory-Allocation word set  @item providing the Memory-Allocation word set
 @item providing the Memory-Allocation Extensions word set (that one's easy)  @item providing the Memory-Allocation Extensions word set (that one's easy)
 @item providing the Programming-Tools word set  @item providing the Programming-Tools word set
 @item providing @code{;code}, @code{AHEAD}, @code{ASSEMBLER}, @code{BYE}, @code{CODE}, @code{CS-PICK}, @code{CS-ROLL}, @code{STATE}, @code{[ELSE]}, @code{[IF]}, @code{[THEN]} from the Programming-Tools Extensions word set  @item providing @code{;CODE}, @code{AHEAD}, @code{ASSEMBLER}, @code{BYE}, @code{CODE}, @code{CS-PICK}, @code{CS-ROLL}, @code{STATE}, @code{[ELSE]}, @code{[IF]}, @code{[THEN]} from the Programming-Tools Extensions word set
 @item providing the Search-Order word set  @item providing the Search-Order word set
 @item providing the Search-Order Extensions word set  @item providing the Search-Order Extensions word set
 @item providing the String word set  @item providing the String word set
Line 3189  Not implemented (yet). Line 3199  Not implemented (yet).
 @table @i  @table @i
   
 @item changing the compilation wordlist (during compilation):  @item changing the compilation wordlist (during compilation):
 The definition is put into the wordlist that is the compilation wordlist  The word is entered into the wordlist that was the compilation wordlist
 when @code{REVEAL} is executed (by @code{;}, @code{DOES>},  at the start of the definition. Any changes to the name field (e.g.,
 @code{RECURSIVE}, etc.).  @code{immediate}) or the code field (e.g., when executing @code{DOES>})
   are applied to the latest defined word (as reported by @code{last} or
   @code{lastxt}), if possible, irrespective of the compilation wordlist.
   
 @item search order empty (@code{previous}):  @item search order empty (@code{previous}):
 @code{abort" Vocstack empty"}.  @code{abort" Vocstack empty"}.
Line 3201  when @code{REVEAL} is executed (by @code Line 3213  when @code{REVEAL} is executed (by @code
   
 @end table  @end table
   
   @node Model, Integrating Gforth, ANS conformance, Top
 @node Model, Emacs and Gforth, ANS conformance, Top  
 @chapter Model  @chapter Model
   
 @node Emacs and Gforth, Internals, Model, Top  This chapter has yet to be written. It will contain information, on
   which internal structures you can rely.
   
   @node Integrating Gforth, Emacs and Gforth, Model, Top
   @chapter Integrating Gforth into C programs
   
   This is not yet implemented.
   
   Several people like to use Forth as scripting language for applications
   that are otherwise written in C, C++, or some other language.
   
   The Forth system ATLAST provides facilities for embedding it into
   applications; unfortunately it has several disadvantages: most
   implorantly, it is not based on ANS Forth, and it is apparently dead
   (i.e., not developed further and not supported). The facilities
   provided by Gforth in this area are inspired by ATLASTs facilities, so
   making the switch should not be hard.
   
   We also tried to design the interface such that it can easily be
   implemented by other Forth systems, so that we may one day arrive at a
   standardized interface. Such a standard interface would allow you to
   replace the Forth system without having to rewrite C code.
   
   You embed the Gforth interpreter by linking with the library
   @code{libgforth.a} (give the compiler the option @code{-lgforth}).  All
   global symbols in this library that belong to the interface, have the
   prefix @code{forth_}. (Global symbols that are used internally have the
   prefix @code{gforth_}).
   
   You can include the declarations of Forth types and the functions and
   variables of the interface with @code{include <forth.h>}.
   
   Types.
   
   Variables.
   
   Data and FP Stack pointer. Area sizes.
   
   functions.
   
   forth_init(imagefile)
   forth_evaluate(string) exceptions?
   forth_goto(address) (or forth_execute(xt)?)
   forth_continue() (a corountining mechanism)
   
   Adding primitives.
   
   No checking.
   
   Signals?
   
   Accessing the Stacks
   
   @node Emacs and Gforth, Internals, Integrating Gforth, Top
 @chapter Emacs and Gforth  @chapter Emacs and Gforth
   
 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 (icluded 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
 indentation. I have also added comment paragraph filling (@kbd{M-q}),  indentation. I have also added comment paragraph filling (@kbd{M-q}),
 commenting (@kbd{C-x \}) and uncommenting (@kbd{C-u C-x \}) regions and  commenting (@kbd{C-x \}) and uncommenting (@kbd{C-u C-x \}) regions and
Line 3234  several tags files at the same time (e.g Line 3298  several tags files at the same time (e.g
 and one for your program, @pxref{Select Tags Table,,Selecting a Tags  and one for your program, @pxref{Select Tags Table,,Selecting a Tags
 Table,emacs, Emacs Manual}). The TAGS file for the preloaded words is  Table,emacs, Emacs Manual}). The TAGS file for the preloaded words is
 @file{$(datadir)/gforth/$(VERSION)/TAGS} (e.g.,  @file{$(datadir)/gforth/$(VERSION)/TAGS} (e.g.,
 @file{/usr/local/share/gforth/0.2/TAGS}).  @file{/usr/local/share/gforth/0.2.0/TAGS}).
   
 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 3289  limitations: GNU C, the version of C pro Line 3353  limitations: GNU C, the version of C pro
 GNU C Manual}). Its labels as values feature (@pxref{Labels as Values, ,  GNU C Manual}). Its labels as values feature (@pxref{Labels as Values, ,
 Labels as Values, gcc.info, GNU C Manual}) makes direct and indirect  Labels as Values, gcc.info, GNU C Manual}) makes direct and indirect
 threading possible, its @code{long long} type (@pxref{Long Long, ,  threading possible, its @code{long long} type (@pxref{Long Long, ,
 Double-Word Integers, gcc.info, GNU C Manual}) corresponds to Forths  Double-Word Integers, gcc.info, GNU C Manual}) corresponds to Forth's
 double numbers. GNU C is available for free on all important (and many  double numbers@footnote{Unfortunately, long longs are not implemented
 unimportant) UNIX machines, VMS, 80386s running MS-DOS, the Amiga, and  properly on all machines (e.g., on alpha-osf1, long longs are only 64
 the Atari ST, so a Forth written in GNU C can run on all these  bits, the same size as longs (and pointers), but they should be twice as
 machines.  long according to @ref{Long Long, , Double-Word Integers, gcc.info, GNU
   C Manual}). So, we had to implement doubles in C after all. Still, on
   most machines we can use long longs and achieve better performance than
   with the emulation package.}. GNU C is available for free on all
   important (and many unimportant) UNIX machines, VMS, 80386s running
   MS-DOS, the Amiga, and the Atari ST, so a Forth written in GNU C can run
   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
Line 3532  An important optimization for stack mach Line 3602  An important optimization for stack mach
 engines, is keeping  one or more of the top stack items in  engines, is keeping  one or more of the top stack items in
 registers.  If a word has the stack effect @var{in1}...@var{inx} @code{--}  registers.  If a word has the stack effect @var{in1}...@var{inx} @code{--}
 @var{out1}...@var{outy}, keeping the top @var{n} items in registers  @var{out1}...@var{outy}, keeping the top @var{n} items in registers
 @itemize  @itemize @bullet
 @item  @item
 is better than keeping @var{n-1} items, if @var{x>=n} and @var{y>=n},  is better than keeping @var{n-1} items, if @var{x>=n} and @var{y>=n},
 due to fewer loads from and stores to the stack.  due to fewer loads from and stores to the stack.
Line 3566  The TOS optimization makes the automatic Line 3636  The TOS optimization makes the automatic
 bit more complicated. Just replacing all occurrences of @code{sp[0]} by  bit more complicated. Just replacing all occurrences of @code{sp[0]} by
 @code{TOS} is not sufficient. There are some special cases to  @code{TOS} is not sufficient. There are some special cases to
 consider:  consider:
 @itemize  @itemize @bullet
 @item In the case of @code{dup ( w -- w w )} the generator must not  @item In the case of @code{dup ( w -- w w )} the generator must not
 eliminate the store to the original location of the item on the stack,  eliminate the store to the original location of the item on the stack,
 if the TOS optimization is turned on.  if the TOS optimization is turned on.
Line 3648  Gforth (direct threaded, compiled with @ Line 3718  Gforth (direct threaded, compiled with @
 1994) and Eforth (with and without peephole (aka pinhole) optimization  1994) and Eforth (with and without peephole (aka pinhole) optimization
 of the threaded code); all these systems were written in assembly  of the threaded code); all these systems were written in assembly
 language. We also compared Gforth with three systems written in C:  language. We also compared Gforth with three systems written in C:
 PFE-0.9.11 (compiled with @code{gcc-2.6.3} with the default  PFE-0.9.14 (compiled with @code{gcc-2.6.3} with the default
 configuration for Linux: @code{-O2 -fomit-frame-pointer -DUSE_REGS}),  configuration for Linux: @code{-O2 -fomit-frame-pointer -DUSE_REGS
 ThisForth Beta (compiled with gcc-2.6.3 -O3 -fomit-frame-pointer;  -DUNROLL_NEXT}), ThisForth Beta (compiled with gcc-2.6.3 -O3
 ThisForth employs peephole optimization of the threaded code) and TILE  -fomit-frame-pointer; ThisForth employs peephole optimization of the
 (compiled with @code{make opt}). We benchmarked Gforth, PFE, ThisForth  threaded code) and TILE (compiled with @code{make opt}). We benchmarked
 and TILE on a 486DX2/66 under Linux. Kenneth O'Heskin kindly provided  Gforth, PFE, ThisForth and TILE on a 486DX2/66 under Linux. Kenneth
 the results for Win32Forth and NT Forth on a 486DX2/66 with similar  O'Heskin kindly provided the results for Win32Forth and NT Forth on a
 memory performance under Windows NT. Marcel Hendrix ported Eforth to  486DX2/66 with similar memory performance under Windows NT. Marcel
 Linux, then extended it to run the benchmarks, added the peephole  Hendrix ported Eforth to Linux, then extended it to run the benchmarks,
 optimizer, ran the benchmarks and reported the results.  added the peephole optimizer, ran the benchmarks and reported the
   results.
     
 We used four small benchmarks: the ubiquitous Sieve; bubble-sorting and  We used four small benchmarks: the ubiquitous Sieve; bubble-sorting and
 matrix multiplication come from the Stanford integer benchmarks and have  matrix multiplication come from the Stanford integer benchmarks and have
Line 3671  factor that Gforth achieved over the oth Line 3742  factor that Gforth achieved over the oth
 @example  @example
 relative      Win32-    NT       eforth       This-  relative      Win32-    NT       eforth       This-
   time  Gforth Forth Forth eforth  +opt   PFE Forth  TILE    time  Gforth Forth Forth eforth  +opt   PFE Forth  TILE
 sieve     1.00  1.39  1.14   1.39  0.85  1.78  3.18  8.58  sieve     1.00  1.39  1.14   1.39  0.85  1.58  3.18  8.58
 bubble    1.00  1.31  1.41   1.48  0.88  1.67        3.88  bubble    1.00  1.31  1.41   1.48  0.88  1.50        3.88
 matmul    1.00  1.47  1.35   1.46  1.16  2.36        4.09  matmul    1.00  1.47  1.35   1.46  1.16  1.58        4.09
 fib       1.00  1.52  1.34   1.22  1.13  1.93  2.99  4.30  fib       1.00  1.52  1.34   1.22  1.13  1.74  2.99  4.30
 @end example  @end example
   
 You may find the good performance of Gforth compared with the systems  You may find the good performance of Gforth compared with the systems
Line 3721  numbers for Gforth on various machines i Line 3792  numbers for Gforth on various machines i
 Known bugs are described in the file BUGS in the Gforth distribution.  Known bugs are described in the file BUGS in the Gforth distribution.
   
 If you find a bug, please send a bug report to  If you find a bug, please send a bug report to
 @code{gforth-bugs@@mips.complang.tuwien.ac.at}. A bug report should  @code{bug-gforth@@gnu.ai.mit.edu}. A bug report should
 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
Line 3767  VolksForth descends from F83. It was wri Line 3838  VolksForth descends from F83. It was wri
 Pennemann, Georg Rehfeld and Dietrich Weineck for the C64 (called  Pennemann, Georg Rehfeld and Dietrich Weineck for the C64 (called
 UltraForth there) in the mid-80s and ported to the Atari ST in 1986.  UltraForth there) in the mid-80s and ported to the Atari ST in 1986.
   
 Hennry Laxen and Mike Perry wrote F83 as a model implementation of the  Henry Laxen and Mike Perry wrote F83 as a model implementation of the
 Forth-83 standard. !! Pedigree? When?  Forth-83 standard. !! Pedigree? When?
   
 A team led by Bill Ragsdale implemented fig-Forth on many processors in  A team led by Bill Ragsdale implemented fig-Forth on many processors in

Removed from v.1.30  
changed lines
  Added in v.1.34


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