Personal Computer News


QL Forth

Categories: Review: Software

 
Author: Roger Thomas
Published in Personal Computer News #106

The multi-lingual QL has gained another Forth compiler. Roger Thomas thinks that this implementation of Forth '83 is particularly good value though it isn't recommended for novices.

Forth Bridge

The multi-lingual QL has gained another Forth compiler. Roger Thomas thinks that this implementation of Forth '83 is particularly good value though it isn't recommended for novices

Despite being just over a year old, there's still precious little software available for the QL. The exceptions are assemblers and languages. One of the latest language packages for the QL is Forth from Computer One.

Features

The Forth compiler comes with a line editor and a 68000 micro-assembler, both of which are overlays to be loaded when needed.

The assembler is supplied so you can write Forth 'words' in machine code, increasing the speed at which programs run.

To go with the two main overlays there's a source file and an overlay to copy files. This is a useful aid as it cuts out the need to return to Basic. The source file contains the error messages and a small number of extensions to the Forth system, one of which is a decompiler so you can look at compiled code.

The other main extensions are sine/cosine functions and a string input routine. A simple game is also included which, while not up to arcade standard, allows you to play with Forth to see how programs are constructed.

In Use

Forth is booted into the computer when you switch on, in the same way as the bundled Psion programs. After the default file has been loaded you enter the interpreter, which allows you to enter Forth words to be executed immediately. For example, the word 'words' has the same effect as 'vlist', found in older implementations of Forth.

To load the editor, type edit and wait about twelve seconds for the overlay to load. Once it's loaded, full programs may be written and edited on screens of 16 rows by 64 columns. If the program is too large for one screen, you can move onto the next screen. To aid in the editing of a screen there are 35 control codes (which may be displayed by pressing F1) which makes the editor much easier to use than the standard Forth line editor.

The assembler is the last of the main programs supplied in the package and is loaded by typing asm. To enter large programs you have to use the editor. The resulting instructions are added to the Forth dictionary, and you can use the new instructions like any other 'word' in the dictionary.

As well as the standard Forth vocabulary there are a number of useful extra words specific to the QL. They make use of QDOS, give floating point numbers and control over graphics and sound, including the facility to produce user defined characters. QDOS is called to manage the Microdrives, giving access to random as well as sequential file handling.

The file handling interface is designed by Laboratory Microsystems of Southampton and comprises a control area and a 128 byte data buffer. As the filing interface calls QDOS, any new hardware which works with SuperBasic should also work with Forth.

The other important specification of the package is the multi-tasker which will support up to ten background and one foreground task. The multitasker is very simple and gives control to background tasks in a round-robin manner. The main limitation is that background tasks must be completed before control is passed back to the foreground task.

In terms of speed Forth gives speed increases of between two and 50 times SuperBasic, with an average of about 11 times. Even calling QDOS you can expect an increase of three times or more. The word definition below does a simple loop of 1 to 32000

: TEST 32000 1 DO 1 DROP LOOP;

In Forth, this loop takes 2.8sec while a FOR...NEXT loop in Basic of the same size takes 61 seconds. Forth programs may be made even faster if some of the words are defined in machine code using the assembler.

Documentation

The documentation comprises a 70 page A5 manual which gives information on all the words and overlays available to the user. The information is set out in a logical manner, different types of words being grouped together and listed alphabetically. Other sections give an introduction to the programs and there's a brief chapter on Forth. Unfortunately, the manual lacks detail on the extensions and the more powerful (and useful) Forth words provided.

Verdict

The only program I've found is that there is no Break key - if a program crashes you have to reset the computer and start again. The manual is the main let-down, as some aspects like the Forth extensions aren't adequately explained, but anyone with a working knowledge of Forth should be able to cope.

Overall, this package is very good value for money. Other languages for the QL cost £60 or more. It becomes even better value when you realise that it's based upon the Forth 83 sold by Microprocessor Engineering, which costs £190 (though that company also offers a version of Forth 83 for the QL for £29.95).

Report Card

Features 5/5
Documentation 3/5
Performance 4/5
Overall value 4/5

 

A Pocket History

Forth was designed by Charles Moore in the late '60s to control radio telescopes. Since then, a number of standards have been produced, the best known being Forth 89, Fig-Forth and Forth 83. QL Forth is based on the latest (and most powerful) version, Forth 83.

The features which give Forth its character are its stack and dictionary. The stack is used for all calculations. Expressions are written in such a way that the information is placed onto the stack before being manipulated. This is called reverse Polish notation (RPN). For example, 1 1 + is used instead of 1 + 1 and 4 * 7 + 3 / (2 + 8) would be written as 2 8 + 3 / 4 7 * +. As you can see, parentheses aren't used and no time is wasted working out what part of the expression is to be evaluated next.

The dictionary stores the keywords, variables, functions and operators. These are called words and the list may be extended by adding new words. The dictionary may be split into parts (vocabularies) so that the same word can have different definitions in different vocabularies.

Roger Thomas