Acorn User


Turbo Compiler

Author: Simon Williams
Publisher: Salamander
Machine: BBC/Electron

 
Published in Acorn User #026

The prospect of producing a machine code program without having to write directly in assembler has always been attractive. One way to achieve this is to work in a compiling language such as Fortran or Pascal, but, leaving aside the necessity to learn a language other than BASIC, there are as yet no full implementations of these languages for the BBC Micro. The alternative is to compile the BASIC code itself, and this, to an extent, is what the Turbo Compiler tries to do.

The compiler resides in only 2K of the micro's RAM, so it is possible to have source and object code co-resident in the machine. This means that code doesn't have to be compiled from tape or disc. Once compiled, the code may be used independently of Turbo, either as a subroutine in a BASIC program, or as free-standing machine code.

Turbo will compile only a limited subset of BBC BASIC and this is perhaps its biggest problem. Keywords handled directly by the compiler are AND, CALL, CLG, CLS, END, EOR, FOR, GET, GOTO, GOSUB, IF, INKEY, LET, MID$, MODE, NEXT, OR, PRINT, REM, RETURN, SOUND, THEN and TO. In addition, the operators ?, ! and $ are supported.

Turbo Compiler

Although the well-produced user guide lists some 65 keywords that may be compiled by Turbo, most of these are only achieved by 'fiddling' the syntax of others. For example, the COLOUR statement must first be translated into its equivalent VDU statement; COLOUR 3 would become VDU &11,&03.

Turbo handles only integer numbers and these must be in hex. Variables are restricted to the resident integers A% to Z% and these may only be assigned values in the range 0 to 255. Line numbers must also lie within this range and multi-statement lines are not permitted.

The publicity suggests that Turbo is an ideal intermediate stage between interpreted BASIC and machine code, and it requries a fairly intimate knowledge of the MOS to be able to 'prepare' a program for compilation. Comparing the following short program in its original and prepared forms gives some idea of the effort required to use it.

Before After
10 MODE 2
20 FOR N%=1 TO 255
30 GCOL0,N%
40 MOVE N%,1023
50 DRAW N%,0
60 NEXT
70 COLOUR130
80 VDU28,4,31,19,0,12
90 END
10 MODE 2
20 FOR N%=&01 TO &FF
30 VDU&12,&00,N%
40 VDU&19,&04,N%,&00,&FF,&03
50 VDU&19,&05,N%,&00,&00,&00
60 NEXT
70 VDU&11,&82
80 VDU&1C,&04,&1F,&13,&00,&0C
90 END

Whether you feel the speed increase (in this case about 25 per cent) is worth the extra effort is up to you. I would rather wait for a more comprehensive compiler that made the machine do a larger proportion of the work.

Simon Williams

Other BBC/Electron Game Reviews By Simon Williams


  • Rubble Trouble Front Cover
    Rubble Trouble
  • DDD Base Front Cover
    DDD Base
  • Fleet Street Editor Front Cover
    Fleet Street Editor
  • Plankwalk Front Cover
    Plankwalk
  • Pole Position Front Cover
    Pole Position
  • 737 Flight Simulator Front Cover
    737 Flight Simulator
  • Ewgeebez Front Cover
    Ewgeebez
  • Osprey Front Cover
    Osprey
  • Pirate Front Cover
    Pirate
  • Nightshade Front Cover
    Nightshade