History of Sinclair BASIC

BASin

History of Sinclair BASIC

[From The History of Sinclair BASIC, by Andrew Owen.]

Sinclair BASIC needs no introduction to enthusiasts of the little rubber-keyed machine, but its evolution is stranger than you might think.

In July 1975, Micro-Soft, as it was then called, shipped BASIC (Beginner's All-purpose Symbolic Instruction Code) version 2.0 for the MITS Altair 8800 hobbyist computer. This was the first commercial version of the BASIC programming language, originally developed by J G Kemeny and T E Kurtz in 1964 at Dartmouth College in the United States.

By then, Kemeny and Kurtz had addressed the main criticisms of BASIC - that it lacked structure and encouraged bad programming habits - but the 4K and 8K versions for the Altair, written by Paul Allen and Bill Gates, were based on the original Dartmouth BASIC.

Microsoft BASIC became so popular that it made Gates and Allen their first fortune and was subsequently supplied with the majority of 8-bit computers. So, not surprisingly, when the ANSI Standard for Minimal BASIC (X3.60-1978) was launched, it was based mainly on the Microsoft version.

In May 1979, Clive Sinclair's engineers began work on the machine that would become the ZX80. Sinclair was inspired to create the machine after seeing how much his son enjoyed using a TRS-80 but guessing that many people would be put off buying one because of the high price - just under £500.

Unlike the MK14, Sinclair's previous foray into the computer hobbyist market, this machine would ship with BASIC based on the ANSI standard. But the aim was to keep costs down, and that precluded paying a licence fee to Microsoft. To this end, Sinclair had already met with John Grant of Nine Tiles in April to discuss the software requirements of the ZX80.

Given the tiny R&D; budget, Nine Tiles stood to make hardly any money out of the deal, but the feeling was that the project was exciting and worthwhile, and one the company would benefit from being associated with.

To achieve the launch price of £79.95 in kit form, RAM was limited to 1K and the integer BASIC had to be crammed into a 4K ROM. Grant wrote the bulk of the ROM between June and July. But the resulting program was 5K in length, so Grant spent that August trimming the code.

According to Cambridge mathematician Steven Vickers, who wrote the subsequent versions of Sinclair BASIC: "The ZX80 integer BASIC, written by John Grant, was in Z80 assembly code pure and simple, though it did use the usual stack based techniques for interpreting expressions."

The lack of support for floating-point numbers overshadows Grant's achievement. He laid the path for things to come, introducing many unique features of Sinclair BASIC, such as the way it refuses to allow most syntax errors to be entered into the program, instead pointing out where the error is in the line before it is entered, making it much easier to learn and use than any other version of BASIC.

The kit was launched at a computer fair in the first week of February 1980, and while it was not a massive success by comparison with the ZX Spectrum, it turned Sinclair's fortunes around, eventually earning him a knighthood, and it sold well enough to persuade him to make a new computer: the ZX81.

Work on the ZX81 hardware had begun in September 1979, even before the launch of the ZX80, but it was the development of the uncommitted logic array, or ULA, which allowed the machine to go into production. The ULA, produced by Ferranti for Sinclair, reduced the chip count and brought the retail cost of the machine, in kit form, down to £49.95.

Again, Nine Tiles was called on to provide the new BASIC, but this time there was 8K to play with. Vickers, who had joined Nine Tiles in January 1980, wrote the BASIC more or less from scratch, only using some of the ZX80 code, making numerous improvements while managing to maintain backwards compatibility with the ZX80 hardware.

"As far as Clive was concerned, it wasn't a question of what the machine ought to be able to do, but more what could be crammed into the machine given the component budget he'd set his mind on," said Vickers in an interview on July 23, 1985. "The only firm brief for the '81 was that the '80's math package must be improved."

The ROM was almost complete by the end of autumn 1980, but support still had to be added for the ZX Printer. Somewhere between this time and the launch, a bug crept in which caused the square root of 0.25 to be 1.3591409. Nine Tiles quickly fixed the bug, but Sinclair was somewhat tardy in making this version available to people who had already bought the machine.

Despite this problem, the ZX81 was well received and became a massive success, spawning a series of clones, both illegal and licensed by Timex, which was manufacturing the UK models for Sinclair at its Dundee plant. Inspired by the public reaction to the ZX81, and annoyed at not winning the contract to design a computer for the British Broadcasting Corporation, Sinclair decided the market needed a budget colour computer.

The ZX80 and ZX81 hardware had been the primarily the work of one man, Jim Westwood, but he had been moved to the flat-screen television department, so the hardware design job on the ZX82, which became the ZX Spectrum, was given to Richard Altwasser - while Vickers at Nine Tiles was again asked to provide the BASIC.

What started out as an expansion of the ZX81 BASIC soon turned into a large 16K program. Sinclair wanted as few changes to the ZX81 code as possible, but Nine Tiles felt that software designed for a machine with 1K was inappropriate for a machine with 16K and that problems would occur later on. They were right.

"Certainly with the Spectrum we wanted to rewrite the code, but there wasn't the time and there definitely weren't the resources," said Grant in an interview on September 8, 1985. "At every point [in the development of the ZX range] Clive wanted the maximum new facilities for the minimum money."

After the best part of a year's work the BASIC was almost finished. While it was greatly enhanced, it was also depressingly slow, but more problems were to follow. The main problem was providing support for the planned peripherals, because no working prototypes were available to Vickers until near the end of 1981. But then, in February 1982, Nine Tiles began to have financial disagreements with Sinclair over royalties which it became apparent would not be forthcoming.

To make matters worse, Vickers and Altwasser both handed in their resignations in order to form their own company, Cantab, which went on to produce the Jupiter Ace, essentially a ZX80 with the Forth language taking the place of BASIC. The result of the delays these problems caused was that when Sinclair launched the machine, it did so with an incomplete ROM. Nine Tiles continued working on the ROM for three months after the launch in April 1982, but by then too many units had been sold and the program was never finished.

The original plan was to issue only a limited number of Spectrums with the incomplete ROM and provide an upgrade, much in the way the bug in the ZX81 ROM had been handled; except that by the time Sinclair got its act together, around 75,000 units had been sold and the plan became unworkable. This is the reason why the microdrive commands don't work in the standard ROM, and led to the development of the shadow ROM in the Interface 1 in order to handle peripherals which should have been supported directly by BASIC.