Classic Computer Magazine Archive ANTIC VOL. 4, NO. 8 / DECEMBER 1985


First serious language for ST users


4xFORTH is a full-scale implementation of the Forth language for Atari ST computers. This product has been used successfully in process control, robotics and similar applications on the MC68000 microprocessor for the past three years-and on the Digital Equipment Corp. PDP-1l minicomputer even before that.
   4xFORTH will run on an ST with a single disk drive, and on either a medium-resolution color monitor or high-resolution monochrome monitor. The 4xFORTH editor will not run properly on a low resolution display, although applications written in 4xFORTH can use low resolution.

If you haven't programmed in Forth, let's start with a little bit of background about how the language works.
   Programming in Forth involves creating procedures called words. A Forth word is placed in the dictionary after being defined by its relationship to other words.
   Two completely different words can have the same name in Forth, with the most recent word being the one found when looked up in the dictionary. It is possible to have two different words with the same name active at different times, depending on their context.
   For example, the word FISH might have two different meanings. If FISH is used as a noun, it refers to a creature that lives in water. If FISH is used as a verb, it refers to an attempt to catch the elusive little beastie.
   The way these distinctions are made in Forth is with the vocabulary structure. Its usage is like this:

VOCABULARY NOUNS / create the NOUNS vocabulary VOCABULARY VERBS / create the VERBS vocabulary

NOUNS DEFINITIONS / Place new words in NOUNS :FISH ." Critter that lives in the water."

VERB DEFINITIONS / Place new words in VERBS FISH ." Catch the critters living in the water."

NOUNS FISH critter that lives in the water.

VERBS FISH catch the critters living in the water.

Up to eight files may be open at the same time with 4xFORTH. The files may be opened with the options of Read Only, Write Only, or Read/Write. When files are opened, they must be assigned a word which parses the file name into a form that GEMDOS accepts. Then the file is assigned a channel number and its open options. For example:

   This creates an entry for the file name B: FORTH. BLK and then opens the file using channel 1 with Read/Write (the 2) attributes. Files can be created with Read/Write, Read Only, Hidden, System/Hidden, and Volume Label attributes.
   For those not familiar with it, the primary Forth primitive for dealing with mass storage is BLOCK.
   Forth divides mass storage in 1024-byte blocks, allowing for very fast random access. This method gives the programmer absolute freedom to create whatever structures are needed, without the overhead of unneeded structures. But because the program editor treats a block as 16 lines of 64 characters, leaving a blank line in the middle of a block leaves 64 bytes of spaces which can create very bulky files.
   The Dragon Group told me they would provide a utility to load files edited with non-Forth editors, such as Mince. This should solve the space problem. But you lose much of the interactive nature of Forth if you must exit to edit your program files.
   A very nice feature of 4xFORTH is its support of a RAM-disk. This means unused memory can be allocated and used as an electronic disk drive which is much faster than either a floppy or hard disk-although when the power is turned off, of course, the contents of the RAM disk are lost. To use the RAMdisk, simply enter:
   <#blocks> SET.RAMDISK
   Blocks from the currently selected file can be copied from the file to the RAMdisk with F>R and, when finished with the RAMdisk, they copy back to the file with R>E
   A highly advanced feature of 4xFORTH is its built-in support of satellite processors. This means a second ST- with or without disk drives-can be attached to the serial port. The implication here is that 4xFORTH can support a Local Area Network! However, this subject is a little too complex for further detailing in a review.
   The 4xFORTH editor will work with the mouse for cursor positioning. The left mouse button moves back a block and the right mouse button moves forward a block-the blocks are first saved automatically.
   In 4xFORTH, it is unnecessary to keep track of exactly where different words are defined. The editor also supports use of the function keys, with control key sequences for additional functions.

The graphics system has Tektronix 4010 emulation. This is important, because more software has been written for the 4010 series display terminals than for any other graphics display. Source code written for Tek 4010 displays can be easily converted.
   The graphics system is very well developed, with primitive routines such as GET.PIXEL, PUT.PIXEL, DRAWLINE, Tek 4010 emulation routine MOV, RDRW and complex routines like RECTANGLE, POLYGON, + SPRITE, -SPRITE, and much more.
   A full GEM interface has been promised for the level 2 version of 4xFORTH.

Commercial Forth packages have assemblers that vary greatly in quality and documentation. But like everything else I have seen so far from the Dragon Group, their 4xFORTH assembler is first-rate.
   The manual's Chapter Five provides an excellent discussion of programming in assembler on the 68000. There is a very complete discussion of addressing modes and instruction set features. Overall, it is the best documentation of a Forth assembler I have ever seen.
   This is not to say the chapter is a complete introduction to programming in assembler. Like the rest of the manual, it assumes that the reader is an experienced all-around programmer, familiar with a variety of languages and processors.
   The assembler itself has very complete error-checking for illegal addressing moves and other quirks of the 68000. As anyone who has attempted to program the 68000 in assembly language can attest, this processor has more than its share of idiosyncracies. The assembler helps watch out for them.

4xFORTH comes with a built-in multi-tasker. This means that although the ST cannot do two things simultaneously with GEMDOS-with 4xFORTH it can!
   4xFORTH multi-tasking uses a cooperative round-robin scheduler that is very clearly documented, with a good comparison of time slice versus round-robin techniques.
   Needless to say, this is another very complex subject. Yes, you can run a two-user system on the ST-simply by connecting a terminal to the serial port. However, for anything more complex, be prepared to deal with ST system internals.

4xFORTH is fast...
   Since the heritage of this language is control of time-critical processes, great effort has been made to optimize performance. This is reflected in speed of execution. Under 4xFORTH the 520ST does one pass of the Sieve of Eratosthenes in 1.1 seconds. (In the Octobei 1985 issue, Antic clocked this test at 3.8 seconds for an ST running Digital Research C. The fastest time tested was 1.97 seconds for a minicomputer using C on UNIX -ANTIC ED)
   And if this is not fast enough, there are also two optional Accelerator packages which greatly increase the speed, at minimum penalty in program size.
   This is the fastest version of Forth that I have ever seen.

With complex software such as a programming language, the quality of the manual is virtually as important as the quality of the program itself. From my point of view as a professional programmer, I am pleased to say that both are extremely well done.
   But there are some problems. The manual can overwhelm a novice programmer, as can any language technical manual. A more serious problem is that there are a number of words in the kernel (the base system) which are not documented. This can be justified, I suppose, under the argument that the undocumented words are internals which should not be used.
   The authors realize the problems of complexity in the manual and address it by suggesting the novice read Leo Brodie's classic books, "Starting Forth" and "Thinking Forth." In addition, I recommend Anita Anderson and Martin Tracy's "Mastering Forth" and Margaret Armstrong's "Learning Forth." All these books are available from the Forth Interest Group, P.O. Box 8231, San Jose, CA 95155. FIG also offers Forth Dimensions magazine, a must for every Forth programmer.
   (Antic wants to re-emphasize that 4xFORTH was primarily designed as a tool for professional software developers already familiar with the Forth language. Understanding the 4xFORTH documentation can be quite difficult without this advanced level of technical expertise. -ANTIC ED)

Although this system is intended for proessional development, there are some frustrating shortcomings.

  • There is no binary save. The source must be reloaded each time an application is to be run. The Dragon Group plans on providing this essential feature in the near future.
  • There is no target compiler. A target compiler allows you to generate a minimal system for a specific applicaton, at the cost of increased complexity The Dragon Group is promising an overlay mechanism and that may be sufficient. But until this feature and the binary save are available, commercial applications are not feasible.
  • There are a number of undocumented words in the system, plus a number of words missing that are specified in the Forth 83 Standard. Not many, but enough to be frustrating.
  • The editor is included in the kernel. This occupies space that could otherwise be used by an application.
A number of features (such as the RAMdisk) are discussed in one part of the manual, but not listed in the index.

There is no decompiler or step-wise debugger. These important features are part of the F83 Public Domain model (available on CP/M, CP/M-86, MS-DOS, and CP/M68K). There are a number of other features in F83 that should be implemented as well. The F83 model is one which vendors should pay attention to in their implementations.
   Although these problems are annoying, they are not fatal flaws.

The Dragon Group has created an excellent version of Forth in this product. 4xFORTH is incredibly fast and has many of the tools and extensions needed by the software engineer.
   Despite some shortcomings, the quality of the software and the manual make this a system that novice programmers can use to learn Forth. At the same time, 4xFORTH is ideal for the professional, once some minor flaws are fixed.
   I believe that 4xFORTH is the most advanced programming environment available on the Atari ST so far.
Dragon Group 148
Poca Fork Road
Elkview, WV 25071
(304) 965-5517

Software engineer Ron Braithwaite is currently the Forth group leader for Rising Star Industries, developing the Valdocs applications software series for the Atari ST and other computers.