FILE NAME:  Hash_Quit.4th
faster download kernel extension for forth programmers
copyright 2002 Mosaic Industries, Inc.  All rights reserved.
---------------------------------------------------------------------
DATE:        9/04/2002
VERSION:     1.0, for QED4 (WildCard Carrier Board recommended to provide
             extra RAM).
---------------------------------------------------------------------
Revised by JLW: 9/26/2003   - Made changes to accommodate kernel extension
 system; moved redefinitions to inline forth.  This fixed the problem
 of setting ; to immediate.  Now it is set immediate in the inline forth.



This program implements a faster compiling version of the Forth interpreter.
Speed is improved by implementing a hash table indexed by the count and first
byte of the name.  The hash table is a 1-dimensional array of vocabulary
xhandles whose contents point to the top NFA in the corresponding linked
list; all of the entries in the particular linked list have the same count
and first byte (see below for exceptions).

Recall that the search vocabulary CONTEXT is searched first, and CURRENT (to
which new definitions are added) is searched second. A new version of
INTERPRET that looks up the hash table contents and sets CONTEXT accordingly
is implemented; this requires a new version of QUIT called FASTQUIT . Install
FASTQUIT as an autostart routine or invoke it at the forth prompt to use the
hash-based compiler. If you do not install FASTQUIT as an autostart or
priority.autostart routine, any ABORT will revert to the standard QUIT
interpreter.

A BUILD_HASH routine builds in RAM a version of the CURRENT vocabulary (which
is the vocabulary topped by LATEST).  New versions of the following will add
entries to the CURRENT vocabulary as well as the hash table:

; END.CODE  VARIABLE  2VARIABLE  XVARIABLE  FVARIABLE
CONSTANT 2CONSTANT XCONSTANT  FCONSTANT
ADDR: ARRAY: DOUBLE: INTEGER: REAL: REGISTER: XADDR:

We suppress the hash while the assembler is the CONTEXT vocabulary.

Key Top level routines:
Allocate_Hash  ( xstart\xend -- )
Build_Hash ( -- )
Setup_Hash ( -- )
FASTQUIT   ( -- )

