version 1.33, 1996/05/13 16:36:56
|
version 1.34, 1996/08/21 14:58:40
|
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 2184 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 2203 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 3212 are applied to the latest defined word (
|
Line 3213 are applied to the latest defined word (
|
|
|
@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 |
Line 3549 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 3583 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 3785 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 |