29 FEB 2000

TRS-80 CamelForth v1.03 -- Enhanced to support LS-DOS host

    P! and P@ commands for port I/O
    SVC  -- TRSDOS/LS-DOS Supervisor Call

    changed EMIT, KEY?, and KEY to vectored high-level
    colon definitions, which call (EMIT), (KEY?), and (KEY).

This allows vectors to be changed to use LS-DOS console I/O.
(in fact, I've done this for you, and created an executable
version of CamelForth for the TRS-80 Model 4.)

I'll show you, step-by-step, how this was done, so you can
do the same for a Model 3, Model 1, or any system running
LS-DOS.

SBOOT4/CMD on a TRS-80 Model 4 or 4P..  even though the 4P
has a built-in loader, you need to run SBOOT4/CMD.

CREATING A /CMD EXECUTABLE OF CAMELFORTH FOR TRSDOS/LS-DOS:

        make a note of the highest used memory address,
        define BYE for CamelForth
        say SAVEU to CamelForth
        say BYE to CamelForth
        use the DUMP command from TRSDOS to create a /CMD file.

To save a new system, use { HEX HERE . }, without the braces,
to display the next available free memory location.  Subtract 1
from this and remember it.  This value needs to be given for
the END= parameter when we use the LS-DOS DUMP command in a moment.

then do { SAVEU } to update the initialization area.

{ 0 0 0 22 SVC } will invoke the @EXIT Supervisor Call, exit CamelForth
and return controle to TRSDOS/LS-DOS.   You should probably define this
as { : BYE  0 0 0 22 SVC ; } before you exit, and then just use { BYE }
instead (and always have BYE to TRSDOS available).

        DUMP  CAMEL/CMD:0  (START=X'6600',END=X'????',TRA=X'6600)

    ..where ???? is the address found by HERE, minus 1.

Now you have Camel Forth for the TRS-80, running on a TRS-80.
A more elegant way of doing this, would be with a high-level forth
word, e.g. { SAVE-FORTH } which would save a new /CMD file, and
perhaps over-writing the existing file. This is left as an
exercise to the TRS-80 CamelForth programmer.

        STANDALONE EXECUTABLE /CMD FOR TRSDOS/LS-DOS v6

The problem remains of console input/ouput -- the system you just
saved still uses the serial port for its I/O.  To create the /CMD
executable of CamelForth, I used SBOOT4T v1.1a, which allows
redirected input from a file.

        SBOOT4T CAMEL80.HEX <INP.FS

..for example, will enter terminal mode, and allow you to use CamelForth
with RS-232 console I/O.  But if you press F9, it will read input from
INP.FS until there is no more to read, then return control to the terminal
interface.   In this way, you can load definitions from a DOS file,
immediately compiling them into CamelForth.  Then, with the facility
described above, save a new CamelForth to TRSDOS/LS-DOS.

        SBOOT4T CAMEL80.HEX <REVEC.FS

..is the command I used to create a standalone /CMD edition of
CamelForth v1.3 for the TRS-80 Model 4.  REVEC.FS is a seqential Forth
source file, which changes KEY KEY? and EMIT to use LS-DOS keyboard and
video, through Supervisor Calls.

Note that the words (KEY) (KEY?) and (EMIT) still use the serial channel,
but these assume the TRS-80 serial port is already initialized.  Serial
port initialization routines for the standalone /CMD executable are left
as another exercise for the TRS-80 CamelForth programmer.

        GLOSSARY OF NEW WORDS

;C SVC ( hl de bc n -- hl de bc af ) ..execute LS-DOS SVC n (Supervisor Call)
                -- NOTE: top of stack after execution, A=MSB, F=LSB.

;C  P!  ( n p -- ) write byte n to i/o port p
;C  P@   ( p -- n )  read byte n from i/o port p

;Z SAVEU ( -- ) ..for new system, save DP and LATEST in UINIT table
 -- this doesn't save the new system for you.. it just makes sure
 that if you generate a new system, it retains the definitions you
 created.

--
29 FEB 2000
Douglas Beattie Jr.  <beattidp@whidbey.net>
http://www2.whidbey.net/~beattidp/
