| @cite{Forth: The new model} by Jack Woehr (Prentice-Hall, 1993) is an |
@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 Committe). 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. |
| |
|
| |
|
| 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 seqence |
@code{-e @var{forth-code}} options that are interpreted in the sequence |
| in which they are given. The @code{-e @var{forth-code}} or |
in which they are given. The @code{-e @var{forth-code}} or |
| @code{--evaluate @var{forth-code}} option evaluates the forth |
@code{--evaluate @var{forth-code}} option evaluates the forth |
| code. This option takes only one argument; if you want to evaluate more |
code. This option takes only one argument; if you want to evaluate more |
| 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 |
| by a signed integer (the exponent). E.g., @code{1e} ist the same as |
by a signed integer (the exponent). E.g., @code{1e} is the same as |
| @code{+1.0e+0}. Note that a number without @code{e} |
@code{+1.0e+0}. Note that a number without @code{e} |
| is not interpreted as floating-point number, but as double (if the |
is not interpreted as floating-point number, but as double (if the |
| number contains a @code{.}) or single precision integer. Also, |
number contains a @code{.}) or single precision integer. Also, |
| with @code{W:}, @code{D:} etc.) produces its value and can be changed |
with @code{W:}, @code{D:} etc.) produces its value and can be changed |
| with @code{TO}. A variable-flavoured local (defined with @code{W^} etc.) |
with @code{TO}. A variable-flavoured local (defined with @code{W^} etc.) |
| produces its address (which becomes invalid when the variable's scope is |
produces its address (which becomes invalid when the variable's scope is |
| left). E.g., the standard word @code{emit} can be defined in therms of |
left). E.g., the standard word @code{emit} can be defined in terms of |
| @code{type} like this: |
@code{type} like this: |
| |
|
| @example |
@example |
| two independent control flow paths? |
two independent control flow paths? |
| |
|
| This should be enough detail for nearly all users, so you can skip the |
This should be enough detail for nearly all users, so you can skip the |
| rest of this section. If you relly must know all the gory details and |
rest of this section. If you really must know all the gory details and |
| options, read on. |
options, read on. |
| |
|
| In order to implement this rule, the compiler has to know which places |
In order to implement this rule, the compiler has to know which places |
| @code{BEGIN}...@code{UNTIL} loops and it is implemented in our |
@code{BEGIN}...@code{UNTIL} loops and it is implemented in our |
| compiler. When the branch to the @code{BEGIN} is finally generated by |
compiler. When the branch to the @code{BEGIN} is finally generated by |
| @code{AGAIN} or @code{UNTIL}, the compiler checks the guess and |
@code{AGAIN} or @code{UNTIL}, the compiler checks the guess and |
| warns the user if it was too optimisitic: |
warns the user if it was too optimistic: |
| @example |
@example |
| IF |
IF |
| @{ x @} |
@{ x @} |
| @code{CREATE..DOES>}. E.g., an assembler usually defines several words |
@code{CREATE..DOES>}. E.g., an assembler usually defines several words |
| that look very similar: |
that look very similar: |
| @example |
@example |
| : ori, ( reg-taget reg-source n -- ) |
: ori, ( reg-target reg-source n -- ) |
| 0 asm-reg-reg-imm ; |
0 asm-reg-reg-imm ; |
| : andi, ( reg-taget reg-source n -- ) |
: andi, ( reg-target reg-source n -- ) |
| 1 asm-reg-reg-imm ; |
1 asm-reg-reg-imm ; |
| @end example |
@end example |
| |
|
| @example |
@example |
| : reg-reg-imm ( op-code -- ) |
: reg-reg-imm ( op-code -- ) |
| create , |
create , |
| DOES> ( reg-taget reg-source n -- ) |
DOES> ( reg-target reg-source n -- ) |
| @@ asm-reg-reg-imm ; |
@@ asm-reg-reg-imm ; |
| |
|
| 0 reg-reg-imm ori, |
0 reg-reg-imm ori, |
| DOES> |
DOES> |
| @var{code} ; |
@var{code} ; |
| @end example |
@end example |
| This is equivalwent to the standard |
This is equivalent to the standard |
| @example |
@example |
| :noname |
:noname |
| DOES> |
DOES> |
| |
|
| At present, the @var{w} part of a compilation token is an execution |
At present, the @var{w} part of a compilation token is an execution |
| token, and the @var{xt} part represents either @code{execute} or |
token, and the @var{xt} part represents either @code{execute} or |
| @code{compile,}. However, don't rely on that kowledge, unless necessary; |
@code{compile,}. However, don't rely on that knowledge, unless necessary; |
| 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). |
| |
|
| tracing/stepping debuggers used in languages with long turn-around |
tracing/stepping debuggers used in languages with long turn-around |
| times. |
times. |
| |
|
| A much better (faster) way in fast-compilig languages is to add |
A much better (faster) way in fast-compiling languages is to add |
| printing code at well-selected places, let the program run, look at |
printing code at well-selected places, let the program run, look at |
| the output, see where things went wrong, add more printing code, etc., |
the output, see where things went wrong, add more printing code, etc., |
| until the bug is found. |
until the bug is found. |
| 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: |
| The next invocation of a parsing word returns a string wih 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>}: |
| 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. |
| THROW}. |
THROW}. |
| |
|
| In the future, Gforth may be able to restore input source specifications |
In the future, Gforth may be able to restore input source specifications |
| from other than the current input soruce. |
from other than the current input source. |
| |
|
| @item data space containing definitions gets de-allocated: |
@item data space containing definitions gets de-allocated: |
| Deallocation with @code{allot} is not checked. This typically resuls 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: |
| @table @i |
@table @i |
| |
|
| @item encoding of keyboard events (@code{EKEY}): |
@item encoding of keyboard events (@code{EKEY}): |
| Not yet implemeted. |
Not yet implemented. |
| |
|
| @item duration of a system clock tick |
@item duration of a system clock tick |
| System dependent. With respect to @code{MS}, the time is specified in |
System dependent. With respect to @code{MS}, the time is specified in |
| @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: |
| Largely terminal dependant. 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. |
| |
|
| @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 retured 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: |
| All files that are left via the exception are closed. |
All files that are left via the exception are closed. |
| 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. Leaving |
| a cell unused in most words is a bit wasteful, but on the machines we |
a cell unused in most words is a bit wasteful, but on the machines we |
| are targetting this is hardly a problem. The other reason for having a |
are targeting this is hardly a problem. The other reason for having a |
| code field size of two cells is to avoid having different image files |
code field size of two cells is to avoid having different image files |
| for direct and indirect threaded systems (@pxref{System Architecture}). |
for direct and indirect threaded systems (@pxref{System Architecture}). |
| |
|
| special words (@code{A!}, @code{A,}, etc.) in order to make the code |
special words (@code{A!}, @code{A,}, etc.) in order to make the code |
| relocatable. Cells, floats, etc., have to be stored at the natural |
relocatable. Cells, floats, etc., have to be stored at the natural |
| alignment boundaries@footnote{E.g., store floats (8 bytes) at an address |
alignment boundaries@footnote{E.g., store floats (8 bytes) at an address |
| dividable by~8. This happens automatically in our system when you use |
divisible by~8. This happens automatically in our system when you use |
| the ANS Forth alignment words.}, in order to avoid alignment faults on |
the ANS Forth alignment words.}, in order to avoid alignment faults on |
| machines with stricter alignment. The image file is produced by a |
machines with stricter alignment. The image file is produced by a |
| metacompiler (@file{cross.fs}). |
metacompiler (@file{cross.fs}). |
| implementation of fig-Forth for the 6502 based on microForth. |
implementation of fig-Forth for the 6502 based on microForth. |
| |
|
| The principal architect of microForth was Dean Sanderson. microForth was |
The principal architect of microForth was Dean Sanderson. microForth was |
| FORTH, Inc.'s first off-the-shelf product. It was developped in 1976 for |
FORTH, Inc.'s first off-the-shelf product. It was developed in 1976 for |
| the 1802, and subsequently implemented on the 8080, the 6800 and the |
the 1802, and subsequently implemented on the 8080, the 6800 and the |
| Z80. |
Z80. |
| |
|