← Back to News

The Xtal BASIC Compiler: Twice the Speed Without Leaving BASIC

In 1987 Crystal Research released a compiler for the Einstein's own BASIC. We ran it on our course's platform game and it went twice as fast - and it is now on the Xtal BASIC course disc.
Last Updated
September 19, 2026
The Xtal BASIC Compiler on the Einstein: XC compiling a program, Mouse In A Hole running compiled, the Family fun pack's compiled menu, and Solo Software's Gold Miner

Anyone who wrote a game in BASIC on the Einstein knows the feeling: the idea works, the listing is right, and everything on the screen moves in slow, visible steps. Xtal BASIC, the BASIC that came with the machine, reads each line of your program as it runs it, every time round. In 1987 its makers, Crystal Research of Torquay, released an answer - the Xtal BASIC Compiler. It is in our library on the X-Master disc. We dug it out, ran it on the platform game from our Xtal BASIC course, and the game ran twice as fast.

"It Would Never Appear at All"

The compiler's manual, in the library as the Xtal BASIC Compiler 5.10 Manual, is by A J Cornish of Crystal Electronics, copyright 1983-87, and was printed and published by Crystal Research Ltd of Magdalene Road, Torquay. It opens with a confession:

Continual improvement to Xtal BASIC has meant that the compiler has tended to get pushed further and further back, to the point that we almost felt that it would never appear at all! Anyway, it is here now, it works, and has been tried and tested with a wide variety of Xtal BASIC software.

It arrived as version 5.10, and the manual explains the number: "This is the first version of the compiler to be produced, but it is designed to support version 5 of the Xtal BASIC interpreter" - the upgraded BASIC described in the Xtal System 5.0 Manual. It was not for everyone. "It is assumed that the user is already a registered user of Xtal BASIC," the manual says, "(you will only have been sold a copy of the compiler under that assumption, or that you will have purchased both interpreter and compiler at the same time!)."

How It Works

It comes as two programs. XC.COM is the compiler: XC HANGMAN reads the saved program HANGMAN.XBS and writes HANGMAN.XBI. XR.COM, the run-time system, runs it. The manual is honest that this is not machine code. XC produces an intermediate program, and XR is, in the manual's words, a "slimmed down" interpreter that runs it faster than BASIC runs the original:

While not operating at anything like machine-code speed, a run-time speed improvement of 1.5 to 5 times is possible, and the speed improvement tends to be greatest in very large programs.

The speed comes from three passes over the program, each of which does once, at compile time, work the interpreter repeats on every line it runs. The first pass lists every line number and checks every GOTO and GOSUB, which can show up mistakes "which may not have been noticed under the interpreter", in parts of a program that never run. The second strips out spaces and REMs and turns numbers and variable names into short tokens. The third replaces each line number in a jump with the distance to its destination, so nothing has to be looked up at all.

What It Did for Our Game

We timed Mouse In A Hole, the platform game our course builds, over three hundred passes of its main loop, on an emulated Einstein:

300 passesXtal BASICCompiled
Mouse standing still22 seconds13 seconds - 1.7 times as fast
Mouse walking48 seconds24 seconds - twice as fast

Twice the speed can be spent two ways: a faster mouse, or the same speed in smaller steps. We did the second. Compiled, the mouse can move 3 pixels at a time instead of 6 and still cross the screen as quickly as it did in BASIC, and it glides where it used to jump.

It will not compile everything. Programs that use EVAL or HOLD are refused. And because the compiled program has no line numbers, an error in it cannot say where it happened, so the manual's advice still stands: "test your programs under the interpreter first".

Games That Shipped Compiled

This was not only for hobbyists. Solo Software's Family fun pack ships six games as compiled .XBI files with XR.COM beside them: Kentucky Derby, Para-shoot, Gold Miner, Apocalypse, Headache and Fire!!!. Run XR LOADER at the 0: prompt and a compiled menu offers all six. Write it in BASIC, compile it to make it quick enough to sell: a way to publish a game without writing a line of machine code.

Try It Yourself

The easiest way in is our Xtal BASIC Course Disc, which now carries XC, XR and a compiled copy of the finished game - type XR GAME at the 0: prompt. The new section S33, Compiling The Game walks through compiling your own copy and spending the speed on smoother movement. The original software is on the X-Master disc, alongside Xtal BASIC 5.02, and the compiler's manual is in the library too. If you are not sure which of the Einstein's BASICs you have, our new guide, BASIC on the Einstein: Which Version Is Which, sorts them out.

The compiler does not make BASIC into machine code, and its manual never pretends it does. For a game that moves as smoothly as the best of the period, the answer is still assembly language, and our Z80 assembly course starts there. But for a BASIC programmer who wanted twice the speed without leaving BASIC, Crystal had the answer on a disc.

The timings and screenshots here come from the machine itself, under MAME; the research and testing were done with Claude Code, as with the rest of the course.

Gavin Watson