The Apple CP/M Book Marray Arnow the Apple CPIM Book the Apple CP/M Book Murray Arnow, Ph.D
Total Page:16
File Type:pdf, Size:1020Kb
The Apple CP/M Book Marray Arnow The Apple CPIM Book The Apple CP/M Book Murray Arnow, Ph.D. Scott, ForeSDlan and CODlpany Glenview, Illinois London ISBN 0-673-18068-9 Copyright © 1985 Scott. Foresman and Company. All Rights Reserved. Printed in the United States of America. Library of Congress Cataloging in Publication Data Arnow, Murray. The Apple CP/M book. Includes index. 1. CP/M (Computer operating system) 2. Apple II (Computer)-Programming. 3. Apple II Plus (Computer) Programming. 4. Apple lIe (Computer)-Programming. I. Title. QA76.76.063A76 1985 001.64'2 85-2393 ISBN 0-673-18068-9 1 2 3 4 5 6 7-RRC-90 89 88 87 86 85 Apple II and Apple lIe are trademarks of Apple Computer, Inc. CP/M, ZSID, ED, DDT, STAT, PIP, and CP/M 2.0 Interface Guide are copyrighted by Digital Research, Incorporated. SoftCard and Premium SoftCard lIe are trademarks of Microsoft Corporation. WordStar is a trademark and is copyrighted by MicroPro International Corporation. 8080 and 8085 are trademarks of Intel Corporation. Z-80 is a trademark of Zilog, Incorporated. Pascal is a trademark of the UCSD Board of Regents. Diablo is a trademark of Xerox Corporation. Notice of Liability The information in this book is distributed on an "As Is" basis, without warranty. Neither the author nor Scott, Foresman and Company shall have any liability to customer or any other person or entity with respect to any liability, loss. or damage caused or alleged to be caused directly or indirectly by the programs contained herein. This includes, but is not limited to, interrupion of service, loss of data, loss of business or anticipatory profits, or consequential damages from the use of the programs. Preface The intent of this book is to introduce the Apple II, Apple II Plus, or Apple lIe computer user to the world of CP/M. The book is meant primarily to be a tutorial on CP/M and in this sense does not deviate greatly from the large library of books on that subject. This book differs in detail from the others in that the examples used and explanations given are aimed toward Apple users. It is assumed that the Apple user has a working knowledge of Apple DOS; when possible, comparisons are made to Apple DOS. There are many examples and detailed descriptions to aid those with less experience. Some of the explanations require a rudimentary knowledge of binary numbers. Appendix A gives an elementary review of binary numbers. There is a distinction between disk and diskette used throughout this book. An 8-inch floppy disk is called a disk. A 5IA-inch floppy disk is called a diskette. This com plies with standard usage. This distinction may seem artificial to an Apple user, but it is necessary. CP/M was first developed for 8-inch disk drives. The understanding of how CP/M works is directly related to this fact. The needs of advanced users are not ignored. A description of the Microsoft BIOS is included, with suggestions on modifications. It is assumed, however, that the advanced user has some programming skills at the assembly-language level and that he or she is familiar with the physical layout of the Apple. I have tried to make each chapter self-contained so that the reader need not search through the book whenever a new term or concept is introduced. The problem with such an approach is that it makes some repetition inevitable. My teaching experience has shown me, however, that, although repetition can be boring to some, it is often welcomed by others when unfamiliar material is introduced. Contents 1 Introduction 1 What Is CP/M? 1 Why Use CP/M? 2 2 Getting Started 4 Installing the CP/M Card 4 The A> Prompt 5 The Directory 5 Making Copies 6 A QUick Look at the System 6 3 The Structure of CPIM 9 The Memory Organization 9 The CCP 10 The Transient Command File 18 A Summary of CCP Built-in and Miscellaneous Commands 19 A Summary of CCP Line-Edit Commands 20 4 Fundamentals 21 The CP/M Concept 21 CP/M Devices 22 The Microsoft Use of Physical Devices 25 Disk I/O 25 5 The STAT Utility 29 Disk Space 29 File Size and Parameters 30 Altering File or Disk Status 31 Physical Device Assignments 32 Disk Parameters 33 User Areas 34 The STAT Help Command 35 A Summary of STAT Commands 35 8 The PIP Utility 37 Copying Files 37 File Concatenation 38 Error Conditions 39 Swapping Disks 39 The CCP Command Line 40 Copying Files to a Device 40 PIP Parameters 42 Special PIP Devices 48 A Summary of PIP Assignments 49 7 The SUBMIT Utility 52 8 The DDT Utility 55 Loading a Disk File into Memory 55 Saving Data to a Disk File 56 More on Loading a File 57 Displaying Memory 58 DDT Commands for the Nonexpert 59 DDT Commands for the Advanced User 61 9 The ED Program 69 Loading or Creating an ED File 69 Editing Text 70 An Example 72 ED Command-Mode Instructions 74 ED Insert-Mode Commands 79 Error Messages 79 10 The BIOS 81 BIOS Functions 81 The Microsoft Vector Jump Table 85 Other CP/M Requirements 87 Zero-Page BIOS Requirements 90 The Standard Microsoft SoftCard 91 Peripheral Cards 94 11 The Microsoft Version 2.20B BIOS 97 The BIOS Map 97 The CPM56.COM Map 101 The CPM56 Diskette Map 102 CPM56 Card Driver Entry Points 103 12 The Microsoft Version 2.23 BIOS 104 The BIOS Map 105 The CPM60.COM Map 110 The CPM60 Diskette Map III CPM60 Card Driver Entry Points 112 13 Patching the Microsoft Standard SoftCard BIOS 113 Squashing Microsoft Version 2.20B Bugs 113 Squashing Microsoft Version 2.23 Bugs 115 Using Other Slots for the Printer 115 Stopping the Printer from Double-spacing 119 Adding XON/XOFF Handshaking 120 14 The Microsoft Premium SoftCard lie (2.28 BIOS) 122 The Comparison to Earlier BIOS Versions 122 The PS lIe Hardware and Software'Configuration 123 PS lIe Standard 6502 BIOS Calls 128 The 6502 BIOS 135 The Z-80 BIOS 140 The PS lIe Diskette Map 143 15 Uploading and Downloading 144 Appendix A: Binary Numbers 147 The Definition of a Binary Number 147 The Hexadecimal Number 148 Converting Decimal to Hexadecimal Notation 149 More Definitions 150 Appendix B: ASCII 151 Appendix C: A Primer on Diskettes 155 The Physical Diskette 155 Sector Skewing 156 The CP/M Diskette 157 Appendix D: The CPIM RWTS (Versions 2.20B and 2.23) 159 Index 161 Introduction II What Is CP/M? CP/M is a copyrighted name belonging to Digital Research, Incorporated; it stands for Control Program for Microprocessors. CP/M is an operating system (aS). The term operating system is computer jargon for the collection of programs used by a computer to communicate with the world. This world as seen by a computer is its hardware, such as the keyboard, the display device, the printer, the disk drives, and any other devices that may be plugged in. A good operating system should permit the computer user to easily access the hardware. The disk drive is a special piece of hardware and in general requires a great deal of attention. The disk drive is used to read information from or write information to a magnetic disk placed in the drive (refer to Appendix C for a detailed description of disks and disk drives.) The disk may be thought of as a chalkboard where information can be written and saved or erased, as required. The problem with a disk is that, although information can be saved on it at arbitrary physical locations, these arbitrary locations cannot be random. This means that there must be a plan to putting information on a disk. Without a plan, the computer could never retrieve anything saved on a disk. Information is usually stored on a disk in physical segments calledfiles. The file locations are stored in a special disk area called the directory. Whenever new information is written to a disk, the as must create a file and put the address of its location in the directory. If the information is to be retrieved, then the as uses the directory data to find the file and read its contents back to the computer. An as must also be able to delete files, add information to a previously created file, and read a specified segment of information from a file. CP/M is an operating system that has become the de facto standard for computers using the Intel 8080 or 8080-compatible microprocessors. It is virtually impossible to find a computer using the Intel 8080, Intel 8085, or Zilog Z-80 microprocessor that doesn't feature CP/M as its as. Consequently, there is currently a tremendous inventory of programs, both commercial and in the public domain, available to the user. The 1 2 • Introduction remarkable thing about these programs is that they can run, with a few noted exceptions, on any computer operating under CP/M. The reason for this is the machine-independent structure of CP/M; details of the CP/M's internal workings are covered later in this book. II Why Use CP/M? As an Apple owner you are probably wondering what justification there is for installing a CP/M operating system in your computer. There are three reasons serious Apple users such as business people and programmers should consider. The first reason is that you can tap into a source of program material not available under Apple DOS.