Introduction Index Next chapter

Part I: CP/M Plus


Chapter 1

Introduction to CP/M Plus

CP/M is an operating system - which means its job is to run programs and help you organise your data. You can use it for:

To do this, CP/M Plus has some special programs called the CP/M commands. These come in two groups, built-in commands and Transient Utility Programs - or Utilities for short. The built-in commands are automatically read into the Spectrum +3's memory every time the CP/M operating system is loaded and they are always available to you. The utilities are also stored on the Start-up disc, but they have to be loaded into the Spectrum +3's memory each time they are used.

Both programs and data are stored in Files, and to run a program what you have to tell CP/M is the name of the file holding the program you want to run. Often you also have to give CP/M the name of the file holding the data the program is going to manipulate for you.

You give CP/M all this information by typing in what are known as Command Lines. These command lines each contain:

You use command lines like this to run programs you buy such as word processor programs and spreadsheets, programming languages such as BASIC, text editors for editing your file, computer games or advanced computing tools such as assemblers. You also use command lines like this to call up the CP/M commands that help you run other programs and organise data.

Within the command line you give all the information CP/M needs to do the job you want. In particular, you must remember to include details of where the program you want to run is stored (ie. which drive it is in) and, similarly, details of where the files you want the program to work on are located. If you don't tell CP/M where to find these files it will assume that they are to be found among the files on your current disc.

Precisely how you present this information depends on the program you want to run or the command you want to use. The details are given by the program's or the command's Form or Syntax. The Form of each CP/M command is given in this User Guide as part of its detailed description in Chapter 5. The Form of the command lines you need to run any commercial programs you buy will be given in the programs' own user guides.

For example, to ERASE a file called FILE.X you would use the command line:

A>ERASE FILE.X

|  |    |

|  |    The Command Tail, in this case the name of the file you want to erase

|  The Command Name, ie. the name of the program you want to run

The System Prompt

The System Prompt is put up on the screen by CP/M to show that it is ready to receive a command. The rest of the command line you type yourself. It automatically appears to the right of the system prompt.

Command lines have to be typed correctly if the command is to work properly. You will need to pay attention to every detail of each command line: every comma, colon, semi-colon, space etc. has to be included exactly as described by the program's or the command's Form.

However, you can type characters in either upper or lower case or even a mixture of the two. For example, your Spectrum will do exactly the same actions whether your command line is:

    A>ERASE FILE.X

or  A>erase file.x

or  A>ERASE file.x

Most mistakes will be picked up when CP/M starts to process the command line (see 'When commands fail', below), but there is always a chance the CP/M will do what you say, rather than what you want! If you spot a mistake while you are typing in the command line, use the [Delete] key to rub out what you have typed back to the mistake and then type the remainder of the command line in again.

When you have finished typing the command line, you press the [Enter] key. This sends your instruction to CP/M for processing. The program you specified in the command line is then run. When the program has finished, CP/M puts a fresh system prompt on the screen. It is then ready to process another instruction for you.

1.1 Getting started

Before you can run any application program under CP/M Plus on the Spectrum +3, the computer has to read CP/M off the CP/M Start-up disc into its memory. The Spectrum loses the information it needs to run CP/M programs each time it is switched off or reset.

As you will find yourself changing the disc in the drive quite often while you run CP/M, you should remind yourself of the rules about handling discs given in Chapters 3 and 5 of the Spectrum +3 User Guide. In particular, remember that you should never remove a disc while the light on the disc drive is on or flashing on and off: that could damage your disc, let alone the data on it.

The steps involved in loading CP/M onto the Spectrum +3 (the process often referred to as 'booting CP/M') are as follows (Note: You may have just done this in the preparation section of this guide: if so, you don't have to load CP/M again):

  1. Check that there is no disc in the drive: then turn the machine on. Your Spectrum then displays its standard Opening Menu.
  2. Hold your CP/M Start-up disc by its labelled end with Side 1 uppermost and insert it into Drive A (the built-in floppy disc drive).
  3. Check that the Loader option is highlighted, then press [Enter]. The Spectrum then displays the message Loader and reads from the disc.

If all is well, the Spectrum then displays a message like:

        CP/M Plus  Locomotive Software Ltd

        vx.x, 61K TPA, 1 disc drive



        RAMDISC vx.x [size=12k] installed

and carries out a few extra commands. Finally it stops, with A> on a fresh line followed by a bright oblong.

If instead the screen flashes red or you see the message Insert TAPE and press PLAY, the disc you've used either isn't suitable for loading in a Spectrum or is damaged in some way. Check that you inserted the correct disc then try again. If it still fails, take the disc back to your dealer.

The bright oblong is called the Cursor and its position marks where the next character you type in will appear on the screen.

Note: To finish working with CP/M at any time, simply make sure the disc drive is empty and then press the Reset button on the lefthand side of your Spectrum.

1.2 CP/M and the keyboard

When you are using the CP/M operating system and programs like Mallard BASIC that run under CP/M, the keyboard works in essentially the same way as it does when you are running Spectrum BASIC.

If you press any letter or digit key on its own, then you type the character shown on the keytop. If you hold down the [Caps Shift] key and press one of the letter keys, you type a capital letter. If you hold down the [Symb Shift] key and press either a letter or a digit key, you type the punctuation mark or other symbol shown on the keytop.

Other key combinations, in particular involving the function keys round the edge of the keyboard, carry out a range of actions. In particular, the four keys either side of [Space] act as Cursor keys and allow you to move the cursor to a different place on the screen, the [Delete] key allows you to rub out the character you typed last and the [Break] key in the top righthand corner of the keyboard usually (but not always) stops whichever program you are using.

However, this is where the similarity ends because the range of special characters you can type, the key combinations you use to type these and the actions you get by pressing particular keys are not the same as those you get when you are using Spectrum BASIC.

In particular, holding down the [Extend Mode] key and pressing a letter key types one of the CP/M 'Control codes'. For example, holding down [Extend Mode] and pressing the A key types the code Control-A. These codes have special actions depending on what you are doing. In Chapter 3, we will see how some of the codes can help you correct typing mistakes in CP/M command lines; other codes may be used by your program to access special features.

Full details of the key combinations you need to type each character and of the special actions and control codes you can access are given in Appendix II alongside the details of the CP/M Character Set.

1.3 CP/M and the screen

CP/M uses the screen in three main modes which give you different numbers of characters on each line of the screen. In addition, you have the option of using the bottom line of the screen purely for messages from the system such as 'Drive not ready - Retry, Ignore or Cancel'. The advantage of having this line as a 'Status line' is that then such messages attract your attention without interfering with the rest of the screen display. (Some Status line messages draw attention to themselves by scrolling right to left like a newscaster). Moreover, they can be cleared away once the problem has been coped with. With the Status line 'turned off' the message simply appears on the next line of the screen and rolls off the screen with the rest of the display.

The three fundamental ways of using the screen are:

The 24 x 51 and 24 x 80 screen sizes are the ones you are most likely to use. 24 x 51 is the standard screen size for CP/M on the Spectrum +3. 24 x 80 is the standard screen size on most other computers that run CP/M. When you run a program that was originally designed to run on a computer with a 24 x 80 screen, you will want to use your Spectrum's 24 x 80 option so that any output from the program is displayed properly on the screen. The 24 x 32 screen is supplied for programs that use colour and which would be adversely affected by the 'attribute clash' effects that you would get on the Spectrum screen when this uses the smaller character size.

To change over to using a different size of screen, you have to send a special group of characters to the screen called an Escape sequence. The way you do this depends on what type of job you are doing:

In 24 x 80 mode, you can swap between the two 'halves' of the screen by holding down [Extend Mode] (or [Caps Shift] plus [Symb Shift]) and pressing [Enter]. (Note: pressing both [Extend Mode] and [Enter] requires both hands, but you only need one hand to press [Caps Shift] and [Symb Shift] together with [Enter].)

The screen may also be swapped over from one side to the other while you are running a program. The standard rule is that you always see the 'half' of the screen with the cursor. The cursor isn't displayed continuously - only when your program pauses - so it is just if the program stops sending output to the screen that you might be automatically swapped over to the other half of the screen.

If you don't want the screen to automatically flip between the two halves, you can disable (and re-enable) this feature by sending further Escape sequences to the screen (the sequences are also detailed in Appendix III). These escape sequences can be sent to the screen while the A> system prompt is displayed by pressing the following keys:

The Status line is also turned on and off by sending Escape sequences to the screen (also detailed in Appendix III). Typically you would send these sequences by pressing keys while the A> prompt is displayed. The keys to press are as follows:

The best way to become accustomed to these different options is to try them out. Simply type the command or the sequence of keystrokes for the option you want and then type a few characters at random to see how the screen now works.

In particular, type the command SET24X80 [Enter] to select a 24 x 80 screen; notice how there is now a [#_] at the lefthand end of the Status line. Next hold down the [Extend Mode] key and press [Enter]. This moves you the righthand end of the screen. Notice how there is now a [_#] at the righthand end of the Status line. These markers on the Status line give you an easy way of telling which half of the screen you are working on. (Note: They are not displayed when the Status line is turned off.)

You should also try out turning the Status line off and on by pressing keys. In particular, note how the keys you press appear as characters in the current command line. Note: The remainder of introduction assumes the Status line is displayed, so finish with the Status line on.

The other aspect of the screen is to think about the colours it displays. When you first load CP/M, the screen is shown as white characters on a blue 'page'. But this isn't the only combination of colours you can use: you can change either the foreground colour (the colour used to write characters) or the background colour (the colour used to write characters against) whenever you like.

The colours that you can use are Black, Blue, Red, Magenta, Green, Cyan, Yellow and White and they can be displayed either at normal intensity or as the 'Bright' version of the colour (though there is no such thing as Bright Black!). All these colours can be used either for the foreground or for the background. In general, you should make both colours either normal intensity or bright: if you mix a 'normal' colour with a bright one, you just get the normal version of both colours.

To change the screen colour, you can use a special CP/M command called PALETTE. The command line you need is:

        PALETTE background-colour foreground-colour [Enter]

Important: Background-colour and foreground-colour are what are known as 'place-holders'. They mark the place in the command line that you need to specify a particular piece of information and they also describe the information that is required. In fact, what is needed at these points when you actually type your command line are the numbers which represent the colours you want. The numbers you need to type are given in the table below. These numbers probably look a little strange: they are in fact chosen to be compatible with the CP/M systems on other Amstrad computers, some of which show more colours.
Normal colourNumberBright colourNumber
Black 0
Blue 2Bright Blue 3
Red 8Bright Red 12
Magenta10Bright Magenta15
Green 32Bright Green 48
Cyan 34Bright Cyan 51
Yellow 40Bright Yellow 60
White 42Bright White 63

So for example, if you want to have Bright Cyan characters (colour 51) on a Bright Red background (colour 12) you would use the command:

        PALETTE 12 51 [Enter]

When you change colour, the border of the page is instantly changed to your new background colour. You won't see any other effect until something is written on the screen, for example when you type new commands, and then the new colours are only used for the updated parts of the screen. As a result, your screen display can become a very complex pattern of colours.

When CP/M is loaded, it works with (Bright) White characters on a Blue background. The command to restore the screen to this combination is:

        PALETTE 2 63 [Enter]

1.4 More about CP/M

Before you go on to use CP/M to run applications programs, it is worth looking at the components of CP/M command lines in a little more detail and what happens when you get the command wrong.

A>ERASE FILE.X

|  |    |

|  |    The Command Tail, in this case the name of the file you want to erase

|  The Command Name, ie. the name of the program you want to run

The System Prompt

More about file names

CP/M identifies files by a two-part name. The first part is called the Filename and the second part the Filetype.

The filename can esssentially be any combination of up to eight characters, though you shouldn't use certain special characters:

< > = ! | * ? & / [ ] ( ) . , : ; \ + -

Often just the letters of the alphabet A...Z and the digits 0...9 are used. (CP/M doesn't distinguish between capital letters and small letters in file names and so there is no difference between using A...Z and a...z.)

The filename will usually have been chosen to suggest what the file contains but this doesn't have to be so.

The filetype is up to three characters long, and again the characters recommended are A...Z and 0...9. However, the sort of operations that are to be done using the file may force you to give the file a particular filetype.

When typing in your command line, you will always have to give the filename and often you will have to give the filetype as well. If so, the way to type this is the filename, followed immediately by a dot, followed immediately by the filetype. For example, if the file you want to specify has the filename MYFILE and the filetype TXT, you would type MYFILE.TXT in your command line.

The other piece of information you may have to give CP/M is a letter that tells it which disc holds the file you want.

CP/M can cope with up to 16 drives, which it calls A, B,...P. So, for example, if MYFILE.TXT is on drive B, you might have to type B:MYFILE.TXT. The B: tells CP/M to look for the disc in Drive B.

At any one time, CP/M calls one of these drives its Default Drive and you don't need to give the drive letter for files on the disc in that drive. This is usually Drive A but you can change it as we shall describe later. Thus specifying MYFILE.TXT will usually be the same as specifying A:MYFILE.TXT.

More about the System Prompt

The main job of the system prompt is to tell you that CP/M is ready to receive a new command. If there is a system prompt on the screen with the cursor to the right of it, you can type in your command.

The system prompt also tells you which drive is the current default drive. When the system prompt is A>, the default drive is Drive A - the built-in disc drive. If you have two floppy disc drives, you might change the default drive to Drive B (your second disc drive); the system prompt would then become B>. (How to change the default drive is described on page 18.)

More about the Command Name

The Command Name tells CP/M which command you want to use or which program you want to run. This could be:

You will be able to recognise which of your files contain programs you can run from their filetype. CP/M programs have the filetype COM (ie. names like MYPROG.COM) and Submit files have the filetype SUB (for example, MYSUBMIT.SUB).

The command name has two parts:

The command name never includes the filetype of a program, a command file or a Submit file.

The location part of the command name is only included when the command or program is not immediately available. CP/M internal commands are always available; the other programs that are immediately available are the CP/M external commands and other programs on the disc in your default drive.

For all other commands and programs, you have to tell CP/M in which drive to look for the program. For example, if you want to use the external command GET which you have stored on the disc in Drive B, you would start your command line:

        B:GET ...

Note: Not B:GET.COM ...

More about the Command Tail

The information a program needs in the Command Tail and the order this is given in depend on the program. It is all laid out in the 'Form' or 'Syntax' statement for the command line and must be followed exactly if the program is to work correctly.

The Form of the command line for each CP/M command is given in Chapter 5 where the commands are described in detail. The form of the command lines you will need to run the commercial programs you buy depends on the programs' own user guides.

The Form statement shows you how to give CP/M the details of the files you want the programs to process and it tells you how to specify the program options you want to take advantage of. The way it does this is through options like d:, filename, parameter, and physical-device written in a different style to the rest of the line. (In this manual these are always written in an italic script). These are known as placeholders and they show where you need to insert details of the actual job you want to do, for example the name of the file you want to copy or the name of the file you want to store the copy in.

For example

        RENAME new-name=old-name

tells you to type RENAME, followed by a space, followed by the new name you want to give the file, followed by =, then the old name (ie. the current name) for the file, and finally press [Enter] to send the command to CP/M for processing. So if you wanted to rename the file FILE.X and call it MYFILE.X1, the command line you would type would be:
        RENAME MYFILE.X1=FILE.X [Enter]

What you need to replace the placeholders with should be explained either in the notes describing the command line or in a section covering the conventions used in the manual. There may also be parts of the command line that you can miss out if they are not appropriate. The way this is shown in this manual is explained at the start of Chapter 5.

When commands fail

Commands fail because:

You can usually tell why a command has failed from what appears on the screen.

1.5 Some practice in using CP/M

In principle, you now know enough about CP/M to run any well-documented CP/M program.

Unfortunately, this will not always be the case. We give advice on how to go about choosing the software to buy in Chapter 2 but, even so, you are advised to spend some more time learning about CP/M itself. Then, you'll be able to get the CP/M application software you buy working that much easier.

The rest of this introduction takes you through some simple uses of CP/M. Although you can just read it, we suggest that you work through the instructions using the Spectrum as it will get you used to how CP/M works.

The Spectrum is supplied with more than 30 utilities. Some of these utilities extend a similarly-named built-in command to give that command extra features.

As we described earlier, you give instructions to CP/M by typing in what are known as Command Lines. These must be absolutely correct if they are to have the right effect but it doesn't matter if you make a mistake while typing in the line: just use the [Delete] key to rub out what you have typed back to where you made the mistake and then type it in again from that point.

At the end of each command line, you have to press the [Enter] key; this sends the instructions to CP/M. We will remind you to do this throughout this introduction by putting [Enter] at the end of each command line we suggest you type in. But in line with almost every reference book on CP/M, these are omitted in the more advanced parts of this User Guide.

Command lines will only be obeyed if they are typed when CP/M is ready to receive a command, which it shows by putting a system prompt (for example, A>) on the screen.

The rest of this section is designed to help you learn what instructions to give CP/M.

What's on your discs

The first thing you will want to know about any disc you put in the drive is what files are on the disc.

The names of all the files on a disc are held in a Directory and you look at the contents of the directory with the aid of DIR, one of the built-in CP/M commands.

Put your CP/M Start-up disc back in the drive. To see the names of the files on this disc type in this instruction after the A>:

	DIR [Enter]

CP/M never distinguishes between lower case and upper case letters so you can use whichever you prefer. You don't even have to be consistent.

Up on your monitor screen will come something like:

	A>dir

	A: S01CPM3  EMS : RPED     BAS : LANGUAGE COM

	A: PALETTE  COM : BASIC    COM : SET24X80 COM

	A: DIR      COM : DISCKIT  COM : ED       COM

	A: ERASE    COM : SETKEYS  COM : SETLST   COM

	A: PIP      COM : RENAME   COM : RPED     SUB

	A: PROFILE  SUB : SET      COM : SETSIO   COM

	A: SETDEF   COM : TIMEOUT  COM : SHOW     COM

	A: SUBMIT   COM : TYPE     COM : RAMDISC  FID

	A: DUMP     COM : RESET    KEY : DEVICE   COM

	A>

The leftmost column is full of 'A:'s because the disc is in the drive CP/M calls drive A.

The rest of the list is made up of alternate columns of filenames and filetypes, starting with filenames. Each filename goes with the filetype immediately to its right - so SxxCPM3 and EMS is one file, BASIC and COM is another, and so on.

Some of these files contain CP/M programs, some hold BASIC programs and some are data files. You can tell which is which from their filetypes.

For example, you will see that most of the files listed on the screen have the filetype COM. This means that the file holds a program that CP/M can run. Other special filetypes in this list are: BAS - indicating a file containing a BASIC program; SUB - indicating a file that contains the instructions to run a sequence of CP/M programs; and EMS. The EMS file is the one that contains CP/M.

Much of the time, you will be interested, not so much in what files are on a disc, but whether the file or files you want are on the disc. The DIR command can do this for you.

Suppose you want to see if you have a file with the filename SET and the the filetype COM on this disc. The command line that does this is:

	DIR SET.COM [Enter]

Notice that we have quoted the name of the file by putting its filename and then its filetype, separated by just a dot.

The response on the screen will be:

	A:SET     COM

If the file hadn't been on the disc, you would have seen the message:
	No File

If you had known that the filename of the file you wanted was SET but you couldn't remember its filetype, you could have used the DIR command to list out the whole directory as before. A better solution would have been to give DIR a template that fits the name you are looking for and instruct it to search through the directory for all the files that match this template.

Templates are constructed using the Wildcards * and ? - an asterisk represents any number of characters but a question mark only represents a single character.

The template for all the files with the filename SET is SET.* and so the command line you would type in is:

	DIR SET.* [Enter]

What will appear on the screen is again:

	A:SET     COM

which tells you that DIR has found just one file matching the template - the file SET.COM.

You would use a similar template if what you wanted listed out was all the program files on the disc. This time we would use an asterisk in place of the filename:

	DIR *.COM [Enter]

You would also use an asterisk in the template if you knew just the first few characters of either the filename or the filetype or if you wanted to list all the files with the same few characters at the start of their filenames.

Say, for example, that you wanted DIR to list out all the files on the disc that have filenames starting with SET, regardless of their filetype. The command line that does this is:

	DIR SET*.* [Enter]

Notice that you have to use two asterisks: one in the filename and one in the filetype.

So far, we have just described how to use the asterisk wildcard. You would use the question mark wildcard if, for example, the files you wanted listed out all had filenames starting with SET but no more than six characters.

Suppose you want all these files whatever their filetype. The command line you would need is:

	DIR SET???.* [Enter]

We will tell shortly of some other uses of wildcards and how these will often save you a lot of typing.

Copying files

The CP/M utility that makes a copy of a file, either on the same disc or on another disc, is called PIP. This utility is not built into CP/M: instead it is stored on Side 1 of your CP/M Start-up disc and it has to be read from the disc every time you want to use it.

The information you give PIP is the name of the file you want copied (the Source) and the place you want the copy stored as (the Destination). PIP will proceed to make the copy, provided that there is enough room on the disc for the new file.

To illustrate how the PIP utility works, we will make a copy of the file called BASIC.COM on the Data disc you prepared in the initial preparatory session. BASIC.COM holds your copy of the Mallard BASIC programming language. In copying this file to your Data disc, we are taking advantage of a good opportunity to move this file from your CP/M Start-up disc to a separate 'BASIC' disc where it can be stored alongside your BASIC programs.

(Note: The techniques we describe here are important throughout your use of CP/M, particularly if you don't have a second disc drive. They don't just apply to copying files from one disc to another - but to any case when you want to make use of more than one floppy disc at a time.)

You might expect the commands involved in making this copy to be very different, depending on whether you just have one floppy disc drive or whether you have added another disc drive to your system. But in fact they are remarkably similar, thanks to a subtle trick whereby the Spectrum pretends to CP/M that your single disc drive is really two disc drives - called Drive A and Drive B. The only real difference is that on a two-drive system, you can put each of the discs into its own drive and leave them there throughout, but on a single-drive system, you have to swap from one disc to another according to the needs of the program you are using.

On a single-drive system, you can see whether CP/M currently regards the drive as Drive A or Drive B from the message in the bottom righthand corner of the screen (on the 'Status' line). Normally this shows Drive is A, but the moment the drive is changed from Drive A to Drive B, the message in the bottom right hand corner of the screen changes to Drive is B and you will get a message asking you to replace the disc currently in the drive by the 'disc for Drive B' - ie. the one that you would use in the second drive if you had such a drive.

Similar messages appear when the drive is changed from Drive B to Drive A.

In this case, the disc to put in 'Drive A' is Side 1 of the CP/M Start-up disc and the one to put in 'Drive B' is Side 1 of your Data disc. If you have a two-drive system, you can insert both these discs now. On a single-drive system, start with the CP/M Start-up disc in the built-in drive (with Side 1 uppermost) because this has the PIP program on it.

The command line you use whether you have one or two drives at your disposal is:

	PIP B:=A:BASIC.COM [Enter]

This tells CP/M to copy the file BASIC.COM on the disc in Drive A and to store the copy on the disc in Drive B. Notice that you give PIP the details of the Destination file, before you give it details of the Source file.

CP/M's first job is to read the file BASIC.COM into memory. The PIP command tells it that this file is on the disc in Drive A and as the built-in drive is currently Drive A, it looks and finds BASIC.COM on the disc currently in the drive. So it goes ahead and reads it.

Then it wants to write a copy of this file on your Drive B disc. On a two-drive system, this disc will already be in your second disc drive, but on a single-drive system, the drive is changed from A to B and the following rolling message is displayed at the bottom of the screen:

	Please put the disc for B: into the drive and press any key

Release the Start-up disc from the drive, insert the 'disc for B:' (your Data disc) with Side 1 uppermost, and press, say, the space bar. The computer then writes a copy of BASIC.COM onto this disc and again gives it the name BASIC.COM. You can check that this has been done by typing:

	DIR B: [Enter]

Note: In some cases, the file will be too big to copy in one go. When this happens, CP/M will copy as much as it can (as described above), then put up the message Please put the disc for A: into the drive and press any key so that it can read some more of the original file. Later it will ask again for the disc for Drive B. Simply keep swapping over discs and pressing the space bar until the copy has been completed.

As with DIR, you can use a template to specify a number of files to copy at the same time but often there won't be a template that fits all the files you want to copy and no others. When this happens, you have to type a number of PIP commands. This can be fairly laborious - particularly as the PIP command is stored on disc and has to be loaded into memory each time before it is used. Fortunately, there is a neat way of making a sequence of copies that doesn't involve loading PIP into memory specially for each copy. This is explained in Section 3.3.

If you want to have a second copy of a file on the same disc as the original, you have to give the new file a different name from the original: you cannot have two files with the same name on one disc. For example, to make a second copy of the BASIC.COM file on your Data disc and call this COPY.TMP you would give the command:

	PIP B:COPY.TMP=B:BASIC.COM [Enter]

Changing the default drive

So far in this tour, we have been using Drive A as the default drive - ie. as the drive CP/M will assume you want it to work with unless you tell it otherwise. Drive A is the default drive that you always get immediately after CP/M has been loaded and often there's no need to change this. But if you are using a number of files on your Drive B disc, it may be better to change the default drive to Drive B. The command you use to do this is simply:

	B: [Enter]

CP/M responds by making the system prompt B> - to show that Drive B is now the default drive. The letter usied in the system prompt always shows you which drive is currently the default drive.

Whenever the system prompt is B>, the default drive is Drive B and any files that are on Drive B can be specified just by typing their filename and filetype but any files that you want to use on Drive A have to be written with A: in front of them. So, for example, the PIP command we gave above when Drive A was the default drive:

	A>PIP B:COPY.TMP=B:BASIC.COM [Enter]

becomes when the default drive is Drive B:
	B>A:PIP COPY.TMP=BASIC.COM [Enter]

Return to drive A as the default by typing A: [Enter]

Organising your discs

As well as letting you copy files, CP/M helps you to rename them or erase them from the disc. These (and other similar) operations are often referred to as Disc Housekeeping. As you use CP/M more, you will find you need these quite often.

The CP/M command to use to rename files is called RENAME - often abbreviated to REN. This command works purely on the directory of a disc, substituting the new filename and filetype for the old ones. The data itself is not changed.

You can change the name of a file as many times as you want. All you have to give RENAME is first the new name and then the old.

We shall illustrate this by changing the name of the COPY.TMP file you made on your Data disc, to TEMP. The command line that does this is:

	REN B:TEMP=B:COPY.TMP [Enter]

Obviously the drive letter should always be the same in both the new name and the old.

If you have a single-drive system, you will notice how this time you haven't had any message about inserting the disc for Drive B. The reason for this is that CP/M still sees the disc drive as drive B (from the last action you did). As Drive B is the only disc it needs to read for this command and as you've got the Drive B disc in the drive, it simply goes ahead and renames the file for you.

So far, we have only described changing the name of one file. Templates like the ones you set up for use with the DIR and PIP commands can also be used with RENAME. However, there are two things to be careful about here:

  1. you must be careful to ensure that the way you use wildcards in the new file specification is identical to the way you use them in the old
  2. you must have the supplementary RENAME utility available on the default drive.

You erase any files you no longer need with the ERASE command - often abbreviated to ERA.

To show how to use the ERASE command, we shall erase the file you have just renamed TEMP. The command line that does this is:

	ERA B:TEMP [Enter]

Again you won't have had a message about inserting your Drive B disc.

The ERASE command also allows you to set up a template with wildcards and so use just one command line to erase a number of files. This should be used with care, as files once erased cannot be restored. Again, you have to have the supplementary ERASE utility available on the default drive when you use this command.

However, there is an extra feature of the ERASE command that ensures that none of the files that fit the template are erased until you confirm that you want this done.

We shall illustrate this by using this feature to erase BASIC.COM from your Start-up disc. Check that the current default drive is drive A (ie. the system prompt is A>) then type in the following command line: (Note: If you don't want to use your new Data disc for BASIC programs, then you could if you wish erase BASIC.COM from your Data disc instead of from your Start-up disc by putting B: in front of the filename in the command).

	ERA BASIC.* [C] [Enter]

The [C] tells CP/M that you want to use the 'Confirm' or 'C' Option of the ERASE command.

A number of the CP/M commands and utilities have Options, which we cover mainly in the reference sections of this user guide. They are always specified by putting their name between square brackets at the end of the command line. In some cases, you can omit the closing square bracket.

In this case, you will first get a message telling you to insert the disc for Drive A (CP/M needs this disc both to find the files to erase and, as it happens, to find the supplementary ERASE utility). Then you will see:

	A: BASIC   .COM (Y/N)?

Type Y to confirm that you want this file erased.

File sizes

Before you can say whether there is enough room for a file on a disc, you need to know three things - how big the file is; how much free data space there is on the disc; and whether there is room in the directory for its name. The directories on Spectrum discs can't hold more than 64 names.

For example, you can find out how big the PROFILE.SUB file is through the command line:

	DIR PROFILE.SUB [SIZE] [Enter]

What this does is use an extra features of the DIR command provided by the DIR utility - the SIZE option. DIR searches through the directory as before but this time it displays, not just the filename and the filetype, but the size of the file as well.

Among the information that should now be on your screen is:

	A: PROFILE .SUB   1k  

This tells you that PROFILE.SUB occupies 1k of disc space and so there will have to be at least 1k of free space on the disc if you are to put a second copy of this file on it.

The 'k' here stands for Kilobyte and it is the unit in which disc space is always measured. It corresponds to roughly 1000 characters. The disc in the drive can store up to 173k of data.

The next thing to do is to find out how much free space there is on the disc you propose to use. The utility to use here is SHOW and to find out how much space there is on the disc in drive A, you use the command line:

	SHOW A: [Enter]

Up on the screen will come something like this:

	A: RW, Space:       29k

This tells you that the amount of free space on the disc is 28k, while the RW tells you that the Spectrum is allowed to both read from and write to discs in Drive A. (If you erased the copy of BASIC.COM on your Data disc rather than that on your Start-up disc, the amount of space will be 1k rather than 29k!)

The fact that the status of the drive is RW is no guarantee that you will be able to write to the disc in the drive. If the Write Protect Hole on the disc is open, you will always be prevented from writing to that disc and from erasing or renaming any of the files.

The remaining check is that there is enough room in the directory for trhe new filename. The maximum number of names that can be held in the directory is 64 and once that number of directory entries has been reached, no more files can be written onto the disc, however much free space there is available on the disc. (Note: The number of directory entries you have used up isn't always the same as the number of files on the disc: larger files can use up more than one entry in the directory.)

SHOW is again the utility to use, but this time with one of its options. The command line to use is:

    SHOW A:[DIR] [Enter]

Up on the screen will come something like:

    A: Number of free directory entries:   36

(34 if you erased BASIC.COM from your Data disc, rather than form your start-of-day disc.)

These commands together confirm whether you have both enough room both on the disc and in the directory for the new file you wish to make.

Looking at files

To find out what the PROFILE.SUB file contains we need to use another of CP/M's built-in commands, TYPE.

The command line that lists out its contents is:

    TYPE PROFILE.SUB [Enter]

If you do this, you will see that each like of the file is rather like the commands you have been typing in yourself. We will explain why next.

Note: TYPE is only useful to display simple ASCII text files such as PROFILE.SUB. If you try to display anything other than an ASCII text file, the result won't be readable.

Some shortcuts to take

A useful facility of CP/M is that it lets you put a number of command lines into a file and then just type one command line to get exactly the same effect as typing all the commands in separately.

The command you type in uses the SUBMIT utility, which is stored on side 1 of your CP/M Start-up disc. The file holding the command lines must have the filetype SUB. PROFILE.SUB is just such a file.

Most of the commands in PROFILE.SUB are PIP commands, which copy the two files PIP.COM and SET24X80.COM to a special drive called Drive C. This isn't a drive that you can insert discs in, but part of the Spectrum's memory which is specially set up to work like an extra disc. This drive, also known as the Memory disc or RAM disc, is only small (just 12k) but it can be used as a temporary storage place for a few files that it is useful to have available while you're working. The storage can only be temporary because the memory is wiped clean the moment you switch off or reset your machine.

The other commmand line in the file uses the SETDEF utility to instruct CP/M to look for its utilities on more than one drive. This is another useful shortcut provided by CP/M.

The particular form used here:

    SETDEF *,C:[ORDER=(SUB,COM)]

tells CP/M two things:
  1. to look for the programs you want to run first on the default drive and then on Drive C; and
  2. to execute the commands in a SUB file in preference to running a program with the same name.

PROFILE.SUB is a special SUB file. It is accessed by a SUBMIT command embedded in the file that loads CP/M, and the command lines within the file are obeyed every time you load CP/M - you won't normally need to SUBMIT this file yourself. However, if you did want CP/M to carry out these commands again (for example, because you accidentally erased PIP.COM and SET24X80.COM from the Memory disc), you would simply have to type:

    SUBMIT PROFILE [Enter]

(You don't have to give the filetype because it has to be SUB.)

A final shortcut to mention here are the keystrokes you can use to save effort in typing in and correcting command lines.

Rather than use the [Delete] key to rub out everything back to the part of the command line you want to correct, you can use the cursor keys [<] and [>]. You can then use the [Delete] key and [Graph] key (next to the [Delete] key) to erase characters and type in any new characters you want at the cursor position.

You can also use the [Edit] key to recall the previous command line. This is covered, alongside details of other editing shortcuts, in the section on Command Line Editing (Section 3.5).

Your Spectrum +3 is now well set up for working with CP/M application programs. Chapter 2 contains advice on buying and running software, while Part II of the User Guide tells you about writing and running Mallard BASIC programs.

From time to time, you will need to check up on how CP/M itself operates. For this, we have provided Chapters 3 and 4, the separate sections of which describe how to carry out particular actions. Chapter 3 covers general 'housekeeping' tasks; Chapter 4 covers the more complicated actions involved in setting up your Spectrum to work with printers, modems and the like. Chapter 5 gives full details of the individual CP/M commands and utilities.


Introduction Index Next chapter