eForth for the Rabbit 2000

by Ken Staton

eForth 1.0 by Bill Muench and C. H. Ting, 1990.

Ken Chen's Z80 code words for the kernel.

Coded new ?RX, TX!, P@, P!.

Modifications: The code space and name space are no longer separated.

The executable is compiled with Dynamic C (LOADER.C).  I have been using Rabbit Core Module (RCM) 2300 (Digikey: 316-1014-ND. Rabbit Semiconductor: 101-0453.).  You will  need a development kit (Digikey: 316-1015-ND), which includes Dynamic C, a Rabbit Core Module, a prototype board and programming cable.  The JackRabbit development kit also works (Digikey: 316-1000-ND).  http://www.rabbitsemiconductor.com/

The eForth binary image is called as a subroutine that returns to the Dynamic C program when the forth words `BYE`, `forth`, or `forget` are invoked.  `BYE` exits eForth and makes no changes to the image.

IMPORTANT Serial reminder: the programming cable must be disconnected from the header for your program to run. The eForth source uses serial PORT C by default. This requires wiring a RS-232 transceiver as shown in the documentation with the development kit.  The binary image for use with Rabbit Semiconductor's Rabbit Field Utility (RFU) uses serial PORT A by default, which allows communicating with Forth using the programming cable's "DIAG" connector.

The eForth source is written for the Macroassembler AS, a free, portable macro cross assembler for a variety of microprocessors.  http://www.alfsembler.de/

I used the Win32 binaries. 

The command line invocation of the assembler is:

asw -cpu z180 -P -L forthR2000_rev20a.asm

To generate the binary image, use this command line invocation of P2BIN

(the 1st option is a lower case L):

p2bin forthR2000_rev20a -l 0 -r $-$

The binary image is written to flash using Dynamic-C's #ximport.

The loader program then relocates it to SRAM.

Extensions:

`flash` exits eForth with the code pointer as the return value.  The Dynamic C loader program then asks for confirmation of writing the new image to flash.

`forget` exits eForth with the original code pointer as the return value.  The Dynamic C loader program then asks for confirmation of writing the new image to flash.  Note that it is possible to write a corrupted image to flash if your code has modified the memory where Forth was loaded.

LOAD automatically uses memory above HERE and invokes BLOAD which does a protocol-less transfer that waits forever for the 1st character, then keeps reading characters until they stop for longer than a hard coded timeout value.  When this timeout occurs, LOAD invokes READ to compile the file into the dictionary. 

Files to be loaded must end with the line:

HAND 2E EMIT

LOAD and READ are useful in slow systems that compile slowly and miss characters during file transfers.  Loading the words into a buffer and then compiling them will work faster than using the FILE word that compiles each line as it is received.  Ultimately the transfer speed is limited by the execution time of  LOAD.

INIT defines a word that is run when eForth starts.  You must define this word and exit eForth using "flash" for your Forth code to run at power up.  If INIT does not exist, eForth starts in the interpreter.  This is implemented with DOINIT and ROMin. 

My version 2.0 implementation deviates from Ting’s model (my version 1.0 did too).

I continue to use Direct Threaded Code.  I will not support shadow ROM.  My ROM image gets relocated to RAM at a different address.  The RAM image in ROM gets extended by re-writing the ROM image in flash at exit, which re-writes the user variable initialization (UZERO through ULAST) in ROM in addition to creating an image for the new words .

| © 2005 Ken Staton