Laser CompilerApplications Programmation

The amazing Bertram Carrot reviews the latest Ocean/Oasis ottering. Can it speed up the poor man's miserably slow BASIC? Will Carrot become a top-notch machine code progger?

For a long while now I've been working on Curse of the Android Lemmings, the latest Carrot megazap written entirely in BASIC and sporting one of the slowest gameplays known to mankind. So it was with much glee that I wrestled with the padded bag that arrived courtesy of Securicor a couple of days before this issue went to press. Just the job, I thought, to put some perzaz into the robot rodents.

The Laser Compiler is the latest in a line of programming aids for those who can't or won't ‘get their hands dirty' with a bit of Z80 machine code. Laser BASIC, reviewed in February's Amstrad Action, does a lot for those who believe that POP IY is a funny spelling of Olive Oil's boyfriend. It provides all kinds of wizzo sprites for use in your own games, and machine-code routines to manipulate them.

Laser Compiler tackles the bits of program not directly concerned with putting lemmings on the screen;the calculation and program logic involved in a good game. When you've compiled a BASIC program with Laser, you'll notice a significant speed improvement, not in the sprites themselves, but in the way the program works out what to do next.

Two sample programs are included in the manual; the notorious Sieve of Eratosthenes, invented by an ancient Greek to show off the speed of his BASIC compiler, and a routine to draw a circle. If you run these two programs under Amstrad BASIC against their Laser compiled equivalents, you'll see a speed improvement of 20 to 30 times for the Sieve and about 3 times for the circle plot. Well worth having, but what sacrifices do you have to make?

Well, for a start, you can't use any floating-point numbers. Not as much of a problem as you might think, especially when writing games, as nearly everything is done with integers anyway. It does mean that the RND function (which normally returns a number between 0 and 1) has to be rewritten, and any programs you want to compile will need to be adjusted accordingly. There are some restrictions on the use of MEMORY, and immediate mode commands, such as AUTO, RENUM and NEW, are not supported. Nothing that should really worry you, though.

Syntax checking

What is a bit more worrying is the ‘fussy' syntax checking. If you write ‘IF INKEY(32) THEN GOSUB 1000' in a program, you'll have to alter the line to read ‘IF INKEY(32) < > 0 THEN... before Laser will accept it. It won't accept the Pascal-style square brackets around array elements e.g. DIM Array$[20], although Amstrad BASIC does, and was none to happy with the statement ‘IF caught THEN RETURN'. It demands a full Boolean expression (e.g. caught = 1) to compile.

The manual gives details of which keywords aren't supported, and lists the error messages the compiler may produce. It would have been useful to have had some of these explained, and there were a couple the compiler produced which weren't listed, including the unhelpful ‘RUNTIME ERROR-UNKNOWN ERROR. PROGRAM TERMINATED'. Considering how well Laser BASIC is documented, I think Laser Compiler deserves more than 15 pages.

The compiler

The compiler is generally well behaved, and will take your source BASIC, whifch should be thoroughly debugged, and compile it in two passes. The first pass checks the syntax, and reports errors, showing where in the offending line the problem lies. The second pass generates the machine-code. adding in the Laser run-time code to produce a stand-alone program. This code is quite lengthy, around the 10K mark, and is longer if your program includes Laser BASIC sprites. Using Laser Compiler is the only way to create a program with sprites which will run without Laser BASIC being present.

The final product is run only, and as such may be sold by you, without further permission from, or payment to Ocean. A very realistic approach. Compilation of a typical 10K program takes about three minutes, including disc swaps. You can rim the compiler from tape, but it's awkward.


Compiler v Interpreter 

You may not be aware that your Amstrad micro, like all others, doesn't understand BASIC!

There is a chip inside your computer, called the BASIC interpreter, which translates any program you write in BASIC into machine-code. All micros can understand machine-code, and act on the instructions an interpreter produces.

The trouble with doing things this way is that a lot of time is taken up translating each instruction. When you run a BASIC program, each command is translated as it is met. This means that every statement in a simple loop like this:

10 FOR N = 1 TO 20
20 PRINT "Curse of the Android Lemmings"

is translated 20 times! It's amazing BASIC programs run at any speed at all. The advantage, of course, is that no permanent change is made to your program, so you can view and edit it immediately if there's something wrong.

A compiler on the other hand, takes your program (known as the source code) and translates itonce and for all into its machine-code equivalent — the object code. When you run the program, it's the object code which is executed, and no translation work is done at all. If there are bugs in your compiled program, though, you'll have to go back to the source program, correct it there and recompile before you can retest it.

 The best compromise, and one which Laser Compiler offers, is to take a program that you've developed and tested under the built-in interpreter, and compile it to give you extra speed.

Test programs

And so to C.O.A.L., or at least the programs I tried it on before trusting it with the game which combats insomnia. I have to admit at this stage that in the time available for the review, I only managed to get one out of three test programs compiled and running under Laser. The first was a simple database, which reserves MEMORY for a couple of machine-code sub-routines. Laser rejected the use of HIMEM in the program, and a small rewrite would be necessary to put the code into memory in some other way.

The second was a published BASIC listing for a game. Laser compiled the program without problem, but when run the ‘UNKNOWN ERROR' described above, crashed my 6128.

The third program was another mag listing, and after quite a bit of rewriting, Laser compiled this to machine-code over twice as long as the original. Although this compiled program ran all right (and a good bit faster than the original), part of the screen display was corrupted. The interpreted version had no such problems, and it's hard to see what could be causing them.

Even with these problems, it's not fair to conclude that Laser won't compile fairly standard BASIC programs. If you were writing your program for compilation, you'd make sure you stuck to the syntax it could understand. Using Laser BASIC would also encourage this, as the routines provided there are all compatible with the Laser Compiler.

All in all, Ocean's two programming aids will work together to provide much of the sophistication normally found only in games written entirely in machine-code. The extra memory overhead of a compiled program should not be too much problem, bearing in mind the program space available in Amstrad micros.

Now, you see, these giant lemmings keep throwing themselves of the cliff and your job is to catch them in your wellies ....


The Verdict

The Laser Compiler is a good integer compiler, though the review copy seemed o little rough round the edges. Although it won't provide a dramatic increase in graphics speed (Laser BASIC will do this for you) it considerably speeds up Calculation and logic processing.


If would be interesting to compare Laser Compiler with the new HiSoft Integer Compiler (how dbout it, Ed, Sir?)


? Handles a large subset of Amstrad BASIC keywords.
? Compiles fast, though in two passes.
? Produces stand-alone code, which may be marketed without royalties.


? Adds considerably to length of programs.
? Doesn't handle floating-point numbers.
? Manual could be more detailed.


★ PUBLISHERS: Ocean / Ocean IQ
★ YEAR: 198X
★ CONFIG: CPC 464, 664, 6128
★ DEVELOPPER: Oasis Software
★ PRICES: £19.95 cass, £24.95 disk


» Laser  Compiler    ENGLISHDATE: 2019-05-25
DL: 30 fois
SIZE: 50Ko
NOTE: 40 Cyls

» Laser  Compiler    (Release  DISC)    ENGLISHDATE: 2019-11-24
DL: 36 fois
TYPE: image
SIZE: 215Ko
NOTE: Scan by Loic DANEELS ; w1852*h1169

Je participe au site:
» Newfile(s) upload/Envoye de fichier(s)
★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

» Applications » Assembler-Kurs (Sybex)
» Applications » Bin-King (CPC Amstrad International)
» Applications » Mastercode
» Applications » Disassembler (CPC Magazin)
» Applications » Basic - Locomotive
» Applications » Jrt Pascal

CPCrulez[Content Management System] v8.7-desktop/cache
Page créée en 845 millisecondes et consultée 341 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.