WACCI 138 Index - Home Page www.wacci.org.uk

01 - Thanx & Stuff 02 - Fair Comment 03 - A to Z of the CPC 04 - From the Archives
05 - Twenty Questions 06 - Keyboard Scanning 07 - Meet the Relatives 08 - Programmers' Patch
09 - Genesis 10 - Famous Last Words

img_138_03_01.gif - 4,156 bytes

The A-Z of the CPC: CP/M

Your CPC's alternative operating system is the gateway to a whole world of free software, as David Cantrell explains

Don't get a complex

Your CPC is a sufficiently complex computer that it needs an operating system. This is a program which runs when the machine starts up which provides basic functionality like making it easy to use the hardware.
  For example, it provides 'firmware' functions which let you put text on the screen. Without those, you would have to access the screen memory directly, and that's a bitch of a job as any demo coder will tell you. Normally, the CPC runs a simple ROM-based operating system which includes the Locomotive BASIC interpreter.
  If you have a disk drive, then one of the things the OS does when starting up is to run a small program in the disk ROM. This program 'patches' the OS to add support for the disk. It adds a few RSXes and changes the code in memory to replace the OSes cassette support with disk support. This patched OS is known as AMSDOS.

The old world

But if you have a disk drive, then you will also have another OS available to you - CP/M. This OS was very popular indeed in the late '70s and early '80s for microcomputers. Its popularity came from the way it hid the details of the computer's design from the programmer, and that it did this job on very many different computers. Back then, there was no standard hardware design like we have today with PCs.
  Instead, all micros were radically different. They all accessed their disks differently, wrote to the screen differently, read data from the keyboard differently. CP/M hid all that.
  Any programmer working in CP/M knew that his program would work on any other CP/M computer, regardless of whether it was made by Northstar, Kaypro, Amstrad, or any of a hundred other now-defunct companies. Of course, for all this magic to work, each computer manufacturer had to write their own special version of CP/M to handle their unique hardware. But as far as the users and programmers were concerned, there were no differences - because CP/M made things Just Work.

Boot camp

Unlike AMSDOS, where the OS is stored in ROM, CP/M is stored on disk. On all computers, including the CPC, the very first thing the computer does is run a program stored in ROM. On the CPC, this program is the built-in OS.
  However, on most other machines, including the Amstrad PCW and the IBM PC, that program in ROM is much simpler. It knows just enough to read the first sector of a disk and then execute whatever it finds there. On the CPC, the equivalent of this titchy ROM program is the |CPM command, which is one of the RSXes set up by AMSDOS.
  This tiny program, usually just 512 bytes long, is known as a 'boot loader'. It is a little more clever than the program in ROM; it knows enough to read another program from the disk and run it. In the case of a CP/M machine, that program is CP/M itself. (Things are a bit more complicated with the later versions of CP/M, but let's ignore that.)

Circles within circles

CP/M is just an operating system, nothing more, nothing less. On its own, it is useless. It would be like the Mac OS with the menus, icons and pointer removed; or Linux without the ability to type in a command; or, come to think of it, AMSDOS without Locomotive BASIC.
  So the very first thing CP/M does is to load a program called the Command Control Processor, or CCP. This is a special program, and is treated somewhat differently to all other programs which are stored as files on the disk. The CCP, on the other hand, is so intimately tied to CP/M itself that it doesn't appear as a file on disk. Instead, it lives in the 'reserved' area of disk along with the OS. And what it does is present you with the familiar A-prompt.

What it feels like for a CPC

For programmers, CP/M provides a set of calls which do pretty much the same job as some of the CPC firmware calls do - print text, load data from disc, that sort of thing. Only a limited range of features are available, however. Since CP/M programs have to work on all CP/M machines, it only provides the functionality available on every such machine.
  That means no graphics, for instance, and no sound beyond a simple beep. It is technically possible to get at the CPC's other functionality, but this is frowned upon, as it will make your code incompatible with every other CP/M machine in the entire universe - rather defeating the point of writing a CP/M. program.
  Whilst the CP/M calls provide much the same functionality as the firmware, the calls themselves are rather different. They are at different memory locations, the input and output registers differ - the programming interface really is very different. But the concept is the same.
  Much CP/M programming is done in assembler. Unlike AMSDOS, though, lots of other languages are also available. These include C, Pascal, and Fortran. There are even a few different implementations of BASIC, although they are all somewhat different to the Locomotive BASIC we all know and love.

If it quacks like a duck...

From the user's point of view, CP/M on one machine is the same as CP/M on another - just like one PC is the same as another, even if they're made by different companies. The fact that each computer manufacturer needed to customize the OS to suit their hardware, which modern PC manufacturers don't need to do, isn't really that relevant.
  Even application programmers don't need to worry about the differences between different machines' CP/Ms, so a program written for one CP/M machine will work on any other. (That said, using extra features provided in later versions of CP/M can make software incompatible with early machines, just as some 6128 BASIC programs won't run on a 464.)
  This makes a huge library of software available, much of which was written by people who don't even know that our CPCs exist. This includes historic applications like Wordstar, DBase and Supercalc, as well as thousands of public domain and shareware programs.

Where to get it

There's a huge amount of CP/M software available online from various sources. I have gathered much of it together in one place, at ftp://ftp.barnyard.co.uk/cpm.
  If you're not fortunate enough to be on-line but still have access to a CD-ROM drive, it is also available from me on CD at cost price - 1.75. My address is Flat 2, 11 Beulah Road, Thornton Heath, Surrey CR7 8JH.
  If you need CP/M itself, then the source code is also available on my ftp server or CD (hehe). If you have a disk drive, however, you should already have a copy of CP/M anyway.

About the author

David Cantrell - david@cantrell.org.uk - got given his first computer, a CPC 464, for Christmas in 1984, and has played with puters ever since. He has worked for the past five years as a programmer, system administrator and security conslutant. His work has included launching magazines such as FHM, Q, Empire, Max Power and New Woman online, for which he apologises, as well as working on the Playstation 2 advertising campaign, doing dodgy work for dodgy governments at a major communications and defence contractor, and writing security applications and policies for a satellite broadband ISP.
  His writing and code has appeared in various open-source projects and professional publications, and his current interests include cryptography, Land Rovers, tooth-curling maths, and Roman military tactics. For some reason, the BBC saw fit to employ him recently.

01 - Thanx & Stuff 02 - Fair Comment 03 - A to Z of the CPC 04 - From the Archives
05 - Twenty Questions 06 - Keyboard Scanning 07 - Meet the Relatives 08 - Programmers' Patch
09 - Genesis 10 - Famous Last Words

WACCI 138 Index - Home Page www.wacci.org.uk