JUDIN. FERNANDEZ RUTH ASHLEY
' ll eee t FR BS nw ae
SE
USING CP/M°
by JUDI N. FERNANDEZ RUTH ASHLEY
Co-Presidents DuoTech
John Wiley & Sons, Inc., Publishers
New York ¢ Chichester * Brisbane * Toronto * Singapore
Copyright © 1980, by John Wiley & Sons, Inc. All rights reserved. Published simultaneously in Canada.
Reproduction or translation of any part of this work beyond that permitted by Sections 107 or 108 of the 1976 United States Copyright Act without the permission of
the copyright owner is unlawful. Requests for permission or further information should be addressed to the Permissions Department, John Wiley & Sons, Inc.
Library of Congress Cataloging in Publication Data:
Fernandez, Judi N 1941-
Using CP/M®
(Wiley Self-Teaching Guides)
1.CP/M (Computer program) 2. Microcomputers — Programming. I. Ashley, Ruth, joint author. II. Title.
QA76.6.F 46 001.64’2 80-36673 ISBN 0-471-08011-X
Printed in the United States of America 81 80 1098 765 4
Iv
To Peggy Kolbe, who supports all our writing efforts
Acknowledgments
Our thanks to Bill Gutz and Walt Jellison, who sold us CP/M, to Paul Ward, who helped us get our early versions running,
to P. Scot McIntosh, who provided technical assistance and reviews while we wrote this book,
to Mary Hoogterp and Donna Tabler, for testing the content, and
to Barbara Tabler, for typing the manuscript and trying out our answers whenever she didn’t believe them.
vi
To The Reader
About CP/M
CP/M — Control Program/Microcomputers — is a disk operating system for microcom- puters based on the 8080, 8085, and the Z-80 type microprocessor chip. It is a software package developed and distributed by Digital Research of Pacific Grove, CA. It has be- come the most common microcomputer operating system and many other commercially available software packages are written to run under CP/M.
An operating system is a set of programs that helps you operate the computer and perform routine work functions. The CP/M system includes programs that allow you to run other programs, create files, erase files, copy files, translate, and test 8080 Assembler language programs, print data from files, display the directory of a disk, and so on. With- out CP/M or a similar operating system, it would be very difficult and tedious for you to perform even the most trivial task on your computer.
This book assumes that you have a microcomputer and a CP/M package. Our intent is not to help you select a system, but to help you use what you already have. If you do not yet have your system, but have selected the machine and CP/M, you will still benefit from studying this book. You will need to skip the machine exercises and come back to them when your system has been installed.
This book presents the basic CP/M package delivered by Digital Research. Your hardware manufacturer may have adapted CP/M to fit the features of its equipment. They will, however, most likely have added functions. Therefore everything presented in this book should work on your system no matter what hardware you are using. For extra features study the manuals that arrive with your system — after you have finished this book.
There have been several versions of CP/M released by Digital Research. Each new release is an upgrade of earlier releases. Nothing is lost ,but some features may have been changed as well as new features added. This book is current with release 2.0. However, we will warn you of differences from earlier versions.
vii
About the Authors
The authors have published more than 100 computer-related instructional courses. We use CP/M daily in our own work and have a great deal of practical experience in using it and in explaining it to others. Our small business system consists of an Altos CPU, two Shugart disk drives, Perkin-Elmer Fox terminal, and Diablo printer. On a daily basis our system is used for word processing, COBAL, FORTRAN, BASIC, Assembler, and Pascal programming.
How to Use This Book
This Self-Teaching Guide consists of 10 chapters that have been carefully sequenced to introduce you to CP/M and to help you to develop a useful set of skills. We have made every effort to organize the material in the best possible learning sequence, so that you can begin using CP/M as quickly as possible. We strongly recommend that you study the chapters in order. You will learn to do easy tasks, then successively more complex tasks, until you have mastered the system.
Each chapter begins with a short introduction followed by objectives that outline what you can expect to learn from it, and ends with a Self-Test which allows you to measure your learning and practice what you have studied. Each chapter also contains a Suggested Machine Exercise that guides you in transferring your new knowledge to the real, hands-on envixsonment.
The body of each chapter is divided into frames — short numbered sections in which information is presented or reviewed, followed by questions which ask you to apply the information. The correct answers to these questions follow a dashed line after the frame. As you work through the book, use a folded paper or a card to cover the correct answer until you have written yours. And be sure you actually write each re- sponse, especially when the activity is coding CP/M commands. Only by actually writing out the commands, and checking them carefully, can you get the most from this Self- Teaching Guide.
And don’t worry! There’s almost nothing you can do, apart from outright physical abuse, that can damage your system. Certainly there’s no command you can enter that will hurt either CP/M or the hardware. At the most, you can lose some data, and that’s what this book and the Suggested Machine Exercises will help to prevent.
For the proper physical care of your system see your manufacturer’s recommenda- tions.
Contents
To the Reader vii How To Use This Book ix Chapter 1 Introduction to CP/M 1
Microcomputer Components, 1 The CP/M Programs, 5
CP/M Architecture, 10
Disk Drives, 11
Disks, 14
Files, 15
Booting, 18
The New CP/M System, 19 Self-Test, 20
Answer, 22
Suggested Machine Exercises, 22
Chapter 2 Typing CP/M Commands 24
General Command Format, 24 CP/M Command Processing, 28 CP/M Control Characters, 30 Self-Test, 38
Answer, 40
Suggested Machine Exercises, 40
Chapter 3 CP/M Built-In Commands 42
DIR Commands, 42
ERA Commands, 45
REN Commands, 46
TYPE Commands, 49
SAVE Commands, 51 Generalized File References, 51 Version 2.0 Enhancements, 60
xi
xii CONTENTS
User Number, 60
Self-Test, 63
Answer, 65
Suggested Machine Exercises, 66
Chapter 4 CP/M Transient Programs 68
Program-Related Transients, 72 System-Related Transients, 75 CP/M Transients, 87
Self-Test, 89
Answer, 90
Suggested Machine Exercises, 91
Chapter 5 The STAT Command 93
Device Assignments, 94
Disk Status, 95
File Status, 97
STAT for Version 2.0, 98
User Status, 103
Disk Status, 104
Stat Options List, 105
Self-Test, 106
Answer, 108
Suggested Machine Exercises, 109
Chapter 6 Using PIP 111
Self-Test, 128 Answer, 130 Suggested Machine Exercises, 131
Chapter 7 Introduction to ED 133
Character Editing, 134
Character Pointer, 136
Line Numbering, 138
Upper Case Translation, 139
The Setup, 140
Using Line Numbers and Upper Case Translation, 144 Insert Level, 145
Tabbing, 149
ED Error Messages, 154 Self-Test, 157
Answer, 159
Suggested Machine Exercises, 160
Chapter 8
Chapter 9
Chapter 10
Appendix A Appendix B Appendix C
Index
CONTENTS xiii
Editing Existing Files 163 ED Line Management, 168 Displaying Lines, 170
Character Pointer Commands, 173 Delete Commands, 177
Insert Command, 181
Search and Replace Commands, 185 Terminating ED, 192
Self-Test, 197
Answer, 199
Suggested Machine Exercises, 201
Advanced ED Functions 202
Two New Commands, 202 Combined Commands, 204 MACROS, 207
Libraries, 209
Switching Disks, 212
Self-Test, 213
Answer, 214
Suggested Machine Exercises, 215
Submitting Command Files 216
Self-Test, 230 Answer, 232 Suggested Machine Exercises, 232
Changing Device Assignments 235 PIP Parameters 237 Reference Summary 239
241
CHAPTER ONE
Introduction to CP/M
CP/M is a set of programs that runs a microcomputer. To be more specific, CP/M en- ables you to control the operation of a microcomputer.
Before you can learn to use CP/M, you need to have some background informa- tion. What major components does the microcomputer have? What major components does CP/M have? How do the components of both interact to produce a functioning system? This introductory chapter will answer these questions for you as it introduces some of the terminology used in the computer world.
When you have finished this chapter, you will be able to:
identify the required components of a microcomputer under CP/M, identify the functions of the major parts of a CP/M system, specify names for disk drives,
recognize valid filenames,
show how to select a given disk drive,
interpret error messages that may result from drive selection.
MICROCOMPUTER COMPONENTS
The microcomputer controlled by CP/M typically includes main memory, a console, a printer, and at least one disk drive. We’ll look at these components before we talk about what CP/M does with them.
1. A microprocessor that is to use CP/M must have at least 20K bytes of main memory. Main memory is the storage area inside the computer itself as opposed to external storage on your disks or tape. It is contained inside your computer just as the Z80 or 8080 or 8085 chip is. In order for any program to run on your computer it must be stored in main memory. (This includes the CP/M programs.)
In computer terms, “K”’ refers to about one thousand — actually 1024 —so 20K means more than 20,000. A byte is the amount of storage space required to store one character of data. So CP/M requires enough main memory in the microcomputer to
2 USING CP/M
store at least 20,000 characters. Most microcomputers that run under CP/M have more memory — 32K is common but many have 48K, 64K or more. Early versions of CP/M could run with as little as 16K bytes.
(a) What term refers to the amount of storage needed to store one letter, such as “B”’?
(b) How would you specify that a microprocessor has room for about 32 thousand characters?
(c) Would the microprocessor in (b) above be large enough to handle CP/M?__
(d) What's the difference between main memory and external storage?
(a) byte; (b) 32k bytes; (c) yes; (d) main memory is inside the computer; external storage is on an outside device like disk or tape
2. The microcomputer system that is to use CP/M must have at least one disk drive. The drive supports one of various types of disks. The most common is the 8-inch floppy disk. This is a flexible disk encased in a stiff paper envelope. A 5%-inch diameter “mini-floppy” disk is used in some microcomputers. Aside from their size, the floppy disks look and work much the same. The floppy disks come in single- or double-sided, single- or double-density formatted. A single-sided, single-density 8-inch disk holds 256K bytes of data. A double-sided, double-density 8-inch disk holds up to four times as much. A single-sided, single-density 5-4 inch disk holds 72K bytes. Some microcom- puters use a “hard disk’’. This provides even more storage and is also supported by CP/M.
The disk drive determines the type of diskette you use. If you have a drive designed to haridle 8-inch, single-density, single-sided diskettes, then you can’t put any other type of diskette in that drive.
Whatever type of disk drive your microcomputer has, CP/M requires at least one. The maximum number of drive, depends on your specific CP/M package, and we’ll discuss that later.
(a) Are disk drives used for main memory or external storage?
(b) How many disk drives are required by CP/M?
(c) Does CP/M require any particular type of disk drive?
(d) What type of disk has more storage available at a time —a 5-% inch, an 8-inch disk, or a hard disk?
INTRODUCTION TO CP/M 3
(a) external storage; (b) at least one; (c) no; (d) hard disk has more
3. CP/M also requires one console device for communication purposes. One type of console is the teletype-style console. It looks pretty much like a typewriter, with a key- board and a printing unit. You “talk” to CP/M by typing on the keyboard. CP/M echoes what you type on the printer so that you can see what you’re typing. (This is a major difference from a regular typewriter, where the keyboard directly controls the printer. Under CP/M it may look like you’re typing directly on the printer, but in fact CP/M is in between.)
Another common type of console is the video terminal. This terminal includes a TV-like screen and a typewriter-like keyboard. You communicate with the micro- computer by typing at the keyboard. CP/M communicates with you by displaying messages on the console screen.
The console keyboard is arranged basically like typewriter keys, but it usually includes extra letters and symbols such as brackets ([, ]}) and other signs (for example < and >). It also contains special keys. The most important one for the CP/M user is the control key. It may be labeled CTL, CNTL, CTRL, or CONTROL. This key is crucial to using CP/M. You'll be very familiar with the control key by the time you finish this book.
(a) How many consoles does CP/M require? (b) Does CP/M require a teletypewriter or a video console? (c) At the console, the letters you type appear on the display device (video screen or
printer). What causes the letters to be displayed?
(d) Name one special key that is needed for CP/M.
(a) one; (b) either; (c) CP/M reads and echoes each character; (d) control key
4. | The microprocessor, the disk drives, and the console are frequently supplemented with a line printer or list device. The printer is used for making “hard copy” versions of files and data from the disks, and for output from programs run on the micro- computer.
CP/M does not require a line printer. If you have a teletype-style console, you probably won’t have a separate line printer. If you have a video console, you may also have a line printer.
Which of the following hardware devices are required by CP/M?
(a) At least 20K of main memory. (b) A console device.
(c) A line printer.
4 USING CP/M
(d) At least one tape device. (e) At least one disk device.
5. A peripheral device is a device attached to the microprocessor, but not part of it. Each disk drive, the console, and the line printer are all considered separate peripheral devices even though several of them may be physically part of the same piece of equip- ment. Other peripheral equipment may be present as well. For example, some micro- computers may read or punch a paper tape, or use cassette tapes in addition to disks for storage. These can also be handled by CP/M as peripheral devices. When CP/M is first installed on a new system, it is tailored so it knows what peripheral devices are attached.
Match the items below with descriptive phrases on the right:
(a) main memory (1) peripheral device (b) printer (2) essential to CP/M (c) disk drive
(d) console
(e) tape drive
(a) 2; (b) 1; (©) 1,2; (d) 1,2; (1
6. CP/M monitors a microcomputer system made up of various pieces of equipment, which is called hardware. CP/M itself, however, is software. That is, CP/M consists of programs of data, not equipment. CP/M is an operating system; it is a system of pro- grams that allow you to operate your computer. The software provided by CP/M lets the microprocessor know what peripheral devices are available and acts as an interface between the microprocessor and you. It also acts as an interface between any two peripheral devices, or between the microprocessor and any attached device.
Which of the following are functions or features of CP/M? ©
(a) serves as a hardware device (b) interfaces between pieces of hardware (c) operating system
(d) software
INTRODUCTION TO CP/M 5
THE CP/M PROGRAMS
We have said several times that CP/M is a set of programs. In the frames that follow, we’ll overview the major CP/M programs.
7. The Functional Disk Operating System (FDOS) is the portion of CP/M that handles all input and output between main memory and the peripheral devices. FDOS is usually pronounced as “F-doss,” or “F-doz.”
FDOS is a set of programs that supports any other program that requires input or output services. If you were writing a program to print data on a line printer, you could write your own output routines. However, you could save yourself a lot of time and trouble by simply calling on FDOS to do the work for you.
All the other CP/M programs use FDOS to read input or write output.
Which of the following functions would be handled by FDOS? (a) Write data on a disk. (b) Arithmetic calculations. (c) Read data from the console. —___ (d)_ Read data from a disk.
(e) Write data on the line printer.
8. FDOS consists of two parts: the basic input/output system (BIOS), and the basic disk operating system (BDOS). We'll look at these parts separately.
The basic input/output system (BIOS) handles the transfer of data between any peripheral device (except the disk) and the microprocessor. BIOS is usually pronounced “BY-ose.”
BIOS handles these functions:
®@ locates the correct device,
checks to see if the device is busy and if so, waits until it’s free,
checks the device for any hardware malfunction,
transfers the data to or from the device at the correct speed for that device, checks the transferred data for any obvious errors.
(a) What does BIOS stand for? (b) What is the basic function of BIOS?
(c) What CP/M program is BIOS part of?
6 USING CP/M
(d) A typical line printer can receive data at a speed of 120 characters per second. A typical video console can receive characters at a speed of 960 characters per second. What CP/M program is responsible for sending data to each device at the
correct speed?
(a) basic input/output system; (b) transfer data between main memory and peripheral devices; (c) FDOS; (d) BIOS
9. The basic disk operating system (BDOS) controls the organization of data on a disk. BDOS is usually pronounced “‘B-doss” or “B-doz.”
Data is kept on disk in files. A file is a set of related data. For example, your office might have a payroll file that contains the payroll information for all your company’s employees. This file, in turn, contains records. For the payroll file there would be one record for each employee that would contain an employee’s name, address, wage rate, tax rate, and so forth.
The payroll file is an example of a data file. Another type of file you will have is a program file, which contains all the commands that make up one computer program. Each command is a record.
One disk may contain many files. It’s not unusual to have more than 50 files on one disk. BDOS keeps track of all the files on the disk.
(a) What do the letters BDOS stand for? (b) What CP/M program is BDOS a part of? (c) What is the basic function of BDOS? _—____
The diagram below depicts the structure of a disk. Label the three levels as file, disk, or record. (d)
@) (f)
(a) basic disk operating system; (b) FDOS; (c) organizes data on the disk; (d) disk; (e) file; (f) record
INTRODUCTION TO CP/M 7
10. Every file must have a name. BDOS keeps a file directory on each disk. The directory shows all the file names, their sizes, and their exact locations on the disk.
Every time you add a new file to a disk BDOS does the following:
e@ checks the directory to make sure there is no file with the same name, @ checks the directory to make sure there is room for the file, @ updates the directory with an entry for the new file.
(a) ‘ What CP/M program maintains the disk directory?
(b) What information does the disk directory contain?
(a) BDOS; (b) file name, file size, file location
11. Suppose you want to type out a file from disk to your line printer. Identify whether BIOS or BDOS handles each of the following functions.
(a) Locates the correct disk drive.
(b) Waits until the disk drive is ready. SSE (c) Checks the disk directory to find the location of the file.
(d) Waits until the printer is ready.
(e) Transfers the data from the disk to the printer.
(a) BIOS; (b) BIOS; (c) BDOS; (d) BIOS; (e) BIOS
12. The preceding frames have discussed the FDOS and its two major parts, BIOS and BDOS. Another major set of CP/M programs is the console command processor (CCP). This is the part you will use directly. The CCP reads whatever you type on the console and processes the commands you give it. Everytime you interact with CP/M you use the CCP. You can enter commands to list a directory or erase a file and CCP will process the command and do as you ask. You can request processing external to CCP, and the CCP will handle the request and then return to you. All your commands at the console are handled through the CCP of CP/M.
(a) What does CCP stand for? (b) Can you interact with CP/M without using the CCP? _..--_—=——SE
If so, how?
8 USING CP/M
(a) console command processor; (b) no
13. The CCP program contains several routines for functions that you will use all the time. You will learn how to use the functions in Chapter 3, but we’ll overview them here:
DIR displays the directory of a disk,
ERA erases a file from a disk.
TYPE displays a file.
SAVE writes data from main memory to a disk file. REN renames a file.
USER changes the user number (version 2.0 and up).
Because these functions are part of the CCP, they’re always available to you whenever CP/M is running on your computer. Therefore they’re called built-in programs. The commands that you type to use them (DIR, ERA, etc.) are called the built-in commands.
(a) What major CP/M program contains the built-in programs?
(b) To use a built-in program, you type a built-in son your console.
(c) If your computer is on but you haven’t loaded CP/M into main memory, would
the built-in commands work? ___________ Why?
(a) CCP; (b) command; (c) no, because they’re part of CP/M
14. The other CP/M programs you are studying in this section, such as BIOS and BDOS, are also built into the CP/M package. Whenever CP/M is running on your system, they are automatically stored in main memory and are available to CP/M. However, you have no commands to use them. They are only called by other programs. For example, CCP uses BIOS to communicate with your console.
Even though they are built-in programs, they have no matching built-in commands.
Match the functions below with their characteristics. —_____—_ (a) CCP, FDOS, BIOS 1. Built-in program —_____ (b) DIR, ERA, TYPE 2. Built-in command 3. Always available when CP/M is running
(a) 1, 3; (b) 1,2, 3
INTRODUCTION TO CP/M 9
15. Any program that is not built-in is called a transient program. The term “‘tran- sient” refers to the fact that the program is only loaded into main memory when it is needed. A transient program is kept in a file on disk. Its filename becomes the com- mand that you type if you want to use the program.
Your CP/M system disk contains several transient programs provided by Digital Research. You might also buy other transient programs from other sources or write your own.
There are only a few built-in commands, but you can have as many transient commands as you can fit files on a disk.
Match the program types on the left with their descriptions on the right. (a) built-in program 1. Only stored in main memory when
(b) transient program needed.
2. Always in main memory when CP/M is running.
3. You can write one.
4. You can buy one and add it to your system.
5. Part of CP/M package from Digital Research
(a) 2, 5; (b) 1,3, 4,5
16. The built-in programs are always in main memory whenever CP/M is running. A transient program must be loaded into main memory from disk each time it is used.
Which type of programs do you think would be faster to run?
Built-in programs; because there’s no loading time
17. (a) Give an example of a built-in program that has no matching built-in com- mand. (b) Which CP/M program contains the built-in programs? (c) A program that’s loaded from disk into main memory each time it’s used is called a (d) Which type of program is faster?
10 USING CP/M
(a) you might have said CCP, FDOS, BDOS, or BIOS; (b) CCP; (c) transient program; (d) built-in
CP/M ARCHITECTURE
You have seen the major built-in programs of CP/M —FDOS, which contains BDOS and BIOS, and CCP. The following section explains how CP/M organizes your computer’s main memory to allow for both built-in programs and transient programs.
18. The diagram on the right shows how Last (highest) CP/M organizes your computer’s main memory address memory. You can see where FDOS and
CCP. are stored.
The transient program area (TPA) holds all transient programs and data you are using.
The sizes of the FDOS and CCP areas are fixed. They’re large enough to hold those programs. The size of your TPA equals your computer’s main memory size minus the sizes of CCP, FDOS, BOOT, and the system area. So the TPA size varies from system to system. Refer to the diagram above to answer these questions.
First (lowest) memory address
(a) CCP is in the (lowest/highest) ____._._-=~=~=~~—~—~~———_—r part of memory.
(b) The size of CCP is (fixed/variable)
(c) The size of FDOS is (fixed/variable)
(d) The size of the TPA is (fixed/variable)
(e) Suppose your system has 32K bytes of memory. Suppose also that the reserved area, FDOS, and CCP take up 6K bytes. How large is your TPA?
(a) highest; (b) fixed; (c) fixed; (d) variable; (e) 26K bytes
19. Boot, the program in the lowest part of memory, has a very special function. Since the CCP is higher than the TPA in memory, and since the TPA can vary in size, CP/M needs to know exactly where to find the beginning of CCP. BOOT is a very small program that tells CP/M where CCP is.
INTRODUCTION TO CP/M 11
Whenever you start up the system, control goes to the part of main memory where BOOT is. BOOT reads the entire CP/M system into memory. It then trans- fers control to the BIOS, which in turn branches it to the CCP. We often think of BOOT as kicking (or “‘booting”’) control to the beginning of the CP/M system. CCP takes over and you’re ready to go.
Some transient programs might also use the FDOS and CCP areas in memory: If this happens, then FDOS and CCP need to be reloaded from disk before CP/M can continue. Such transient programs end by transferring control to BOOT. BOOT causes CCP and FDOS to be reloaded then transfers control to BIOS.
(a) BOOT is located at the (beginning/end) _____9 _____ of main memory. (b) When you start up your system, control goes first to
(c) BOOT transfers control to ____________,, which transfers it to
(a) beginning; (b) BOOT; (c) BIOS; CCP
Now you know that CP/M is an operating system. It drives a microcomputer sys- tem that includes at least 20K of main memory and various peripheral devices. These peripherals include a console, at least one disk drive, and perhaps others as well. CP/M itself is made up of the full disk operating system, which includes the BIOS and BDOS, the console command processor (CCP), the transient program area (TPA), and the BOOT.
Now we’re going to look more closely at some items that you’ll be using under CP/M: the disks, the disk drives, and the files that reside on the disks.
DISK DRIVES
20. CP/M comes in several versions; the most common are version 1.4 and 2.2. CP/M 1.4 supports one to four disk drives. CP/M versions later than 2.0 support up to 16 drives. The principles are the same in both systems.
As you know, various types of disk drives can be supported by CP/M. These drives have individual names within the CP/M system. Drives are named in alphabetical order. Thus, the primary drive is named “A” and the secondary drive is named “B”.
(a) What is the highest possible drive name in version 1.4 CP/M? (b) What is the highest possible drive name in version 2.0 CP/M?
(a) D; (b)P
12. USING CP/M
21. The exact method for turning on CP/M varies with the hardware involved. But no matter how it’s done, the CCP gives you your first message like this:
64K CP/M VERSION 2.2 A>_ This symbol represents the cursor. ~w_SY The first line tells you the size of the CP/M system on your A disk. The second line (A>) tells you two things: the CCP is ready to receive a command, and the cur- tently selected disk drive is A. The currently selected drive is also called the active or default drive. CP/M always starts up on drive A. You can select another disk drive, and
change the active drive, by entering the desired drive name followed by a colon. If you type this:
A>B: and press return, the CCP responds with this: B>_
Now the B drive is active and the CCP is ready for another command.
(a) Given the prompt below, which drive is active?
B>_
(b) How can you make “D” the active drive? (c) How can you select drive A?
(d) When CP/M is started, which disk drive is selected for you?
(a) drive B; (b) enter D:; (c) enter A:; (d) drive A
22. If you select a drive your setup doesn’t have, CP/M can’t select it. Suppose you have a two-drive system and you enter:
A>C: CP/M will give you an error message. The standard message looks like this:
BDOS ERROR ON C: SELECT_
Any character from the keyboard will cause CP/M to boot and give you the prompt again. Under the standard CP/M you'll get that same message for any invalid drive name with the invalid drive name repeated in the message.
INTRODUCTION TO CP/M 13
Some manufacturers have modified CP/M and illegal drive names may end in a cryptic message — like TRANSIENT DISK ERROR #80 — or even hang up the system. You may have to restart to get the system working again. You'll want to try this on your machine to see exactly what happens.
Sometimes you may select a legal drive but not have a disk loaded. This will cause a system hang-up under standard CP/M —CP/M will just wait until a disk is in- serted or until you boot the system. Some hardware manufacturers have modified this and you may get some more specific, or more cryptic information.
Suppose you are using a CP/M version 1.4 system. Your microcomputer has two disk drives, with a disk in each. You start it up and get A>. What happens for each entry below?
(a) A>B: (b) A>D: (c) A>G: (d) A>A (a) the B drive is selected; (b) BDOS ERROR ON D: SELECT;
(c) BDOS ERROR ON G: SELECT; (d) drive A remains active
23. The colon is a critical part of drive selection. If you enter a drive name without the colon, the CCP doesn’t know you want to select a drive. It thinks you want to run a program of that name. If it can’t find any program with that name, you'll get a message like this:
A>B B?
A>
The prompt you get always indicates the active drive. Because the CP/M system didn’t recognize B as a drive name, the current drive remained active.
For each example below tell what might have happened.
(a) A>Bi BDOS ERROR ON B: SELECT_
(b) a>B:
14 USING CP/M
(Cc) ADH: BDOS ERROR ON H: SELECT_
(d) arc
(a) either the system has only one disk drive or the B drive has no disk in it;
(b) drive B was selected;
(c) either there is no H drive or the H drive has no disk in it;
(d) the colon was omitted and drive A remains active; also, no program named C exists on drive A
DISKS
24. Disks used by CP/M systems are specific to the drives used. They are often de- scribed as being “IBM-compatible” because of their format. Each disk is divided into tracks and sectors, as you can see here. The number of tracks and sectors depends on the size and type of disk. A typi- cal 8-inch disk contains 77 tracks and is divided into 26 sectors.
The tracks are concentric rings. The sectors form wedges that intersect with the tracks. You
can see that sector 20, track 12, could be used to refer to a specific part of the disk. (You won’t have to do this, but the BDOS does when it locates files or data.) Sometimes when CP/M finds a disk error, it may tell you the track or sector involved.
The track nearest the out- side edge is track 0, and the next is track 1. The entire CP/M system, including FDOS and CCP, generally resides on these two tracks of an 8-inch diskette. When you start up CP/M, the entire system is loaded (or copied) into main memory. The rest of the disk is available to store transient programs and your files.
sector track
INTRODUCTION TO CP/M 15
(a) What is the difference between a track and a sector?
(b) What tracks or sectors contain the CP/M system on an 8-inch diskette?
(c) Suppose a disk has 77 tracks. How many are available for transient programs and files?
(a) tracks are concentric rings and sectors are wedges; (b) tracks zero and one; (c) 75
25. The system tracks contain all the CP/M built-in programs: the BIOS and BDOS, CCP, and BOOT. BDOS puts the directory on the first track after the system tracks. (Under version 2.2, your system may be modified to use more than two tracks. How- ever, the system tracks will still act as a whole.) BDOS sets up the directory as files are added to the disk. It keeps track of what files are on the disk and where they are. You'll learn to use the directory later in this book.
Which of the following are physically located in the system tracks of a CP/M disk?
(a) BDOS (b) BIOS _—___—. (c) CCP —____—._ (d) TPA —____ (e) BOOT ____.. (f)_ directory (g) data files
a,b, c,e
FILES
26. <A file on a CP/M disk is a set of information. It may be a program, information, or such items as letters or reports. A file is anything you have called a file and stored on a CP/M disk.
16 USING CP/M
Every file on a disk has a unique name with two or three parts. Here’s an ex- ample of a filename:
A:CHAP1.PRN Let’s look at the parts of this name separately.
The first part is the drivename. This part of the filename may vary, depending on which drive the disk is placed. It’s not a permanent part of the filename. If used, it’s followed by a colon.
The second part is the filename proper. It has from one to eight characters and must start with a letter. The third part is the filetype. It has from zero to three char- acters. Every file doesn’t need a filetype. But if one is used, it is separated from the filename proper with a period.
If you type a filename longer than eight characters or a filetype longer than three characters, CP/M truncates (chops off) the extra characters. Thus, WEDNESDAYS. MENUS will be,read as WEDNESDA.MEN.
Indicate if each name below is a valid CP/M filename. If not, state why it is in- valid.
(a) A:FILE6
valid ___-__—siinvalid (b) FILE6.SIX
valid __ = S—Ssinvalid
(c) 6FILE.SIX
valid ____+_+_____—_siinvalid (d) FILESIXTEEN valid ______+———iinvalid (e) A WAND ese, A a ee ah
(a) valid; (b) valid; (c) invalid (doesn’t begin with a letter); (d) this is valid but will be read as FILESIXT; (e) valid (but could be confused with drive A:)
27. The filename and filetype may be determined by the user. But CP/M recognizes certain filetypes and may treat them differently. Here are a few of the standard file-
types.
$$$ CP/M uses this to indicate a temporary file.
COM A CP/M command file; a file with this filetype is run as a transient program.
PRN A print file; a file with filetype PRN can usually be printed out
directly.
INTRODUCTION TO CP/M 17
BAK A backup file; CP/M programs create these automatically under certain conditions.
COB
FOR
BAS These represent computer source programs in various languages —
ASM COBOL, Fortran, Basic, Assembler, PL/I and PL/M.
PLI
PLM
CP/M has other standard filetypes also. Many files will have filetypes needed by your transient programs. You may have inventory data of type INV, correspondence files of type COR, and extra files of type X. Or you may not use filetypes for many of your files.
Indicate if each filetype below is valid or invalid. If it is invalid tell why.
(a) COM
valid _______ invalid (b) COMMAND
valid —___________ invalid (c) DOC
valid —___________ invalid (d) 6X
valid —________ invalid
(a) valid; (b) valid but will be read as COM; (c) valid; (d) valid
28. Each combination of filename and filetype on a disk must be unique. That means you may have several files named TEXT! on a disk if each has a different filetype. You may also have several files of the same type as long as each has a different file- name. The drivename may be the same for each file on the same disk. You can use the same filename-filetype combination on many different disks because you'll never have two disks on the same disk drive at once.
Which of the sets of complete filenames below represent unique names?
(a) A:TEXT1.DOC (c) A:TEXT3.DOC
A:TEXT1.BAK B:TEXT3.DOC A: TEXT1 B:TEXT3.BAK
_s (b) A: TEXT2.DOC (d) B:TEXT4.DOC A:TEXT2 B:TEXT3.DOC
A: TEXT2 A: TEXT4.DOC
18 USING CP/M
29. CP/M allows you to protect your important disks from being written on. You can give any drive, except the A drive, read/only status. This means that you can read any file on the disk, but you can’t write on it. When a disk is read/only, you can’t add a new file, erase or change a file, or rename a file.
The opposite of read/only status is read/write status. This means that you can read files from a disk and write on any files on the disk.
You will learn how to assign read/only status and read/write status later in this book.
Match each status with its characteristics.
—______ (a) read/only 1. read files —____ (b) read/write erase files change files
rename files
write new files
(a) 1; (b) 1,2, 3, 4,5
30. With CP/M version 2.0, you can also assign read/only status to individual files. If you want to protect just one file on a disk, you can do so. You will learn how to do this later.
(a) What CP/M versions allow read/only status protection for an entire disk?
(b) What CP/M versions allow read/only status protection for individual files?
(a) all versions; (b) 2.0 and later
In the previous section you have seen some special CP/M information about the disks, the disk drives, and the files on the disks. In the next section you'll learn how to start your CP/M system.
BOOTING
31. When you turn on your computer it may just sit there waiting for instructions. Before they can do anything, computers must have a program stored in main memory. Some computers have an automatic start capability. However, when using CP/M as your operating system, for most computers CP/M must be put into main memory. But
INTRODUCTION TO CP/M 19
you have no command to do this since there is no program in memory to recognize and respond to a command.
The first program you load into memory each time you turn the power on must be bootstrapped in. That is, it must pull itself in. You'll have to learn how to do this for your computer. Usually it’s a hardware function such as pushing a button or flip- ping a switch, and perhaps entering a trigger character. Check with your hardware manuals to find out.
Whatever the process, the system boot function will cause the system tracks from the disk on drive A to be read into main memory. If you’re trying to load CP/M, the disk you put in drive A when you boot must contain the CP/M system programs on the system tracks.
A boot is also called a “cold start” because it’s how you get the system started when it’s completely cold; meaning that it contains no programs. After a cold start, control goes to the BOOT program which boots control to the CCP. This will give you a startup message telling your system size, followed by the CP/M prompt, A>.
(a) How do you get the first program into your computer’s main memory after you turn the power on?
(b) Describe the disk you must use to boot CP/M.
What drive must it be on? (c) A system boot is also known as a
(d) If you successfully boot CP/M, what message should appear on your console?
(a) boot it in;- (b) any disk containing the CP/M system programs on the system tracks, drive A; (c) cold start; (d) CP/M prompt (A>)
THE NEW CP/M SYSTEM
When you first get CP/M it must be tailored to your system. For example, BIOS needs to know exactly what peripheral devices you have. (After BIOS has been cus- tomized it’s generally referred to as CBIOS, meaning “customized” BIOS.)
If your CP/M has not yet been tailored to your system, it must be done. Tailor- ing requires a knowledge of 8080 Assembler language and the hexadecimal number sys- tem. If you know these things, you can probably tailor your own system following the instructions in your CP/M Alteration Guide. If you don’t, you'll need to get some help.
In the remainder of this book we’re going to assume that your system has these features:
@ video console,
20 USING CP/M
@ line printer, @ at least two floppy disk drives, @ no paper tape or magnetic tape devices.
This is the most common office microcomputer configuration. If your system is different, don’t worry. The material you study here will still be valid, although the ex- amples might be slightly different. Any time that we’re discussing a command that is device dependent, we'll be sure to let you know.
This chapter has introduced you to the basic features of CP/M and the micro- computers that use CP/M. In the next chapter you'll begin learning how to enter a CP/M command. Before you start chapter 2, take the Self-Test and try your hand at the suggested machine exercises.
SELF-TEST
This Self-Test will help you determine if you have mastered the objectives of this chapter. Answer each question to the best of your ability, then check your answers in the answer key at the end of the test.
1. Which of the following are required components of a microcomputer under CP/M? (a) main memory
(b) disk drives
(c) tape drives
(d) console
(e) paper tape reader
2. Identify the CP/M program that performs each function below:
(a) interprets keyboard entries
(b) performs file management
(
) is customized to handle input and output operations
Q
(d) transfers control to the CCP
3. | Under CP/M, what memory area is reserved for programs that are not built-in?
INTRODUCTION TO CP/M 21
Suppose your screen shows this prompt:
(a)
(b)
(c)
(d)
A>_
What is the active drive?
How can you switch to drive B?
What does it mean if CCP responds
BDOS ERROR ON B: SELECT_
What does it mean if CCP responds
B? A>_
Which of the complete filenames below represents a file of type COM, name STEST, on drive A?
——___— (a) A.COM.STEST
(b) A.STEST.COM
___ (c)_ A:STEST:COM ____ (d)_ A:STEST.COM
Match each term below with its correct definition.
(a) hardware (1) storage area in the computer’s micro-
(b) software processor
(eo): peripheral device (2) screen on a video terminal
(4) “anainmémory (3) any piece of input/output equipment
(e) system tracks oy zeroand one (5) any piece of equipment (6) wedges of disk
(7) any computer program
22 USING CP/M
Chapter 1 Answer Key
Compare your answers to the Self-Test with the correct answers given below. If all your answers are correct, you are ready to go on to the next chapter. If you missed any questions, you may find it helpful to review the appropriate frames before going on.
l. a,b,d
2. (a) console command processor (CCP) (b) basic disk operating system (BDOS) (c) basic input/output system (BIOS or CBIOS) (d) BOOT
3. transient program area (TPA)
4. (a) drive A (b) enter B: (c) either no drive B or no disk in drive B (d) you entered B without the colon
5. d
6. — (a), G) (b), (7) (c), (3) (d), (1) (e), (4)
Suggested Machine Exercises
Each chapter in this book ends with a suggested machine exercise. If you have your microcomputer and CP/M disk, we strongly recommend that you work these exercises. This is the best way to become comfortable with the CP/M system.
If you don’t know how to boot your system, this first exercise is vital because every other exercise in this book starts by booting. Unfortunately we can’t tell you how to boot because the process depends on your microcomputer.
1. Your system manual should tell you how to boot your system. If not, check with someone who would know, perhaps a colleague or your salesperson.
2. Turn the power on, load the system disk in drive A, and boot.
INTRODUCTION TO CP/M 23
If you get no console message, try these things:
a. check to see that your console is connected to the microprocessor and the power is on. If it’s a separate device, it probably has a switch called LOCAL or LINE. Make sure this switch is in the LINE, not LOCAL, position,
b. some systems need to warm up for a minute or two, so wait awhile and try again,
c. if all else fails, get help.
If the boot succeeded, you should get a message something like this: CP/M nnkK VERS nn A>_
nnK tells the size CP/M thinks your main memory is. Later in this book you'll learn how to change the size. VERS n.n tells you what version of CP/M you have.
Practice booting the system several times.
If you have more than one drive, install disks in the other drives and practice switching back and forth from one disk to another.
Try selecting a drive that contains no disk. You should get an error message, and you may have to boot to continue.
Try selecting drive Z:. You should get a BDOS error. Type any character to con- tinue. (Your system may behave differently.)
Shut down your system and go on to Chapter 2,
CHAPTER TWO
Typing CP/M Commands
You use CP/M programs by typing and entering commands. A typical command might be:
ERA JOHNSON.LET
This command asks CP/M to erase the disk file named JOHNSON.LET. There are many commands corresponding to the various CP/M built-in and transient programs. You'll be learning the command details in later chapters. In this chapter, we will cover the gen- eral format of all CP/M commands, what happens when a CP/M command is entered, and some special functions you can use when typing CP/M commands.
When you complete your study of this chapter, you will be able to:
@ write a basic CP/M command involving a program and a file,
@ write CP/M commands for programs that are not on the active drive,
®@ write CP/M commands for files that are not on the active drive,
® briefly describe what happens after a CP/M command is entered,
© given error messages resulting from CP/M commands, state the general cause of the error,
@ identify the control characters that invoke major CP/M control functions.
GENERAL COMMAND FORMAT
1. ‘In order to enter a CP/M command you must be at command level. This means you must have a CP/M prompt such as A>_.
The general format of a CP/M command is: d>programname [operands] <carriage return> The d> indicates the command prompt that’s provided by the CCP.
Programname is the name of the program you want CP/M to execute. It must be either a built-in command or the name of a COM file (command file) on one of the drives.
24
TYPING CP/M COMMANDS 25
A COM file is a transient program that has been translated into machine language and appropriately edited by the system so that it is completely ready to be run on your computer. Its filename will always be in this format: programname.COM. For example, your CP/M disk includes these transient program files: PIP-;COM, ED.COM, STAT.COM.
In the CP/M command you only enter the programname; don’t type the “.COM.” Then you type the operands, if there are any. The command is terminated with a <carriage return>, which causes the CCP to process the command. The <carriage return> is a special key on your keyboard that may be labeled RETURN or ENTER.
(a) Before you ‘can enter a CP/M command, what must appear on your terminal?
(b) Programname must be the name of:
a. a CP/M built-in command,
_____._-b. a COM file on one of the drives, —__ c. either of the above, d. none of the above.
(c) Suppose your A disk contains these files: PIP,;COM, STAT.COM, and TEST.COM.
You want to run the TEST program. What entry do you make? A>
(a) CP/M prompt (d>); (b) c; (c) TEST
2. If the COM file is not on the active drive, you must tell CP/M where to find it. You can switch to the correct drive, as in:
A>B: B>CALC
You can also precede the programname with the drivename, as in:
A>B: CALC
The major difference between these two techniques is the drive that remains active after the CALC program terminates. In the first example, the B drive remains active; in the second example, the A drive remains active. In the first example, B becomes the default for file references of CALC. In the second, A is default drive for file references of CALC even though CALC came from B disk.
For the following questions assume that your A disk contains PIP.COM, STAT.COM, and TEST.COM, and your B disk contains SORT.COM, MERGE.COM, and LIST.COM.
26 USING CP/M
(a) Show the entry or entries you would make if you want to run the SORT pro- gram but leave the A drive active.
A>
(b) Show the entry or entries you would make if you want to run the LIST pro- gram and leave the B drive active.
(a) A>B:SORT; (b) A>B: B>LIST
3. Here’s the general command format again: d>programname [operands] <carriage return>
Some programs do not involve operands. In these cases, just type the program- name and press the carriage return key.
Many programs require a file as input. If so, type at least one space and then the filename as an operand, after the programname. If the file is on the active drive, you don’t need to include the drivename. For example, if you want to erase the file named SOURCE.DAT from disk A, you could enter either of these commands:
A>ERA SOURCE.DAT A>ERA A:SOURCE.DAT
If SOURCE.DAT is on disk B, you have three choices. You could switch the disks and reboot, but this isn’t very practical. You could make drive B active, or you could enter this command:
A>ERA B:SOURCE.DAT
In most cases use the complete filename, including the filetype. We'll let you know when the filetype should be omitted.
(a) Show the general format for a CP/M command that does not require a filename. d>
(b) Programname is separated from operands by
(c) Ina filename, the drivename is — a. always needed b. sometimes needed
c. never needed
TYPING CP/M COMMANDS 27
(d) When a filename is an operand, do you generally include the filetype?
_ (e) Drive B is active. You want to erase the INVENTY.COM file on disk A. Show the fastest way to do this.
B>ERA
(a) programname; (b) one or more spaces; (c) b; (d) yes; (e) B>ERA A:INVENTY.COM
4. The built-in commands must not be preceded by drivenames, as they are not related to drives. (Recall that they are part of the CCP.)
(a) Which of the following will type the file named INVENTY.DAT on drive B? (TYPE is a built-in command.)
a. A>TYPE B:INVENTY.DAT —__— b. A>B:TYPE INVENTY.DAT
c. A>B: B>TYPE INVENTY.DAT
(b) Which of the following may not be prefixed with a drive name?
a. built-in commands
—____— b. transient programnames
c. filenames
(a) a,c; (b) a
5. For the questions below, assume that you have two disks containing these files:
Drive A Drive B SORT.COM INVENTY COM MERGE.COM INVENTY .DAT SORT.DAT PARTS .DAT
(a) Show the command(s) to run the SORT program using the file named PARTS.DAT as an operand. Leave control on drive A.
A>
28 USING CP/M
(b) Show the command(s) to erase SORT.DAT. (ERA is a built-in command.) Leave control on drive B.
B>
(c) Show the command(s) to run the SORT program with INVENTY.DAT as an operand. Leave control on drive A.
B>
(a) A>SORT B:PARTS.DAT; (b) B>ERA A:SORT.DAT;
(c) B>A: A>SORT B:INVENTY.DAT
CP/M COMMAND PROCESSING
6. Now that you have seen what a CP/M command generally looks like, let’s discuss what happens when you enter the command. First of all, CP/M searches for the program you named as programname. If it’s a built-in program, it’s already a part of the console command processor (CCP). It was loaded into main storage when the system was boot- ed. Otherwise CP/M looks for the appropriate COM file on the disk on the specified drive. (If no drive was specified, the active drive is assumed.)
If it can’t find the correct program, the CCP returns an error message — “‘pro- gramname?”. CP/M does not search the other drives. Below is a sample printout in which we accidentally misspelled the ERA programname.
AD>ERRA INVENTY.DAT ERRA?
A>_
A message of one word followed by a question mark means the system can’t recognize your programname. Either you misspelled it or the appropriate COM file is not on the specified drive.
The CP/M prompt is then repeated, as shown in the above example, so that you can enter the correct command. You’ll have to type it over again; you can’t go back and correct the earlier attempt.
(a) When you enter a CP/M command, what’s the first thing the CCP does?
TYPING CP/M COMMANDS 29
(b) Suppose you have the following interaction:
A>TYP JOHNSON.PRN TYP?
A> _ What could be wrong? a. TYP is not a built-in command. —____._ b. JOHNSON.PRN is not a file on the A disk. c. TYP.COM is not a file on the A disk.
(a) CP/M searches for the programname program; (b) a and c
7. — If the CCP successfully locates your transient program on the specified disk, it reads the program from the disk into the TPA. Depending on your hardware, you may be able to hear this happening. If it’s a short program it could take less than a second to load. Longer programs may take five seconds or longer.
CCP also stores any operands in an area of main memory where the transient program can find them. Control is then given to the beginning of the program. You are now out of command level and into program level.
What happens next depends entirely on the program. Most programs will check the filename(s) and other operands, and display error messages if they aren’t correct. You'll be learning more about this when you study the built-in commands and transient programs later on.
When the program terminates, CCP resumes control and you’re back at command level again. You'll know when this occurs because you'll get the CP/M prompt.
(a) Below is shown a typical CP/M interaction.
A>COPY BA
(3 SECOND WAIT) A>_
Briefly describe what happened during the three second wait. (Note: COPY is not a built-in command.)
30 USING CP/M
(b) Here’s another interaction.
A>SORT INVENTY.DAT FILE NOT FOUND_
What program sent the error message? __________________ At what level
are you now?___—SCSCSCSCSCC;Man you enter a CP/M command now?
(a) CP/M searched for and loaded the COPY program, passed the operands to it, and gave it control; the COPY program ran and terminated and CP/M resumed control; (b) SORT, program level, no (you must have the CP/M prompt to enter a CP/M command)
CP/M CONTROL CHARACTERS
Whenever you’re typing CP/M commands or using the CP/M built-in commands and transient programs, you can use a special set of control characters. In the next section of this chapter, you'll learn what these control characters are and how they make your console tasks much easier.
8. First, what is a control character? It’s a keyboard character that you type while holding down the CONTROL key. Many of the keys on your terminal keyboard are capable of sending three different signals. If you hit the key without SHIFT, it sends the lower-case character, as a typewriter would. If you hold down the SHIFT key and hit a character key, it sends the upper-case character. If you hold down the CONTROL key and hit a character key, the control character is sent. Like the shift key, the CONTROL key doesn’t do anything by itself.
Not all character keys on your keyboard have control values. On most terminals the letters do, but the numbers and symbols don’t. If you hold down CONTROL and hit a non-control key, the result depends on your terminal. Our terminal sends the lower-case character.
CP/M displays a control character as two characters —a caret (*) followed by the upper-case letter for that key. So control-p is displayed this way: “P. (Your terminal may display “as t.) We’ll use this convention throughout this book, but it’s important to remember that the control characters are one character, not two. The two keys are pressed at the same time, not one after the other.
(a) How do you type S?
(b) If you press CONTROL by itself, what happens?
TYPING CP/M COMMANDS 31
(a) hold down CONTROL and type the “‘s” key; (b) nothing
9. While you’re typing a CP/M command, you may make a typing error. You can correct errors by using the control characters and the. rubout or delete character.
Your terminal has a key labeled RUB or RUBOUT, or DEL or DELETE. This key erases the previous character from memory. CCP will echo the deleted character on your terminal display. For example, the key sequence ER RA EDED A will produce this display:
ERRAARA _ Inside the system ERA will be stored.
If you type ARA XY and then notice that you meant to use ERA, you could enter six delete characters and start over. The corrected entry would look like this:
A>ARA XYYX ARAERA XY _ Only ERA XY is stored at this point and you can continue entering the filename. (a) Suppose you intended to type SORT INVENTY.DAT and instead typed this: SORT INVENTRY.DAT_ How many delete characters must you enter to correct it?
(b) How does the display appear after the delete characters are entered?
(c) What do you type to correct the entry now?
(d) What value is stored when you enter the corrected command?
(a) 6; (b) SORT INVENTRY.DATTAD.YR; (c) Y.DAT; (d) SORT INVENTY.DAT
10. CP/M supplies several control codes that you can use to clean up your corrected displays and make them easier to read on the screen. Control-R (*R), control-U (*U), and control-H (*H) are all very useful when you are typing CP/M commands.
“R—this control character retypes the current command line, as it appears in memory, on a new console line. The echoed deleted characters will be removed. The key sequence ERRA A’R will produce this display:
ERRAARA# ERA
32 USING CP/M
The pound sign (#) indicates that the old line has been abandoned. You can continue typing your command on the new line.
“U—this control character deletes the current command line from memory. On your terminal a pound sign is displayed and the cursor moves to the beginning of a new line. The key sequence ERRA*U would produce this display:
ERRA# Newer versions of CP/M have some additional line correction commands:
“H —backspaces the cursor one position so that you can type over a letter. You could use “H instead of rubout/delete. The key sequence E R R “H A would produce this display:
ERA
“X —backspaces the cursor to the beginning of the line. (In earlier versions, ~X is the same as “U.)
(a) Examine this key sequence: S QA U ARE. What will be stored in memory?
(b) If your command line gets hard to read, what character will display a “clean” version on a new line?
(c) What character deletes the entire line? _. SSE
(d) On your system, what does ~X do?
a. Delete line (Skip question e.)
b. Backspaces cursor to beginning of line (Answer question e.)
(e) What character backspaces the cursor one character?
(a) SQUARE; (b) “R; (c) “U; (d) the answer depends on your system; (e) “H
11. The “C function is called the system reboot. When you type “C, control is forced to the beginning of the CP/M program and parts of the system are read in from the disk in drive A. If that disk has been removed, you’ll get an error message or the system will hang up.
You learned earlier that booting is also called a “cold start”. Rebooting with a °C is often called a “‘warm start”.
“C can be used to stop a CP/M program when you don’t want to continue. This is called “aborting” the program. “C always returns you to the CP/M prompt, even from the program level. (A program that is not part of the CP/M system, such as a BASIC interpreter, may or may not recognize “C; all CP/M programs do.)
TYPING CP/M COMMANDS 33
(a) What is the effect of typing “C while a CP/M system program is running? (b) Does “C cause the CP/M system to abort, cold start, or warm start?
(c) From where is the CP/M system read after “C is entered?
(a) abort the program; (b) warm start; -(c) the disk on drive A
12. When a CP/M program is executing, you can type “C at any time to abort it. The program will respond to “C within a few seconds. However, when CCP is displaying the command prompt and waiting for input, °C will only work at the beginning of the command line immediately after the prompt. Suppose you have started to type a command and change your mind and decide to reboot. What commands do you need to type in order to reboot? Show them be- low.
A>SORT B:INV_
‘U or “X followed by A>*C
13. A cold start always puts you on A drive. A warm start leaves you on the active drive, even though it loads the system from drive A.
(a) Suppose you type: A>°C What wili the system respond? (b) Suppose you type: B>°C What will the system respond? (c) | Suppose you type: A>ERA*C
What will the system respond?
34 USING CP/M
(d) °C is a fast way to return to the A drive from any other drive. True or false?
(a) A>; (b) B>; (c) nothing —“*C must be the first character here to be recognized as a reboot; (d) false —“C leaves you on the active drive
14. The *S function interrupts system output until any other character is typed at the console. If a CP/M program is displaying a lot of data that is rolling off the top of your screen before you have a chance to read it, “S will stop it. When you're ready to continue, hit any character except “C. “C will abort the program.
(a) Suppose you’re displaying a file by using the built-in command TYPE. What character can you type to temporarily interrupt the display?
(b) What character can you type to resume the display?
(c) What character can you type to abort the TYPE function and return to command level?
(a) “S; (b) any character except “C; (c) “C
15. If you’re working at a video terminal and would like a hardcopy listing of your interactions with CP/M, *P will turn on your line printer. The printer echoes each character you type and each character that CP/M displays. (Some printers store char- acters until you hit carriage return and will then print the whole line.) To turn off the echo print, simply hit *P again. It acts like a toggle switch alternately turning the printer on and off.
(a) What character can you type to turn on the echo printing function? (b) What character can you type to turn off the echo printing function?
(a) “P; (b) *P
16. A cold or a warm start also turns off echo printing.
(a) What do you type to start echo printing?
TYPING CP/M COMMANDS 35
(b) Show three ways to turn off echo printing.
(c) Suppose you’re using TYPE with echo printing on. You want to abort the pro- gram and continue working with echo printing on. Show the command, or
commands, to abort a program and leave echo print on.
(a) “P; (b) *P, °C, boot; (c) “C followed by *P
17. All the CP/M programs recognize the “P command. Therefore you can turn echo printing on at the command level and execute a CP/M program. Echo printing will stay on throughout the program execution unless you turn it off or the program performs a reboot.
If you start executing a CP/M program without echo printing, you may or may not be able to turn echo printing on without returning to command level. Some of the CP/M programs, such as TYPE, are output-only programs. They are not expecting any input and therefore cannot recognize “P. To use echo printing with these programs, you must turn it on at the command level before you enter the CP/M command.
Other CP/M programs, such as ED, do recognize input. With these programs you can turn echo printing on and off at the program level.
Non-CP/M programs may not recognize *P. When you execute such a program, echo printing may get turned off automatically as soon as the program is started.
Match the programs described below with the statements on the right. ———— (1) DIR is a built-in command a. You can get a hardcopy of the out- that is output-only. put by turning on echo printing
(2) SORT is a non-CP/M pro- before entering the command. gram that allows input and b. You can get a hardcopy of part of output. the output by turning echo printing (3) ED is a CP/M transient on and off while it is executing.
program that allows both c. You can’t get a hardcopy of the out- input and output. put using echo printing.
d. Any of the above may be correct because we don’t know how the program works.
(1) a5 (2) d; (3) a,b
36 USING CP/M
18. Recall that you can interrupt the output of a CP/M program with *S. Recall also that any other character, except “C, restarts the output.
Suppose you're typing a long file using the built-in command TYPE. After it starts, you decide you want to turn on echo printing. What can you do?
(a) Type *C to abort the program, followed by “P to turn on echo printing, then enter the TYPE command again.
(b) Type *S to interrupt the output, followed by “P to turn on echo printing, then *S to restart the output.
(c) Nothing—you can’t use echo printing with TYPE.
a - (b is incorrect because the “P would restart the output rather than turn on echo printing.)
19. All the control characters you have studied in this section — rubout/delete, “R, *X, “U, “H, “C, “S, and *P—are CP/M control characters. They work when you are at CP/M command level. They may also work when you are at the program level, but that depends on the specific program.
If you are working with non-CP/M programs — programs that have been written or purchased elsewhere — you'll have to examine the program documentation to find out what control characters the program will recognize. Many programs that were written to work with CP/M will recognize the same characters, but others won’t.
The CP/M built-in commands and transient programs recognize these control characters. Later on, as you study each program, we will remind you of the relevant control functions.
(a) The control characters are always recognized at the command level. True or false?
(b) All CP/M programs recognize the control characters presented in this chapter. True or false?
(c) All non-CP/M programs do not recognize the control characters presented in this chapter. True or false?
(a) true; (b) true; (c) false (some programs are written to recognize the same control characters)
TYPING CP/M COMMANDS 37
20. There are basically two different ways for a program to handle input data. One way is to read each character, store it, and display it on the terminal screen but not process it until you hit the carriage return <CR> key. This is the most common way of handling input data that might contain more than one character, such as the CP/M commands. It gives you time to think, find the right keys, and correct typing errors before you hit <CR>.
The other way is to read a character and process it immediately (without waiting for you to push <CR>). This is sometimes used when the program is only expecting a one-letter command. For example, programs frequently ask yes or no questions such as:
DO YOU REALLY WANT TO QUIT (Y OR N)? _
The instant you type Y or N, it will be read and processed. This can be surprising if you’re not expecting it; your display will change while you’re still reaching for the <CR> key.
Some CP/M control characters (as mentioned previously) are processed immedi- ately, even if typed in the middle of a command that’s being stored. They’re not stored as part of the command, and they’re usually not displayed per se. (You see their effect, but the characters themselves are usually not displayed.)
What happens if you type another control character such as “A? The effect depends on the specific character you type. Thgre are some other CP/M control char- acters that we have not yet discussed — “E, “I, “J, “M, and “Z. You’ll learn about these in later chapters. Except for these, the system will treat a control character as a regular character: it is read, stored as part of the command, and displayed.
At the CP/M command level, identify whether the following characters would be stored or processed immediately.
(a) “U (b) D («) ? (d) “A (e) .%
(f) rubout/delete (g) “C at the beginning of a line (h) “C in the middle of a line
(a) processed; (b) stored; (c) processed; (d) stored; (e) stored; (f) processed; (g) processed; (h) stored
In this chapter you have studied the general CP/M command format, what hap- pens when you enter a CP/M command, and the CP/M control characters. Now you're ready to begin learning the commands themselves, but first complete the Self-Test and try the machine exercises.
38 USING CP/M
CHAPTER 2 SELF-TEST
This Self-Test will help you determine if you have mastered the objectives for this chapter. Answer each question to the best of your ability. Then check your answers in the answer key at the end of the test.
1. Assume that your disks contain these files:
(b)
(c)
(d)
(e)
Drive A Drive B PIP.COM JOHNSON.LET ED.COM JONES.LET TEST.COM INDEX PRN TEST.DAT INDEX COM
Write a command to run the ED program using the file JOHNSON.LET. Leave the A drive active.
A>
Write a command to run the INDEX program which requires no operands. Leave the A drive active.
A> Rewrite your command for question (b) to leave the B drive active. A>
Write a command to TYPE the file named INDEX.PRN. TYPE is a built-in command. Leave the B drive active.
B>
Write a command to TYPE the file named TEST.DAT. Leave the B drive active.
B>
2. | Suppose you had this CP/M interaction:
(a) (b)
(c) (d)
A>TYPE JONES.LET FILE NOT FOUND
A>_
What program issued the message FILE NOT FOUND? ____-SE
What went wrong? — SSS
At what level are you now?
Can you enter a CP/M command now?
TYPING CP/M COMMANDS. 39
Suppose you had this CP/M interaction:
(c)
A>ERA TEST.DAT A>_
What happened?
At what level are you now?
Can you enter a CP/M command now? —____ SSeS
Suppose you had this CP/M interaction:
(d)
A>INDEX INDEX?
A>_ What program issued the message INDEX?
What went wrong?
What level are you now at?
Can you enter a CP/M command now?
The more you know about the control characters, the easier it will be for you to ‘use your terminal. Give the correct character for each of the following functions. Try to work from memory.
(a)
(b)
(c) (d) (e) (f)
Restart CP/M from the beginning (system reboot; warm start; abort).
Interrupt output display.
Restart output display.
Echo print on, ____________ Echo print off. Delete entire line.
Delete previous letter.
Reshow current line.
Only answer the following questions if your system includes these functions.
(g) (h)
Backspace one character.
Backspace to beginning of line.
40 USING CP/M
Chapter 2 Answer Key
Compare your answers to the Self-Test with the correct answers given below. If all your answers are correct, you are ready to go on to the next chapter. If you missed any questions you may find it helpful to review the appropriate frames before con- tinuing.
1. (a) A>ED B:JOHNSON.LET; (b) A>B:INDEX; (c) A>B: followed by B>INDEX; (d) B>TYPE INDEX.PRN; (e) B>TYPE A:TEST.DAT
2. (a) TYPE; (b) JONES.LET is not on disk A; (c) command level; (d) yes 3. (a) TEST.DAT was erased; (b) command level; (c) yes 4. (a) CP/M; (b) INDEX.COM is not on disk A; (c) command level; (d) yes
5. (a) C; (b) *S, any character but “C; (c) *P, *P; (d) “U and in some systems “X; (e) rubout/delete; (f) “R; (g) “H; (h) *X
Suggested Machine Exercises
Before you go on to the next chapter, you should practice some of the things you have learned here. You're not actually ready to enter any commands yet, but you can practice some of the control characters.
1. Start your system.
2 Boot.
3 When you’ve got the A prompt, continue.
4. Type this sentence: HI THERE.
5 Enter it. What response do you get? CCP should respond “‘HI?” 6
If you have a line printer, turn on echo print. (Do you remember how to do
this? Hold down the CONTROL key and hit the letter P.) Type a few letters to
‘make sure your printer is echoing. If not, hit carriage return. If it still doesn’t
print, check the following:
(a) Is your printer cable connected?
(b) Is your printer power on?
(c) Is the printer on-line as opposed to local?
(d) Did you hit *P just once? Remember that it’s a toggle switch. If none of the above succeeds, you may need to get some help from a colleague or your hardware/software dealer.
10. 11.
TYPING CP/M COMMANDS 41
Reboot. (Use “U or *X to get to the beginning of a line to do this.)
Check echo printing; it should now be off. Turn it on again.
Type this sentence, but make a lot of mistakes and corrections: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
Practice using delete/rubout; “R if you need it, “H and “X if you have them. Compare your CRT display to the echo print listing.
Turn echo print off. Type a few letters to make sure it’s off.
This is enough for now. Shut off the system and continue with Chapter 3.
CHAPTER THREE
CP/M Built-In Commands
CP/M has commands built into the Console Command Processor (CCP). These built-in commands will display all or part of a disk directory, display file contents, erase files, or change filenames.. You can even create a file from whatever is in memory. CP/M version 2.0 allows you to change your user number as well. In this chapter, you'll see how to use the CP/M built-in commands to perform these functions.
When you complete your study of this chapter, you'll be able to:
code specific (unambiguous) file references,
code generalized (ambiguous) file references,
display or print all or part of a disk directory,
erase specified files from a disk,
change the name of a file on a disk,
display or print the contents of a (printable) file, create a file on disk from data in memory,
assign or change a user number for CP/M version 2.0.
Versions 1.4 and: earlier versions of CP/M support only one user. Later versions of CP/M support many users. When you first enter CP/M, you are in user area 0. If that doesn’t change, you’ll operate as a one-user system, as in basic CP/M. In this part of the chapter we’ll consider user number 0 under version 2.0 to be equivalent in effect to version 1.4. Then we’ll see how other user numbers are used and what effect they have on the built-in commands. You'll be able to skip over that section if your system is earlier than version 2.0.
THE DIR COMMAND
1. The DIR command is used to display the disk directory on the console. An entry like this:
A>DIR
42
CP/M BUILT-INCOMMANDS 43
results in a complete directory listing of the active disk at your console. If you want an echo print listing you can use “P before entering DIR. Under Version 1.4, the directory is displayed as a list and looks like this:
A:PIP cOM A:INVENTY DAT A:TEST cOB A:SORT coB
Under version 2.0, the directory looks like this:
AtPIP COM: INVENTY DAT: TEST COB: SORT cos
The entries are formatted four across and separated by colons. Column 1 contains the drivename in both versions. The period that separates the filename from the filetype is not included in either.
The directory listing of drive B can be obtained by entering DIR B:
Suppose drive C is active.
(a) How can you display its directory? Cc>
(b) How can you display the directory on drive A? Cc>
(c) What information is included in a directory listing?
(a) C>DIR; (b) C>DIR A: (or C>A:, A>DIR); (c) complete names of all files
2. The DIR command can be used to list a single file if you use the filename. If you specify A>DIR GAME.ONE, you will get one of two responses. If drive A con- tains a file named GAME.ONE, you'll get:
A:GAME ONE
If drive A doesn’t contain that file you’ll get the message NOT FOUND. Figure 3.1 contains a list of files that might appear on a disk. On this list, which commands below would result in the message NOT FOUND?
(a) A>DIR COPY.COM _____ (b)_ A>DIR TRY.NOW
(c) A>DIR FIVE
(4) A>DIR THREE.CH
44 USING CP/M
(1) TRY (10) PIP.COM (19) CORRES.XX (2) PRACTICE (11) ED.COM (20) CORRES.DK3 (3) THIS.NOW (12) COPY.COM (21) BILLING.DT (4) ONE.CH (13) INVOICE.XX (22) SUPPLIES.DT (5) TWO.CH (14) INVOICE.WI (23) PROGRAM.COB (6) THREE.CH (15) INVOICE.DK (24) PROGRAM.REL (7) FOUR.CH (16) CORRES.WI (25) PROGRAM.PRN (8) FIVE.CH (17) CORRES.DK1 (26) PROGRAM.DAT (9) INTRO.CH (18) CORR.DK2 (27) PROGRAM.COM
Figure 3.1. File Listing, Drive A
3. Suppose you want to find out whether your B disk contains the INVENTY.DAT file. Which of the following commands would be the most efficient?
(a) A>DIRB: (b) A>DIR B:INVENTY.DAT (c) A>DIR
4. Like all of the built-in commands, DIR works very fast. If you’re using a video terminal under version 1.4 and have a lot of files to be listed, some of the filenames may roll off the top of the screen before the listing is finished.
You can interrupt the listing with “S. DIR works so fast that you may need to pose your fingers over the CONTROL and S keys before you enter the DIR command. (Echo printing slows down the output.)
DIR is an output-only function and is not expecting any input. If you type any character other than “S while DIR is running, it will abort immediately.
(a) How can you temporarily stop the DIR listing? (b) How can you restart the listing again? —
(c) While the listing is stopped, how can you abort the DIR command?
(d) While the listing is running, how can you abort the DIR command? ____
CP/M BUILT-IN COMMANDS 45
(a) type “S; (b) type any character except “C; (c) type “C; (d) type any character except “S
THE ERA COMMAND
5. The ERA built-in command is used to erase files from the directory and from the disk. Here is its format:
ERA file-name
The command ERA XYZ.PRN will erase the file of that name from the active disk directory. The space the file occupied is made available. The active drive prompt is displayed after the file is erased. If a file of that name doesn’t exist on the active drive, the different versions have different responses. Version 2.0 and later versions return the message [NO FILE]. Older versions do not give you a message; therefore you won’t know that nothing has been erased.
(a) Write a command to erase the first file from the list in Figure 3.1. A> (b) Suppose you have the following dialogue with CP/M: AD>ERA B:FERNANDEZ.LET NO FILE
A>_
What happened?
(a) A>ERA TRY; (b) there is no file of that name on drive B
6. Files can be erased from any disk that is not read/only (R/O), if you prefix the filename with the drivename. ERA B:XYZ.COM will remove file XYZ.COM from the disk on drive B and from the directory of drive B. If you try to erase a file from a read/only disk, you get a BDOS error. Striking any key will reboot the system.
Write commands to accomplish the following functions. (a) Erase the file named INVENTY.DAT from disk A. A> (b) Erase the file named COPY.COM from disk C. A> (c) Display the directory of disk C. A> (d) Display the directory of disk A. A> (e) Find out if COPY.COM is on disk B. A>
46 USING CP/M
(f) Erase COPY.COM from disk B. A> (g) Check to seé of COPY.COM was erased from disk B.
(a) A>ERA INVENTY.DAT; (b) A>ERA C:COPY.COM; (c) A>DIR C; (d) A>DIR; (e) A>DIR B:COPY.COM (or DIR B: but DIR B:COPY.COM is more efficient; (f) A>ERA B:COPY.COM; (g) A>DIR B:COPY.COM
THE REN COMMAND
7. The REN command is used to change the name of a file on a disk. REN just renames the file; it doesn’t make another copy or move the file anywhere. REN is only concerned with the directory entry. Here is the format of the REN command:
REN new-name=old-name
Notice that the new name is specified first, followed by an equal sign and the filename as it currently exists. You may use spaces around the equal sign if you wish. The com- mand REN NEW.ONE=XYZ.PRN will change the name of the current file XYZ. PRN on the active drive to NEW.ONE.
Write commands to change filenames on the active drive as indicated below: (a) change ONE.CH to CHAP1.BK
(b) change PROGRAM.COM to PAYROLL.COM
(c) change PRACTICE to TRYOUT.DOC
(a) REN CHAP1.BK=ONE.CH; (b) REN PAYROLL.COM=PROGRAM.COM; (c) REN TRYOUT.DOC=PRACTICE
8. Either or both of the filenames in the REN command can be preceded by a drivename. If you use a drivename on both filenames, they must be the same. If not, CP/M will question the second filename and won’t rename anything. If you use a drive- name on one filename, the same drive will be assumed for the other filename. If a drivename is not included, the active drive will be used.
CP/M BUILT-IN COMMANDS 47
Indicate which drive will be used for each valid REN command below. If the command is invalid give the reason.
(a) A>REN XYZ.PRN=XYZ.LST
(b) A>REN A:XYZ.PRN=XYZ.LST
(c) A>REN B:XYZ.PRN=A:XYZ.LST
(d) A>REN XYZ.PRN=B:XYZ.LST
(ec) B>REN XYZ.PRN
(a) drive A; (b) drive A; (c) invalid, drivenames are different; (d) drive B; (e) invalid, only one filename is included
9. Aside from invalid REN commands, two types of errors may arise when you issue REN commands. You may name an old file that doesn’t exist or you may give a new name. that already does exist. In either case, no file is renamed. Suppose your disk contains these files:
FILE1 .TEX FILE1.BAK TEX.COM FILE2.TEX FILE2.BAK PIP.COM FILE3 .TEX FILE3 .BAK ED.COM
You want to change FILE1.BAK to FILE1A.TEX. What happens if you code it like this?
REN FILE1.BAK=FILE1A.TEX
First the system looks for the old filename in the directory, but FILE1A.TEX doesn’t exist and you will get an error message “NOT FOUND”. Suppose you re-enter the line like this:
REN FILE2.TEX=FILE1.BAK
Now the system can locate FILE1.BAK in the directory to change it. It also checks the directory to be sure it isn’t duplicating a filename. In this case, FILE2.TEX is in the directory and you get an error message “FILE EXISTS”. If you really meant that last command, you would need to erase (ERA) or rename (REN) FILE2.TEX before renaming FILE1.BAK.
48 USING CP/M
Refer once again to Figure 3.1. For each command below indicate the new file-
name or error message that results.
(a)
(b)
(c)
(d)
A>REN CORRES.DK2=CORR.DK2
A>REN A:TRY.OUT=TRY
A>REN THREE.CH=THREE.CHP
A>REN THREE.CH=PRACTICE
A>REN A:FOUR.CHP=B:FOUR.CH
A>REN PREF ACE.CPM=INTRO.CH
(a) new name of CORR.DK2 is CORRES.DK2; (b) new name of TRY is TRY.OUT; (c) message NOT FOUND; (d) message FILE EXISTS; (e) error — different drive- names (?B:FOUR.CH); (f) newname of INTRO.CH is PREFACE.CPM
10. (a)
(b)
(c)
Write commands to accomplish these operations on files from Figure 3.1.
The INVOICE files are to be called BILL with the same filetypes:
The PRACTICE file is to be named SIX.CH.
BILLING.DT is to be changed to CORRES.WI. The old CORRES.WI can be removed.
CP/M BUILT-INCOMMANDS 49
(a) REN BILL.XX=INVOICE.XX, REN BILL.WI=INVOICE.WI, REN BILL.DK=INVOICE.DK; (b) REN SIX.CH=PRACTICE; (c) ERA CORRES.WI, REN CORRES.WI=BILLING.DT
THE TYPE COMMAND
11. The TYPE built-in command displays the contents of a file at the console. Here is the TYPE format:
TYPE filename
As with other commands, a drivename can precede the filename. The file must contain printable characters such as textual material, source coding, or character data. Files of non-printable characters such as COM files, will try to type, but you'll see garbage on
the screen. (If your terminal has a bell, it may also ring several times. This won’t hurt the terminal.)
(a) How can you use TYPE to produce a printed copy of a file on the line printer?
(b) How can you temporarily stop a partially displayed file? (c) How can you restart it?
(d) How can you permanently stop (abort) a file that is typing at the console?
(a) use “P before carriage return; (b) use “S; (c) type any character but “C; (d) hit any key other than *S
12. Refer to Figure 3.1 again. Suppose your A drive is active and you enter this command:
TYPE THIS.NEW
The system will respond with 7THIS.NEW — it couldn’t find a file with that name. If you enter TYPETHIS NOW, the system will respond 7TYPETHIS NOW — you left out the space and the CCP didn’t recognize TYPE. If you enter TYPE THIS.NOW, the contents of that file will be displayed on the screen (if it’s printable).
Write commands to display the contents of the files from Figure 3.1. Assume drive B is active.
(a) file (23) B>
50 USING CP/M
(b) file (2) B> (c) file (10) B> (d) The COM file isn’t in printable form. How can you cancel the display?
(a) B>TYPE A:PROGRAM.COB; (b) B>TYPE A:PRACTICE; (c) B>TYPE A:PIP.COM; (d) hit any key (except *S)
13. Refer to Figure 3.1 and write commands to perform the sequence of operations below.
(a) Display a-complete directory. A>
(b) Remove the PROGRAM file of type PRN. A>
(c) Change the name of the REL type PROGRAM file to PATCH.REL. A>
(d) Display the contents of the PROGRAM file of type COB. A>
(e) Produce a printed listing of PROGRAM.COB. A>
(f) Stop the-display of PROGRAM.COB in mid-TYPE.
(a) A>DIR; (b) A>ERA PROGRAM.PRN; (c) REN PATCH.REL=PROGRAM.REL; (d) A>TYPE PROGRAM.COB; (e) use “*P before the TYPE command is entered; (f) use “S at the appropriate time
CP/M BUILT-IN COMMANDS 5
THE SAVE COMMAND
14. The SAVE built-in command is used to put the contents of the Transient Pro- gram Area (TPA) on disk as a file. This is the SAVE command format:
SAVE n filename
Here n refers to the number of “‘pages” of data—CP/M considers 256 bytes to be a page. You'll use the SAVE command only if you’re involved with assembler language programming or regenerating a system. But since it is a built-in command, we’re intro- ducing SAVE here.
SAVE 3 FILE.XY
This example causes the first three pages (three x 256 bytes) in the TPA to be written on the active disk and named FILE.XY. Just as you can’t ERAse or REName a file on a Read/Only disk, you can’t SAVE a file onto an R/O disk.
Which of these SAVE commands is in correct format? (a) SAVE PROGRAM.COM
(b) SAVE 6 ZAP.COM
(c) SAVE ZAP .COM 6
(d) SAVE6ZAP.COM
GENERALIZED FILE REFERENCES
15. A file reference is used to identify a particular file or group of files on a disk. The file reference is specific when it refers to a single file, CP/M documentation calls this an “unambiguous filename” or “ufn.” Any file reference that includes the drive, the filename, and the filetype refers to only one file and is unambiguous. The drive can be omitted if the appropriate disk is on the active drive.
A generalized file reference may refer to a number of different files. CP/M calls this an “ambiguous filename” or “afn.” One way of specifying a generalized file refer- ence is to use an asterisk for either the filename or filetype, and the actual filename or filetype for the other. *.COM refer to all the files on the active disk that have filetype “COM,” no matter what the specific file name is.
Label the file references below as specific or generalized. (a) B:INVENT.DEC (b) INVENT.* (c) A:*.DEC
52 USING CP/M
(ad) INVENT.DEC
(e) Which of the file references above are unambiguous (ufn)?
(f) Which of the file references above could refer to more than one file?
(a) specific; (b) generalized; (c) generalized; (d) specific; (e) a,d; (f) b,c
16. A complete file reference may include a drivename as well as a filename and filetype. Either the filename or the filetype, or both, can be replaced with an asterisk. The asterisk means that any combination of characters will do. The drivename cannot be replaced with an asterisk since a command can deal with only one disk drive at a time. However, the drivename can be omitted if the active drive is appropriate. Match the file references with their descriptions.
(a) *.PRN (1) Invalid file reference.
(b) JOBTIME.* (2) Refers to all files with filetype PRN.
(c) *:JOBTIME.PRN (3) Refers to all files with filename
(4) #:** JOBTIME
(ce) ** (4) Refers to all files on all disk drives. ___ @®_—B-*.coM (5) Refers to all files on the active disk.
(6) Refers to all files with filetype COM. (7) None of these.
(a) 2; (b) 3; (c) 1; @) 1; (@)5; (7
17. Suppose the active disk contains these files:
PAYROLL.COB PIP.COM PAYROLL.REL ED.COM PAYROLL.PRN COPY.COM PAYROLL.DAT DISKTST.COM
Write file references that refer to the files described below.
(a) All the files that have PAYROLL as the basic filename.
CP/M BUILT-IN COMMANDS 53
(b) All the files that have filetype COM.
(c) The COBOL source file (type COB) for the PAYROLL program.
(d) All the files on the disk.
(a) PAYROLL.*; (b) *.COM; (c) PAYROLL.COB; (d) *.*
18. You have seen how the asterisk is used to indicate a generalized file name. The asterisk indicates any number of ambiguous characters — up to eight for the filename or three for the filetype.
You can also use a question mark (?) as a character in an ambiguous filename. The question mark indicates just one ambiguous character. The reference 7TEST.DAT would be matched with any of these filenames: ATEST.DAT, BTEST.DAT, CTEST.DAT, etc. But it would not be matched by NEWTEST.DAT or AITEST.DAT.
To answer the questions below, assume that your active disk contains these files:
PAYROLLS.COM PAYROLL1.DAT PAYROLL2.DAT PAYTAXES.COM PAYTAXES.DAT PAYROLLS.COB PAYTAXES.COB
(a) Name any files that match PAYROLL?.DAT
(c) Name any files that match PAYTAXES.CO?
(a) PAYROLL1.DAT and PAYROLL2.DAT; (b) PAYROLLS.COM and PAYTAXES.COM; (c) PAYTAXES.COM and PAYTAXES.COB
54 USING CP/M
19. The question mark can be used to set any position in a filename or filetype, to refer to any character. The reference X?Z.* refers to any three character filename that begins with X and ends with Z, no matter what the filetype is. These files are all included.
XYZ XYZ.TEM X2Z.PRN XAZ.B
Suppose a disk contains these files:
D330T1.WS D330B1.WS D330C1.WS D331T1.WST D331B1.WST D330C1.TWS PIP.COM WS.COM
Write file references to refer to the groups of files indicated below. (a) All the files whose filename ends with T1.
(b) All the files whose filename includes 330.
(c) All the files of filetype WS and filename ending with C1.
(a) D33?T1.* or 2229T1.*; (b) 233027.*; (c) 2222C1.WS
20. Under CP/M the filename has eight characters while the filetype has three char- acters. A blank is considered a specific character. The filename PIP.COM is really PIPHHEEB.COM, where } indicates a blank. The filename TESTDATA is really TESTDATA.bHb.
If you use the generalized reference P?.COM, you have really specified P?46646B.COM. A matching filename will have blanks in positions 3 through 8; that is, it must be no more than two characters long. These filenames would match: P1.COM, PT.COM, and P.COM. But the filenames PIP.;COM and PAYROLLS.COM would not match.
CP/M BUILT-IN COMMANDS 55
Suppose a disk contains these files:
XYZ.A XYZ X006:A XYY.A XYX X007.A XYY.B WALL X008.B XYX.B ROOM X009.C Which files are included by each file reference below.
(a) 222."
(b) 22X.* =
() *
(d) X2229277.A
(e) X2227.B
(f) X22.B
(a) XYZ.A, XYY.A, XYY.B, XYX.B, XYZ, XYX; (b) XYX.B, XYX; (c) XYZ, XYX, WALL, ROOM; (d) XYZ.A, XYY.A, X006.A, X007.A; (ec) XYY.B, XYX.B, X008.B; (f) XYY.B, XYX.B
21. In writing generalized file references the asterisk is really an abbreviation that fills the rest of a filename or filetype field with question marks. Examine these examples:
TE* PRN is equivalent to TE???27? PRN
TE*.* is equivalent to TE??????.22?
marks. This will create the generalized (ambiguous) file reference.
The files in figure 3.1 are numbered for your convenience. Indicate which files match each file reference below.
(a) *
Ge a ee ee (c) T*.CH
(d): (OF 2 8 (e) C*.D*
(Bs: We es
(a) MES DY = a2 = 8 es
56 USING CP/M
Cs eee (i) P*
(a) 1,2; (b) 1,5; (c) 5,6; (d) 12, 16, 17, 18, 19, 20; (e) 17, 18,20; (f) 14, 16; (g) 15, 17, 18, 20, 21, 22, 26 (don’t forget that the characters following * will be ignored); (h) 10, 23,27; (i) 2
Now that you’ve learned how to write a generalized file reference, let’s practice
some DIR and ERA commands. SAVE, TYPE, and REN must have specific’ filenames.
22. In the DIR command the filename can be specific or generalized, as in these examples:
B: This refers to all files on drive B.
= This refers to all files on the active drive. X?2.* This is a typical generalized file reference. XYZ.COM This refers to a specific file.
Write two different commands to display the complete directory on the active
(a) (b) What is the general effect of each DIR command below? (c) DIR * (d) DIR *.* GO) TOUR CON a ee 5 me 21s gel 4 re oe EC a ee
(g) DIR T?6?.PRN
CP/M BUILT-IN COMMANDS 57
(a) DIR; (b) DIR *.*; (c) list all files on the active drive with no (or blank) filetype; (d) list entire directory (all files) on the active drive; (e) list all COM files (filetype COM) on the active drive; (f) list all PRN files with filename beginning with T on the active drive; (g) list all PRN files on the active drive that have filenames of three or four characters with T in the first position and 6 in the third
23. Refer to Figure 3.1. Assume drive A is active. Which of the DIR commands below will return the NOT FOUND message?
(a) DIR CORRE.* ___ (b)_ DIR PRACTICE.* (c) DIR PROGRAM (a) DIR *.CH?
(e) DIR IN??.* _____ (f)_-—«zDIR IN*#
(g) DIR XYZ.COM
(a) (No filename is CORRE.); (c) (no PROGRAM filename has a blank filetype); (e) (No filename starting with IN has only four characters); (g) (No file with that name is on the disk.)
24. Use Figure 3.1 and give the numbers of filenames that would be included in directory listings produced by these DIR commands.
(a) DIR PRACTICE.* (b) DIR *.CH? (c) DIR IN*.* (d) DIR CO?2.* (ec) DIR P*.* (f) DIR 22V*.*
(a) 2; (b).4, 5,6, 7,8,9; (c)9, 13, 14,15; (d) 12,18; (e) 2, 10, 23, 24, 25, 26, 27; (f) 8, 13, 14, 15
58 USING CP/M
25. The ERA command can also reference a generalized filename. Refer again to Figure 3.1. How many files are removed from the disk by each ERA command below?
(a) ERA PRACTICE
(b) ERAPROGRAM* (c) ERA CORRES.DK2
(4) ERA *.COM
(6) ERA PCH 5. ee () ERAT??.CH
(s:) ERAXYZ.COM (h) ERA BILLING.DT
() ERA*
(a) 1; (b) 5; (c) none; (d) 4; (€) 2; (f) 1; (g) none; (h) 1; (i) 2
26. All files can be erased from a disk with the command ERA *.*. When you enter this command CP/M gives you the message ““ALL FILES (Y/N)?”. If you enter “Y,” all files on the disk are erased. If you enter “N,” the ERA *.* command is canceled and nothing is erased.
Suppose you have disks on drives A and B that contain these files:
drive A drive B PROGRAM.COB TRY PROGRAM.REL PRACTICE PROGRAM.PRN THIS.NOW PROGRAM. DAT INVOICE.XX PROGRAM.COM INVOICE.DK PIP.COM INVOICE.WI ED.COM
Write commands to accomplish the following functions, working from the active drive indicated.
(a) Remove PIP.COM from disk A. A>
(b) Display the complete directory of the disk on drive B. A>
(c) Remove files TRY and PRACTICE from drive B. A>
CP/M BUILT-IN COMMANDS 59
(d) Change the active drive to B. A a et es (e) Remove all the PROGRAM files from drive A. B> (f) Remove the INVOICE files from drive B. B> (g) Display the directory listing for drive A. B> (h) Sketch the resulting display.
(a) A>ERA PIP.COM
(b) AD>DIR B:
(c) A>ERA B:*
(d) A>B:
(ce) B>ERA A:PROGRAM.* (f) B>ERA INVOICE.*
(3) B>DIR A:
(h) A:ED COM
27. Refer to Figure 3.1. Assume drive A is active. Write commands to erase files as indicated below.
(a) Remove files (4) through (9).
(b) Remove all the files.
(c) Remove files (16) through (20).
(a) ERA *.CH; (b) ERA *.*; (c) ERA COR*.* (or COR???.* or CORR*.*)
60 USING CP/M
VERSION 2.0 ENHANCEMENTS
You’ve seen how the CP/M built-in commands are used in version 1.4 and single user (0) version 2.0. DIR, ERA, RENAME, and TYPE have some differences in version 2.0. In addition, version 2.0 has a new built-in command, USER. If you use version 1.4 or earlier, you may skip ahead to the Self-Test if you wish.
USER NUMBERS
28. Version 2.0 allows 16 ‘different user numbers (0-15). Internally, user numbers are associated with files. If you create a file as user 5, for example, that file is associated with user number 5. Other user numbers can not access the file. After a cold start the system puts you in user number 0. If you don’t change that, you’ll operate just as you learned for version 1.4. If you do change the user number, CP/M moves to another part of the directory. Files associated with user 0 can no longer be accessed, although the active drive remains the same. The user number remains the same until you change it or until another cold start is performed.
(a) How many user numbers does version 2.0 support? —-- SS (b) What user number is in effect directly after a cold start? (c) Suppose a disk contains files attached to user numbers 0, 1, 2 and 6. Can you
access all the files at any given time?
(a) 16; (b) 0; (c) no—only those for the active user number
29. The USER built-in command is used to change user numbers. Here is its format: USER n
For example, USER 5 selects user number 5. The n can be a number from 0 through 15. The selected user number remains in effect until another USER command is issued or a cold start is performed.
How would you accomplish the following:
(a) Select user numiber 0.
(b) Select user number 11.
CP/M BUILT-INCOMMANDS 61
(c) Select user number 2.
(a) cold start or USER 0; (b) USER 11; (c) USER 2
30. Under version 2.0, a user number is associated with each directory entry. When you enter DIR you get a directory listing of all files associated with the active user number. Of course, if all files are associated with the same user number, you'll get a complete listing.
(a) Explain why a 2.0 DIR listing might not include all the files on the disk.
(b) Suppose you are under USER 0 and you want directory listings of all files as- sociated with user numbers 0 and 5. Write the commands you need.
(a) Only the non-system files of the active user are listed; (b) DIR; USER 5; DIR
31. The ERA, REN, and TYPE commands can refer only to files associated with the active user. If you enter ERA *.*, you will erase all files associated with the current user number. If you attempt to rename a file that has a different user number, you'll get a NOT FOUND message. If you try to erase a file that has a different user number, the result will be the same as if the file didn’t exist. If you try to TYPE a file that isn’t attached to the active user number, it won’t be typed —just questioned as a non- existent file. The point is that CP/M can only recognize filenames attached to the cur- rent user number. You can perform the desired operation by changing to the correct user number. In later chapters you'll learn more about handling files and determining user numbers on a disk.
(a) How many commands are needed to erase all user files from a disk that has user numbers 2,3, and 4? Assume you have just done a cold start.
62 USING CP/M
(b) How could you rename'a file of user 7 if user 6 is active?
(a) 6 (3 USER commands and 3 ERA *.* commands); (b) change to USER 7 and use the REName command
32. The SAVE command also has a slightly different effect under version 2.0, but for a different reason. When you SAVE a file the active user number becomes associated with it. In version 1.4 the memory area in the TPA is likely to be destroyed by the SAVE operation, so a file can only be SAVEd once. In version 2.0 the TPA isn’t altered by SAVE, so the same set of “pages” can be SAVEd under several different filenames and user numbers.
(a) Under what user number is a file SAVEd?
(b) Suppose you have a six “page” program in the TPA under user number seven. Write the commands to create two files, one called SAVONE.COM attached to user seven, and one called SAVTWO.COM attached to user eight.
(a) the active user; (b) SAVE 6 SAVONE.COM, USER 8, SAVE 6 SAVTWO.COM
As you’ve seen, user numbers supported under CP/M version 2.0 affect most of the built-in commands. The DIR command lists only files associated with the active user. ERA allows you to erase only files of the active user. REN lets you rename only files of the active user. And only those files can be TYPEd as well. The SAVE com- mand allows you to resave the same area of the TPA. USER, a sixth built-in command, allows you to move freely between the various user areas on a disk. As you continue in your study of CP/M, you'll see many applications for these features of built-in com- mands under CP/M version 2.0.
(1) (2) (3) (4) (5) (6) (7)
CP/M BUILT-IN COMMANDS 63
PIP.COM (8) SUPPLY.FIL (15) SALES.DOC ED.COM (9) COPY.DOC (16) SALES.HST COPY.COM (10) SUPPLY.DOC (17) SALES.FIL SUPPLY.ASM (11) RECORDS.LOC (18) ST.LST SUPPLY.REL (12) RECORDS.STT (19) ST.DOC SUPPLY.PRN (13) RECORD.ORD (20) DISK.DOC SUPPLY.COM (14) RECL.AV
Figure 3.2. Files on Drive B
CHAPTER 3 SELF-TEST
This Self-Test will help you determine if you have mastered the objectives of this
chapter. Answer each question to the best of your ability. Then check your answers in the answer key at the end of the test.
These questions are based on the disk containing the files shown in Figure 3.2.
We will use version 1.4 CP/M, or version 2.0 with only user 0 on the system, for the first nine questions.
1.
Write commands to display the entire directory. A>
Write a command to display all directory entries with filenames beginning with S, no matter what the filetype is.
B>
Write a command to remove all DOC type files from drive B.
B>
Write a command to change the name of RECL.AV to REC.ASM. B>
Write a command to display the contents of file SUPPLY.FIL on the console. B>
Suppose SUPPLY.FIL contains about 200 lines of data. How can you read the first few lines at your console?
How can you produce a printed copy of SUPPLY.FIL on the line printer?
64 USING CP/M
8. Write a command to create a file named “MEM.SAV” from eight “pages” in the TPA. Store MEM.SAV on drive A.
B>
9. Consider the files shown in Figure 3.2. Suppose you have just cold started the system. You have several things to do.
@ Erase files (11), (12), and (13).
@ Type printed copies of files (15) and (17).
@ Change the name of file (18) to STATES.
@ Change the name of SUPPLY.FIL to be INVENTY.DAT. e@ Examine the complete directory listing at the console.
Write all the commands you would need. Show the prompt at the beginning of each line to indicate the active drive.
A>
The next three questions relate only to CP/M version 2.0 with multiple user numbers.
10. Give two ways you can access user number zero.
11. Suppose you are using a disk on which files are associated with user numbers 0, 3, and 7. How can you examine all the user directory entries?
12.
CP/M BUILT-IN COMMANDS 65
Suppose you are using the same disk as above (11) and have just cold started the system. Write these commands:
(a) Remove OPENST.REC from user 3. (b) Rename user 7 file OUTGO.BK to be called CASHFLOW.OUT. (c) Display the contents of user 0 file DIRECT.ION.
Chapter 3 Answer Key
Compare your answers to the Self-Test with the correct answers given below. If
all your answers are correct you are ready to go on to the next chapter. If you missed any questions, you may find it helpful to review the appropriate frames from this
chapter.
1, DIR B: or DIR B:*.*. Alternatively, you could switch drives then issue DIR. 2. DIR S*.* or DIR $?2277.*
3. ERA *.DOC or ERA ??22227?.DOC
4. | REN REC.ASM=RECL. AV
5. TYPE SUPPLY.FIL
6. Type “S as soon as several lines appear on the console.
7. Type “P before entering the TYPE command.
8. SAVE 8 A:MEM.SAV
11.
12.
USING CP/M
A>Bi (If you omitted this step, your file references all need the drive prefix)
B>ERA RECO*. * (R*.* or REC*.* will also erase file (14) )
B>TYPE SALES.DOC (Enter “P first)
B>TYPE SALES.FIL (Enter “Pp after)
B>REN STATES=ST.LST B>REN INVENTY.DAT=SUPPLY.FIL B>DIR (or DIR *.* — You may need to use *S)
cold start CP/M or USER 0
You will need to use three DIR commands and change user numbers between them.
(a) USER 3; ERA OPENST.REC (b) USER 7; REN CASHFLOW.OUT=OUTGO.BK (c) USER 0; TYPE DIRECTION
Machine Exercise Suggestions
If you have a CP/M system available, you may want to spend some time getting
used to the built-in commands before you continue. The following machine practice
will help.
1. Start up system and boot. (Use a copy of your original CP/M disk.)
2. Install another disk in drive B.
3. Geta directory of A disk.
4. Get a directory of B disk.
5. If you have a line printer, turn on echo printing and get a directory of A disk. Notice how much slower the output is. Turn off echo printing.
6. Get another directory of A, and this time interrupt the display and start again.
7. Rename PIP.COM as COPY.COM. (If your disk already has a COPY.COM, re- name PIP.COM as PIP2.COM.)
8. Check the directory for all COM files. PIP.COM should not appear but your new name should.
9. | Change the file with a new name — PIP2.COM or COPY.COM — back to PIP.COM again and recheck the directory.
10. Save 2 pages of the TPA as PRACTICE.PRN. (Don’t worry about what you’re
saving. Some nonsense data will get saved.)
11. 12. 13.
CP/M BUILT-IN COMMANDS 67
Display the directory. PRACTICE.PRN should appear. Type PRACTICE.PRN. A couple of lines of meaningless data should be displayed. Erase PRACTICE.PRN and recheck the directory.
The remaining steps pertain to. user numbers under version 2.0. If you are work-
ing with an earlier version of CP/M, skip the remaining steps and go on to Chapter 4.
14. 15. 16. 17. 18. 19. 20. 21.
Change to user 2.
Check your directory. Are there any files for user 2?
Save two pages of the TPA as PRACTICE.PRN.
Check the directory again. PRACTICE.PRN should appear.
Go back to user 0 and check the directory. PRACTICE.PRN should not appear. As user 0, try to type PRACTICE.PRN. You should get an error message.
As user 0, try to erase PRACTICE.PRN. Do you get a message?
Go back to user 2 and erase PRACTICE.PRN. Check the directory. Is it gone?
This completes the suggested machine exercises for Chapter 3. Shut down your
system and go on to Chapter 4.
CHAPTER FOUR
CP/M Transient Programs
The typical 8-inch CP/M system disk contains the system on tracks 0 and 1. The commands you learned to use in the last chapter are built into the console command processor of CP/M. The disk also contains various transient programs that are supplied by Digital Research or your supplier. These transient programs can be used to get information about your disks, to perform common operations, to create files, and to assemble or compile new programs.
In this chapter we’re going to overview the transient programs routinely supplied by Digital Research as a part of the CP/M system disk. You probably won’t use all of these, but it’s a good idea to know what’s available. As you use CP/M on the job, you'll quickly learn which of these transient programs you'll need to use a great deal.
When you complete this chapter, you will be able to:
e Differentiate between built-in and transient programs.
@ Identify the CP/M transient programs that would be used to perform various functions.
@ Use the DUMP transient program to produce a listing in hexadecimal format of any file.
@ Use the SYSGEN transient program to copy the CP/M system tracks to an- other disk.
@ Use the MOVCPM transient program to place the CP/M system tracks in mem- ory or change the system size.
1. In the last chapter you learned to use the CP/M built-in commands. These are built into the CP/M system and are included in the system tracks on a disk. Whenever CP/M is running, those built-in commands are present and can be used. Now we’re going to look at CP/M’s transient programs. These are programs provided by Digital Research in addition to the CP/M system itself. They aren’t included on the system tracks, so a given CP/M disk might not include all of these. However, your master disk will have them. You’ll eventually want to copy the transient programs you use on a regular basis, onto many of your disks.
68
CP/M TRANSIENT PROGRAMS 69
(a) How are built-in programs different from transient programs, in terms of where they are located on a disk?
(b) Which type of CP/M programs are automatically “on” any CP/M disk?
(c) What type of CP/M program might not be included on every initialized CP/M disk?
(a) built-in programs are on system tracks, transient programs are on other tracks; (b) built-in; (c) transient
2. The transient programs provided with CP/M serve several purposes. We’ll overview all of them in this chapter. Later chapters are devoted to a more detailed study of some of the major CP/M transients.
Each CP/M transient program is on the disk in the form of a file of filetype COM — also called a COM file. They can be run by entering the filename (without COM) and any required parameters. You'll learn what parameters are required for each. Here is a directory listing of a CP/M disk that contains only the standard CP/M trans- ient programs:
A:ASM COM A:LOAD COM A:ODT COM A:SYSGEN COM A:MOVCPM COM A:DUMP COM A:STAT COM A:PIP COM A:ED COM A:SUBMIT COM
Which of the programs below can be run from this disk:
(a) SAVE _____ (b)_ SUBGEN
(c) PIP
(d) REN
(e) SYSGEN
__(f) “ED
70 USING CP/M
a, c, d, e, f (a and d are built-in and available on every CP/M disk. b — SUBGEN — is not on the disk.)
3. The ED program is CP/M’s text editor. You use it to make new files or change old ones. ED is concerned with “ASCII” files, made up of strings of characters. Typi- cal ASCII files might be correspondence, a chapter in a book, a mailing list, or a source program written in any language supported by the computer.
To use ED you enter a command in this format:
ED specific-file-name [destination drive]
If the file you specify exists, ED will let you change it or add to it. If the file doesn’t exist, ED will create a directory entry and let you put information in the file. You can determine what filetype to use by the kind of data the file can provide. For ex- ample, an assembler program file must have type ASM. Other programs require such types as COB (COBOL), FOR (Fortran), or PLM (PL/M). Most other files may have whatever filetype seems appropriate. One very common filetype used for textual files is TEX. We'll cover ED in detail later in this book. [destination drive] is an optional drive name of form B:. This tells ED to put the edited file out to a specific disk. It leaves the current file where it is.
Suppose a disk contains only these files: ED.COM, PROG1.ASM, and PROG1.TEX.
(a) What can you do with PROG1.TEX after you enter the command shown below? A>ED PROG1.TEX
(b) What command will let you create a file called TWO.COM?
(c) What command will let you modify the assembler language source program?
(a) change it or add to it; (6) ED TWO.COM; (c) ED PROG1.ASM
4. The PIP program (PIP.COM) is CP/M’s file handling utility program. With PIP (it stands for peripheral interchange program) you can copy files from one disk to another or from a disk to any peripheral device. In fact PIP does all the internal con- versions needed to load, print, punch, copy, and combine disk files. What you can do with PIP is limited only by the peripheral devices of your system. We'll devote an entire chapter to PIP later in the book.
PIP is used to transfer files from a disk to any device. When you want a tran- sient program to be copied to a new disk, you need to PIP it over. Any file, of any filetype, can be PIPped. Under version 2.0, you can PIP a file from any user area to
CP/M TRANSIENT PROGRAMS 71
the active user area. You may find you want the PIP transient program on every CP/M disk you use. PIP can also be used to make another copy of a file on the same disk — under a different name.
(a) Which of these can be copied to another disk with PIP? ED.COM ERA
(b) Which of these transfers can be performed using PIP? __—— disk-to-disk ______ printer-to-disk —___. disk-to-printer
(a) ED.COM; (b) disk-to-disk or disk-to-printer
5. The STAT transient program provides general status information about a disk,
a user number, or a file. STAT tells you the size of a file and whether it is read/only or read/write. It tells how much space is left on a disk or how many (and which) user numbers are active on the disk. You can also use STAT to change the file status. You'll learn to do this in the next chapter.
The SUBMIT transient program lets you use a single command to refer to a set of CP/M commands. To use SUBMIT you must first create a file of type SUB using the ED program. This SUB file contains other CP/M commands and parameters. It may include XSUB, another CP/M transient program referenced only from within SUB files. As you'll see, several operations take a number of different commands and parameters. You'll learn in the final chapter to create your own files for submitting to CP/M.
(a) What program provides status information about files or disks?
(b) What program lets you execute a series of CP/M commands by entering a single command? (c) What program is used to create a new file? _.-._>>>E
(a) STAT; (b) SUBMIT; (c) ED
6. Identify the CP/M transient program that would be used to accomplish each function below:
(a) Copy a file from one disk to another
72 USING CP/M
(b) Copy a file from one disk to another, erase the original file and list the directory of the source disk — with a single command, ____———SS—S—S—CSS (c) Identify the user numbers active on a particular disk.
(d) Modify the contents of a TEX file
(a) PIP.COM; (b) SUBMIT.COM; (c) STAT.COM: (d) ED.COM
PROGRAM-RELATED TRANSIENTS
Three of the CP/M transient programs are closely related to programming your microcomputer. We’re not going to teach you to write assembler language programs in this book. However, we will show you how to use the ASM, LOAD, and DDT com- mands to invoke these transient programs. You’ll also learn what is needed as input and produced as output for each.
7. The ASM program is one of the CP/M assemblers. It.translates a source file writ- ten in 8080 Assembler Language into your machine’s internal language — the only language that your computer can understand.
If you are going to program your computer using Assembler Language, this is what you would do. Use ED to create a source file of Assembler Language commands. Your filetype will be ASM; for example, you might create a file named PAY7. ASM.
Then use the ASM program to translate the file into machine language. ASM takes a file of type ASM, “assembles” it, and produces two output files. Both output files have the same filename as the ASM file, but one has filetype HEX while the other has filetype PRN.
The HEX file contains the hexadecimal number system form of your machine language code. This is printable, but not very readable. The PRN file contains a copy of your original source file with the hexadecimal equivalent of each line, along with any error messages. The PRN file is somewhat readable. By displaying the PRN file, you can find out how your source code was translated and also what errors were identified by the ASM program.
Suppose your disk contains these files: ASM.COM, LOAD.COM, PAY7.ASM, MAIL.ASM and MAIL.DAT. A command like this will assemble the PAY7 program:
A>ASM PAY7
The filetype isn’t entered, although it must be ASM. This command invokes the CP/M assembler and produces as output PAY7.PRN and PAY7.HEX.
(a) Write a command to assemble the MAIL. ASM file. A>
CP/M TRANSIENT PROGRAMS 73
(b) What readable file is produced as output? (c) What other file is produced as output?
(a) A>ASM MAIL; (b) MAIL.PRN; (c) MAIL.HEX
8. The LOAD program is used to convert a HEX file to a COM file. This turns the file into a command file that is executable as a transient program by typing the file- name and hitting RETURN. If you enter the command:
A>LOAD PAY7
the file PAY7.HEX, created by ASM PAY7, is “loaded” and translated into machine executable code. The output is then filed on disk as PAY7.COM. You can now enter PAY7 and run the program.
As you can see, if you know how to write programs in 8080 Assembler Language, this method will enable you to create new transient programs that run under CP/M.
(a) What filetype is needed for input to LOAD? (b) Write a command to load the file produced by ASM MAIL. A>
(c) What file will contain the output?
(a) HEX; (b) A>LOAD MAIL; (c) MAIL.COM
9. Most assembler programs (in fact, most programs) don’t work perfectly the first time. They need to be tested and debugged. (Debug is a quasi-technical term for “get- ting the bugs out,” or making a program work correctly.) CP/M provides the DDT transient program as a dynamic debugging tool to help programmers debug their as- sembler language programs. Either HEX or COM files can be debugged with DDT. We’re not going to go into details of DDT here, but assembler programmers can inter- act with the computer as they test and run their programs.
DDT has a side effect that is often useful for non-programmers. You can use DDT to bring any COM or HEX file into the TPA. Then you can use the built-in SAVE command to place it on disk — by any name and under the current user num- ber.
(a) What are two uses of the DDT transient program?
(b) What filetypes can be specified with the DDT command?
74 USING CP/M
(a) debug assembler programs and put a HEX or COM file in TPA; (b) COM and HEX
10. Another CP/M transient program often used with programming or debugging is DUMP. You specify DUMP like this:
DUMP specific-file-name
You can specify a file of any filetype, including HEX and COM. DUMP displays the file contents in coded form, using hexadecimal numbers. In order to read the re- sult, you must be able to translate the hexadecimal numbers yourself. We’re not going to teach you how to do that here; it’s quite complex. If you’re not a programmer you won’t need to use DUMP displays. If you are a programmer you should already know how to interpret hexadecimal code.
If you’re going to use DUMP, don’t forget your CP/M control characters. “P will turn echo printing on and off. *S will interrupt the display. “C will abort the DUMP display.
(a) TYPE will not show you what’s in an unprintable COM file. What CP/M tran- sient program will allow you to display the contents of an unprintable file in a
“semi-readable” form? (b) DUMP displays file contents using _.__=>==> SE Ss numbers. (c) Write the command to display the contents of the file named MAIL.COM.
(d) What control character will temporarily interrupt a dump display? (e) What control character will abort a dump display? (f) What control character will echo print a dump display?
(a) DUMP; (b) hexadecimal; (c) DUMP MAIL.COM; (d) *S; (e) *C; (f) *P
11. Name the CP/M program (built-in or transient) that can accomplish each func- tion below.
(a) Copy program files to a different disk.
(b) Produce a hexadecimal listing of file contents. =» ===> (c) Write a file consisting of a specific number of pages from the TPA. __.__ (d) Change the name of a file.
(e) Convert a HEX file to a COM file. (f) Debug a HEX or COM file.
(g) Bring any COM file into the TPA.
CP/M TRANSIENT PROGRAMS 75
(h) Create an ASCII (printable) file. (i) Convert an ASM file to a HEX file.
(j) Determine the amount of space left on a disk.
(a) PIP; (b) DUMP; (c) SAVE; (d) REN; (e) DDT and LOAD; (f) DDT; (g) DDT; (h) ED; (i) ASM; (j) STAT
SYSTEM-RELATED TRANSIENTS
Two CP/M transient programs are used for handling the system tracks om a CP/M disk; SYSGEN and MOVCPM. As you know, each CP/M disk that you use when booting (cold starting) must contain a CP/M system tailored for your equipment. SYSGEN is used to copy a working system to a new disk so you can boot with that disk as well. MOVCPM is used to change the size of CP/M. We'll see how both are used in this section.
12. The SYSGEN transient program is used to generate a new system disk. In effect, SYSGEN allows you to copy the system tracks from one disk to another. The SYSGEN program will tell you what to do after you enter the command. First SYSGEN gives you the CP/M version number and another instruction, similar to this:
A>SYSGEN SYSGEN VERSION 2.0 SOURCE DRIVE NAME (OR RETURN TO SKIP)_
You have two choices at this point. You can enter the name of the drive from which you wish to copy the system tracks — the source of your system — or you can just hit carriage return. You need to enter a drive name, unless you have already placed a copy of CP/M in memory. You'll learn to do that with MOVCPM a bit later. For now, let’s assume you want to use the system from the disk on drive A. (a) Write the drive name as you would enter it.
SOURCE DRIVE NAME (OR RETURN TO SKIP)____
(b) What is the name of the transient program used to place CP/M system tracks on
a new disk?
(a) A; (b) SYSGEN
76 USING CP/M
13. As soon as you enter a drive name for SYSGEN, the CCP reads and processes it, and the next line is shown. You don’t need to include a colon or hit enter. Now the console shows this:
A>SYSGEN
SYSGEN VERSION 2.0
SOURCE DRIVE NAME (OR RETURN TO SKIP)A SOURCE ON A, THEN TYPE RETURN_
The system waits to give you time to insert the desired source disk (the one you want to copy the system tracks from) into the A drive. If it is already on the A drive you simply hit RETURN. Otherwise you change disks on drive A — without using either a cold or warm start — then hit RETURN. The system tracks are read into memory (the TPA) and you get these messages at the console:
FUNCTION COMPLETE DESTINATION DRIVE NAME (OR RETURN TO REBOOT )_
The system now expects you to tell which drive contains the disk into which you want to copy the system tracks. Remember that we want to place the system on the disk on
our second drive. What do you enter?
B (no colon or carriage return)
14. After the destination drive is entered, you get this message:
DESTINATION ON B, THEN TYPE RETURN_
You can now place the destination disk on drive B, if it isn’t there already, then hit RETURN. When you do, you get these messages.
FUNCTION COMPLETE DESTINATION DRIVE NAME (OR RETURN TO REBOOT )_
This is the same set of messages you saw earlier. But now FUNCTION COMPLETE means that the destination disk contains the CP/M system from memory. You can specify another drive name if you have several disks you need to initialize with your system tracks. You can even specify the same drive again and change disks on drive B. The same system you loaded into the TPA in memory can be used as often as needed. CP/M simply copies it to each destination drive you select. When you have finished, hit RETURN. The system does a warm start and gives you the command prompt, ready for another command.
CP/M TRANSIENT PROGRAMS 77
Here is a copy of a complete SYSGEN interaction:
OMAKDYNAWH—
A>SYSGEN
SYSGEN VER 2.2 SOURCE DRIVE NAME SOURCE ON A, THEN FUNCTION COMPLETE DESTINATION DRIVE DESTINATION ON C, FUNCTION COMPLETE DESTINATION DRIVE
10 A>_
(OR RETURN TO SKIP)A TYPE RETURN
NAME (OR RETURN TO REBOOT )C THEN TYPE RETURN
NAME (OR RETURN TO REBOOT)
Use the line numbers as you answer the questions below.
(a) (b) (c) (d)
On which line is the source drive entered?
On which line is the destination drive entered?
On which lines: does the system wait for you to change drives?
Which line indicates that the system tracks are copied to the disk on drive C?
At which lines did the operator hit RETURN?
(a) 3; (b) 6; (c) 4,7; (d) 8; (e) 1,4, 7,9
15.
You can use SYSGEN to initialize a new disk even if your system supports a single drive. Examine the sequence below.
A>SYSGEN SYSGEN VER 2.2
SOURCE DRIVE NAME SOURCE ON A, THEN FUNCTION COMPLETE DESTINATION DRIVE DESTINATION ON A, FUNCTION COMPLETE DESTINATION DRIVE
A>
{OR RETURN TO SKIP)A TYPE RETURN
NAME (OR RETURN TO REBOOT )A THEN TYPE RETURN
NAME (OR RETURN TO REBOOT)
(a) At what point would you remove the source disk from drive A and insert the
destination disk?
(b) What would be the result if you didn’t change disks?
(a) at DESTINATION ON A, before hitting RETURN; (b) no change to the disk
78 USING CP/M
16. The SYSGEN program writes the system in the TPA to the system tracks of the destination disk. It doesn’t touch the rest of the destination disk. If the disk was empty before SYSGEN, the directory will still be empty afterward. If you want transient pro- grams or other files on your newly initialized disk, you use PIP to copy them.
You can also use SYSGEN to put your system tracks on a disk that contains data files. For example, you might purchase a CP/M-compatible disk containing game pro- grams. You can copy your system tracks onto it using SYSGEN. This will not interfere with the directory or data on the disk. It will enable you to boot with that disk if necessary. As you may recall, you can boot (cold start) your machine only with a disk containing CP/M system tracks for your system on drive A.
(a) How does a SYSGEN operation affect the directory of the destination disk?
(b) Under what circumstances can you use a disk without your CP/M system tracks?
(c) Does initializing an empty disk differ from copying your system to a disk con-
taining data? += ————COCSCSCSdTF' 0, how?
(a) it doesn’t touch the directory; (b) if you don’t boot with it; (c) no difference
17. When you use SYSGEN, you might make certain errors. If you enter a drive name that your system doesn’t recognize, such as a number, you'll get a message like this one for version 1.4:
INVALID DRIVE NAME (USE A, B, C OR D)
followed by a repeat of the request for source or destination drive. Of course, version 2.0 supports more drive names. The INVALID message will be repeated every time you enter a drive name your system doesn’t recognize.
Suppose you are working with a system that has two drives and you accidentally enter D as the destination drive. You get the second message below:
DESTINATION DRIVE NAME (OR RETURN TO REBOOT)D = = => DESTINATION ON D, THEN TYPE RETURN _
The system has recognized the drive name, but it hasn’t yet noticed that it doesn’t actually have a D drive. Since you don’t have a D drive, you can’t put your destination disk on it. If you hit RETURN, you get a disk error message or your system hangs up, depending on your hardware. You may need to boot (cold start) and begin the SYSGEN program again. You get a similar response when you try to use either source or destination drive without a disk loaded. If you notice an error before CP/M does, you can use “C to terminate SYSGEN at any point.
CP/M TRANSIENT PROGRAMS 79
Suppose you are using a version 2.2 system that may support up to 16 drives (A through P). Only six are actually attached, however. What sort of error message would you get from each sequence below?
(a) SOURCE DRIVE NAME (OR RETURN TO SKIP)V
(b) SOURCE DRIVE NAME (OR RETURN TO SKIP)J SOURCE ON J, THEN TYPE RETURN
(c) How could you have avoided the error message in (b) after you have entered drive J?
(a) INVALID DRIVE NAME; (b) a disk error or system hangup; (c) enter “C instead of carriage return
18. You have seen how to use SYSGEN to copy your system tracks from one disk to another. Let’s review the process. Suppose you have four disk drives. You want to put the system from the disk currently in the A drive on two new disks. You will use drive B for both new disks, since that one is easier to reach from your console. At the start you have your master CP/M system disk on drive A and an empty disk on drive B. Make the appropriate entries and answer the questions below.
(a) A>
(b) SYSGEN VER 2.2 SOURCE DRIVE NAME (OR RETURN TO SKIP)
(c) SOURCE ON A, THEN TYPE RETURN ‘What must you do before you type RETURN?
(d) FUNCTION COMPLETE
What function is complete at this point?
(e) DESTINATION DRIVE NAME (OR RETURN TO REBOOT) (f) DESTINATION ON B, THEN TYPE RETURN What must you do before you type RETURN?
80 USING CP/M
(g) FUNCTION COMPLETE
What function is complete at this point?
(h) DESTINATION DRIVE NAME (OR RETURN TO REBOOT) (i) DESTINATION ON B, THEN TYPE RETURN What must you do before you type RETURN?
(j) |. FUNCTION COMPLETE DESTINATION DRIVE NAME (OR RETURN TO REBOOT)
How do you terminate SYSGEN?
(a) SYSGEN; (b) A; (c) nothing; (d) the system is in the TPA; (e) B; (f) nothing; (g) the system is on the disk in drive B; (h) B; (i) change disk; (j) hit RETURN
19. Usually we put the CP/M system on every disk we use. That way we can boot with any disk. It doesn’t take up any usable data area, so it may as well be there.
CP/M is copyrighted by Digital Research. When you purchase the master disk from Digital Research or an authorized dealer and sign the registration card, you have the right to make up to five copies for one computer system. If you make copies to use on another microcomputer, you’re violating Digital Research’s copyright.
You should label every disk that contains the CP/M system tracks with the same copyright notice on your CP/M master diskette. This label can be your signal that the disk contains the system tracks.
When you purchase a fresh disk, what two steps should you take to initialize it?
(a) put the system tracks on using SYSGEN; (b) add the copyright label
Later on you'll learn some other steps we take to initialize a new disk.
20. The MOVCPM transient program is used to move a CP/M system into memory and to alter its size. In the process, you can tailor the system to whatever size you need to work with. From there you can execute the system (warm Start), create a COM file, or initialize a disk using SYSGEN. After your initial command, the CCP gives you messages about what it is doing. MOVCPM allows two operands and its effect depends on the operands you use. The first operand can be omitted or it can state the size of the system you want.
CP/M TRANSIENT PROGRAMS 81
MOVCPM Constructs and executes a CP/M system the maximum size for your hardware.
MOVCPM 32 Constructs and executes a 32K system.
If you specify a memory size larger than the one in your computer, the results are unpredictable. If the system “hangs up” you might have to boot before you can continue using CP/M. If your actual memory size is 32K or larger, the example above will result in screen messages like these:
A>MOVCPM 32 CONSTRUCTING 32K DOS VERS 2.0
ENTERY FOR HARD DISK SYSTEM 32K DOS VERS 2.0
A>_
If your microcomputer includes a hard disk, you’ll enter Y after the question. Otherwise you'll use a carriage return as we have here. Suppose you have a CP/M disk configured for 32K on your A drive. Your machine has 48K memory.
(a) What command will construct a 48K system and execute it?
(b) What command will configure the system you have and perform an automatic warm start?
(c) What would happen if you enter MOVCPM 84?
(a) MOVCPM or MOVCPM 48; (b) MOVCPM 32; (c) unpredictable; you may have to reboot.
21. There could be a number of reasons why you would want to change your memory size. Perhaps you’ve expanded your computer with another 16K memory board. You don’t have to buy a new CP/M; just tell your existing system about your new memory size.
Another reason might be that you’ve bought a transient program that requires a reserved memory area at the top of memory. We have one program that requires 1K of memory to be set aside outside of CP/M. Therefore all of our system disks say 63K instead of 64K, which is what we really have. Thus, our memory architecture is:
82 USING CP/M
reserved for special program use
63K
reserved for system use
If you buy such a program, its documentation should tell you exactly what to do. Suppose you have just expanded your system from 32K to 48K. You have five disks already containing your old 32K system.
(a) Do you need to buy a new CP/M system disk? (b) What CP/M program can be used to reconfigure your memory: size?
(c) What CP/M program can be used to copy your new system to all your five disks?
(a) no; (b) MOVCPM; (c) SYSGEN
22. The command MOVCPM, with no operands, constructs a maximum size system for your computer and executes it immediately. Why would you do this? Suppose you have a 64K memory but all your disks are configured to 63K, like ours. You can temporarily use all 64K by using the MOVCPM command. You can also switch back to 63K by a cold start or by entering MOVCPM 63.
If the system that’s stored on your disks is less than your maximum memory size, there’s usually some reason. Exercise caution in making a change.
Suppose your system has 32K bytes of main memory. You have booted from a disk that contains a system configured for 20K bytes. The disk also contains the file MOVCPM.COM.
(a) Write a command to temporarily switch to a 32K system. A>
(b) Write a command to temporarily switch to a 25K system. A>
CP/M TRANSIENT PROGRAMS 83
(c) Show two ways to return to the 20K system.
(d) Suppose you don’t know what size memory your computer has. How can you
find out?
(a) MOVCPM or MOVCPM 32; (b) MOVCPM 25; (c) MOVCPM 20 or a cold start; (d) enter MOVCPM with no operands and you'll get a message like this:
CONSTRUCTING DOS nnk SYSTEM CP/M DOS nnkK VERS n.n
“nnK” tells you the size of main memory
23. As you have seen, the first operand of MOVCPM is used to change the memory size or use your system’s maximum. The second operand is used to specify where you want the new system to go.
If you omit the second operand, the new system is automatically rebooted and takes effect immediately. You might want to do this if you are only making a tem- porary memory size change for the purpose of one job.
If you include the second operand, which is merely an asterisk (*), the new sys- tem remains in the TPA and is‘not executed. You would do this if you want to write the new system onto one or more disks.
MOVCPM 32 would move a copy of the system tracks from the active disk into the TPA, change the memory size to 32K, and reboot using the new system size.
MOVCPM 32 * would move a copy of the system tracks from the active disk into the TPA, change the memory size to 32K, and wait for further instructions.
(a) Write a command to load the system into the TPA, change the memory size to 40K, and keep the new system in the TPA.
A>
(b) Write a command to load the system into the TPA, change the memory size to 63K, and reboot immediately using the new system.
A>
(c) Suppose you’re using a transient program that requires a memory size of 2K less than your full memory size. Suppose that your full memory size is 48K. You don’t want to make a permanent change to any of your disks but want to change the size right now so you can use this program. What CP/M command would you enter?
A>
84 USING CP/M
(d) When you’re done with the above job, how can you get back to the 48K mem- ory size again? (There are several possible correct answers to this question.)
(e) Suppose you’ve added 16K to your computer so that you now have 64K. You want to change the system tracks of all your disks to the new size. What MOVCPM command would you enter?
A>
(f) Would any of the above commands affect the system tracks of the active disk?
If so, which ones?
(a) A>MOVCPM 40 *; (b) A>MOVCPM 63; (c) A>MOVCPM 46; (d) you could enter A>MOVCPM 48 or just A>MOVCPM or you could boot the system from disk again; (e) A>MOVCPM 64 * will keep the new system in the TPA so that you can SYSGEN it onto your disks; (f) no — only SYSGEN does that
24. When the new system is left in the TPA, you get a message like this:
READY FOR "SYSGEN" OR “SAVE nn CPMxx.com" A>_ We'll discuss each of these alternatives in turn. If you want to copy the new system onto some disks, use the SYSGEN command. A>SYSGEN
SYSGEN VER 2.2 SOURCE DRIVE NAME (OR RETURN TO SKIP)_
Do you remember what happens now? If you enter a valid drivename, the system is loaded into the TPA from the selected disk. However, if you hit return without enter- ing a drivename, it’s assumed that the system is already in the TPA.
Since you’ve just used MOVCPM to create a new system in the TPA, you should definitely use the system that’s in the TPA already. You just’ hit return, then you can specify as many destination disks as you want.
Suppose you want to change the disk on A drive from a 64K system to a 63K system. Show the commands you would enter.
(a) A> CONSTRUCTING 63K DOS VERS 2.2 READY FOR "SYSGEN" OR "SAVE 34 CPM63.COM"
SYSGEN VERS 2.2
CP/M TRANSIENT PROGRAMS 85
(c) SOURCE DRIVE NAME (OR RETURN TO SKIP)
(d) DESTINATION DRIVE NAME (OR RETURN TO REBOOT) FUNCTION COMPLETE
(e) DESTINATION DRIVE NAME (OR RETURN TO REBOOT)
A>
(a) A>MOVCPM 63% (the asterisk is important as it causes MOVCPM to save the new system and wait for a SYSGEN or SAVE command); (b) A>SYSGEN; (c) return only; (d) A; (e) réturn only
25. The response to MOVCPM xx * is
READY FOR "SYSGEN" OR "SAVE nn CPMxx.coM" You’ve seen how the SYSGEN command is used. The SAVE command is used to create a COM file containing the system from the TPA. “nn” tells you the exact num- ber of pages to save. This will vary for different computers and even for different size versions. You'll see the exact number of pages you need to save.
Why would you want a COM file containing the CP/M system? Ordinarily you wouldn’t, but if you want to DUMP the system, or if you want to change it using DDT, then you need the COM file. You'll only want to do this if you’re tailoring your system and you know 8080 Assembler Language.
Show the commands to create a 32K system and save it as a COM file.
(a) A>
CONSTRUCTING 32K DOS VERS 2.2 READY FOR "SYSGEN" OR "SAVE 32 CPM32.COM"
(a) A>MOVCPM 32 *; (b) SAVE 32 CPM32.COM
26. When you're trying to make a COM file, you may want to use the maximum system size your equipment supports. The first operand can be an asterisk.
A>MOVCPM * *
The above command means to construct a system of the maximum size from the active drive and wait for further instructions. Note that MOVCPM * (just one asterisk) wouldn’t work because the system interprets the scle asterisk as the first operand. It would construct a maximum size system and automatically reboot.
Write a set of commands to save the 20K system from drive A as a COM file. (a) A>
86 USING CP/M
READY FOR "SYSGEN" OR "SAVE 30 CPM20.cOM"
(b) A>
Suppose the A drive contains a 32K system disk and the B drive contains a 30K system disk. Both disks contain the MOVCPM.COM file. You have booted from A and are currently using the 32K system. Show the command to load the 30K system and reboot from it — without changing disks.
(c) A>
(a) A>MOVCPM 20 *; (b) A>SAVE 30 CPM20.COM; (c) A>MOVCPM 30
27. You’ve'seen a lot of different options of MOVCPM and SYSGEN. Let’s review the various things you can do. The full format of the MOVCPM command is:
d>MOVCPM [=] [*]
With no operands, the maximum size system is constructed in the TPA and immediately executed.
The first operand gives a new system size, which must be less than or equal to the actual memory size. An asterisk means to construct a maximum size CP/M. It’s only used when the second operand is also used.
The second operand tells what to do with the system in the TPA. If omitted, the system automatically boots from the version in the TPA. If the second oper- and is included the-.system does not boot, but puts out the following message and
waits for further instructions.
| READY FOR "SYSGEN" OR “SAVE nn CPMXx.COM"
The SAVE command will make a COM file out of the system. You usually only do this if you’re tailoring your system.
SYSGEN copies the system onto the system tracks of a designated destination disk. The source can be either the TPA or another disk. To use the TPA as the source, don’t type a source drive. To use a disk as the source, type the appropriate drivename.
Suppose you want to temporarily use a 30K memory size. (a) What command would you enter? A>
(b) How can you go back to your maximum size?
Suppose your disk in drive A has a 64K system (the maximum for your hard- ware) and you want to change it to a 60K system. Show the commands you would use.
(c) a>
CP/M TRANSIENT PROGRAMS 87 CONSTRUCTING 60K DOS VERS 2.2 READY FOR "SYSGEN" OR "SAVE 34 CPM60.COM” (d) A> SYSGEN VER 2.2 (e) SOURCE DRIVE NAME (OR RETURN TO SKIP)
(f) DESTINATION DRIVE NAME (OR RETURN TO REBOOT) FUNCTION COMPLETE
(g) DESTINATION DRIVE NAME (OR RETURN TO REBOOT )
Suppose you want to construct a 30K system and save it as a COM file on the A disk. Show the commands you would use.
(h) A>
CONSTRUCTING 30K DOS VERS 2.2 READY FOR "SYSGEN" OR "SAVE 32 CPM30.COM"
(i) A> () Change your command in (h) above so the system size is at a maximum. A>
Suppose you want to copy the system from the B disk onto the A disk. Show the commands you would use.
(kK) ®
(l) SYSGEN VER 2.2 SOURCE DRIVE NAME (OR RETURN TO SKIP) FUNCTION COMPLETE
(m) DESTINATION DRIVE NAME (OR RETURN TO REBOOT) FUNCTION COMPLETE
(n) DESTINATIGN DRIVE NAME, (OR RETURN TO REBOOT }
(a) A>MOVCPM 30; (b) MOVCPM with no operands; (c) A>MOVCPM 60 *; (d) SYSGEN; (e) return; (f) A; (g) return; (h) A>MOVCPM 30 *; (i) SAVE 32 CPM30.COM; (j) A>MOVCPM * *; (k) SYSGEN; (1) B; (m) A; (n) return
CP/M TRANSIENTS
28. Any CP/M transient program reference can be prefixed by a drivename. This causes the program to be loaded from the named drive instead of the current drive. Thus, A>B:SYSGEN will invoke the SYSGEN program from the disk on the B drive. A remains the active drive, and CP/M will return to drive A after SYSGEN is finished. A>B:ASM ABC will load the ASM program from drive B and assemble program
88 USING CP/M
ABC.ASM from drive A. The drivename can precede any transient program name. If the program COM file does not exist on the specified (or default) drive, CP/M will question the command and return a drive prompt such as A>.
For each command below, indicate from which drive the CP/M transient program will be loaded.
(a) A>MOVCPM (b) A>B:MOVCPM (c) B>MOVCPM (d) B>A:MOVCPM Suppose you have this CP/M interaction:
A>MOVCPM 32 * MOVCPM?
(e) What’s wrong?
(a) A; (b) B; (c) B; (d) A; (e) the A disk does not contain the file MOVCPM.COM
In this chapter we have looked briefly at the transient programs provided by Digital Research as part of the CP/M system disk. We looked at the system-related transients, and you learned to generate a new CP/M system of the appropriate size using MOVCPM and/or SYSGEN. Now you know all there is to know about these two programs.
We looked briefly at the programming-related transients. You saw what type of files can be operated on by ASM, LOAD, and DDT. You saw how to produce a hexa- decimal dump of any file using the DUMP transient. We won’t deal with programming anymore in this book.
We overviewed programs used for status information, file management, creating or changing files, and running a series of CP/M commands. The rest of this book deals with the STAT, PIP, ED, and SUBMIT programs in detail. You'll learn to use all their options as you continue.
Your master CP/M disk may contain other transient program files. Some of these are supplies by Digital Research for use in tailoring the system. Others may have been added by your CP/M suppliers. Your documentation should explain exactly what these files are and how they are used. Look also for any files of type DOC, PRN, or MSG. TYPE such files and you may find additional documentation.
CP/M TRANSIENT PROGRAMS 89
CHAPTER 4 SELF-TEST
This Self-Test will help you determine if you have mastered the objectives of this
chapter. Answer each question to the best of your ability, then check your answers in the answer key at the end of the test.
1.
Name the CP/M program that accomplishes each function described below.
(a) Determine how much space is left on a disk.
(b) Copy a file to another disk.
(c) Create a new file.
(d) Runa series of CP/M programs with one command.
(e) Change the name of a file.
Which of the CP/M programs in question 1 would be located in the system tracks Of CP/M: disk? ne
drive A drive B PIP.COM SALES.ASM ED.COM SALES.DAT SYSGEN.COM ASM.COM DUMP.COM LOAD.COM MOVCPM.COM DDT.COM
Figure 4.1
Figure 4.1 shows the transient programs contained on two disks. The following
questions refer to these.
3.
Write a command to create a HEX file and a PRN file from the assembler source code in SALES.ASM.
B>
Write a command to create a COM file from the HEX file. B>
90 USING CP/M
5. How can you obtain a printed listing of the PRN file?
6. Produce a hexadecimal listing of the SALES.ASM file at the console.
B>
7. Suppose you want to copy the system tracks from the disk on drive A to a new
disk on drive C.
(a) What drive will you use? — (b) What command do you enter first?
(c) What source drivename will you enter?
(d) What destination drivename will you enter?
8. Suppose you want to configure a 48K system and place a copy of it on drive C as a COM file. You also want to place the 48K system on the disk in drive D.
(a) (b)
(c)
Write the first command you need? A>
The response you get is this;
READY FOR "SYSGEN" OR "SAVE 32 CPM48.COM"
How do you create a COM file on drive C?
fae Roe ce ee Re
How do you write the system tracks to the disk on drive D?
9. | Write a command to configure and execute a temporary 32K CP/M system.
Chapter 4 Answer Key
Compare your answers to the Self-Test with the correct answers given below. If all your answers are correct you are ready to go on to the next chapter. If you missed any questions, you may find it helpful to review the appropriate frames in this chapter.
1. (a) (b) (c) (d) (e)
STAT PIP
ED SUBMIT REN
2. REN only. The rest are transient programs.
CP/M TRANSIENT PROGRAMS 91
ASM SALES LOAD SALES TYPE SALES.PRN with *P or use PIP to copy SALES.PRN to the printer.
A:DUMP SALES. ASM (or you could TYPE SALES.HEX) These produce differ- ent formats, but both will be in HEX.
(a) A
(b) SYSGEN
(c) A
(d) C
(a) MOVCPM 48 *
(b) SAVE 32 C:CPM48.COM
(c) use SYSGEN, but don’t enter a source drive
MOVCPM 32
Machine Exercise Suggestions
In this machine exercise you'll practice with SYSGEN and MOVCPM. Use a copy
of your master CP/M disk in drive A. If you have a fresh disk, use it as the destination disk. Otherwise, use any other disk that contains the same system tracks as your master disk.
1.
Start up the system and boot. Notice in the boot message what size CP/M you
_ have.
Check the directory of your A disk. You'll need these program files during this exercise:
DUMP.COM SYSGEN.COM MOVCPM.COM
If your disk doesn’t contain all these files, find one that does and boot again. Copy the system from the master disk to a destination disk.
Make a COM file of the system on disk A. Store the COM file on A. a. Use MOVCPM to move the system into the TPA.
b. Use SAVE to save it as a COM file.
c. Check your directory on A. Is CPMxx.COM there?
Ne}
2
10.
USING CP/M
DUMP the COM file. Practice using “S to interrupt and restart the dump. You don’t need to wait for the entire dump. When you’ve seen what the dump looks like, abort the program.
Erase the COM file you created in 4 above.
On your other disk, create a 20K system. a. Use MOVCPM to create the 20K system. b. Use SYSGEN to store it.
Put the 20K system disk in A and boot. Your boot message should now say 20K.
Replace the 20K system tracks with the correct system tracks (from your master disk).
Boot from both disks. They should both show the same system size. That’s enough for now. Shut down your system and go on to Chapter S.
CHAPTER FIVE
The STAT Command
This chapter covers the STAT program which you can use to display or change the status of various files and devices. For example, STAT can be used to change the status of a disk from read/write to read/only.
The STAT program has several functions. For peripheral devices it can display or change device assignments, or display a table of permitted assignments. For disks, STAT can display remaining space, display read/write status, and for 2.0 and later versions, display active user numbers.
STAT can also be used to display the size of files on the disk. In later versions of CP/M, STAT can. display or change the read/write status as well as display or change the system status of files. You'll learn what these mean in this chapter. STAT can dis- play the characteristics of the disk drives and even display a STAT command summary in the later versions of CP/M.
When you have finished studying this chapter, you will be able to:
Write STAT commands to display the status of the various devices. Interpret status displays produced by the various STAT functions. Write STAT commands to change the read/write status of a disk. Write STAT commands to change device assignments.
And if you’re working with a newer system:
@ Write STAT commands to change whether files appear in the directory. @ Write STAT commands to alter files from read/write or read/only status. @ Write STAT commands to identify user information on a disk.
First well look at STAT features for earlier versions of CP/M. Then we’ll discuss the additional features added at version 2.0. We'll start with device assignments.
93
94 USING CP/M
DEVICE ASSIGNMENTS
1. When a program wants to write data on the printer, it will say “write on LST:,” not “write on printer.” BDOS has a table that says “LST:=printer.”’ LST: is a logical device and the printer is a physical device. CON: is a logical device and the correspond- ing physica] device is the CRT:. If you use a teletype console, it may be assigned to both LST: and CON:.
Suppose you change your console type from a teletype to a CRT, or add a paper tape reader and punch. CP/M can be tailored so you can change your logical device assignments. You won’t need to get a new version of CP/M and no one will have to rewrite your other programs.
(a) Which of the following describes a logical device? —___ An actual piece of hardware such as the line printer or CRT.
A functional name such as console or list device.
—__ Any device containing its own memory area. The CPU. (b) BDOS maintains a table that sets logical devices equal to
(c) Logical device assignments are (fixed/changeable)
(a) a functional name such as console or list device; (b) physical devices; (c) changeable
2. CP/M recognizes four logical devices.
CON: This is the operator’s console. The CCP sends messages to this device and reads commands from it.
RDR: This is an input device that some programs may use to read data.
PUN: This is an output device that some programs may use to write data. PUN stands for “punch.”
LST: This is the output listing device. Most programs send print data to this device.
(a) When you sit down at your terminal to communicate with CP/M, which logical device are you using?
(b) When you use *P to turn on echo printing, which logical device does the echo printing?
(c) If your system had a paper tape reader, which logical device would it be?
THE STAT COMMAND 95
(a) CON: (b) LST: (c) RDR:
CP/M can be modified to allow you to change device assignments at the console using the STAT transient program. Since this modification isn’t made in all systems, we’ve discussed it briefly in Appendix A.
DISK STATUS
3. | The command STAT, with no operands, displays the read/write status and amount of space available on each disk. A typical interaction is:
A>STAT
AsR/W, SPACE: 157K
BrR/0, SPACE: 118K A>_.
What does the read/write status tell you? Under CP/M you can protect an impor- tant disk from being accidentally erased or written over by giving it a read/only status. You can read from the disk, but you can’t write on it.
When you first install a disk on a non-A drive, it automatically receives a read/ only status. “C, the warm start, changes the status to read/write. If you want to use the read/only status, enter STAT d:=R/O, where d is the drive name.
(a) What command produced this output?
ArtR/0O, SPACE: 121K BrR/W, SPACE: 118K
(b) Can you write on the disk in A drive?
(c) Can you read from the disk in A drive?
(d) Can you erase files from the disk in A drive? —-- SESS
(e) Can you write on the disk in B drive?
(f) Can you read from the. disk in B drive?
(g) Can you erase files from the disk in B drive?
(h) How much room is available on disk A?
(@) How much room is available on disk B? —--_»_E
(j) Suppose you change the disk in B drive. What read/write status does the new disk have? ________ How can you change the status?
(k) Write the command to change the disk on B from R/W to R/O status.
96 USING CP/M
(a) STAT (with no operands); (b) no; (c) yes; (d) no; (e) yes; (f) yes; (g) yes; (h) 121K bytes; (i) 118K bytes; (j) R/O, °C; (k) STAT B:=R/O
4. If you try to write on an R/O disk, you'll get this message;
BDOS ERR ON 4d: R/O
The system will wait for any response. The instant you type something, the system will reboot, automatically giving all disks R/W status. You’ll then lose the R/O status and must re-establish it, if you want it.
(a) What does this message mean: BDOS ERR ON A: R/O_ (b) How do you continue after this message?
(c) What effect will your action have on the read/write status of the disks?
(a) you tried to write on a disk that was read/only; (b) type any character; (c) all disks become R/W
5. The command STAT displays both the read/write status and the amount of available space on all disks. If you just want to find out the amount of available space on a specific drive, use this command format:
STAT d: The output will look like this: BYTES REMAINING ON d: nnnK (a) What command produced this message shown below? BYTES REMAINING ON B: 124K. (b) Suppose you want to put a new file on disk A, and you’re not sure there’s enough room. How can you find out?
(a) STAT B; (b) STAT A: or STAT
THE STAT COMMAND 97
(a) Write a command to display the space on disk B. Write a command to display the read/write status of all drives as well as the amount of available space.
Write a command to change drive B to R/O status.
What do you type to change all disks to R/W status?
(a) STAT B:; (b) STAT; (c) STAT B:=R/O; (d) “C (system reboot)
The preceding frames have covered the STAT functions for disk status. STAT
also provides several functions for individual files on a disk.
FILE STATUS
7.
STAT will display the size of a file. The command format is: STAT filename. Here’s an example: A>STAT PIP.COM
RECS BYTS EX D:FILENAME.TYP 55 7K 1 A:PIP.COM
The output shows that PIP.COM contains 55 records, takes up 7K bytes, and
uses one disk extent. (A disk extent is a 16K-byte block.)
(a)
(b) (c)
What command produced the message shown below?
RECS BYTS EX D:FILENAME.TYP 178 23K 2 B:INVENTY.DAT
What does “EX” stand for? ; If a file had 60K bytes, how many disk extents would you expect it to use?
(a) STAT B:INVENTY.DAT; (b) extent; (c) 4
98 USING CP/M
8. In the command STAT filename, the filename can be generalized. STAT will list the status of all files on the selected disk that match the general filename and also give the amount of available space on disk. The files will be listed in alphabetical order.
Here’s an example:
A>STAT *.COM
RECS BYTS EX D:FILENAME.TYP 60 8K 1 A:COPY.COM 11 2k 1 A:DAR.COM 55 7K 1 A:PIP.COM 178 23K 2 AzWS.COM
BYTES REMAINING ON A: 116K
(a) In the above example, how many records does COPY.COM contain? (b) How many extents does WS.COM use? (c) How much space is available on the A disk?
(d) Write a command to find the status of all ‘files on B disk that start with the letters INV.
A>
(e) Write a command to display the status of all files on A. A>
(f) Show three different commands to find out the amount of space remaining on A. ee A> A>
(g) Which of the above commands is the most efficient if you just want to find out the available space? A>
(a) 60: (b) 2; (c) 116K bytes; (d) A>STAT B:INV2222?.* or STAT B:INV*.*; (e) A>STAT*.*; (f) A>STAT A: or A>STAT or A>STAT *.*; (g) ADSTAT A:
STAT FOR VERSION 2.0
So far the STAT commands you have studied pertain to CP/M versions before release 2.0. If you are working with an earlier version, skip the remaining frames and go on to the Self-Test for this chapter. If you have version 2.0 or later, continue with frame 9.
THE STAT COMMAND 99
9. Read/write protection has been enhanced with release 2.0. It is now available on a file-by-file basis and for the disk as a whole. The read/write status for each file is stored with the file directory entry.
When you create a new file it is assumed to have read/write status. To change the status enter this command:
STAT filename $R/O
The filename may be specific or general. File status is not affected by “C, as the disk status is. To change the status back to read/write, use this command:
STAT filename $R/W
Notice that at least one space precedes the status operand (R/O and R/W) and that it begins with a dollar sign. STAT lists the changed file(s) on the console.
(a) When a new file is created what is its status? (b) Write a command to set the status of A:INVENTY.DAT to read/only. A> (c) How can INVENTY.DAT be reset to read/write status? A Sa oe (d) Write a command to set the entire disk on B drive to read/only status. A> (e) Write a command to set all the files on B disk to read/only status.
(a) R/W; (b) A>STAT INVENTY.DAT $R/O; (c) STAT INVENTY.DAT $R/W; (d) A>STAT B:=R/O; (e) A>STAT B:*.* $R/O
10. Another feature of version 2.0 allows you to declare system files. A system file is not listed in the directory when you enter DIR. However, it is still related to a user number. Only the files of the active user number are identified by STAT.
When you use CP/M, you'll usually need a set of files that might include PIP.COM, STAT.COM, and ED.COM. Since you know these are available to you they don’t need to be in a directory listing. You can make them system files.
System status bears no relationship to read/write status. A system file can be written on or erased as long as it has R/W status.
100 USING CP/M
(a) If you log on as USER 1 and then enter A>DIR, what will be listed? a. All files on A disk linked to user 1. b. All files on all disks related to user 1. c. All files on A disk regardless of user number. d. All files on A disk linked to user 1 except for system files. (b) Can you erase a system file?
(a) d; (b) yes, as long as it has R/W status
11. Because a file is called a “system” file does not make it a part of the system tracks. It’s still a separate file and must be separately copied to each disk that you want it on.
Suppose you want to initialize each new disk with the system tracks and these system files: PIP.COM, ED.COM, STAT.COM, and P3.TEX, which is a user 0 file.
(a) How do you copy the system tracks? (b) How do you copy the system files? == (c) How do you copy the user file?
(a) SYSGEN; (b) PIP; (c) PIP
12. To give a file system status, use this command: STAT filename $SYS To remove system status, use this command: STAT filename $DIR
The filename can be specific or generalized. STAT will tell you which filenames were set by the command to SYS or DIR.
(a) Write a command to make A:PIP.COM a system file. A>
(b) Write a command to make all the COM files on disk B system files. A>
(c) Write a command to make all files on A system files.
(a) A>STAT PIP.COM $SYS; (b) A>STAT B:*.COM $SYS; (c) A>STAT *.* $SYS
THE STAT COMMAND 101
13. You saw before that the command STAT ED.COM produces output in this format:
RECS BYTS EX D:FILENAME.TYP 48 6K 1 A:ED.COM
This has changed slightly with version 2.0. The output now may look like this:
RECS BYTS EX ACC 48 6K 1 R/O (A:ED.COM)
ACC means “access” and gives the read/write status of the file. This example is read/ only (R/O). Parentheses around the filename indicate that it has system status. If the file were not a system file, parentheses would not appear.
(a) ' Write a command to display the size, read/write status, and system status of all COM files on A disk. A>
(b) Write a command to display the read/write status of B:INVENTY.DAT. A>
(c) Suppose you have forgotten what system files are on A disk. DIR won’t tell you. Write a command that will. A>
(d) In the output from (c), how can you identify a system file?
(e) Suppose you enter one of the above commands and get this message: STAT?
What’s wrong?
(a) A>STAT *.COM; (b) A>STAT B:INVENTY.DAT; (c) A>STAT *.*; (d) by parentheses around the filename; (e) the CCP can’t find the STAT.COM file on A disk; it’s either not there or not available to your user number.
14. The file status display may also have a SIZE field, as shown in the following interaction:
A>STAT *,.DAT $S
SIZE RECS BYTS EX ACC D:FILENAME.TYP 200 200 25K 2 R/W A:INVENTY.DAT 100 100 12K 1 R/W = A:PARTS.DAT
102 USING CP/M
The SIZE field gives the file size in records. It will match the RECS field unless the file is random access. Since the subject of random access files is beyond the scope of this book, the SIZE field will not be discussed further.
(a) To display the SIZE field, what operand do you use? (b) Is the file SIZE given in bytes or records?
(a) $8; (b) records
15. The preceding section has discussed the various STAT options for file status. The general command format is:
STAT filename [$R/O $R/W $SYS $DIR $S]
With no status operands the status of the file is displayed. The $S operand also causes the SIZE to be displayed. The $R/O, $R/W, $SYS, and $DIR operands change the status of the file.
(a) Write a command to display the status of B:SORT.COM.
A>
(b) Rewrite the command in (a) to include the SIZE field in the display. A>
(c) Write a command to display the status of all files on A disk that start with INV. A>
(d) What will the display from (c) tell you? —__—— a. The size of the files.
——__— b. The number of bytes remaining on the disk.
—_____. c._ The read/write status of the files.
_____ d._ The system status of the files.
e. The user number of the files.
(e) Write a command to make all files on B disk system files. A>
(f) Write a command to make all COM files on A disk read/only. A>
(g) Write a command to display the names of all system files on B disk. A>
THE STAT COMMAND 103
(h) Examine this listing: Xx Acc D:FILENAME. TYP 1 R/O 8:DDT.COM
4 1K 1 R/W B:DUMP.COM 1 1
R/0 (B:LOAD.COM) R/W B:PIP.COM
(a) A>STAT B:SORT.COM; (b) A>STAT B:SORT.COM $8; (c) A>STAT INV*.*; (d) a, b, c,d; (e) A>STAT B:*.* $SYS; (f) A>STAT *.COM $R/O; (g) A>STAT B:*.*; (h) B:LOAD.COM
USER STATUS
16. The command STAT USR: causes the current user number to be displayed. It also tells you what user numbers are linked to files on the active disk. Here’s an example:
A>STAT USR:
ACTIVE USER : 1 ACTIVE FILES: 0125
A>_ The display tells you that you’re logged on as user 1. The A disk contains files belong- ing to users 0, 1, 2, and 5.
(a) What command obtained the output shown below? —.-_»_-_-SE
ACTIVE USER : 1 ACTIVE FILES: 012 5
(b) According to the above output, what’s your current user number? (c) What users have files on the active disk? >_> EESSSSSSS
(a) STAT USR:; (b) 3; (c) 0, 2, and 3
104 USING CP/M
17. STAT USR: can be combined with DIR to identify the user numbers of all non- system files on a disk. The following listing shows you how.
A>STAT USR:
ACTIVE USER : ie} ACTIVE FILES: 025
A>DIR A: INVENTY DAT:PARTS DAT: INVENTY cOM
A>USER 2
A>DIR
A:* PAYROLL DAT: TAXES DAT: PAYROLL COM:PAYREP cOM A: TAXRE1 COM: UPDATE COM: QUARTER COM
A>USER 5
A>DIR A: INVOICES PRN
STAT USR: told all the user numbers on the file — in this case 0, 2, and 5. We displayed the directory under each user number. If we had wanted to see system file names as well, we would have used STAT instead of DIR. (This assumes that STAT.COM is available for every user number.)
(a) Suppose you forget what user number you're currently using. What command should you enter? A>
(b) Suppose you’re looking for DUMP.COM on A disk and you don’t know what user number to use. You do know it is a system file. What procedure would you use to find the user linked to DUMP.COM?
(a) A>STAT USR: (b) First, use STAT USR: to find out what user numbers are active. Then use STAT ** under each relevant user number until you find the file you want.
DISK STATUS
18. The command STAT d:DSK: will display the characteristics of the disk in the specified drive. If the drive is omitted, all drives are shown.
THE STAT COMMAND 105
Here’s an example: A>STAT AsDSK+
A: DLRIVE CHARACTERISTICS 1944: 128 BYTE RECORD CAPACITY 243: KILOBYTE DRIVE CAPACITY 64: 32 BYTE DIRECTORY ENTRIES 64: CHECKED DIRECTORY ENTRIES
128: RECORDS/EXTENT 8: RECORD/BLOCK 26: SECTORS/TRACK 2: RESERVED TRACKS
The drive shown above has the capacity for 1944 records (each record is 128 bytes long); 243K bytes; 64 directory entries; 128 records on each extent; 8 records per block; 26 sectors per track; and 2 reserved tracks.
“Checked directory entries” tells how many directory entries your system will check to see if a new disk has been installed on the drive. The system usually checks all the directory entries for floppy disks.
You probably won’t use this command very often as the information doesn’t change unless you change your disk hardware.
(a) Write a command to give you the capacity of your A drive. A>
(b) Write a command to give you the capacity of all your drives.
(a) A>STAT A:DSK: (b) A>STAT DSK:
STAT OPTIONS LIST
19. You've learned a lot of STAT functions. Will you have trouble remembering which format is for which function? STAT VAL: displays a list of all the STAT command formats. It looks like this:
Temp R/O disk: d:=R/0
Set Indicator: d:filename.typ $R/O $R/W $SYS $DIR Disk Status : DSK: d:DSK:
User Status : USR:
Iobyte Assign:
CON: TTY: CRT: BAT: UC1i:
RDR: = TTY: PTR: UR1i: UR2: PUN: = TTY: PTP: UP1: UP2: LST: = TTY: CRT: LPTs ULI:
106 USING CP/M
Earlier versions list only the logical to physical options, like this:
CON: = TTY: CRT: BAT: UC1: RDR: = TTY: PTR: UR1: UR2: PUN: = TTY: PTP: UP1: UP2: LST: = TTY: CRT: LPT: UL1:
Suppose you want to display the status of a file but you forget what command format to use. What command should you enter?
(a) A>STAT VAL:
You have now studied all the various functions of the STAT program.
CHAPTER 5 SELF-TEST
This Self-Test will help you determine if you have mastered the objectives of this chapter. Answer each question to the best of your ability, then check your ans- wers in the answer key at the end of the test.
1. Briefly describe what the STAT program does.
2. Examine the following interaction.
A>STAT STAT?
A>_
What’s wrong?
3. | Write the appropriate command for each of the following STAT functions. a. Display the number of bytes available on A. (Use the most efficient method.) A> b. Make B disk read/only. A>
THE STAT COMMAND 107
c. Display the status of all COM files on A. A> d. Make B disk read/write. A>
e. Display the read/write status of B disk. A>
How do you continue after this message?
BDOS ERROR ON At READ ONLY_
(If you are working with an earlier system, skip the rest of this self-test.)
Write the appropriate command for each of the following STAT functions.
a. Make PIP.COM a system file. A>.
b. Make INVENTY.PRN read/only. A>
c. Display the read/write status of SORT.COM. A>
d. Display your current user number. A>
e. Display the characteristics of all disk drives. A>.
f. Display the names of all system files on B disk. A> —___________ g. Review all the STAT commands. A>
Write a command to find out all the user numbers on B disk.
B>
The response to your command in question 6 is:
ACTIVE USER : 1 ACTIVE FILES: 0O 1
Write a sequence of commands to display directories of all non-system files on this disk.
B>
B>
B>
B>
108 USING CP/M
8. (Optional.) You have learned enough facts to write a sequence of commands to erase all the files from question 7. See if you can put them all together. (Assume that there is a STAT.COM for user 0 and another STAT.COM for user 1.)
B> B> B> B> B> B>
Chapter 5 Answer Key
Compare your answers to the Self-Test with the correct answers given below. If all your answers are correct you are ready to go on to the next chapter. If you missed any questions, you may find it helpful to review the frames given in parentheses follow- ing the answer.
1. Your answer should include these points: @ display device status @ change device status
2. The system can’t find the STAT.COM file on A disk.
AD>STAT A: A>STAT B:=R/O A>STAT *.COM Cc
A>STAT
cao oes
4. Type any key
A>STAT PIP.COM $SYS A>STAT INVENTY.PRN $R/O A>STAT SORT.COM
A>STAT USR:
A>STAT DSK:
A>STAT B:*.*
A>STAT VAL:
ems ao op
6. B>STAT USR:
THE STAT COMMAND 109
1. 2: 3.
B>DIR B>USER 0 B>DIR
(Optional.) You need to give all files read/write status before you can erase them. In our solution, we erase user O files then switch to user 1. The last step erases all remaining files.
B>STAT *.* SR/W B>ERA *.* B>USER 1
B>STAT *.* $R/W B>ERA *.*
Suggested Machine Exercises
Start your system. Boot. (Use a disk with STAT.COM.)
If you have a line printer, turn on echo print.
Steps 4-13 experiment with disk read/write status.
4.
12.
SO OO FON ON
Install any disk in B drive but don’t reboot.
Display the status of both disks. A should be R/W and B should be R/O. Reboot (*C).
The reboot turned off echo print so turn it back on again.
Display the status of both disks again. Both should now be R/W.
Make the A disk R/O.
Display a directory of the A disk.
Try to erase one of the files on the A disk. (For safety’s sake, choose a file that is duplicated on another disk.) What happens? You should get a BDOS error message. Do you remember what to do now? Type any character.
The reboot turned off echo print so turn it back on again.
Steps 13-15 experiment with the file status functions.
13. 14. 15.
Display the status of STAT.COM. Display the status of all COM files on the A disk. Display the status of all files on the B disk.
110 USING CP/M
The remaining steps pertain to release 2.0 and beyond. If you’re working with an earlier release, skip the remaining steps and go on to chapter 6.
Steps 16-19 continue to experiment with the file status function. 16. Display a directory for your user number.
17. Select any file and make it a system file.
18. Display a new directory. Notice that your system file does not appear. 19. Restore the file to directory status.
Step 20 demonstrates the drive status function.
20. Display the characteristics of all disk drives on your system. Steps 21-23 demonstrate the user status feature.
21. Display the current user status.
22. Change your user number.
23. Display the user status again.
This completes the suggested terminal practice for STAT. When you are ready, go on to chapter 6.
CHAPTER SIX
Using PIP
One of the most useful CP/M utility programs is the peripheral interchange program — PIP. PIP is used to transfer files from one device to another. You can copy a file from disk to disk, or from disk to a peripheral device such as CON: or LST:. You can also transfer files from an input device such as CON: or RDR: to any other device. Thus, PIP is one way to create a new disk file under CP/M. (You'll be learning the usual way in later chapters.) PIP can be used to copy the CP/M programs from one disk to an- other so you'll need PIP whenever you initialize a disk. You'll find you use PIP more and more as you become more familiar with it.
PIP can also combine files into a new file, and modify the file or files as it copies. In almost all cases, the original source file is unaffected by PIP; changes appear in the new file.
After you complete this chapter, you will be able to:
Write a PIP command to copy a single file.
Use the continuing PIP format to copy a series of files.
Use generalized names to copy a collection of files using either PIP format. Use PIP parameters to specify changes in the new file(s).
Use PIP to concatenate files.
Place a copy of PIP.COM in a new user area.
1. The CP/M utility program that you use to copy files is called PIP — the peri- pheral interchange program. With PIP you can copy a file onto the same or another disk, changing its name if you wish. You can also combine files or copy several files with one command. By using codes you can modify the copied file, such as putting it in all upper case letters or adding line numbers.
Name the CP/M program that accomplishes each function below. (a) Make a copy of a file on another disk. _.__-_»_-SEE (b) Give the amount of space left on a disk. (c) Copy the system tracks to a new disk. SEE
111
112 USING CP/M
(d) Copy a data file, convert it to lower case, and rename it.
(a) PIP; (b) STAT; (c) SYSGEN; (d) PIP
2. In order to use PIP to copy files, the PIP.COM file must be present on an instal- led disk and available to your user number. Later in this chapter we’ll see how to get PIP into your user area. A drive prefix can be used with PIP to access the program from any drive.
When you copy a file with PIP, the original file is not altered. It remains in the previous location after the PIP operation. Any requested changes will appear in the new version, which may have the same name if it is on a different disk or user or user number.
The general form of the basic PIP command is:
PIP destination-file=source-file [parameters] <CR>
Any changes to the file are specified as parameters. We'll cover those later in the chapter. First we'll examine the basic copy function of PIP.
(a) Suppose you have the PIP.COM file on drive A, but drive B is active. How can invoke PIP without switching the active drive? (b) Here is a valid PIP command: A>PIP PROGRAM.FOR=SAMPLE. FOR
Which file(s) exist(s) before the PIP command is entered?
(c) Which file(s) exist(s) after the PIP program is executed?
(d) What difference will there be between the two files? _..--
(a) A:PIP; (b) SAMPLE.FOR; (c) PROGRAM.FOR and SAMPLE.FOR; (d) just the name
3. A specific file can be copied to the same disk or to another. The drive name prefix can be part of either or both filenames in the PIP command. Whenever the drive name is omitted, the active drive is assumed for that file. For example, in this com- mand:
A>B:PIP STOCK.MOD=B:STOCK.MED
USING PIP 113
PIP.COM is on drive B, as is the source file STOCK.MED. The destination file is to be created on drive A, the active drive. For each example below, give the drive on which the PIP program and the source file are located, and identify the drive where the destination file is to be created.
(a) B>A:PIP A:PAY.FOR=PAY.FOR
PIP _________________ source. —__________ destination (b) A>PIP PAY.FOR=PAYROLL.FOR
PIP Cs source Ls deestination (c) | C>A:PIP B:PAY.COM=C:PAY.COM
PIP TC Scourrce Ts eestination (d) B>PIP A:PAY.DAT=B:PAY:PER
PIP ___ source Ts deestin ation
(a) A,B, A; (b) A, A, A; (c) A,C,B; (d) B,B,A
4. | Write commands to perform these operations. PIP.COM resides on the active disk. (a) Copy a file named PEOPLE.DAT from drive A to drive B. Don’t change the name. A> (b) Copy the same file as in (a), but change the name to EMPLOYEE.LST. A> (c) Copy file SALARY.HST from drive B to drive A. Don’t change the name. A>
(d) Make another copy of SALARY.HST on drive A. Name the new copy SALARY2.HST.
(a) A>PIP B:PEOPLE.DAT=PEOPLE.DAT (or =A:PEOPLE.DAT) (b) A>PIP B:EMPLOYEE.LST=PEOPLE.DAT (or =A:PEOPLE.DAT) (c) A>PIP SALARY.HST=B:SALARY.HST (or A:SALARY.HST=) (d) A>PIP SALARY2.HST=SALARY.HST
114 USING CP/M
5. Abbreviated PIP commands can be used when you are copying files without changing names. This may happen when you are copying from one disk to another or from one user number to another. You can use any of these forms:
PIP specific-filename=d:
PIP d1:specific-filename=d2: PIP d:=filename
PIP di:=d2: filename
Answer (a) in the preceding frame could be written PIP B:PEOPLE.DAT=A: or B:=PEOPLE.DAT and would have the same effect. Answer (c) could be written PIP A:=B:SALARY.HST or SALARY.HST=B: instead. The file named SALARY.HST on disk B would be copied to the A drive and given the same name.
Write the shortest possible commands to copy these files. PIP.COM is on disk A.
(a) Make a copy of file BSMONEY.XYZ on disk A. Change the name to MONEY. BAK.
A> (b) Copy the same file as in (a), but don’t change the filename. A>
(c) Make a copy of file ANTHRO.REC from drive A onto drive B. Don’t change the name.
(a) A>PIP MONEY.BAK=B:MONEY.XYZ (b) A>PIP MONEY.XYZ=B: or A:=B:MONEY.XYZ (c) A>PIP B:ANTHRO.REC=A: or B:=A:ANTHRO.REC
6. We've been talking about copying one file at a time by specifying a specific filename in the PIP command. CP/M also lets you specify a general filename as a source file causing several files to be copied. The rules for coding general filenames for use in PIP are the same as those in other CP/M commands. You can use an * to fill out one part of the name with any characters, or a ? to fill a specific position with any character.
When you use a general filename the command must take this form:
~ PIP d:=general-filename PIP d1:=d2:general-filename
The command PIP B:=*.COM will result in the copy of all files from the active disk that have filetype COM to disk B. No names are changed. If COM files already exist on disk B with the same names, they are destroyed. When you specify a general filename in a PIP command, PIP displays the specific names of the files it copies so you know the results.
USING PIP 115
Assume PIP is on disk A.
(a) Write a command to copy all files of filetype FOR from disk A to disk B. A>
(b) Write a command to copy all files from disk B to disk C. A>
(c) Write a command to copy all files whose filenames begin with A2 from disk B to disk A.
(a) PIP B:=*.FOR; (b) PIP C:=B:*.*; (c) PIP A:=B:A2*.*
7. PIP can also be used to combine several source files into.a single destination file. This process is called concatenation. Here is the command format for concatenation:
PIP destination=sourcel,source2 ;source3,etc.
The destination filename is written as usual. The source filenames you wish to combine are typed and separated by commas. All the names must be specific; no ambiguity is allowed. Each source file is processed separately so each can be on a different disk if necessary. CP/M assumes each source file to be concatenated contains printable (ASCII) characters and ends with an end-of-file character (“Z). (You'll learn how to create this type of file in chapter 7.) The end-of-file characters, except for the last,
are eliminated in the destination file.
(a) Write a command to combine files ONE.ASM and TWO.ASM into a new file, NEW.ASM, on the same drive.
A>
(b) Write a command to combine these three files: STOCK.ONE, STOCK.TWO and STOCK,THR, from drive B into a file MASTER.STK on drive A.
A> (c) How many end-of-file marks will be in MASTER.STK after the three source files are concatenated?
(a) A>PIP NEW.ASM=ONE.ASM,TWO.ASM
(b) A>PIP MASTER.STK=B:STOCK.ONE,B:STOCK.TWO,B:STOCK.THR (Did you put the drivename before each source filename? In this example, it’s necessary or PIP will look on disk A for the file/s.)
(c) only one
116 USING CP/M
8. | When files are concatenated under CP/M, they are combined in the order you specify. If the destination file existed before the command, its data is replaced with the new file. The source files are unchanged in most cases, but it’s possible to specify the destination as one of the source files. For example:
PIP MASTER.STK=MASTER.STK,STOCK.ADD
In this case, the files MASTER.STK and STOCK.ADD will be combined into a single file which will replace the original MASTER.STK.
(a) Write a command to combine files FIX.ONE from disk A, disk B, and disk C into a file FIX.ALL on disk B.
A>
(b) Write a command to combine the three source files from (a) into the original source file from disk B.
B> (c) In which of the above cases [(a) or (b)] are the source files unchanged after the
concatenation?
(a) A>PIP B:FIX. ALL=FIX.ONE,B:FIX.ONE,C:FIX.ONE (b) A>PIP B:FIX.ONE=FIX.ONE,B:FIX.ONE,C:FIX.ONE
(c) in (a)
9. PIP also allows you to refer to physical and logical devices that are attached to your system. The logical devices you can use are the ones given in STAT — CON: (console) and LST: (list) being the most common ones. Another useful device name is PRN: (print). PRN: is similar to LST:, except that under PRN: tabs are expanded to every eighth character position, lines are numbered, and a new page starts every 60 lines. Several additional device names are also available but aren’t used much by non- programmers.
You can combine file and device names in the same PIP compnand. For example, PIP CON:=B:STUDENT.DAT will copy the file STUDENT.DAT frbm disk B to the console.
(a) Write a command to concatenate files A: FILE.ONE and B:FILE.TWO and copy them to the list device. Use line numbers, tab expansion, and ‘paging.
A>
(b) Perform the operation in (a) above but don’t use line numbers, tab expansion, or paging. A>
USING PIP 117
(c) Copy file NEW.ASM from disk B to the console device.
(a) A>PIP PRN:=FILE.ONE,B:FILE.TWO; (bo) A>PIP LST:=FILE.ONE,B:FILE.TWO (c) A>PIP CON:=B:NEW.ASM
10. When you enter a PIP command, CP/M copies the file. You may be able to hear disk movements or changes. When the operation is complete you'll receive the active drive prompt again.
If you enter a command that is invalid for some reason, you'll get an “INVALID FORMAT” or “NO FILE” message. The copy will not even begin if the command line is not correctly formed.
You can’t interrupt or abort the PIP process once it has begun unless your destination is a device such as CON:, LST:, or PRN:. If so, you can interrupt the out- put using “S, as usual, and restart it with any character except “C. You can abort the command by typing any character except *S. PIP responds with:
ABORTED: filename A>.
What is indicated by each of these interactions?
(a) A>PIP FIX. ONE=FIX.BAK
PIP? A>_
(b) a>PIP FIX.ONE=FIX.BAK
NO FILE: =FIX.BAK A>_
(c) A>PIP FIX.ONE,FIX.BAK INVALID FORMAT: ,
A>.
118 USING CP/M
(d) A>PIP LSTI=FIX.BAK
ABORTED: FIX.BAK
pe
(a) PIP.COM is not on disk A; (b) file FIX.BAK is not on disk A; (c) we need = instead of ,; (d) the PIP operation was aborted
11. We have been discussing the one-line command format of PIP. All of the func- tions and formats we’ve covered also work with the other PIP format. If you simply enter PIP and press carriage return, PIP responds with a PIP command prompt like this:
A>PIP
*
Now you can enter a command line, just as in a one-line PIP command. When you enter the line, the operation takes place. However, instead of returning you to CP/M at the active drive, the system leaves you in PIP and gives you another command prompt. You can continue entering command lines until you don’t need PIP any- more. To return to CP/M level simply press carriage return when you receive an asterisk (*). You are immediately returned to the active drive.
Suppose you need to copy three files FIX.ONE, FOX.TWO, and FOX.TWI from disk A to disk B. You also need a file B:FOXY.ALL made up of FOX.TWO and FOX.TWI. You'll want to use the multiple line format.
(a) Write your first entry. A> (b) Write a command line to copy FIX.ONE
*
(c) Write a command line to copy FOX.TWO and FOX.TWI
*
(d) Write a command line to create B:FOXY.ALL
*
(e) How do you terminate PIP?
USING PIP 119
(a) A>PIP; (b) *B:=FIX.ONE; (c) *B:=FOX.TW?; (d) *B:FOXY.ALL=FOX.TWO,FOX.TWI; (e) carriage return (In (d) you could have used the source files on disk B.)
12. The multiple line format of PIP may also be used to copy files on disks that don’t contain PIP.COM. For example, suppose you have disk 1 containing PIP.;COM and disk 2 containing SORT.COM. You want to copy SORT.COM to disk 3, which doesn’t contain PIP.COM either. Also, suppose you have only two drives.
First, put disk 1 on drive A, disk 3 on drive B, and enter PIP. CP/M responds:
A>PIP
*
—
Then remove disk 1 from drive A, install disk 2, and enter: *B:=SORT.COM
The copy will be successfully made.
After starting PIP, you cannot write on the disk you changed. (It will have R/O status.)
Suppose you also want to copy SORT.MSG to disk 3. However, it’s on disk 4, which does not contain PIP. If the above PIP session is ongoing, how would you make the copy?
ee en Se ee ne een Saree ary
Put disk 4 in drive A and enter *B:=SORT.MSG.
You have now seen the basic copy functions of PIP. With PIP you can copy one file with a specific filename, or several files with an ambigious name. You’ve seen how to concatenate files with PIP and how to use both PIP formats. Now we’re going to look at the PIP parameters. Each of these has a specific effect on the copy operation.
The PIP command has 19 different parameters that you can use to modify the file being copied. Appendix B includes a complete listing with brief explanations for you to refer to later. We’re going to look at the various parameters and see how you can use them as you work with CP/M.
13. One useful parameter is E, which stands for “echo.” When you use the E para- meter the transferred data is also echoed (or displayed) on the console. This tends to slow down the PIP operation, however it does show exactly what is being transferred. To use a parameter, enclose it in square brackets [E] immediately following the source filename.
120 USING CP/M
Which of these commands is correctly formed? (a) PIP [E]STOK.ONE=STOK TWO (b) PIP STOK.ONE[E]=STOK.TWO (c) PIP STOK.ONE=STOK.TWO[E]
14. Parameters are available for translating a file into all upper case letters (U) or all lower case (L). The destination file will be all one case or the other, depending on the parameter used. Parameters can be combined as in this example:
PIP STOK.ONE=STOK.TWO[EU]
The file STOK.TWO will be transferred as STOK.ONE, with all lower case letters con- verted to upper case. STOK.ONE will be echoed on the console. The parameters can be in any order and either upper case or lower case letters may be used.
Write commands with parameters to accomplish these operations.
(a) Copy FILE.X from disk A to disk B. Convert all upper case letters to lower case. Don’t display it on the console.
A>
(b) Copy all files of type SM6 from disk B to disk A. Convert lower case letters to upper case. Don’t display any on the console.
A>
(c) Copy file DEPART.TYM as DEPART.NEW. Convert to all upper case letters and display the transferred data.
(a) PIP B:=A:FILE.X[L] ; (b) PIP A:=B:*.SM6[U] ; (c) PIP DEPART.NEW=DEPART.TYM [UE] or[EU]
15. Some parameters can be used only with certain types of files. Only files with alphabetic characters, for example, can be converted to upper case or lower case. And only printable characters will make sense on the console. The Dn parameter — delete
n characters — only makes sense for certain files. When you specify Dn, any characters that extend beyond column n are deleted. This can only be done with a file containing printable characters. Dn is often used to truncate long lines that are being sent to a narrow printer or console. If a print device has only 40 columns, you might specify [D40] , especially if you only need to see the first 40 columns.
USING PIP 121
(a) Could you specify D60 for a COM file?
(b) Write a command to transfer FILE.XY as FILE.AB, convert it to upper case, delete anything beyond column 50, and echo the result on the console.
(a) no — COM files aren’t printable files; (b) PIP FILE.AB=FILE.XY[UEDS0] (The parameters can be in any order.)
16. You saw earlier that you can PIP a file to the PRN: device with the result that line numbers are added, tabs are expanded, and a page break occurs every 60 lines. With three parameters you can achieve the same effect on a LST: or disk file. If you then TYPE the resulting disk file, the effect will be the same as PIPping it directly to PRN:, but now you also have a copy on disk. Here are the parameters:
N__ Add line numbers Tn Expand tabs every n columns Pn Start a new page every n lines
If you use T without n, no tabs are expanded. If you use P without n, a page break occurs every 60 lines. Therefore a parameter of [NT8P] or [NT8P60] has the same effect as PIPping a file to the PRN: device.
Write parameter lists to accomplish the following:
(a) Convert to lower case, expand tabs to every 4th column.
(b) Page after 50 lines, add line numbers, and limit destination file to 80 characters per line.
(c) Create a disk file in the same format as a PRN: file.
(a) [LT4] ; (b) [NPSOD80] ; (c) [NT8P] or [NT8P60]
17. When line numbers are added with [N], leading zeros are suppressed and the number is followed by a colon, like this.
1: LINE1 2: LINE2
122 USING CP/M
If you specify [N2], leading zeros are printed and a tab is inserted following the num- ber. If the destination is disk, T8 is assumed. If the destination is LST:, the tab setting on the printer is used. In the example below we had the printer tab set at 15.
000001 LINE1 000002 LINE2
If you specify [N2Tn], the tabs will be expanded so that the next character begins in column n+1. For [N2T10] the display looks like this: 000001 LINE1
000002 LINE2
Don’t use E with N. The combination is legal but the line numbers get mixed up because PIP numbers the lines that are displayed as well as the lines that are stored or listed.
(a) Write the parameter list to number lines in this format:
11 RESTORE1 2: RESTORE2
*
(b) Write the parameter list to number the lines and insert tabs, expanded to
column 15.
— a cot Oe
(a) [N] } (6) [N2T14]
18. The F parameter is used to filter, or remove, form feeds (page breaks) from a file. Suppose you created a disk file using this parameter list [NT8P50]. Now you want to print it out but you need exactly 54 lines per page. What do you do? You use this command:
PIP LST:*CURRENT FIL [FP54]
The F parameter filters all the page breaks from CURRENT.FIL and P54 inserts new ones every 54 lines. If F and P are in the same parameter list, the existing page breaks are always removed before the new ones are added.
Assume that DOCUMENT.FUL was originally created with these parameters: (N2T8P60]. Write commands to accomplish the following:
(a) Print DOCUMENT.FUL with line numbers, tabs expanded normally, and 60 lines per page.
A>
USING PIP 123
(b) Print DOCUMENT.FUL with tabs expanded every 10 columns and 48 lines per page. A>
(c) Print DOCUMENT.FUL with tabs expanded every eight columns and no page breaks.
CO
(a) TYPE DOCUMENT.FUL (or PIP LST:=DOCUMENT.FUL); (b) PIP LST:=DOCUMENT.FUL[FP48T10] ; (c) PIP LST:=DOCUMENT.FUL[F] (Remember that the order of parameters and whether you use capital or small letters
is unimportant. You may use parameters that would occur anyway, such as T8 for question (c) above.)
19. We've covered quite a few PIP parameters for use with files that contain character data. Before we continue, give the parameter you'd use to accomplish each of these functions:
(a) Display transferred data on the console.
—.u (b) Expand tabs every six columns.
(c) Insert a page break every 50 lines.
une (d) Remove all page breaks.
mum (€) Convert lower case letters to upper case. au. (f) Convert upper case letters to lower case. aoa (g) Add line numbers to a file.
sence (h) PIP only the first 72 characters of each line.
(a) B; (b)T6; (c) PSO; (d) Fi (@—)U; (HL; (NorN2; (h) D72
20. Sometimes you may not want to copy an entire file in a PIP operation. You can use the § and Q parameters to tell PIP to start (S) and quit (Q) copying at certain points. If you use S, but not Q, the copy will start at the point you specify and run to the end of file. If you use Q, but not S, the copy will start at the beginning of the file and quit where you specify. If you use both, you can determine both the first and last parts of the new file.
124 USING CP/M
You specify the starting or quitting location as a string of characters. Suppose you want to start copying where the word SUBROUTINE first appears. You code the parameter like this:
[SSUBROUTINE*Z]
To quit where the next RETURN appears, you’d modify the parameter to look like this: [SSUBROUTINE*ZQRETURN“Z]
Notice that each string is terminated with *Z. Upper and lower case letters in the string must exactly match in the file.
Write parameters to indicate the following:
(a) Begin the copy operation where CHAPTER 2 occurs.
(b) The last part of the new file should be ;END.
(c) Assume the text of this frame is a file. You want a copy the third sentence into a separate file.
(a) [SCHAPTER 2°Z]; (b) [Q;END*Z]; (c) [SIf you*ZQfile.*Z]
21. You might have coded more words for question (c) of the preceding frame. That’s perfectly all right. The copy