Your Spectrum
Issue 21, December 1985 - Basic Compilers
Home Contents KwikPik


you're going to have to make a difficult choice and you're going to have to make it on your own. Only by working out what you personally want from a compiler will you pick the right one.
There're three major things to think about: compatibility with ZX Basic - will you have to modify existing programs to get them to compile? Can you write and test programs in ZX Basic and compile them when they're finished? Speed is obvious - do compiled programs go that much faster than ZX Basic? Do they go fast enough for the programs you're writing? And, of course, ease of use - is getting a compiled program finished, tested and working too much brain-strain to be worth the hassle?
Got your choice buds in gear? Right, let's take a look at the two latest offerings! PSS's Mcoder III is a much matured version of Mcoder I and II. It's
Speccy Basic compilers have been no big thing but the choice is getting bigger and the packages are getting better. Dave Janda has his finger on the stopwatch ...
Wow! Suddenly we've gone from Basic compilers being perverse novelties to having a choice of four or five major products. There's Mcoder I and II, the new Mcoder III, Blast (which we blasted in ish 19), Hisoft's new Colt compiler and you can still cop hold of Simon Goodwin's ZIP which appeared in stages in YS issues 3 to 6!
Extended Basics are also right trendy at the moment. Besides our own YS MegaBasic there's Betasoft's Beta Basic and Ocean's new Laser Basic. But remember these products are enhancements of ZX Basic.
A compiler, on the other hand, transforms your original Basic program into machine code making it many times faster. A compiler will never write code as well as you can, so the results won't have the lightning speed of hand-written programs. But you can create fast programs faster with a compiler and you can take all those hundreds of Basic programs you've got sitting around and inject new life into them!
So which compiler should you go for? This is a tricky question as they all offer different facilities and have their own pros and cons. Sorry - but


Here's how the three compilers tested compared with ZX Basic. The graphs show their relative performance based on whichever compiler was the fastest at each particular test. The figures at the end of each bar give the actual benchmark timing in seconds.
Benchmark 3


Most benchmark programs don't really do practical tests. The short program here (you don't want or need long benchmarks) does five tests which should give a more reasonable idea of how the compilers compare. The program is designed to work first time with all Speccy compilers so don't buy a compiler if it can't run this - it's got problems!
100 PAUSE 0: CLS: FOR c=0 TO 5: FOR b=0 TO 255: PLOT b,c: NEXT b: NEXT c: BEEP 1,1
Line 100 Plot across the width of the screen six times.
110 PAUSE 0: CLS: FOR b=0 TO 87: CIRCLE 127,87,b: NEXT b: BEEP 1,1
Line 110 Draw 88 circles.
120 PAUSE 0: CLS: LET a=0
130 PLOT 0,0: DRAW 255,a: IF a<175 THEN LET a=a+1: GO TO 130
Lines 120-130 Draw 176 lines.
140 BEEP 1,1: PAUSE 0: CLS: FOR x=1 TO 4: PRINT AT 0,0;: LET e=1
150 PRINT x;: IF e<704 THEN LET e=e+1: GO TO 150
Lines 140-150 Print four screens of numbers.
160 NEXT x: BEEP 1,1: PAUSE 0: CLS: FOR x=1 TO 4: PRINT AT 0,0;: LET f=1
170 PRINT CHR$ (64+x);: IF f<704 THEN LET f=f+1: GO TO 170
180 NEXT x: BEEP 1,1
Lines 160-180 Print four screens of characters.
Mcoder III, £12.95 PSS (nnnn) nnnnnn
Colt, £12.95 Hisoft (nnnn) nnnnnn
Blast, £24.95 OCS (nnnn) nnnnnn
Benchmark 1 Benchmark 4
Benchmark 2 Benchmark 5

.......... FASTER

mega-advantage is that it's a floating- point compiler. Just like ZX Basic, you can manipulate fractions and decimal places. Sounds obvious? Most Speccy compilers are integer (whole number) only. This makes them fast but means that many programs need serious modifications before they will compile. Of course, floating-point compilers are slower but take a look at the benchmarks - Mcoder III ain't half bad at all!
In the blue corner is Hisoft's Colt - an integer-only baby that goes like greased lightning. Colt also has a few enhancements up its sleeve - its so- called 'executive' command. While you're changing your programs to integer-only you might as well throw in a few of these for added vitality.
Mcoder III wins the compatibility stakes hands down. PSS claims it will compile any old Basic program straight away. Errr ... sorry, but not if they use MERGE, LIST or LLIST or the Interface 1 commands; CAT, ERASE, FORMAT and MOVE. The first three are hardly likely to be a problem but it's a shame that the Interface 1 stuff isn't supported. Anyone for Mcoder IV?
Since Colt can only handle integers, you're going to have to convert your programs to use just whole numbers or fake fractions using several variables or strings. Not a very pleasant task for existing programs but something you can live with when you write new ones. However, you can run both Colt-
compiled and normal Basic programs together and pass variables between the two. This is a bit like shutting the door after the program has colted - it's handy but it slows everything down again!
Colt does handle some floating-point in commands where it is necessary such as BEEP and CIRCLE. But there are other compatibility problems - you can only have single-dimension arrays. Unjumbling all those big tables into single-dimension arrays is a real drag!
In contrast, Colt is the speed-freak's friend. A FOR ... NEXT loop runs about 100 times faster than normal. If you're into those silly and inaccurate little eight benchmark programs used by some megabrained mags, you'll find colted programs on average run around 50 times faster than good ol' ZX Basic. You can squeeze even more out of Colt if you disable its 'executive' commands - handy extras that provide error trapping, a real- time clock, windows and sprites - or if you opt to disable the Break key.
Mcoder III is slowed down by its floating-point routines. FOR ... NEXT loops and the like are dramatically improved as are the basic arithmetic operations +,-,/ and *. But more complex maths such as COS, SIN and so on are only just faster than normal ZX Basic. Just to be awkward, I'd have liked the ability to specify that some variables are to be treated as integers. That way, you could still compile existing programs first-time but could also get full speed improvements out of programs you
write specifically to be compiled!
As for using the two, Mcoder III is something of a shock. The 'manual' is three sides of cassette-inlay card with very little technical info. It's hardly enough to describe a game these days let alone a compiler! To compile a program, you load your original into the Speccy and then load and run the first part of the compiler. When you're prompted, you load and run the second part. This is going to wear the tape out faster than usual - which reminds me, there's no built-in way to transfer the compiler onto microdrive!
Colt is much more a professional product as far as the programmer is concerned. It has a built in routine to back itself up onto tape or microdrive and Hisoft won't object if you use colted programs in your own commercial products. It's easier to use as well. Compiled programs usually sit at locations 40000 so you can link them to ZX Basic and machine-code as you will. With the 'executive' removed, Colt will compile whacking great programs - up to 32K in length.
So which one do you choose? Mcoder III doesn't exactly offer you new possibilities but it will give your existing programs a kick in the backside. If you just want a two to three times speed increase with no messing about, this has to be the one. Colt on the other hand is a welcome new tool for library - converting existing programs is a drag but if you write stuff especially for it, you should be able to produce some superb programs!
Home Contents KwikPik