IV. CForth

Thanks to Mitch Bradley, we have a version of FORTH which is easily modified to allow FORTH to interact with our UNIX system code (the device driver and other system functions like popen()). As of this writing, we are using CFORTH 1.55 which, according to WMB, should conform to the new ANSFORTH standard. From time to time, small errors in new releases will be noticed when you try to use our current code with a new release. If the documentation with CFORTH does not make it clear who's fault the errors are, you should email WMB the code that is giving you the problem. Try to narrow the problem down before bothering him, though. Mitch Bradley can be reached via email at wmb@forthware.com. The previous bug fixes should all be accounted for in my mail folder, "~kevin/Mail/Forth".

As with the device driver code, CFORTH resides in the appropriate sub-directory of "/applic/dsp/csource". The only code changes you need to make, except for bug fixes, should be those that install our FORTH primitives. A primitive is a word in FORTH that is written in C and compiled into FORTH when dspforth is constructed. The following files are needed to create the primitives. Unless otherwise noted, all of these files are located in "/applic/dsp/csource/cforthx.y":

Create
nircases.h The case statements that define the primitives.
nirmain.h Initialize buffers used in forth.c by nircases.h.
nirsetup.h Initialize #defines and datatypes.

Modify
config.h Definitions to configure CFORTH. Change forth.dic -> dspforth.dic.
forth.c Contains WMB's primitive definitions. Include nircases.h in function inner_interpreter(). Include nirmain.h in function init_forth(). Include nirsetup at top of forth.c.
init.x List of primitives as they would be typed in forth. Add our primitives the way you want them used in CFORTH. Make sure that they are in the same order as prims.h.
io.c I/O subroutines for CFORTH. Modifiy title() to display our version info about device driver, port primatives, spectrum primatives and date of last update of these versions. Change the prompt from ``ok'' to ``UR_OK''.
loadcom.fth Default FORTH files to load. Add ``fload tasking.fth'' if you wish to use the multitasking features. loadutil.fth Creates the dspforth dictionary. Change forth.dic -> dspforth.dic.
makefile The makefile for dspforth.
Change:
SYSTEM = SYSV
FP=-DFLOATING
SD=-DSOURCE_DEBUG
OPTIMIZE=-O

Comment out DEBUG and SYSCALL. Add to INCLUDE:

../nirsetup.h ../nirmain.h ../nircases.h ../dsp56.h

Add to OBJS:

dsp_if.o

Change forth to dspforth. Add:

sm56dev.o: makefile $(INCLUDE) ../sm56dev.c
<hard tab> $(CC) $(CFLAGS) -c ../sm56dev.c

If using ccalls, add:

extend.o: makefile $(INCLUDE) ../extend.c
<hard tab> $(CC) $(CFLAGS) -c ../extend.c
prims.h #defines the case statement primitives to be associated with a unique primitive number. Add our primitives here after WMB's.
Include
dsp56.h Header file for DSP56001 boards from spectrum.
sm56dev.c Interface library for DSP56001 boards.
dsp_if.o Object file created when device driver was built. Needs to be placed in the ./unix sub-directory.

While compiling, sm56dev.c will give numerous warnings. NC assures me that these do not cause a problem. Eventually, all of our primitives should be converted to ccalls (see extend.orig). extend.c has been modified to include a RPC (Remote Procedure Calls) interface for FORTH.