DESPITE ITS SUCCESS in the specialist games market, the Spectrum has always been a general-purpose computer. Until recently it has been handicapped by an obscure operating system, no standard disks and a limited home TV display resolution. Locomotive Software have addressed all three of these problems with the launch of CP/M Plus for the +3.
When micros first appeared, models were all totally incompatible, like game machines today. After a while people decided it was a waste to rewrite programs for every new machine, so they dug out a program written in 1974 that would control disks and a simple display on ANY computer with an 8080 processor, or its souped-up successor the Z80. The program was called Control Program/Monitor, or CP/M for short.
CP/M was important because it mean that programs could be written once and work on lots of different machines without changes. All the machine-specific bits were handled by calling the control program. This was a bit slow and restrictive — it ruled out graphics and sound — but it was worth it, because thousands of CP/M programs were written — programming tools, business software, and text games like adventures. Many programs are available at just the cost of a disk and duplication — just a few pounds — from legal ‘public domain’ software libraries like PD-SIG.
Spectrum CP/M only runs on the +3. It consists of a single three inch disk, brimful with 346K of files on both sides, and a hefty manual. It loads from the +3 ‘loader’ option in about ten seconds, plus another ten while it automatically configures the serial port and an 11K RAM disk (drive C).
Once CP/M is loaded you have about 61K of fast memory free for programs, with no need for ‘paging’. Usually on a +3 the screen and ROM mean you only have about 40K free in one space, plus a 64K RAM disk. In CP/M up to 15K of otherwise unused memory can work as a fast but small simulated disk — useful when copying small files with only one drive. The rest of the 128K contains the code of CP/M, which runs entirely independently of the Spectrum ROM.
Spectrum CP/M Plus has 37 standard commands, but there’s no maximum — the package includes facilities to make your own commands, in BASIC, machine code or by chaining together existing ones. If you type a word CP/M doesn’t know, it automatically looks for a file of that name and either executes it — if it’s a program — or reads commands from it as if you typed them — if the file contains text. This simple scheme is very powerful.
+3 CP/M initially recognises 15 ‘housekeeping’ commands. The simplest is TYPE, which shows a named file on the screen, waiting for a key between pages.
You enter DIR to find the names of disk files. DIR takes about 3-5 seconds to read and display a directory of 27 files — plus an extra eight seconds if you’ve just changed the disk, and the computer needs to update its record of the disk structure.
DIR (SIZE) uses the separate DIR utility program, and takes nine seconds to load that 15K program, read the same directory, sort it into alphabetical order and display it over 31 lines.
DIR work on +3 DOS disks, but TYPE — like most commands — can only decipher the data on CP/M disks. It just plaintively prints PLUS3DOS if you ask it to look at a file created by +3 BASIC.
SHOW tells you the amount of space in a drive. DATE lets you read and set the date and time, used to mark files. The rather rudimentary +3 hardware means that the clock loses time when the disk is accessed. The date reverts to Christmas 1982 whenever you reset the system.
ERASE and RENAME let you remove files from a disk or change their names. SET can protect a file from ERASE. Names can include ‘wildcard’ characters, as in +3 DOS, so you can use one command to process several files with similar names.
DISCKIT copies disks. It takes about two minutes to copy a 173K disk on a single drive computer — a minute to read and write the data, plus another minute for you to swap the disks back and forth eight times.
PIP is the rather clumsy ‘Peripheral Interchange Program’. It lets you copy files back and forth between disks, the screen, serial and parallel ports — but not MIDI, which did not exist when CP/M was designed.
There are ten configuration commands. For example, the PALETTE command lets you set the foreground and background colours; the default is white on blue. The other 12 commands are only briefly mentioned in the manual — they are ‘advanced programming tools’ — well, they were when CP/M was invented, but today they seem a bit crude.
ED is the standard CP/M line editor, and is horrible; not much better is RPED, a screen-editor for up to 200 lines of text, written by Amstrad in protected BASIC. It’s simple to use but very rudimentary, and won’t let you copy or move information between lines. RPED is alright if you just want to write a few command-files, but it’s not much good for programming.
You get two assemblers — for the 8080 processor rather than the Z80 — and can try them out by assembling the well-commented RAM disk source code provided. All the 8080 instructions run on the Z80, but they have different mnemonic names so the source looks pretty odd! To make things even stranger, the program uses Z80 codes which the 8080 couldn’t handle, and these are ‘defined’ as bytes and words in the program. Even so, it’s an interesting example.
Like ZX BASIC, CP/M is usually controlled by typing commands at the keyboard. However, CP/M lets you change the characters produced by every key, and there’s a massive character set, including foreign accents and loads of weird squiggles.
Some commands use the square and curly brackets, which Amstrad didn’t mark on the keyboard. Locomotive have positioned these sensibly on unused pairs of symbol-shifted keys. BREAK is the equivalent of CP/M’s ‘Escape’, and EDIT usefully recalls the last list entered for editing -try doing that in GEM or on an Apple Mac!
EXTEND works as a ‘control’ key so, for example, Control S and Control Q stop and start scrolling; the TRUE and INVERSE VIDEO keys give the same effect more conveniently.
You can divert input and output to any device with commands. If you’ve got a printer connected, Extend P is a convenient way to copy all display output to it.
Keys repeat, without over-running, when you hold them down for a while, but there’s no key-click, and on this early review version the cursor disappeared annoyingly when the arrow keys were held down. At first, Locomotive Software excused this on the grounds that the tried to make the screen display fast, and no-one complained about this bug on earlier Amstrad CP/M machines. Since then, Locomotive have relented and the latest versions of CP/M do not have this cursor problem. You can ‘type ahead’ while commands are running. Sometimes the characters you enter get lost, but usually they appear on the next command-line. The effect depends on what the computer is doing, but it’s a useful feature when you get used to its quirks. The line editor lets you move back and forth through up to 239 characters of command and ‘parameters’, adding and deleting at will. Unfortunately you can’t edit characters unless they’re on the same display line as the cursor.
Mallard BASIC is a 28K code file. It loads from the CP/M command level in about 5.5 seconds, leaving just over 30K for file-buffers, variables and your program.
Mallard BASIC is aimed at serious programmers, and is very like IBM’s GW BASIC or Microsoft’s MBASIC. You enter program lines of up to 255 characters, but the syntax isn’t checked at once, as it would be in ZX BASIC. If a mistake is found when the line is executed, you are then thrown into the line editor.
The BASIC editor works like the CP/M command editor, with extra tricks to move up and down between screen lines, search for a specific character, and delete or overwrite chunks of text. You must tell it the width of the screen line with the WIDTH command before it will work in 32-column or 80-column mode, or strange things can happen!
In BASIC, the keyboard functions are sadly inconsistent with the CP/M command level — a common problem with early operating systems where every program has its own conventions. EXTEND A works like EDIT in CP/M, recalling the last line as long as you have not yet started to enter a new command. BREAK is ignored, but EXTEND C will stop your program unless you’ve protected against it.
Control G is the only way to make a sound, unless you resort to OUT instructions to control the speaker directly. Type Control G in BASIC, to hear a simple ‘beep’ sound. In CP/M this only makes a sound when you print the character — not when you type it.
Display control is rudimentary, with no graphics commands at all. You have to print control characters to change colours, move the cursor or clear the screen. In ZX BASIC you’d type CLS, but in Locomotive BASIC you must use terminal control codes: PRINT CHR$(27);"H";CHR$(27);"J". This gibberish means your programs will work on most other CP/M machines, and suits the IBM PC or Amstrad PCW, both of which run Mallard BASIC and use the same control codes.
Mallard BASIC allows four different data-types. Integers — whole numbers between -32768 and 32767- are more concise and slightly faster than other numeric types and are particularly useful for array subscripts. Maths functions like SIN and LOG use the default seven-digit floating point ‘single precision’, and real number-crunchers can add, subtract, multiply and divide 16-digit ‘double precision’ numbers. You pay for the precision in time and memory.
Variable names can be as long as you like, but strings are limited to 255 characters, unlike ZX BASIC. Locomotive BASIC has the big advantage that you don’t have to tell the system the maximum length of string array variables.
Like Microsoft and ZX BASIC, but unlike more modern BASICs, Mallard BASIC is not well-suited to structured programming. There’s IF... THEN... ELSE, which can be nested but must be on one line, and WHILE... WEND for loops that start with a test.
Unlike +3 BASIC, Mallard has proper file-handling and lets you trap errors, mask the bits of integer values, search strings and trace the current line-number. Overall it’s much mere like Fortran than Pascal, although when it comes to program development it has the edge over both those languages in that it is interpreted, and you can edit and test the code very quickly.
Sadly, there’s no compiler available. Locomotive say, unconvincingly, that their interpreter is as fast as other people’s compilers. Methinks they expect people to use other languages if they need the speed of compiled code.
Three file-handling schemes give you most of the traditional data-processing options, including sophisticated ISAM (Indexed Sequential Access Method) files, usually only found on big multi-user systems.
You can manipulate normal text files, printing lines then reading them back, one by one, in order. Alternatively you can use ‘random access’, dividing a preset file space into fixed-sized sections, called ‘records’. Later you can tell the system to GET or PUT collections of text and numbers in any section in the file, just by supplying the appropriate record number.
ISAM files come in two parts — one file contains the data, as in a random file, and another file, the ‘index’, contains labels or ‘keys’ used to access the data. You no longer need slot numbers, as you can associate any number of keys — strings of up to 31 characters — with any record in the data file. You can use up to eight independent indices with one file. ISAM files can save a lot of work, but it takes a while to get the hang of them and they tend to be wasteful of disk space.
You can’t write a shoot ’em up in Mallard BASIC, but it’s still a valuable addition to the Spectrum programmer’s armoury.
CP/M is no use unless the implementation is genuinely compatible with the thousands of programs available for the system. has quirks, as you might expect, but it runs most CP/M programs.
The disks, at 173K, are small by modem standards, but many CP/M machines had even smaller drives — 88K was not unknown! CP/M software is often sold on 5.25 inch disks, but conversion is not too much of a problem, as lots of firms and interest groups can convert CP/M stuff for CPC and PCW computer users with three inch drives. Spectrum CP/M seems to work fine with 173K Amstrad disks. Pro Pascal and Pro Fortran, for the PCW 8256, just plugged in and worked, although they were short of space for files on my single-drive +3.
Most CP/M systems had two drives. The +3 can run a plug-in drive B, but most people won’t want to spend that much. Locomotive provide useful two-drive emulation on drive A — the system lets you use two disks in one drive, telling you when to swap them. But beware: this can get very tedious if the program is copying a file, one line at a time, from one disk to another! An optional status line, at the bottom of the screen, says which disk should be in the drive at any time.
Spectrum CP/M can display a maximum of 51 characters per line, or 32 per line with full colour control. Most CP/M packages expect an 80-column display. To get around this, Locomotive provide a simulated 80-column mode, showing 80 columns in two overlapping 51-column sections. There’s a marker on the status line to show which side you’re on. Flicking back and forth can follow the cursor, or be manually controlled. Either way it works with most packages, but makes some very hard to use.
Text output is slow: screen updates are about a third the speed of ZX BASIC, in both sizes; scrolling is about 60% of ZX BASIC speed in 51-column mode, but — bizarrely — only 44% of Sinclair’s speed when scrolling a 32-column display.
CP/M uses two characters to mark the end of a line. Some printers only expect one, and give double-space output when you use them from CP/M. You can cure this by adjusting a switch inside your printer, unless you’ve got a really cheap and nasty model. You must use the serial or parallel ports — ZX and Alphacom printers won’t work at all from CP/M.
The manual is in three sections: the first 100 A5 pages explain how you use the system — entering and editing commands, performing ‘housekeeping’ tasks such as copying and editing files and disks, and ‘configuration’ — customising the system to your favourite key layout, language or printer. This part of the manual shows the benefits of CP/M’s 14-year life and Locomotive’s long experience of the system. It’s clearly written, although a long and wordy read for anyone who doesn’t like books. It’s packed with little comments that show that the authors have actually done what they are writing about.
The next section, 160 pages long, covers Mallard BASIC. It’s a tutorial introduction to the language — incomplete but quite a good ‘taster’.
The tutorial is no substitute for a proper reference guide, so the £10 Mallard BASIC Reference Manual is probably a vital purchase if you’re serious. It starts with a similar tutorial, followed by an extra 300-odd pages — methinks there’s a frustrated blockbuster novelist at Locomotive Software.
The CP/M manual ends with over 100 pages of appendices, covering disk contents, keywords, machine code system calls, detailed device specifications and error messages. My pre-release copy lacked an index, which Locomotive will add in the final version. They recommend that techies buy the Digital Research CP/M Plus Manual, for further information about the programming tools and the design of the system.
At £30 for CP/M Plus, utilities, and Locomotive BASIC, this package is a bargain if you’re at all interested in computers for their own sake.
CP/M Plus transforms the +3 from an ingenious but ageing games machine into an old-fashioned but useful non-specific computer SYSTEM. Like many others, I’ve found such systems a fascinating kind of general-purpose tool and toy to have around the house. It’s fun, but it takes hundreds of hours to learn your way around such a system, and not everyone can be bothered.
Even if you don’t want to be a hacker, you can be a power user with CP/M, using whatever parts of it appear to run a customised computer system for work, business or fun. Suddenly there’s more to be read in computer magazines, because you can run all the CP/M packages reviewed in CRASH, Amstrad magazines and multi-format titles like Computer Shopper.