[comp.lang.forth] Forth Interpreter Source Code

lawitzke@eecae.UUCP (John Lawitzke) (12/01/87)

> 	A 68020-based interpreter in a SUN environment would make my day.

The SUN User Group Tape that was distrtibuted in 1985 (I believe)
contains a Forth Interpreter with Source Code (I haven't looked at it
close enough to say if all the source is there) Since I have a copy
of this and the README file claims it is public domain, I can
provide a copy of it to you. Please respond via e-mail if interested.

The following is the README file which contains a description of the
interpreter:
=====================================================================


		68000 Unix Forth-83

NOTE:  This software is provided with no guarantee of any support whatsover.
I am willing to answer questions so long as the time I spend doing so
does not interfere with other work.
Suggestions for improvement are welcome, and the code to implement said
improvement is even more welcome.

This directory tree contains source code (*.f) and binaries (*.exe) for the
Unix version of F83.  F83 is a public-domain version of Forth which
conforms to the Forth-83 standard.  F83 was originally written by Michael
Perry and Henry Laxen.  This 68000 Unix version was written by Mitch Bradley,
using the Perry/Laxen version as a starting point.
It has been extended significantly over the original F83, including

a) A full 32-bit implementation
b) Files
c) Floating Point
d) Exception handling
e) Some string functions
f) More powerful terminal control.
g) An emacs-style command line editor
h) Stand-alone capability
i) structured decompilation of conditionals

There are three Unix versions:
a) 16-bit stacks, 16-bit compiled relative addresses
b) 32-bit stacks, 16-bit compiled relative addresses
c) 32-bit stacks, 32-bit compiled absolute addresses

Version c) is the one that I normally use.  The same source code can
be made to generate any of these 3 versions.  All of the already-compiled
forth files (.exe) that you find herein are for version c).

This system should run on any Sun Unix release.  It will probably also
run on just about any 68000 Unix system, perhaps requiring a few mods
to wrapper.c (and almost certainly requiring recompilation of wrapper.c)

This Unix version diverges from the other Laxen/Perry versions in a few ways.

1) Versions a) and b) are relocatable to any 64K boundary.
   The Laxen and Perry CP/M-68K version is not.
   This change is necessary and desireable for some versions of Unix.
   One of the implications is that branching words take relative offsets,
   as opposed to absolute branch targets as in the original version.

2) All variables in the kernel are user variables instead of being stored
   in the dictionary.  The vocabulary threads are similarly kept in the
   user area.  This makes the system completely ROM-able.  This feature
   has never been used.  Instead, the versions I have which are stored
   in ROM copy themselves to RAM for execution.

3) Multi-tasking is not implemented in version a). (it is implemented
   in versions b and c).

4) The editor is not implemented.  This would be easy, except that BLOCK
   is not implemented either.  Block would be easy to implement, but I
   haven't done so, preferring to use real files.  A portable interface
   to Unix files is provided (see the subdirectory "files.dir"), and
   the available Unix editors are much better than any Forth editor that
   I have ever seen, so I have little motivation to use BLOCKs.
   If you must use blocks, you should be able to make the Laxen and
   Perry BLOCK code work.  Look in original.dir to find the original
   Laxen/Perry code.

5) The printer control words are not implemented.  Unix already has
   better facilities for printing.

Getting started:

  You need to install some files:
     cp ./forth /usr/local
     mkdir /usr/local/lib/forth
     cp kernel.dir/files.exe /usr/local/lib/forth
     cp lib/* /usr/local/lib/forth

  Add to your .login file:
     setenv FPATH .:/usr/local/lib/forth

  To run forth, type to the shell (or the csh):

     forth

  "bye" will get you out.  All words are recognized in lower case only.
  If you want to use upper case, execute "caps on" from inside forth.
  This will cause input to be recognized in either upper case or lower
  case.  Also, it will cause new definitions to be created in lower case,
  regardless of the case that was typed.
  
  See the file "./doc/forth.nr" for additional command-line options.

  If the first command-line argument ends in ".exe", that is taken
  to be the name of the forth binary to use.  This is useful for
  running forth systems that have pre-compiled applications that
  have been "snapshotted".

  Lots of semi-random documentation is in ./doc

Regenerating the system:

  There are "Makefile"s in various subdirectories.  Executing "make" in
  the topmost directory will recompile the wrapper.c program, yielding
  a new "forth" program.

  Executing "make" in ./kernel.dir will recompile the whole forth system.
  You shouldn't have to do this, unless you want to change the kernel.

Conventions:

  Files whose names end in ".f" are forth source code.
  Files whose names end in ".exe" are forth binary code (dictionary images).
  Files whose names end in ".dir" are directories.
    
Implementation details:

  See "./doc/implementation.doc".

Use on versions of Unix other than 4.2BSD:

  See the file "./doc/porting.doc" for hints on how to make this run on
  different Unix implementations.

Directories:

  kernel.dir:   Kernel code
  doc		A mish-mash of Forth documentation, including some
  		of the papers I've written about Forth.
  lib		A library of utility packages in source code form.
  		Some of the utilities are already compiled into the
		default dictionary (files.exe).
  doc/files     Documentation for the file system interface.
  cpu.dir	Code to access grotty low-level hardware functions
  		only accessible when running stand-alone 
  files.dir	The portable file system interface.
  files.dir/cpm CP/M version of the above.
  stand.dir	Utilities for use when running stand-alone on a
  		Sun Workstation under the Sun PROM Monitor.
  stand.ast.dir	Stand-alone code for running on other 68000 machines
  original.dir	Perry/Laxen F83 distribution for 8080 (version 1)
  f83ms.dir	Perry/Laxen F83 distribution for MS-DOS (version 2)
  test.dir	Test programs to verify and illustrate the use of
  		some of the utility packages.

May the FORTH be with you!

Mitch Bradley

415/960-7243     (Office)
415/961-1302     (Home)

USENET: decvax!decwrl!sun!wmb
==============================end or README=========================
-- 
j                                UUCP: ...ihnp4!msudoc!eecae!lawitzke
"And it's just a box of rain..." ARPA: lawitzke@eecae.ee.msu.edu  (35.8.8.151)