Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 (Tek) 9/26/83; site tekchips.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!zehntel!hplabs!tektronix!tekchips!toma
From: toma@tekchips.UUCP (Tom Almy)
Newsgroups: net.lang.forth
Subject: Re: Speaking of Princeton
Message-ID: <112@tekchips.UUCP>
Date: Fri, 21-Sep-84 11:09:48 EDT
Article-I.D.: tekchips.112
Posted: Fri Sep 21 11:09:48 1984
Date-Received: Wed, 26-Sep-84 02:21:08 EDT
References: <3033@utah-cs.UUCP>, <128@cadovax.UUCP>
Organization: Tektronix, Beaverton OR
Lines: 47

----------
I have "solved" all the problems presented in the Forth I run under UNIX
(it is Forth-79 which I implemented, written in assembly and Forth like the
fig Model).

Q1: How do I implement ?TERMINAL
A1: Some UNIX systems have an IOCTL call to tell if a key has been typed.  Since
    the system I run on doesn't, I use the signal facility to catch control-C's.
    One control-C causes ?TERMINAL to return TRUE, while two in a row (before
    KEY is executed) will cause execution to abort and return to the outer
    interpreter loop.  This works quite well.

Q2: How do I implement Eaker's Case without droping to assembly language?
A2: The originally published description was in high level.  If you only have
    a version showing a code word, (OF), then use this version of OF instead:
    : OF   4 ?PAIRS COMPILE OVER COMPILE = COMPILE 0BRANCH
      HERE 0 , COMPILE DROP  5 ; IMMEDIATE
    All of the other words remain the same.  You may have to alter this if
    yours is not a standard fig-Forth system.

Q3: How do I save the Forth image for later execution?
A3: This is conceptually simple, but in practice the code must be tailored
    for the system (each system I have has to do this with different code).
    1. The origin table must be patched so that upon a cold start the initial
       dictionary pointer, fence, etc., will be correct (so that the application
       will appear present).
    2. Creat a new file (I use "f.out" on unix).  Write to it the file header
       necessary for proper loading (this is system dependent).  The header
       contains the "magic number" and the sizes of the code data and bss
       segments.
    3. Write out the image.
    4. Close the file.

    I have successfully done this for V7 UNIX, our internal UNIX implementation
for a 68000 system here at Tektronix, CP/M 68k (which has executable files that
look suspiciously like UNIX), and CP/M 86.

	Of course the major problem with my solutions for Q1 and Q3 is that you
have to be able to do UNIX system calls.  If you don't have that ability then
you must add a CODE word to do it.  Mine takes the call number and a pointer
to the argument structure as arguments, thus it can do any system call.  I
add another layer to give functions which match section II of the UNIX manual.

Tom Almy
Tektronix Inc
(many hub systems)!tektronix!tekchips!toma