www.jupiter-ace.co.uk
Previous Page > Index of General Forth Information > GO FORTH : Part 1
Personal Computer News 1983, April 08 - Go FORTH: Part 1, page I

PCN
Build up your complete reference library of micro computing

Personal Computer News 1983 Cover page


Personal Computer News 1983 Cover page



Personal Computer News 1983, April 08 - Go FORTH: Part 1, page II
GO FORTH PART 1
BEYOND
BASIC
Basic and Forth were both developed in the early 1960's, and of the two, Basic became the first high-level programming language on most of today's micros.
But the situation is changing - with the arrival of cheap disk drives and larger memory capacity, you can now use programming languages besides good old Basic. One such language is Forth, which has only recently been recognised as one of the most powerful and flexible software tools for micros.
Basic (Beginners All purpose Symbolic Instruction Code) was developed at Dartmouth College in the US. `It was based largely on Fortran, and was intended for use by people who had little or no previous computer experience and were not not necessarily adept at mathematics.
The ability to program a computer with the minimum time and effort appealed to other colleges and institutions, and Basic was adopted as their primary programming language.
Extensions were added to Basic so that today there are many makes of micro with dialects of Basic that are incompatible.
Forth, on the other hand, was largely developed by one man, Charles H Moore. Moore felt hindered by the programming languages of the day, Fortran and Algol. So he developed a tool to increase his productivity.
Over the years he extended the language, adding a compiler, for example. In 1971 Moore wrote a radio-telescope data acquisition program in Forth for the National Radio Astronomy Observatory at Kitt Peak, Arizona.
Forth gained interest among groups other than astronomers and in 1979 the Forth Interest Group (FIG) was formed to promote its usage.
Basic is implemented on most microcomputers in the form of ROM. Changes to its features are difficult, involving the addition and/or replacement of chips. The situation is quite different with Forth, however. Most Forth systems are on floppy disks, and if there is a feature missing from the existing system it is easy to add it, either temporarily or permanently.
Both languages are fully interactive and conversational - calculator-like commands can be used with each. For example:-
Basic: PRINT 4+3 (return)
7
Forth: 4 3 + . (return)
4 3 + . 7 OK (result on same line)
The example shows that with either language it is not necessary to write a program to achieve the desired result. This is not the case with languages such as Cobol and Fortran, where a complete program would have to be written to achieve the same result.
The commands and functions of Basic are held as a series of machine
code routines in the ROM. In the example above, the Basic interpreter 'scanned' the input line and executed the appropriate routines in the ROM to achieve the desired result. This is true for Basic whether a line of input or a program is running. The interpreter will scan each line and execute the routines concerned with each command.
The way Forth handles the example is radically different, however. Virtually all Forth operations involve the use of a stack, which is the responsibility of the programmer to maintain. Basic programmers don't have to worry about the stack as the interpreter handles it with little or no help.
Use of the stack in Forth is one of the reasons why the language is so fast in operation, typically 100 times faster than the equivalent Basic program. The above example shows that the two numbers 4 and 3 are 'pushed' onto the stack, the Forth word '+' then adds the two topmost numbers on the stack and leaves the result on top of the stack.
To display the result (on top of the stack) another Forth word is used, the result is displayed on the output device with one trailing blank (ASCII 32).
Unlike the Basic interpreter, the Forth system is roughly divided into three levels. The lowest level contains the fundamental stack manipulation, arithmetic, logical and string operators.
The second or middle level is composed of commands to implement a compiler, high order control constructs and data structures. These are written in Forth itself and this is one of the reasons why Forth is so portable between different systems.
The third or top level of the system contains commands for a conversational monitor - not to be compared with the Basic monitor.
The main words in a Forth system are held in the dictionary, and all of them are available to the programmer. The dictionary can be altered or amended as the programmer wishes. For example:-
: 43ADD 4 3 + . ;
uses what is known in Forth as a colon definition. The word 43ADD is compiled and added to the dictionary and can be used like any other Forth word.
If you want to find the result of 4+3 you enter 43ADD (return) and the answer 7 OK would be displayed to the output device.
This adding-to the language can't be achieved in Basic. Even with disk Basics the only way to achieve anything near the result would be to call a separate routine held on disk. For the programmer Forth provides a powerful tool to develop software. Forth is a complete system, providing the programmer with a compiler, interpreter, editor, assembler, debugging aids and virtual memory.
Some versions of Forth do not provide all these features so an editor can be missing, for example but even with the simplest Forth system it is possible to add these
Telescope at Kitt Peak, Arizona.
This is a telescope at Kitt Peak, Arizona, similar to the one first controlled by Forth, viewed from the exterior (above) and inside (right). Since its original development as a language for controlling radio telescopes, a wide range of other applications have been developed, including the control of video game arcade machines and microprocessor-controlled home appliances such as washing machines.
Personal Computer News 1983, April 08 - Go FORTH: Part 1, page III
 
Telescope at Kitt Peak, Arizona.
Telescope at Kitt Peak, Arizona.
add these later. Once added to the existing system, these enhancements can be used like any other part of the system.
There are some fundamental differences that the Basic programmer should know about Forth. All data is entered in Forth in Reverse Polish Notation (RPN).
Referring back to the examples, it can be seen that the operands are placed on the stack before the operators. It is more efficient to place the operators after the operands.
The same method is employed in Basic. The statement PRINT (A+B)*(C+D is broken down by the Basic evaluation monitor to AB + CD + * . This 'breaking down to basics' takes some time, which results in Basic programs executing slowly.
Variables are not normally catered for in Forth. The small Basic program will demonstrate this:-
10 LET A=1
20 LET B=85
30 LET C=31
40 PRINT A+B+C
RUN
117
There is no need to declare variables in this example of Forth. The same result is achieved thus:-
: DEMO 1 85 31+ + . ;
DEMO 117 OK
It should be noted that variables can be declared in Forth.
The major constraint for the newcomer to Forth is that it operates with integer only and the maximum
number that can be placed on the stack is 32767, while the lowest is -32768. This is not a great hindrance. as Forth provides words that operate on double numbers. It should also be noted that most programming applications require only the use of integer arithmetic.
There is in the US a Forth system running on a PDP-11/34 which controls an entire observatory: the telescope, dome, printers, CRTs and data acquisition equipment.
There are many more control structures in Forth than in Basic. Due to the nature of RPN, conditional control structures can seem strange in Forth. This is demonstrated below in a comparison with the equivalent Basic code.

10 REM TEST IF A >100
20 IF A >100 THEN PRINT "YES"
30 IF A <=100 THEN PRINT "NO" LET A=125
RUN
YES

: TEST 100 >IF. "YES" ELSE. "NO" THEN; 125 OK
TEST YES OK

The best way is as follows:-
IF true
ELSE not-true
THEN
That is, IF the condition was true (which it was) do something (print YES) ELSE if condition was not true, do something else (THEN).
Personal Computer News 1983, April 08 - Go FORTH: Part 1, page IV
GO FORTH PART 1
Stage 1
First write the first five machine-dependent assemble language routines which link FIG-Forth to the operating system.
Stage 2
Input the kernel of the Forth language, then your compiler and start Forth cold (check with Debug).
Stage 3
Turn off the first set of debug flags.
Stage 4
Turn off the second set of debug flags.
Stage 5
Write the system to the storage medium and then reboot.
START-UP WITH
FIG-FORTH
Forth is available on tape or disk for many popular micros, but you can't buy a ready-made version for every machine. And the large number of machines coming on the market means there will be delays before Forth can be produced for them.
But you can get standard FIG-Forth up and running for yourself, and to do this you start with the public-domain documentation published by FIG (the Forth Interest Group).
The FIG-Forth documentation comes in two parts - the installation manual and the assembly language source code. The manual provides instructions for customising the assembly language for specific microcomputers, full definitions of all words implemented in FIG-Forth, and the FIG-Forth model, which is a FIG-Forth interpreter written in FIG-Forth.
The assembly language listings are implementations of this model for several microprocessors, including 8080 - which can be used with Z80-based microcomputers - 8086, 6502, 6809, and 68000. Each of the listings was developed for a specific micro, and any machine-dependent code and constants you'll need to replace are detailed in the listings.
In order to link FIG-Forth into the operating system of your micro you have to provide five machine-dependent assembly language routines.
1. KEY reads the keyboard and puts the appropriate ASCII character onto the FORTH stack.
2. EMIT takes an ASCII character from the FORTH stack and writes it to your terminal (screen).
3. ?TERMINAL tests for the BREAK key being pressed and puts 0 or 1 onto the FORTH stack as appropriate.
4. CR sends carriage return and line feed to your screen.
5. R/W allows you to write a disk sector.
The installation manual gives precise specifications for these routines along with examples. You should therefore find it fairly easy to write them. provided you have suitable documentation for using the ROM or Disk Operating System on your computer.
If you don't use disks you can omit R/W and still get FIG-Forth running, but although this lets you type in and RUN programs you have no way of LOADing or SAVEing them.
If you don't have disks, the manual suggests that you write a version of R/W that uses RAM to simulate disks.
The idea is that you reserve a block of memory to represent a disk, and use R/W to read and write on it. You can then use ROM routines to LOAD and SAVE this 'disk' area on tape.
The easiest way to get FIG-Forth into your microcomputer is to type in the source code, replacing the machine-dependent sections with your own code, and re-assemble. You may not be able to do this on a small machine, either because you do not   have enough memory   to fit it all
(the source code will take up between 30K and 40K) or because your assembler won't allow you to assemble into the area of memory you want the Forth object code to go to.
Some assemblers let you get round these problems by assembling the source code in sections, or by writing the object code to tape instead of directly to memory.
On Z80-based computers you also have the problem of having to use the 8080 source code listing. The 8080 object code will run on a Z80 processor, but the assembly language is completely different.
If you can't assemble the source code you can still get Forth up by using your machine code monitor to type in the object code that is included with the assembler listing. The object code in the published listings has been assembled to a suitable location for the computer it was developed on, and you may not be able to use the same area of memory on a different computer. For example, the 8080 FIG-Forth was developed on a CP/M system and starts at 100 Hex, like all CP/M COM files, while ROM-based 8080 and Z80 microcomputers have ROM from 0 up to 2000 or 4000 Hex.
So if you type in the object code you'll have to change all the absolute addresses so the code will run at the new position. The easiest way to do the relocation is to move the code by a whole number of pages, so you only need to alter the high byte of each absolute address.
If you put 8080 FIG-Forth in from 4100 Hex upwards you will need to add 40 Hex to the high byte of each absolute address but leave the low byte unchanged. Typing in the object code allows you to get Forth. running on a computer with as little as 8K of RAM.
Some of the assembler listings include routines to help you in debugging the Forth when you first get it into your computer. There is no debugging support in the 6809 listings, but the 8080 listing contains a breakpoint facility, and the 6502 and 8086 listings contain trace routines.
Implementing Forth for yourself certainly requires a lot of work, but the end result is worth it, and you'll learn a great deal in the process. Even if you have bought a tape or disk version the FIG-Forth documentation can be useful, and will contain information you won't find in the documentation.
You can get FIG-Forth installation manual and assembler listings for 8080, 6502, 6809 and 6800 from Forth Interest Group UK. The cost of the listing and of the manual is £3.50 each to members and £5 each to non-members. The group can also provide assistance to members in implementing Forth. Full details can be obtained from Keith Goldie-Morrison, Forth Interest Group UK, 15 St Albans Mansion, Kensington Court Place, London W8 5QH.
Key to easy FORTH
If you have neither the time nor energy to develop your own implementation of Forth, there are many pre-packed versions available for most popular micros.
Part 2 of this Micropaedia will consider versions of Forth for the Apple, IBM and Sinclair ZX81 micros. But these are not the only
micros for which pre-packaged Forth programs are available. The easiest version is for the Jupiter Ace micro, because this runs Forth as a native language (see page VI). There are also popular easy-to-install Forth implemen-
tations for the Atari 800 and BBC micros. But if you have the time, you will learn more about Forth by installing the language yourself.


 
Personal Computer News 1983, April 08 - Go FORTH: Part 1, page V
 
FORTH USERS
ASSEMBLE

High-level languages are easier to use, less dependent on specific features of the computer and more portable than low-level languages. But low-level languages allow you to make full use of all features of the computer and allow more efficient optimisation of speed and memory requirements.

Forth is sometimes described as a 'high-level low-level' language because, while it includes high-level constructs which make it easier to use and also portable, it includes low-level features which allow control of the computer down to bit level.
FIG-Forth includes provision for incorporating assembly language into the definitions of Forth words. Forth assemblers have been published, and some implementations include an assembler. Virtually all Z80 Forth assemblers use the '8080 superset' format - 8080 mnemonics with additions for the extra Z80 instructions.
Like everything in Forth, assembly language uses Reverse Polish notation, so we have to write, for example, 0#LDA, instead of LDA#0 for the 6502, or 0 A MVI, instead of MVI A,0 on the 8080 or LD A,0 on the Z80. Assemblers vary in the exact format for defining words, but you generally find that you have to use something like:-

CODE word-name assembly language C; with CODE taking the place of the colon and 'C;' taking the place of the semi-colon in the usual Forth definition.

The main application for assembly language in Forth is to use operating system or ROM routines from a Forth program. For example, in CP/M we can use an operating system routine by the assembly language instruction CALL 5, with the number of the OS routine we want in the C register, and any parameters required in the E register or the DE register pair.
Thus, to send a character to the printer we could write, in 8080 assembly language:-

LHLD CHAR ; Address of character into HL
MOV E,M ; ASCII code of character into E
MVI C,5 ; 5 is function number to print on printer CALL 5 Access to operating system.

In Forth we would write this as

0 VARIABLE CHAR
CODE PRINT CHAR LHLD, M E MOV, 5 C MVI, 5 CALL,
NEXT JMP, C;

and then PRINT would print the ASCII character corresponding to the value in the variable CHAR. Note that assembly language in Forth must end with a jump to NEXT, the Forth inner interpreter.

We can also define another useful word based on PRINT:-

: CPRINT CHAR ! PRINT ;

which would be used as n CPRI NT to print the ASCII character corresponding to the number n.

The BBC microcomputer operating system is accessed in a similar way, with OSBYTE and OSWORD calls.

For example, an OSBYTE call with 89 Hex in the accumulator will turn off the cassette motor if the X register contains 0 or turn on the cassette motor if X contains 1.

In 6502 assembly language we would write:-

LDX ONOFF ; Get flag from actress ONOFF
LDA#&89 ; OSBYTE number
JSR OSBYTE ; Operating system call

To do this in Forth we would write

HEX FFF4 CONSTANT OSBYTE 0 VARIABLE ON/OFF
CODE MOTOR ON/OFF LOX, 89#LDA, OSBYTE JSR
  NEXT JMP, C;

and then MOTOR would turn the cassette motor on or off according to the value of the variable ON/OFF.

We can use MOTOR to define another word, *MOTOR, which works like *MOTOR in BBC Basic
: *MOTOR ON/OFF ! MOTOR ;

so that 0 *MOTOR will turn the motor off and 1 *MOTOR will turn the motor on.

You can extend the use of OSBYTE and OSWORD calls in Forth to add the Basic commands *FX, VDU, etc, to Forth.

If you do not have a Forth assembler you can enter machine code into definitions using the following Forth words:-

CREATE name sets up a dictionary header for name. n , enters the 16 bit number n into the next two dictionary bytes and advances the pointer.
n C, enters the 8 bit number n into the next dictionary byte and advances the pointer.

SMUDGE toggles the 'smudge' bit in the definition's name field, allowing the interpreter to find the word in the dictionary.

The machine code must be in the normal order, not in Reverse Polish. Thus, while we have to write '89 LDA', in Forth 6502 assembly language the machine code for this instruction must be entered as 'A9 89'.

The assembly language examples above translate into machine code as follows:-

CP/M

HEX CREATE PRINT 21 C, CHAR, 5D C, OD C, 05, CD C, 0005, C3 C, NEXT, SMUDGE

BBC

HEX CREATE MOTOR AE C, ON/OFF, A9 C, 89 C, 20 C, OSBYTE, 4C C, NEXT, SMUDGE

You can use ordinary Forth words while entering assembly language or machine code definitions, in order to calculate operands. For example, in 6502 assembly language we can write 'LDA FRED + 1,' which we would enter in Forth assembly language as 'FRED 1 + LDA,' or in machine code as 'AD C, FRED 1 +,'.

These calculations are performed at assembly or entry time, not at execution time, so in the preceding example, if Fred had been given the value F000 Hex the machine code would come out as AD 01 F0, and changing the value of FRED before the machine code was run would have no effect on it.

Changing up
to Forth
Forth is one of those rare languages that has survived and flourished because of the vitality of its users rather than its inventors.
It was the Forth Interest Group in San Carlos, California that published the FIG-Forth installation manual in November 1980 and it has been FIG chapters around the world that have kept alive interest in the language until the recent explosion of commercial interest in it.
The installation manual was written in the days when an Apple II was about the most sophisticated piece of micro hardware you could get for implementing Forth.
It was intended to be as transportable as possible, with four or five kilobytes written as assembler listing and the remainder to be compiled by typing in the Forth high-level source.
There are seven areas to the FIG installation model of Forth. They include boot-up parameters, machine-code definitions, high-level utility definitions, installation dependent code, high level definitions, system tools and RAM workspace.
First the boot-up parameters go in, consisting of 34 bytes that jump to a cold start, then a warm re-start and finally entry of the initial variables and registers.
Then 600 to 800 bytes are taken up with machine code definitions peculiar to your computer. Your micro is thus a standard Forth stack computer (don't worry - it's not a permanent change).
After that come the high-level utility definitions, which allow you to control the Forth stack computer. These are colon definitions, user variables, constants and variables.
These are followed by the machine dependent code (see Start-up with FIG-Forth), which varies from machine to machine and is the least portable aspect of this installation.
The machine dependent code is itself followed by about 30 high-level definitions involving your interaction with the language. They include compiling aids, finding, forgetting listing and number formatting. They are positioned after the machine dependent codes so you may FORGET part of them and recompile them with new definitions from your disk.
The system tools include an editor that allows you to place the editor and assembler source code on disk. Then there is the RAM workspace - which is self-explanatory.
Personal Computer News 1983, April 08 - Go FORTH: Part 1, page VI
GO FORTH PART 1
PCN Forth
PLAYING THE ACE

The Jupiter Ace is munching its way into the low-priced micro market as it brings Forth as a native language for less than £100. Forth is a faster language than Basic and you'll notice it when you Pac your men onto the screen and try to catch them.

Unfortunately, they don't move in colour - and it will probably be cheaper for Jupiter Cantab to bring out a colour micro than for it to try to develop a cheap colour adaptor for the Ace.

VI

Forth's speed and ease of use are attractive, but the attractiveness pales somewhat if you have to keep LOADing cassette versions onto your favourite micro, then reLOADing every time you crash. But there is an alternative in the Jupiter Ace.

The Jupiter Ace dialect of Forth-79 has about 12 extra words, and several departures from the accepted standard. There is enough room in ROM to contain the original; but as many Ace users will have moved from Basic to Forth they will be looking for points of similarity during the early stages. They will find the presence of words like LOAD, SAVE and VERIFY reassuring.

And as the Ace has little in the way of storage facilities, the related Forth screens and block handling commands are largely superfluous.

First hands-on impressions of a Basic user. when confronted by Forth are, 'it won't do anything except say OK', or 'How do I get a cube root, and where are the strings then?'. And there seems to be little help forthcoming.

The concept of building up your language as you go along, and of using reverse Polish notation, seems totally strange. Later, and after much dogged perseverance, you suddenly realise you're programming effectively, and probably faster than you ever did with an amalgam of Basic and machine code. Mind you, the reverse Polish still looks back to front.

The general philosophy of the Ace, and of many other Forth implement-

ations, is that the legions of software authors will step in and supply the Forth-79 extensions you need, but cannot quite get to grips with. These include 64 bit floating point accuracy, comprehensive string-handling, printer routines, and even the functions LN and ex02x.

Given time the software wizards will come up with the goods, but what do you do while you are waiting? If you're not an advanced mathematician and machine code expert the bare Forth-79 standard will confine you to certain areas of programming activity, such as fast graphics games, left-scroll shop-window displays, in-out porting, and simple arithmetic.

The Ace does offer some consolation, in that it has the additional floating point words FNEGATE, INT, UFLOAT, F + , F-, F*, F , F., and IN and OUT for Z80 configured ports.

Other non-standard words in Ace Forth are also quite useful. INVIS prevents OK and other responses appearing right in the middle of your latest graphics creation, and even FAST and SLOW, relics of the ZX81, are handy. The latter protects you against fearsome crashes while the former can almost double the speed of some routines at the expense of error trapping. Another plus is the handbook, which provides hints on how to implement Turtle Graphics in Forth, how to generate mathematical functions (albeit with limited accuracy) and quite a lot more if you happen to

Personal Computer News 1983, April 08 - Go FORTH: Part 1, page VII
 
Jupiter Ace

- know what it is you are looking for.

Of course, there are disadvantages with the Ace. The word REDEFINE has to be typed in - like everything else - letter by letter on an idiosyncratic rubber keyboard, and as it is so useful, surely something shorter like ALTER would have been better. I would also gladly abandon ASCII, which performs the simple task of yielding the ASCII code of the first character of a word in the input buffer. CMOVE, which can send large chunks of code from one end of spare memory to the other in a blink of the eyelid, is preferable. Another quite serious omission is EXPECT, which would have taken characters from the keyboard to any selected position in memory - useful for string handling this one.

At first I thought it would be simple to implement CMOVE by defining it in Forth:-

: cmove address 1, address 2, number of bytes
dup if else exit then check for zero bytes
swap dup rot 1 + + swap set up DO LOOP
do
dup c@ic! 1+ transfer bytes
    loop

This routine works well on the unexpanded machine, but when you add on 16K or more the word is impossibly slow. Forth is not always fast.

The only solution is to resort to a machine code 'primitive' version of CMOVE, using a Z80 LDIR routine, and this will transfer at the rate of 100K per second or less.

This is fine if you know about machine code, but not much use if you don't.

Some more useful non-standard words are included in the Ace dialect. BSAVE, BLOAD and BVERIFY allow the user to SAVE and LOAD selected blocks of memory onto tape. This could be the contents of the screen, or perhaps a routine placed above Ramtop.

Incidentally, the Ace cassette format is compatible with the Sinclair Spectrum, and it is possible to crossload the two machines. Thus, you can load the contents of Ace ROM into the Spectrum and use a readily available dissassembler to see what makes Forth tick. Data transfer between Ace and Spectrum via cassettes would also be relatively easy to implement.

The combination of Ace and Forth-79, without additional words, doesn't come anywhere near the standard set by ZX Basic for number crunching. It can't even rival a low cost scientific calculator, if you disregard the iterative capabilities of a computer, and this is surprising when you consider that Charles Moore and Elizabeth Rather devised Forth for use with Radio Astronomy. ZX Basic uses five byte floating point with nine digit accuracy, while Ace Forth has four byte floating point with six digit accuracy. But even ZX Basic starts to show serious discrepancies quite early when dealing with big number applications.

The answer to this apparent defect lies in the

The
differences
between
Ace Forth
and Forth-79
Ace DIALECT

Additional words
SAVE
VERIFY
LOAD
  BSAVE
  BVERIFY
  BLOAD
  LIST
EDIT
REDEFINE
F+. F-, F*, F , F.
FNEGATE
INT
UFLOAT
ASCII
AT
BEEP
CALL
CLS
FAST
IN
INKEY
INVIS
LINE
NUMBER
OUT
PLOT
RETYPE
SLOW
VIS
Missing Words

-TRAILING
+!
79-STANDARD
>IN
CMOVE
COMPILE
COUNT
DEPTH
EXPECT
FILL
KEY
MOVE
NOT
STATE
SCR
BLOCK
UPDATE
BUFFER
SAVE-BUFFERS
EMPTY-BUFFERS
[COMPILE]

Note: LIST and LOAD have different definitions and CREATE DOES> is replaced by DEFINER DOES> and COMPILER RUNS> is added.

Personal Computer News 1983, April 08 - Go FORTH: Part 1, page VIII
 
A second
orbit
round
Jupiter's
Ace

After using the Jupiter Ace - the first native Forth micro - I must admit to some mixed feelings regarding the machine itself and its implementation of the language.

For those who do not know, the Ace was released last year as the first (cheap) micro to incorporate Forth.

It was designed by Stephen Vickers and Richard Altwasser. Vickers was one of the 'small firm of Cambridge mathematicians' who wrote the contents of the ZX81 ROM. Altwasser was one of the founder designers of the ZX Spectrum.

The pair left Sinclair to form Jupiter Cantab and the Ace is the first product from the partnership.

People who have used the Ace will be aware of some of the striking similarities between the Ace and Sinclair products and that should not be surprising considering the association between the two companies.

Much fuss has been made of the Jupiter design and I agree with a lot of the criticism.

The keyboard is an abomination. At the 1982 PCW show, where the Ace was first shown, Jupiter Cantab explained the problems they were having with the keyboard design and promised to sort things out.

Unfortunately, the end result is not an improvement on a prototype. The keys are of the 'dead flesh' type and need to be struck dead centre to register.

Ace Forth is supposed to be a variant of the Forth-79 standard but it has some irritating characteristics, such as the lack of the 79 standard words CMOVE, EXPECT, NOT. and SP! and inclusion of extra words such as AT, CLS, INKEY and VIS.

The Forth standards team has been trying to get Forth standardised for the last seven years and vendors should not include words in the Forth dictionary that are radically different to the two popular standards.

Forth is meant to be a flexible tool for programmers and a good deal of work can be done to enhance the system.

DJE

Jupiter Ace

fact that Forth is flexible and can be extended. It would be quite time consuming to attempt to modify ZX Basic to produce greater accuracy, but there is virtually no limit to the potential accuracy of Forth.

The absence of well known scientific functions like ex, sin, and x/y is yet another stumbling block with the ACE. The handbook gives an equation for generating sin, with a quoted accuracy of three to five decimal places, but omits to mention that the equation is an infinite series, and that the whole thing goes haywire with large input values. My own efforts at implementing 1n and ex, using Maclaurin's expansion, have been dismal, with very large errors beyond the range -1 <x ≤ 1 .

I am forced to concede, at this stage, that the Ace is a very poor desk-top calculator. Forth literacy still seems in its introductory phase, with little being written at a more advanced level. But it may well move away from its original brief, and become a language suited to non-mathematical applications.

Having complained about the lack of hard information on Forth, it would be unreasonable to keep the little I know to myself - so, here's something to get you started:

0 variable expo


: ↑ f, n, -f n
expo ! expo @ 0 cycle n times
do
over over stack f n times
loop
expo @ 1 cycle n times 1-
do

f* multiply stacked fs

loop 4 roll 4 roll drop drop discard f and leave
f n on stack

;

The word ↑ raises floating point numbers to integer powers between 2 and 90, or less, depending on the ultimate size of the result.

This is noticeably faster than my Sharp calculator. f is the floating point number, and n is the exponent. Here is a method of obtaining cube roots by successive approximation in 20 steps with an initial guess of 1:-

:2over

4 pick 4 pick
;
: 3rt f, - 3 f
1.20 0
do
2over 2over f/ 2over f/ divide number by guess
twice
f+ 2. f/ average guess with result and stack approximation
loop
4 roll 4 roll drop drop
;

The words 3rt and ↑ have a reasonable degree of accuracy. You can transform 3rt into 2rt by removing a 2 over f/ and then, for example, calculate musical intervals of 12 √2 with:-

: 12rt f, - 12 f
2rt 2rt 3rt
;

The above is a good illustration of how Forth can be expanded economically.

Next week

This article can be be downloaded as a PDF document.
PCN - page 1    PCN - page 2

PCN - page 3    PCN - page 4

PCN - page 5    PCN - page 6

PCN - page 7    PCN - page 8