Superbrain_Users_Manual_Sep80 Superbrain Users Manual Sep80
Superbrain_Users_Manual_Sep80 manual pdf -FilePursuit
Superbrain_Users_Manual_Sep80 Superbrain_Users_Manual_Sep80
User Manual: Superbrain_Users_Manual_Sep80
Open the PDF directly: View PDF .
Page Count: 660
Download | |
Open PDF In Browser | View PDF |
USERS MANUAL FOR INTERTEC'S 5UPE~BRAlNTM VIDEO COMPUTER SYSTEM .IMPORTANT NOTICE This version of the SuperB rain Users Manual is intended for use with the . SuperBrain or Sup~rBrain OD Video Computer Systems. However,.this manual is applicable only for those unfts with .Revision-Ot of the· Keyboarq/d~u module, and version 3.0 or.h ighe,rof the DOS and boot loader. If- ypu hav~ a Revision-OO :, .. Keyboard/CPU module, then use only the First or Second Edition of this manual. Docum~nt No.68~1010 . . September 19?O This is the fourth edition of this manual. Your warranty registration form must be returned promptly to assure receipt of future revisions, if any, to this document. *** IMPORTANT *** Do not attempt to write or save programs on your system diskette. It has been 'write protected' by placing a small adhesive aluminum strip over the notch on the right hand side of the diskette. Such attempts will result in a 'WRITE' or 'BAD SECTOR' error. Before using your SuperBrain please copy the System Diskette onto a new blank diskette an (ntertec 1121010 diskette. If you do not have such a diskette, contact you local dealer. He should be able to supply you with one. If you have any questions concerning this procedure please contact your dealer before proceeding. Failure to do so may result in permanent damage to your System Diskette. BEFORE APPLYING POWER TO THE MACHINE INSURE THAT NO DISKETTES ARE INSERTED INTO THE MACHINE. NEVER TURN THE MACHINE ON OR OFF WITH DISKETTES INSERTED IN IT. FAILURE TO OBSERVE THIS PRECAUTION WILL MOST DEFINITELY RESULT IN DAMAGE TO THE DISKETTES. CONFIDENTIAL AND PROPRIETARY INFORMATION Information presented in this manual is furnished for customer reference only and is subject to change. This document is the property of Intertec Data Systems Corporation, Columbia, South Carolina, and contains confidential and trade secret information. This information may not be transferred from the custody or control of I ntertec except as authorized by I ntertec and then only by way of loan for limited purposes. It must not be reproduced in whole or in part and must be returned to Intertec upon request and in all events upon completion of the purpose of the loan. Neither this document nor the information it contains may be used or disclosed to persons not having a need for such use or disclosure consistent with the pu rpose of the loan without the prior express written consent of I ntertec. COPYRIGHT 1980 The following is a trademark of I ntertec Data Systems Corporation, Columbia, South Carol ina: SUPERBRAIN INTERTEC DATA SYSTEMS CORPORATION Columbia, South Carolina THE SUPERBRAIN VIDEO COMPUTER SYSTEM CONGRATULATIONS ON YOUR PURCHASE OF INTERTEC'S SUPERBRAIN VIDEO COMPUTER SYSTEM Your new SuperBrain Video Computer was manufactured at I ntertec's new 120,000 square foot plant in Columbia, South Carolina under stringent quality control procedures to insure trouble-free operation for many years. If you should encounter difficulties with the use or operation of your terminal, contact the dealer from whom the unit was purchased for instructions regarding the proper servicing techniques. I f service cannot be made available through your dealer, contact Intertec's Customer S.ervice Department at (803) 798-9100. As with all Intertec products, we would appreciate any comments you may have regarding your evaluation and application for this equipment. For your convenience, we have enclosed a customer comment card at the end of this manual. Please address your comments to: Product Services Manager I ntertec Data Systems Corporation 2300 Broad River Road Columbia, South Carolina 29210 The SuperBrain is distributed worldwide through a network of dealer/OEM vendors and through I ntertec's own marketing facilities. Contact us at (803) 798-9100 (TWX - 810666-2115) regarding your requirement for this and other I ntertec products. Intertec's new one hundred and twenty thousand square foot corporate and manufilt'wriny fi}(:iliry in Columbia, South Carolina WILL THE MICROCOMPUTER YOU BUY TODAY STILL BE THE BEST MICROCOMPUTER BUY TOMORROW? Probably the best test in determining how to spend your microcomputer dollar wisely is to consider the overall versatility of your terminal purchase over the next three to five years. In the fast-paced, ever-changing world·· of data communications, new features to increase operator and machine efficiency are introduced into the marketplace daily. We at Intertec are acutely aware of this rapid infusion of new ideas into the small systems business. As a result, we have designed the SuperBrain in such a manner as to virtually eliminate the possibility of obsolescence. Many competitive alternatives to the SuperB rain available today provide only limited capability for high level programming and system expansion. Indeed, most low-cost microcomputer systems presently available quickly become outdated because of the inability to expand the system. Intertec, however, realizes that increased demands for more efficient utilization of programming makes system expansion capability mandatory. That means a lot. Because the more you use your SuperBrain, the more you'll discover its adaptability to virtually any small system requirement. Extensive use of "software-oriented" design concepts instead· of conventional "hardware" designs assure you of compatibility with almost any application for which you intend to use the SuperB rain. Once you read our operator's manual and tryout some of the features described herein, we are confident that you too will agree with our "top performance bottom dollar" approach to manufacturing. The SuperBrain offers you many more extremely flexible features at a lower cost than any other microcomputer we know of on the market today. The use of newly developed technologies, efficient manufacturing processes and consumer-oriented marketing programs enables us to be the first and only major manufacturer to offer such an incredible breakthrough in the microcomputer marketplace. Browse through our operator's manual and sit down in front of a SuperBrain for a few hours. Then, let us know what you think about our new system. There is a customer comment card enclosed in· the rear section of this manual for your convenience. Thank you for selecting the SuperBrain as your choice for a microcomputer system. We hope you will be selecting it many more times in the future. TABLE OF CONTENTS INTRODUCTION Section 1 MAJOR COMPONENTS Section 2 SYSTEM OPERATION Section 3 INTRODUCTION TO CP/M FEATURES & FACILITIES Section 4 OPERATION OF THE CP/M CONTEXT EDITOR Section 5 CP/M 2.0 USER'S GUIDE FOR CP/M 1.4 OWNERS Section 6 OPERATION OF THE CP/M DEBUGGER Section 7 OPERATION OF THE CP/M ASSEMBLER Section 8 THE CP/M 2.0 INTERFACE GUIDE Section 9 THE CP/M 2.0 SYSTEM ALTERATION GUIDE Section 10 MICROSOFT BASIC 80 REFERENCE MANUAL Section 11 Section 12 SERVICE INFORMATION Section 13 HARDWAREADDENDUMS Section 14 SOFTWAREADDENDUMS Section 15 - MICROSOFT UTILITY SOFTWARE MANUAL I • INTRODUCTION ) .. Page 6 INTRODUCTION The SuperBrain Video Computer System represents the latest technological advances in the microprocessor industry. The universal adaptability of the SuperBrain CP/M* Disk Operating System satisfies the general purpose requirement for a low cost, high performance microcomputer system. From the standpoint of human engineering, the SuperBrain has been designed to minimize operator fatigue through the use of a typewriter-oriented keyboard and a remarkably clear display. The SuperBrain displays a total of 1,920 characters arranged in 24 lines with 80 characters per line. The video display is usually crisp and sharp due to Intertec's own specially designed video driver circuitry. And, the high quality, non-glare etched CRT face plate featured on every SuperBrain assures ease of viewing and uniformity of brightness throughout the entire screen. The SuperBrain's unique internal design assures users of exceptional performance for just a fraction of what they would expect to pay for such "big system" capabilities. The SuperBrain utilizes a single board "microprocessor" design which combines all processor, RAM, ROM, disk controller, and communications electronics on the same printed circuit board. This type of design engineering enables the SuperBrain to deliver superior, competitive performance. Standard features of every SuperBrain include: two double-density, single-sided mini-floppies with a total of over 350,000 bytes formatted disk storage, 32K of dynamic RAM memory - expandable to 64K (in one 32K increment), a universally recognized CP/M* Disk Operating System featuring its own text editor, an assembler for assembly language programming, a program debugger and a disk formatter. Also standard are dual universal RS232 communications ports for serial data transmission between a host computer network via modem or an auxiliary serial printer. A number of transmission rates up to 9600 baud are available and selectable under program control. Other standard features of the SuperBrain include: special operator convenience keys, dual "restart" keys to insure simplified user operation, a full numeric keypad complement, and a high quality typewriter compatible keyboard. An optional low cost S-100 bus adaptor is available to convert the Supel"Brain Z80A data bus into an S-100 data and address compatible protocol. The S-100 adaptor accommodates one S-100 printed circuit board which can be mounted internally. For reliability, the SuperBrain has been designed around 4 basic modules packaged in an aesthetically pleasing desk-top unit. These major components are: the Keyboard/CPU module, the power supply module, the CRT assembly, and the disk drives themselves. Failure of any component within the terminal may be corrected by simply replacing only the defective module. Individual modules are fastened to the chassis in such a manner to facilitate easy removal and reinstallation. Terminal down-time can be greatly minimized by simply "swapping-out" one of the modules and having component level repair performed at one of Intertec's Service Centers. Spare modules may be purchased from an Intertec marketing office to support those customers who maintain their own "in-house" repair faci Iities. The SuperB rain's cover assembly is exclusively manufactured "in-house" by I ntertec. A high-impact structural-foam material is covered with a special "felt-like" paint to enhance the overall appearance. Since the cover assemblyrs injected-molded, there is virtually no possibility of cracks and disfigurations in the cover itself. And, by manufacturing and finishing the cover assembly in-house, Intertec is able to specify only high quality material on the external and internal cover components of your SuperBrain to insure unparalleled durability over the years to come. 'CP/M is a registered trademark of Digital Research Page 7 INTRODUCTION (continued) A wide variety of programming tools and options are either planned or available for the SuperBrain. Standard software development tools available from I ntertec include Basic, Fortran and Cobol programming languages. A wide variety of applications packages (general ledger, accounts receivable, payroll, inventory, word processing, etc.) are available to operate under SuperBrain CP/M Disk Operating System from leading software vendors in the industry. Disk storage may be increased by adding SuperBrain's S-100 bus adaptor and connecting other auxiliary disk devices, including hard disk drives. And, another model of the SuperBrain - SuperB rain QD - features double density, double-sided disk drives which provide over 700,000 bytes of formatted data. The price/performance ratio of the SuperBrain has rarely been equalled in this industry. By employing innovative design techniques, the SuperBrain is not only able to offer a competitive price advantage but boasts many features found only in systems costing three to five times as much. SuperBrain's twin Z80A microprocessors insure extremely fast program execution even when faced with the most difficult programming tasks. And, each unit must pass a grueling 48 hour burn-in before it is shipped to the Customer. By combining advanced microprocessor technology with in-house manufacturing capability and stringent quality control requirements, your SuperBrain should provide unparalleled reliability in any application into which it is placed. CUTAWAY VIEW SHOWING MOUNTING OF MAJOR SUBASSEMBLIES. Page 8 SYSTEM SPECIFICATIONS FEATURE CPU Microprocessors DESCRIPTION Twin Z80A's with 4MHZ Clock Frequency. One Z80A (the host processor) performs all processor and screen related functions. The second Z80A is "down-Ioaded" by the host to execute disk I/O. Word Size 8 bits Execution Time 1.0 microseconds register to register Mach ine Instructions 158 I nterrupt Mode All interrupts are vectored and reserved. Floppy Disk Storage Capacity Over 350K (700K + on unformatted data on Optional external hard using the optional S-100 SuperB rain aD) total bytes of two double density drives. disk storage can be connected bus adaptor. Data Transfer Rate 250K bits/second Average Access Time 250 milliseconds. 35 milliseconds track-to-track Media 514 inch mini-disk Disk Rotation 300 RPM Internal Memory Dynamic RAM 32K (64K on Superbrain aD) bytes dynamic RAM. Expandable to 64K in one 32K increment. Optional 32K is socketed. Static RAM 1 K bytes of static RAM is provided in addition to the main processor RAM. This memory is used for program and/or data storage for the auxiliary processor. ROM Storage 2K bytes standard. Allows ROM "bootstrapping" of system at power-on. CRT Display Size 12-i nch, P4 phosphor. Display Format 24 lines x 80 characters per line. Character Font 5x7 character matrix on a 7x 10 character field Display Presentation Light characters· on a dark background. *Specifications subject to chango without notice or liability. • Page 9 SYSTEM SPECIFICATIONS (continued) FEATURE DESCRIPTION Bandwidth 15 MHZ. Cursor Reversed image (block cursor) Commu nications Screen Data Transfer Memory-mapped at 38 kilobaud. Serial transmission of data at rates up to 9600 bps. Main Interface RS-232C asynchronous. Synchronous interface optional. Auxiliary Interface Simplified RS-232C asychronous. Synchronous interface optional. Z80A Data Bus 40-pin Data Bus connector. S-100 Bus Connector provided for connection of optional S-100 bus adaptor. Parity Choice of even, odd, marking, or spacing - under program control. Transmission Mode Half Addressable Cursor Direct Positioning by absolute x, yaddressing. System Utilities Disk Operating System DOS Software Optional Software FORTRAN or Full Duplex. One or two stop bits. CP/M 2.2 An 8080 disk assembler, debugger, text editor and file handling utilities. ANSI standard. Relocatable, random and sequential disk access. COBOL ANSI standard. Relocatable, sequential, relative and indexed disk access. BASIC Sequential and random manipulation, interpreter. Application Packages Extensive software development tools are available from leading software vendors including software for the following applications: Payroll, Accounts Receivable, Accounts Payable, Inventory Control, General Ledger and Word Processing. Keyboard Alphanumeric Character Set disk access. Full string Generates all 128 upper and lower case ASCII characters. 'Specifications subject to change without notice. Page 10 SYSTEM SPECIFICATIONS (continued) FEATURE DESCRIPTION Special Featu res 2-Key Rollover, Keyboard lock/unlock - under program control. Numeric Pad 0-9, decimal point, comma, programmable function keys. Cursor Control Keys Up, down, forward and backward. I nternal Construction Cabinetry minus and user- Structural foam Component Layout Four board modular design. All processor related functions and hardware are on a single printed circuit board. All video and power related circuits on separate single boards. Mounting All modules mounted to base. CRT in a rigid aluminum frame. Disk Drive assemblies are mounted into special bracket for ease of servicing. Environment Weight Approximately 45 pounds. Physical Dimensions 145/8" (H) x 21 3/8 (W) x 231/8 (D) Environment Operating: 0 0 to 400 C Storage: 0 0 to 85 0 C; 10 to 85% reI. humidity - non-condensing. Power Requirements 115 VAC, 60 HZ, 3 AMP (optional 230VAC/50HZ model available) 'Specifications subject to change without notice. Page 11 OPTIONAL VERSUS STANDARD FEATURES Since each SuperBrain is designed utilizing the latest advances in microprocessor technology, many features which other system vendors offer as options are offered as standard features on th.e SuperBrain. The SuperBrain Video Computer is designed to satisfy the universal requirement for a low cost, high performance small business system and, hence, there are virtually no options from which to choose. Basically, available options for the SuperBrain include: BASIC 80 FROM MICROSOFT - an extensive implementation of Basic language available for Z80 microprocessors. In just three years of use, it has become the world's standard for microcomputer Basic. Basic 80 gives users what they want from a Basic - ease of use plus all of the features that make a micro perform like a minicomputer or large mainframe. Basic 80 meets the requirements of the ANSI subset standard for Basic and supports many unique features rarely found in other Basics. MICROSOFT FORTRAN 80 - comparable to Fortran compilers on large mainframes and minicomputers. All of ANSI standard Fortran X3.9-1966 is included except the COMPLEX datatype. Therefore, users may take advantage of the many application programs already written in Fortran. Fortran 80 is unique in that it provides a microprocessor Fortran and assembly language development package that generates relocatable object modules. This means that only the subroutines and system routines required to run Fortran 80 programs are loaded before execution. Subroutines can be placed in a system library so that users develop a common set of subroutines that are used in their programs. Also, if only one module of a program is changed, it is necessary to recompile only that module. CENTRONICS-COMPATIBLE PARALLEL INTERFACE(1) - connects directly to SuperBrain's 40 pin Z80A data bus connector and provides for a parallel output as required for Centronics-compatible printers. S-100 BUS ADAPTOR (2) - connects to SuperBrain's auxiliary Z80A data bus edge card connector and provides for the connection of up to one standard sized S-100 bus board inside the SuperBrain cabinet. Bus adaptor includes ribbon cables, S-100 conversion circuitry, S-100 card guides and a metal mounting bracket to enable the S-100 bus adaptor to be installed on the inside cover just to the right of SuperBrain's twin double-density disk drives. SYNCHRONOUS INTERFACE - enables synchronous transmission via the auxiliary RS232 serial communications port. 32K DYNAMIC RAM EXPANSION KIT - a set of sixteen 16K RAM chips which plug into existing sockets on the SuperBrain Keyboard/CPU module to enable expansion of the SuperB rain's dynamic memory from 32K to 64K. Also included with the RAM kit is an additional CP/M DOS Diskette which reconfigures the SuperBrain's Operating System to accommodate all 64K of RAM. (1) Available June, 1980 (2) Available June, 1980 • ( I MAJOR COMPONENTS Page 1 INTERNAL CONSTRUCTION Perhaps the most remarkable feature of the SuperB rain is its modular construction using only four major subassemblies which are clearly defined in their respective functions so as to facilitate ease of construction and repair. These four subassemblies are shown in figure one and described below. isl< Drive Module Keyboard/CPU Module • Page 2 INTERNAL CONSTRUCTION (continued) KEYBOARD/CPU MODULE The control section of the SuperB rain Video Computer is based upon the widely acclaimed Z80A microprocessor. The result is far fewer components and the ability to perform a number of functions not possible with any other approach. The Keyboard/CPU module (figure two) contains the SuperBrain's twin Z80 microprocessors. One Z80A (the host processor) performs all processor and screen related functions while the second Z8QA can be "downloaded" to execute disk I/O handling routines. The result is extremely fast execution time for even the most sophisticated programs. In addition to containing the SuperBrain's microprocessor circuitry, the Keyboard/CPU module contains 32K of dynamic RAM with sockets for an additional expansion capability of 32K (see figure three). Also found on this module is: the character and keyboard encoder circuitry, the "bootstrap" ROM, the disk controller and all communications electronics. Power is supplied to and signals are transferred from this module via a single 22 pin ribbon cable connected to the SuperBrain's main power supply module. Connection of this module to the disk drive subassemblies is via a separate ribbon cable. Figure four shows the connectors on the Keyboard/CPU module which are used for interconnecting this module with the disk drive subassemblies, the main power supply and the optional parallel and/or S-100 bus adaptor. Figure 2 - SuperBrain Keyboard/CPU Module Figure 3 - Dynamic RAM Section Every SuperBrain is equipped with 32K dynamic RAM - on board expandable to 64K. 16 sockets are provided for the additional 32K of RAM. Figure 4 - Keyboard/CPU Module Connectors The 40 pin connector on the top edge of the card is for connection to SuperBrain's optional parallel and/or S100 bus adaptor. The 40 pin connector on the right edge routes signals to and from the disk drive assembly. Page 3 INTERNAL CONSTRUCTION (continued) CRT DISPLAY MODULE The CRT Display Module consists of a 12 inch, high resolution, cathode ray tube mounted in a rigid aluminum chassis. The faceplate of the CRT is etched in order to reduce glare on the surface of the screen and provide uniform brightness throughout the entire screen area . The CRT display presentation is arranged in 24 lines of 80 characters per line. The CRT video driver circuitry is mounted in the base of the CRT chassis to facilitate ease of removal and subsequent repair. I n this manner, either the CRT itself or the video circuitry can be easily exchanged without disrupting any of the other major modules within the terminal (see figu re five). Figure 5 - SuperBrain CRT Display Module This module is easily removed for service or replacement. A single edge connector is provided for connection to SuperBrain's Power Supply Module. • Page 4 INTERNAL CONSTRUCTION (continued) MAIN POWER SUPPL V MODULE The SuperBrain's power supply is a "solid-state, switching" design and employs switching voltage regulators to provide many years of trouble-free service. This design reduces heat dissipation and allows for efficient cooling of the entire terminal with a specially designed whisper fan to reduce environment noise. The entire power supply can be easily removed by unscrewing the three screws holding it into the base of the terminal. Included on the main power supply module are the power off/on switch, the user brightness control and the main and auxiliary RS232 serial ports. By combining the power supply section and external serial communications connections on the same module, the total module count is able to be kept to a minimum thus greatly facilitating ease of field service repair while at the same time minimizing the number of modules required to be stocked to effect competent field repair (refer to figure six). Figure 6 - Main Power Supply • Page 5 INTERNAL CONSTRUCTION (continued) DISK DRIVE MODULES Figures seven and eight illustrate the left and right views of the SuperBrain's specially designed double-density disk drive subassembly. Each SuperBrain contains two of these type drives which are mounted conveniently just to the right of the CRT display module on a rugged aluminum mounting bracket which supports the drives so that they are flush mounted with the front "bezel" of the unit. Power to these drives is derived from the Power Supply Module located just behind the drive assemblies themselves. Data to and from these drives is routed via a single 34 pin ribbon cable connecting the drives to the Keyboard/CPU module. Figure 7 - Top View of SuperBrain Drive Assembly Figure 8 - Bottom View of SuperBrain Drive Assembly • Page 6 INTERNAL CONSTRUCTION (continued) The 8uperBrain can be configured to employ an optional module - the 8-100 bus adaptor. This adaptor plugs into the 8uperBrain's Keyboard/CPU module and mounts internally on the metal bracket supporting the disk drive assemblies. ,Figure nine shows the 8uperBrain with the 8-100 bus adaptor and a single 8-100 printed circuit card. Figure ten shows the same unit without the 8-100 bus module installed. The 8-100 bus adaptor is offered as an optional feature on the 8uperBrain for those users who desire to expand the units' capability with the addition of auxiliary disk devices including the new, more popular Winchester-type drives. A single 8-100 card can be easily inserted in the card guide supplied with each 8-100 bus adaptor (as shown in figure eleven). NOTE: The 8-100 bus adaptor includes cabling, connectors and circuitry to convert the 8uperBrain's Z80 data bus into the 8-100 bus. The actual 8-100 compatible printed circuit board (as is shown in figure eleven) is supplied by the user. Figure 9 - 8uperBrain with 8-100 Bus Adaptor and card installed. Figure 10 - 8uperBrain with 8-100 Bus Adaptor and card removed. Figure 11 - SuperBrain S-100 Bus Adaptor Includes adaptor, 100 pin S-100 connector, card guides, mounting bracket and all necessary cabling. The S-100 card is supplied by the user. SYSTEM OPERATION Page 1 THEORY OF OPERATION The SuperBrain contains two Z80 microprocessors. (Reference Figure 3-1) uP1 is the master processor. It communicates with the 64K RAM and the I/O devices (serial port, keyboard encoder, interface controller, and CRT controller). Aside from these devices, it can also access the 2K ROM and DATA BUFFER RAM in the FLOPPY DISK CONTROLLER. uP2 is slaved to uP1 and can only access the 2K ROM, DATA BUFFER, and the DISK INTERFACE. This processor is used exclusively for disk control. The 32/64 kilobyte main memory consists of up to thirty-two 16K x 1 bit dynamic RAMS. These are divided in four banks (0-3) with each bank containing 16 kilobytes of storage. The RAS-CAS timing sequence necessary for memory access is created by the memory timing generator. There are two devices that can access memory - uP1 and the CRT Controller. uP1 can read and write to memory while the CRT Controller can only perform the read function. Because each device runs at a different speed, two clock frequencies are required for memory timing. The speed is determined by the selection of the control input to the timing generator. The microprocessor functions require the faster clock. The CRT-VI DEO CONTROLLER contains three main devices - the CRT Controller which generates all the timing signals for data display; the video generator which produces the character font; and the octal 80-bit shift register which stores one row of video data. (80 characters) The CRT Controller generates all the timing necessary to display 24 rows of characters with 80 characters per row. Thus the screen can display a total of 1920 characters. These characters are stored in the CRT refresh buffer which is the upper 2048 bytes (2K) of RAM. Because the CRT buffer is not a separate buffer and the processor must also use the same bus to access memory, this bus must be timeshared between the two. This is accomplished by the CRT controller performing a direct memory access (DMA) cycle which is done at the beginning of each scan row. Each scan row is divided into ten scan lines, therefore during the first scan line time, the controller takes control of the processor bus by generating a bus request. After acquiring the bus, it reads 80 characters from the CRT buffer and loads them into the 80 x 8 shift register. This data is then recirculated in the buffer for the next nine scan lines to produce one row of video characters. Therefore, there are twentyfour DMA cycles performed per vertical frame. There are also twenty-five interrupts generated - one for each row scan and one extra during vertical blanking. During the first twenty-four, the processor sets or resets the video blanking depending on whether that row is displayed or not. During the vertical blanking interrupt, the address registers in the CRT controller are initialized to the correct top-of-page address and the cursor register is also updated. The Interface Controller is basically three 8 bit I/O ports (8255). Through this device, the processor can obtain status bits from other devices and react to the status by setting/ resetting individual bits in the 8255. The Keyboard Encoder scans the keyboard for a key depression, determines its position, and generates the correct ASCII code for the key. The processor is flagged by the 'Data Ready' signal via the Interface Controller. The character is then input by the processor. • Page 2 THEORY OF OPERATION (continued) The remaining I/O device is the RS-232-C Serial I nterface Port. Presently, it operates only in the asynchronous mode and adheres to a simplified standard protocol. The baud rate is set to 1200 baud by the operating system (Refer to the Technical Bulletin enclosed at the end of this manuaL) As previously mentioned, uP1 has the capability of communicating with the RAM and ROM in the FLOPPY DISK CONTROLLER. It does this to obtain the bootloader from ROM on power-up and system reset and also when transferring disk parameters and data to/from the Data Buffer RAM. Because the amount of main memory used is the maximum that the processor addressing can support different 16K banks of main memory must be switched off line when communicating with the disk RAM or ROM. In these cases Bank 0 (0000H-3FFFH) is switched out when communicating with the ROM, and Bank 2 (8000H-BFFFH) when communicating with the RAM. The DISK CONTROLLER performs all disk related I/O functions upon command from the main processor. These commands are: • • • • • Restore to track 0 Read sector Write sector Write sector with deleted data mark Format The parameters associated with drive, side, track, and sector numbers are loaded, a status word is set at specified location in the disk RAM. When uP2 receives this status, it sets the 'disk busy' status bit and performs the indicated function. Upon completion, it resets the 'busy' bit thus allowing the main processor (uP1) to retrieve data and status from the RAM. GENERAL SPECIFICATIONS POWER 110/220 VAC 50/60 HZ Dual Switching Power Supplies MEMORY 32/64K bytes (dynamic) MICROPROCESSOR Two Z80's operating at 4MHZ SERIAL PORTS Two asynchronous 'simplified' RS-232-C, programmable ports CRT SCREEN 24 lines, 80 columns 7 x 10 dot character field 5 x 7 dot character font 50/60 HZ refresh rate FLOPPY DISKS Two, 5-1/4", double density, MFM Format (Soft sectored) - 512 Bytes/sector; 10 sectors/track 35/70 tracks/diskette Capacity - 179K bytes formatted single sided, 35 tracks/diskette 358K bytes formatted single sided, 70 tracks/diskette DOS CP/M, Version 2.2 • CRT- VID.EO CONTROLLER ~--------------------- --- '-1 ~-------------- INTR uFf BUS REO RAS BUS AK 4MHZ ___ MAIIl MEMORY 64K x B CAS RAI~ i--=l 10.92 MHZ 16 MHZ --1--+ J..ROCESSOR CONTROL RAM AODRESS 17 __ CR!.CONTROL ... -..-- ._. ·1-- ..1.... -~--- , I L MEMORY BANK INHIBI~_ . ;:; +12 VOC ) +5 VOC > > ) ._.__ -1-- ~_ _ ____ ...-ADDRESS BUS 4P RTS .. f ,--J - INTERFACE RX DATA =f'" SERIAL >--- CTS >- DSR >--- BUS AK PORT _._____ I CONTROLLER ASYNC OTR I j > EXTERNAL BUS .--------+----------+---------~---------~ -5VD IX DATA A15 1/0 CONTROL GNO -12 VDC DO - 07 +-- _____.J--___P.!lIiI..ill!?___-,--_ - - - - ---i----+-------- AO - _. __.___ 1._ l, CONTROL .. . __ . _ _ . _ _ I _______ ..J _____ • _ _ _ _ _ _ _ _ _ •_ _ _ _ I BUS REQ ---001 1.1>r uP2 ~ I 2 MHZ - -, ,- MH~ISK CONTROLLE 8!!L. --------1 ---l--.~..JlAIJL- T11 - - - 1--1""-T'1 ADDRESS CONTROL ----1 I l~ 1 I' DATA BUFFER 2K x B 4MHZ J ~ -~ OISK I WRITE I DAT~ WRITE PRECOI-IP I '--_ _.....-tIINTERFAC RAM lMHZ_ 1- ! I -----+-- ROM 16 KEYBOARD DISK BUSY .. j 14MHZ DATA R KEYBOARD DATA ENCODER LIGETT 8fIHZ 16MHZ 8MHZ 4MHZ 1MHZ L _ _ _I FLOPPY DISK CONTROLLER ""lJ Ql 10.92 MHZ TIMING GENERATOR ------- CO CD W _._---- FIGURE 3-1 SUPERBRAIN KEYBOARD/CPU MODULE BLOCK DIAGRAM • Page 4 INSTALLATION AND OPERATING INSTRUCTIONS UNPACKING INSTRUCTIONS Be sure to use extreme care when unpacking your SuperBrain Video Computer System. The unit should be unpacked with the arrows on the outside facing up. Once you have opened the unit, locate the Operator's Manual which should be placed at the front of the terminal. If you have ordered additional optional software with your system, it will most likely be attached to the outside of the carton in a gray envelope. Extreme care should be used in opening this envelope so as not to damage any of the delicate diskette media contained inside. The MASTER SYSTEM DISKETTE is located inside the front cover of the Operator's Manual. Be careful not to discard or misplace this diskette as it will be vital for the operation of the equipment in later sections. . Now that you have located your Operator's Manual and system diskette you can proceed to remove all packing material on the top and front of the terminal. Once this has been accomplished, you may now remove the terminal from the shipping carton. In some instances, you may notice that the terminal is somewhat difficult to remove from the carton. This is due to the varying amounts of packing material that is placed in each carton. If you should experience such difficulties, rotate the carton on its side. With the terminal on its side, you should now be able to pull outward on the terminal and separate it from the box. Once the terminal is out of the carton place it on a table and remove the protective plastic bag which should be surrounding the terminal. DO NOT DISCARD THE SHIPPING CARTON UNTI L YOU HAVE COMPLETELY CHECKED OUT THE TERMINAl. SET UP Now that you have removed your SuperBrain Video Computer System from its packing carton, you are ready to begin to set up the system. The first step in this procedure is to verify that your SuperBrain Video Computer System is wired for a line voltage that is available in your area. This can be ascertained by looking on the serial tag located at the right rear of the terminal. This tag should indicate that your unit is set up for either 110 or for a 220 VAC operation. DO NOT ATTEMPT TO CONNECT THE SUPERBRAIN VIDEO COMPUTER SYSTEM TO YOUR LOCAL POWER OUTLET UNLESS THE VOLTAGE AT YOUR OUTLET IS IDENTICAL-TO THE ONE SPECIFIED ON THE BACK OF YOUR TERMINAl. Should the voltages differ, contact your dealer at once and do not proceed to connect the SuperBrain Video Computer System to the power outlet. Before connecting the SuperBrain Video Computer System to the wall outlet, be sure that the power switch located at the left rear corner is turned OFF. You may now proceed to connect your computer system to the wall outlet. After completing this connection, turn the power switch to the 'ON' position. At this time, you should hear a faint"whirring" sound coming from the fan in the computer. After approximately 60 seconds the message 'INSERT DISKETTE INTO DRIVE A' will appear on the screen. If this message does not appear on the screen after approximately 60 seconds, depress the RED key located on the upper right hand corner of the numeric key pad. This key is the master system reset key and should reinitialize the computer system thereby displaying the 'I NSE RT' message on the scre~n. If, after several attempts at resetting the equipment you are unable to get this message to appear on the screen, turn the unit off for approximately 3 to 5 minutes and then reapply power to the unit. If you are still unable to get the appropriate message to appear on the screen, contact you r I ntertec representative. SYSTEM DISKETTE Now that you have power applied to the machine and the 'INSERT DISKETTE' message has been displayed in the upper left hand corner, you are ready to proceed with loading the computer's operating system. This is accomplished by locating the small 5%" diskette that was packed with the operator's manual. Once you have located this diskette you will notice Page 5 INSTALLATION AND OPERATING INSTRUCTIONS (continued) that a small adhesive aluminum strip has been placed over the notch on the right hand side of the diskette. This aluminum strip is used to "WR ITE PROTECT" the diskette. Therefore, you may only load and/or read programs off of this diskette. If you wish to write or save programs on the system diskette it will be necessary to remove the small adhesive aluminum strip from the diskette. This is NOT RECOMMENDED as it will subject your diskette to accidental errors that may be induced by you while you are getting familiar with the operating system. You are now ready to proceed with inserting the system diskette into the machine. When facing the front of the machine, you will notice that tliere are two small openings on the right-hand side of the machine. The first opening (the one furtherest to the left) is designated as DRIVE A. The second opening (the one on the right-hand side of the terminal) is designated as DRIVE B. This distinction is extremely important since the disk operating system can only be loaded from DRIVE A. Now that you have located the two disk drives on the system, open the disk drive door on DRI VE A (opening closest to your left). The drive can be opened by applying a very slight pressure outward on the small flat door located in the center of the opening. Once the Drive door has been opened, you are now ready to insert the Operating System Diskette. As noted previously, this is the diskette which was packed with your Operator's Manual. The front of the diskette should contain a small white sticker located in the upper left hand corner of the diskette. This diskette should contain a message indicating that it is the SuperBrain DOS Diskette with CP/M Version 2.0. Once you have located this diskette you may insert it into the machine. Be careful to insure that (1) the small aluminum write protect strip is orientated towards the top edge of the diskette and that (2) the label located in the upper left hand corner of the operating system diskette is facing AWAY from the screen towards the right-hand side of the terminal. Once you have orientated the diskette in this fashion, you may now insert it into the terminal. It is EXTREMELY important that the diskette be properly orientated before inserting it into the machine since improper orientation will not allow the operating system to properly load. Once the diskette has been placed in the machine, be sure that it has been inserted all the way by applying a gentle pressure on the rear edge of the diskette. Once you are certain that the diskette is fully inserted, you may close the disk drive door. This can be accomplished by applying a slight pressure on the door pulling it back into the direction from which it was originally opened. Once you have closed the door, you will notice a small "swishing" sound. This sound is normal and indicates that the computer is now attempting to load the operating system. Some drives are quieter than others and therefore this noise may not be audible in some cases. After closing the door the following message should appear in the upper left-hand corner of the screen: XXK SUPERBRAIN DOS VER X.X A"? If this message does not appear on the screen, try depressing the two RED keys located on either side of the keyboard. This should reset the terminal and thereby attempt to reload the operating system. If after several seconds, the message does not appear on the screen, try depressing the RED keys several more times. If repeated depressions of the RED keys do not bring up the indicated message, then open the door on the disk drive A and remove the system diskette and check to see if it was properly inserted. It is extremely important that the diskette be in the proper orientation before attempting to load the operating system. If you are unsure as to the proper orientation of the diskette, please contact the representative from whom you originally purchased your equipment. Page 6 INSTALLATION AND OPERATING INSTRUCTIONS (continued) After you have checked the orientation of the diskette try reinserting it into DRIVE A (do NOT insert the system diskette into DRIVE B as it will not load from DRIVE B). Once the diskette has been reinserted, close the door on DRIVE A and depress the RED key. If after several repeated depressions of the RED keys the message XXK SUPERBRAIN DOS VER X.X does not appear on the terminal then contact your dealer. REVIEWING THE SYSTEM DISKETTE Now that you have successfully loaded the System Diskette and Disk Operating System, (DOS), the SuperBrain is ready to accept your disk operating system commands. At this time we will review several of the commands in the operating system. However, it is recommended that you refer to the appropriate section in this Manual for a detailed description of all such commands (Section 4 - Introduction to CP/M Features and Facilities). The most used system command is the DI R command. This command directs the operating system to display the directory of all programs contained on the system diskette. You may enter this command by simply typing the letters DI R on the keyboard. After you have typed these letters, it is necessary to depress the RETURN key. Depressing this key instructs the computer to process the line of data that you have just typed. After you depress the RETURN key the computer should respond by displaying all of the programs on the system diskette. These programs will appear in the following form: A: A: A: A: A: ED.COM DDT.COM ASM.COM LOAD.COM DUMP.COM A: A: A: A: SYSGEN:COM PIP.COM STAT.COM SUBMIT.COM To obtain a better understanding of just what this information means, lets take a look at the first line: A: ED.COM The first letter on this line is a letter A. This tells you that the information following this letter is located on DRIVE A. The colon serves as a separator between the Drive designator ("A") and the file NAME and file TYPE. The file NAME is, in this case, "ED" and the file TYPE is "COM". As such, this line tells the operator that a program called ED (the disk operating system text editor) is located on the "A" drive and is a COM type of file. A more detailed treatment of this information can be found in section 4 of this manual. IMPORTANT NOTE: Some of the disk utility programs have a two digit number suffixed to the File name (i.e. PIP 22). This suffix is used to indicate the actual revision and/or version level of the program. DUPLICATING THE OPERATING DISKETTE Now that you have successfully loaded the Disk Operating System on Drive A, it is important to duplicate this diskette onto another disk. This is necessary in order to preserve the original copy of the diskette and guard against any possible damage to the original media. To generate a copy of the operating system you will first need a NEW BLANK DISKETTE. We recommend an Intertec 1121010 diskette for this purpose. If you do not have any blank diskettes of similar quality, please contact the representative from whom you purchased your equipment. He should be able to supply you with an ample quantity of these diskettes. Once you have located a new blank diskette, insert it into DRIVE B. Follow the procedures outlined in the previous paragraphs regarding the insertion of the operating system diskette. The only difference is that you will be inserting the new blank diskette into DRIVE B. Be sure and leave the system diskette installed on DRIVE A. • Page 7 INSTALLATION AND OPERATING INSTRUCTIONS (continued) Once you have installed the new blank diskette on DRIVE B, you are now ready to "FORMAT" the new diskette. It is necessary to format all new previously unused diskettes before attempting to' transfer data to them. This is necessary because all information is stored on diskettes in what is known as the SOFT SECTORED FORMAT which necessitates the writing of certain information on the disks before user programs can be stored on them. To format the disk in DRIVE B enter the command 'FORMAT' at the keyboard. Remember ·to depress the key marked RETURN after typing the words FORMAT. The operating system should now respond by asking you to select the type of diskette being formatted (S or D). This question asks whether the diskette to be formatted is single sided or double sided. Unless you have ordered our new Quad Density SuperBrain QD, the response to this question should be the letter "S" indicating a single sided diskette. After entering the'S' depress the RETURN key. The operating system will now ask you whether you have a 64K (6) or 32K (3) disk operating system. In most cases, the answer to this question will be 3 (32K). After you have entered the appropriate response to this question the operating system will respond by telling you to place a blank diskette on DRIVE B. Since this has already been done, we are now ready to proceed with formatting the diskette and may do so by entering the letter "F". At this point and time you will hear the disk drive reset to track a and begin the formatting process. When a disk is formatted the read/write head positions to track a and rewrites each track (there are a total of 35 on each diskette). The screen will also display the current track which is being formatted. This number should range from a to 34 for a total of 35 tracks. After the disk has been completely formatted, the operating system will respond by asking you whether to "REBOOT" the operating system or whether you wish to format another disk. If you wish to format another disk, remove the newly formatted disk from DRIVE B and insert a new blank diskette into DRIVE B. You may now proceed to format this new diskette by once again entering the letter "F". If you do not wish to format any more diskettes, simply enter a RETURN. The Operating System should now reload and once again be ready to accept new commands. Since the intent of this procedure was to copy the original disk operating system we are now ready to begin that procedure. This can be accomplished by entering the following command on the keyboard: 2~ V PIP B: =*.* After you have entered the above command at the keyboard depress the return key. The system will now begin to copy all of the programs on DRIVE A over to DRIVE B. As each program is copied, its name will be displayed on the screen. This procedure takes approximately 5 to 10 minutes. After the procedure completes, the control of the operating system will be returned to the user. .• Now that you have completed copying the operating system's programs from the A DR IVE to the B DRIVE it is necessary to copy the disk operating system itself (which is located on tracks 0, 1 and 2) onto the DRIVE B. This may be accomplished by entering the following command at the keyboard: SYSGEN 2..7-_ The SYSGEN command is used to generate an operating system and place it on the desired • Page 8 INSTALLATION AND OPERATING INSTRUCTIONS (continued) disk. Once you have entered this command at the keyboard and typed RETURN, the disk operating system will ask you to select which drive that you want to take the source from. The correct answer to this question is the letter "A". After entering "A" depress the RETURN. The next question the program will ask is where do you want the source to be placed (the destination drive). The correct answer to this is the letter "B" indicating DRIVE B. Once you have entered this, the operating system will be copied from DRIVE A onto DRIVE B. After this process has been completed the operating system will ask you whether you wish to duplicate another copy or to reload the operating system. The correct response is to simply enter a RETURN which will reload the operating system. Once the operating system has been reloaded, you may now remove the master disk operating system in DRIVE A. Once this disk has been removed store it in a safe place as you may need it later to generate additional copies of the disk operating system and its programs. At this point you should have removed the master disk from DRIVE A. Now remove the copy from DRIVE B and reinstall it on DRIVE A and close the door on DRIVE A. After you have completed this, depress the RED reset keys located on either side of the keyboard. This will reset the machine and reload the newly installed operating system off of your new diskette. IMPORTANT: If random garbled information is displayed on the screen at this time, this indicates that you have made an error in the use of the "SYSGEN" program. If this is indeed the case, then remove the new diskette from DRIVE A and reinstall the original master system diskette and repeat the previously outlined procedure for generating a new disk operating system. If you still encounter difficulties, please refer to Section 4 of this manual for more detailed information concerning this procedure. Now that you have successfully completed the generation of a new system diskette please refer to Section 4 of this manual for a complete description of all of the operating systems utility programs (DDT.COM, PIP.COM, SUBMIT.COM, etc.). OPTIONAL SOFTWARE Numerous optional software packages are available for use with your SuperBrain Video Computer System. Currently available directly from Intertec are such software packages as Microsoft's BASIC, FORTRAN and COBOL. If you would like additional information on these packages please contact you r local Intertec representative. NEWLY RELEASED SYSTEM PROGRAMS From time to time, Intertec will be releasing additional 'standard' system programs. Listed below is a brief description of several such programs. A complete description of these and other similar programs can be found in the "software addenda" section of this manual. FORMAT.COM Allows the user to format blank diskettes. This program must be run on all new diskettes which have not been previously formatted on a SuperBrain Video Computer System. It is important to note that although you may have formatted these diskettes on other systems, this does not necessarily imply that they will work on a SuperBrain unless they have been formatted on a computer of this type. Therefore, in order to insure complete compatibility please format all new diskettes on a SuperBrain Video Computer System before using. Page 9 INSTALLATION AND OPERATING INSTRUCTIONS (continued) RAMTST.COM This program runs an extensive test on main memory by writing and reading all possible patterns into all locations in the RAM. This program takes approximately 4 to 5 minutes to complete on 32K machines and 8 to 10 minutes on 64K machines. Since different amounts of RAM are contained in the 32 and 64K machines, we have included two RAM test programs. These are: RAMTST32.COM and RAMTST64.COM which are for testing 32 and 64K versions of the SuperBrain Video Computer System. It is important to note that the 64K RAM test program will not execute properly on a 32K machine. At the end of the RAM test program, the message RAM OK will appear on the screen if the test was completed successfully. If any errors were detected during the test, the computer's bell will turn on and continue in a continuous tone manner until the RED reset key is depressed. If a continuous tone such as this is heard on the computer when executing the RAM test, depress the RED reset and try executing the program several times. If the program continues to produce the audible tone, then please contact the I ntertec Service Department. CONFIGUR.COM This program allows the user to configure all parameters for the RS232 MAIN and AUXILIARY serial port. The selected configuration is then permanently stored on the disk along with the disk operating system. As such, the system will be completely reconfigured each time power is applied to the machine or the RED reset key is depressed. A complete description of all of these programs can be found in the software addenda section of this manual. In addition to the descriptions contained therein, most newly released system programs will contain a description program along with the actual COM file. This program will be in the form of FILE NAME.DES. As an example of such a program would be 'FORMAT.DES'. This program .would contain a description of how the format program operates. Therefore, if you are unable to find an adequate description in the software addenda section of this manual for a program on the disk, please check for a DES version of the program on your disk. If such a program exists, you may display the instructions by simply typing the following command: TYPE FI LENAME.DES. VIDEO DISPLAY FEATURES AND CONTROL CODES Various screen control features are available to the operator through the use of 'ESCAPE' sequences. Among these are the following: Absolute cursor addressing [ESC] [Y] [row] [column] The cursor is positioned to the row and column specified. Refer to the SuperBrain screen layout for specific screen formatting information. Erase to end of line [ESC] [en] [K] Data is erased from cursor position to the end of the current line. Erase to end of page [ESC] [en] [k] Data is erased from cursor position to the end of the screen. Display control characters [ESC] [en] [E] Enable transparent mode. Control characters received are displayed on the screen and are not executed. • Page 10 INSTALLATION AND OPERATING INSTRUCTIONS (continued) Disable control character display [ESC] [U')] [D] Disable the transparent mode. Other features are also available using the 'CONTROL' key. They a-re the following: CONTROL CONTROL CONTROL CONTROL CONTROL CONTROL CONTROL [A] [F] [G] [I] [K] [L] [U] - Home cursor (Row 1, Column 1) - Cursor forward - Ring Bell - Tab - Cursor Up - Clear Screen - Cursor Back MASTER RESET FEATURE A Master Reset of all terminal hardware may be accomplished by depressing the solid colored RED key located on the upper right hand corner of the numeric keypad. It is important to note that on some versions of the SuperBrain, this reset feature may involve the depression of two RED keys. If this is the case on your computer system, you will notice that the two RED keys are located on the right and left corners of the alphameric section of the keyboard. CURSOR CONTROL KEYS There are three to four cursor control keys located on every SuperBrain Video Computer System. These keys are located on the right-hand side of the numeric keypad. If your computer has a single RED key (keyboard layout A), it will be located in the upper right hand corner of the numeric keypad thereby leaving only three cursor position keys. If your computer is configured with two RED keys (keyboard layout B - one RED key located on each side of the alphanumeric keyboard cluster), then you will have a total of four cursor position keys on the right hand side of the numeric keypad. In either case, these keys will transmit codes to any program running on the SuperBrain. These codes may in-turn be interpreted by the program to result in cursor movement on the screen. It is important to know that these keys will not produce cursor movement when you are in the operating system mode. The reason for this is that CP/M does not define any use of cursor positioning on the screen. As such, depression of these keys while in the operating system mode will result in the control codes assigned to the individual keys being displayed as control codes on the screen. Page 11 INTERFACING INFORMATION RS-232-C Serial Interface The following chart illustrates the pinouts for the MAIN and AUXI LlARY serial ports and the direction of signal flow. SUPERBRAIN SERIAL PORT PIN ASSIGNMENTS (For use with Revision 3.0 DOS software or higher and Keyboard/CPU Module Revision 1.0 or higher) MAIN PORT PIN # 1 \3UJ .2 3 4 5 6 7 1"3K'I'\ BLI\ \'1,,):( Gr~! 0\((, \,UHT 15 CRI,) 17 YEL 20 IZE"fJ 22 F;:'I--I_ 241.,\3'[;;1-) ASSIGNMENT GND Transmitted Data Received Data Request to Send Clear to send Data Set Ready GND Transmit Clock Receive Clock Data Terminal Ready Ring Indicator Clock DIRECTION (From SB) (To SB) (From SB) (To SB) (To SB) (To SB) (To SB) (From SB) (ToSB) _ (From 58) AUXI LlARY PORT PIN # 1 2 3 7 20 ASSIGNMENT GND Received Data Transmitted Data GND Data Terminal Ready DIRECTION (To SB) (From SB) (ToSB) Bus Adaptor Interface The SuperBrain contains a Z80 bus interface to the main processor bus. These signals are shown in the chart on the following page. When using this interface, it is recommended that all signals be buffered so as not to excessively load the main processor bus. The external bus should ONL Y be utilized for I/O devices using addresses 80H to FFH. Memory mapped I/O is NOT possible since the SuperBrain is internally configured for 64K of RAM. Page 12 PIN CONNECTIONS FOR EXTERNAL BUS PIN 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 SIGNAL NAME SYSRES* A10 A12 A13 A15 GND A 11 A14 A8 OUT* WR* RD* A9 D4 IN* D7 D1 D6 A0 D3 A1 D5 GND D0 A4 D2 A3 A5 A7 GND A6 +5V A2 DESCRIPTION SPARE System Reset Output, Low During Power Up Initialize or Reset Depressed SPARE Address Output Address Output Address Output Address Output Signal Ground Address Output Address Output Address Output Peripheral Write Strobe Output Memory Write Strobe Output SPARE Memory Read Strobe Output SPARE Address Output Bidirectional Data Bus Peripheral Read Strobe Output Bidirectional Data Bus SPARE Bidirectional Data Bus SPARE Bidirectional Data Bus Address Output Bidirectional Data Bus Address Output Bidirectional Data Bus Signal Ground Bidirectional Data Bus Address Bus Bidirectional Data Bus SPARE Address Output Address Output Address Output Signal Ground Address Output 5 Volt Output (Limited Current) Address Output NOTE: * implies negative (Logical "0"') true, Input or Output Connection points for External Bus • NUMERIC KEYPAD . ESC ! @ # 1 2 .3 TAB Q CTRL CAPS LOCK SHIFT W E i S A Z $ 4 i R D X % 5 & 6 7 T V B H B J N ( ) 9 0 0 I U Y G F C A (with cursor keys) M < [ = I I "- ... : ; > + 1 P L K - 7 / SHIFT -, BACK SPACE LINE FEED I I DEL RETURN HERE IS BREAK· 7 B 9 , RESTART 4 5 6 - -.. 1 2 3 0 E N T E R , t - - - - - - - SPACE BAR SUPERBRAIN KEYBOARD LAYOUT A NUMERIC KEYPAD (with cursor keys) ESC ! 1 TAB Q CTRL CAPS LOCK RESTART t SHIFT @ # 2 3 W $ 4 E S A Z 1\ & . ( ) 5 6 7 B 9 0 R C I Y T F D X % H G V B K J N SPACE BAR 0 I U M + : [ " .. : ; > I I 1 P L < - 7 / SHIFT ~ , BACK SPACE LINE FEED I I BRK DEL RETURN REHERE IS START 7 B 9 I 4 5 6 - 1 2 3 0 I Special "re-start" sequence key used in conjunction with other re-start key on right side of keyboard wi \I re-Ioad SuperBrain's Disk Operating System_ A two-key re-start sequence is used to minimize chance of operator error when system is in operation. Both keys must be depressed simultaneously to reload the operating system. SUPERBRAIN KEYBOARD LAYOUT B II E N T E R .- ... t -I , I SUPERBRAIN SCREEN LAYOUT 1 2 3 4 Ii 8 7 8 II 0 1 2 3 2 4 5 Ii 7 890 ! 1 2 3 4 Ii 8 7 8 9 0.1 2 3 4 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 5 6 9 0 1 2 3 456 7 8 901 "-1' I"I"I-I~I-I' 1'1'1'1+1· H·1/1'1' 1'1' 1'1'1-1'1-1'1·1·1+1' 1'1·1'1'1' 1'1 'l'I'I4ft'1 '1'1 'l'I'I'j 2~ f f.+ W x Y z 7 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 9 0 Cl' -i I 2 I 3 3 " 4 4 It 5 5 ~ 6 6 88- 8 /' 9U- 80 Characters 9 This Screen Format of the lntertube's display area provides an easy method of locating and addressing specific screen positions. 10 24 lines 11 • Using the ESC, Y, r, c command,locate both the row character (r and the column (c = 1 ·80) characters. Example: SCREEN DISPLAY COLUMN ROW 12 + 10 1 - 24) COMMAND 1 (Home) ESC Y SP sp 2 13 = 50 20 ESC Y S ESC Y 3 Q 13 An application programmer may find it helpful to maintain a table of row and column numbers with their respective addressing characters as shown on this Screen Format. This will provide quick and easy access to specific screen positions. 14 15 16 , 14 15 16 J 17 0 18 I 18 111 I 19 201 20 2114~ 21 22 IS 22 I23 2311 :14 11 I t I I I I I I 2 3 4 Ii I I I I I 7 8 II 1 o I I I I I 1 2 3 4 Ii I I I I I I I I I I I I I I I I I I I I I I I I I I I I I 7 8 9 Z 1 2 3 4 Ii 8 7 8 II :I 1 2 3 4 Ii 8 7 8 9 4 0 0 0 1 2 3 4 I I 5 I I I I I I I 6 7 8 9 5 1 2 3 0 I I I I- 4 5 6 " 8 9 6 0 1 2 3 4 5 6 7 8 9 7 1 2 3 0 4 5 6 7 8 9 8 0 '4 '"tl Ql to CD -" 01 Page 16 INTERPRETING THE ASCII CODE CHART The figure below illustrates a conventionally arranged ASCII code chart divided into three sections corresponding to control codes (columns 0 and 1) upper case characters (columns 2,3,4, and 5), and lower case characters (columns 4 and 5) . . . . ~ ~b5 B. It s b 4 ~ 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ~ ~ a a a 0 1 1 1 1 0 0 0 0 1 1 1 1 ~ ~ 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 ~ ·1 0 1 00 10 01 1 1 10 0 1 01 4 5 1 10 111 6 7 , p column ~ a a 1 2 1 3 0 1 4 5 0 1 0 1 6 7 8 9 0 1 10 11 12 13 14 15 0 1 0 1 0 00 0 a NUL SOH STX ETX EOT ENO ACK BEL BS HT LF VT 1 DLE DCI DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS 2 SP ! " /I $ % & ( . ) 3 0 I 2 3 4 5 6 7 8 9 + @ P A B C D E F G H I 0 a A S T b c d U e V f W X Y 9 J Z i j K I: k h < L \ - = M. so GS AS J N 1\ SI US / < ? L m n 0 - 0 FF CA q r s t u v w x y z I I I I I I DEL Control codes are not displayable unless in the transparent mode. Some of these codes affect the state of the terminal when they are received by the display electronics. For example, the code SOH causes the cursor to go to the home position, and code DC2 turns on the printer port. Codes which have no defined function in the Super8rain software are ignored if received. The set of 64 upper case alphanumeric characters is sometimes referred to as "compressed ASCII". If the terminal is set for upper case operation only (CAPS LOCK), lower case alpha characters from the keyboard are automatically translated and displayed as their upper case equivalents (columns 4 and 5). If the DE L code is received, it is ignored. Lower case characters received from the input RS-232C port are displayed as lower case. The seven-bit binary code for each character is divided into two parts in this chart. A four-bit number represents the four least significant bits (81, 82, 83, 84) and a three-bit number represents the three most significant bits (85, 86, 87). The chart above also is divided into 8 columns and 16 rows. This offers two ways of indicating a particular character's code. The character code is indicated as either a seven-bit binary number or as a column/row number in decimal notation. For example, the character M is represented by the binary number 1001101 or the alternative 4/15 notation. Similarly, the control code VT is represented by the code 00001011 or the alternative 0/11 notation. I INTRODUCTION TO CP/M FEATURES & FACILITIES 01 [)~[j~Tfll RESEflRl:tI Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896 AN INTRODUCTION TO CP/M FEATURES AND FACILITIBS COPYRIGHT (c) 1976, 1977, 1978 DIGITAL RESEARCH REVISION OF JANUARY 1978 Copyright (c) 1976, 1978 by Digital Research. All rights reserved. No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system, or translated into any language or computer language, in any form or by any means, "electronic, mechanical, magnetic, optical, chemical, manual or otherwise, without the prior written permission of Digital Research, Post Office Box 579, Pacific Grove, California 93950. Disclaimer Digital Research makes no representations or warranties with respect to the contents hereof and specifically disclaims any implied warranties of merchantability or fitness for any particular purpose. Further, Digital Research reserves the right to revise this publication and to make changes from time to time in the content hereof without obligation of Digital Research to notify any person of such revision or changes. Table of Oontents Page Section 1. INTRODUcrIOO 2. FUNCTIOR~ 2.1. 2.2. • •••••••••••••••••••••••••••••••••••••• 1 DESCRIPTIOO OF CP/M ••••••••••••••••••••• 3 General Command Structure ••••••••••••••••• ~ •• 3 3 File References • • • • • • • • • • • • • • • • • • • • • • • • • • • • e~ 3. SWITCHING DISKS • ••••••••••••••••••••••••••••••••••• 6 4. THE FORM OF BUILT-IN CDMMANOO •••••••••••••••••••••• 4.1. ERA afn cr ••••••••••••••••••••••••••••••••••• 4.2. DIR afn cr .........•......•.•••.• ........... 4.3. REN ufn1=ufn2 cr ............................. :t.4. SAVE n ufn cr •••••••••••••••••••••••••••••••• 4.5. TYPE ufn cr •••••••••••••••••••••••••••••••••• 7 7 8 8 9 9 ~ 5. LINE EDITING AND OUl'pur CDNTROL ••••••••••••••••••••• 11 6. TRlINSIENT CDMMANOO • •••••••••••••••••••••••••••••••• 6.1. STAT cr •••••••••••••••••••••••••••••••••••••• 6.2. As.1 ufn cr • •••••••••••••••••••••••••••••••••• 6.3. LCN) ufn cr •••••••••••••••••••••••••••••••••• 6.4. PIP cr ••••••••••••••••••••••••••••••••••••••• 6.5. ED ufn cr • ••••••••••••••••••••••••••••••••••• 6.6. SYSGEN cr •••••••••••••••••••••••••••••••••••• 6.7. SUBMIT ufn parm#l ••• parm#n cr •••••••••••••• 6.8. DUMP ufn cr ......•.•........................ 6.9. IDVCPM cr •••••••••••••••••••••••••••••••••••• 12 13 16 17 18 25 7. BOOS ERROR MESSAGES 33 8. OPERATION OF CP/M ON THE MOO . •••••••••••••••••••••••••••••••• • •••••••••••••••••••••• 27 28 30 30 34 • 1. INTRODUcrION. CP/M is a ITOnitor control program for microcomputer system development which uses IBM-compatible flexible disks for backup storage. using a computer mainframe based u};X:>n Intel's 8080 microcomputer, CP/M provides a general environment for program construction, storage, and editing, along with assembly and J;.t'ogram check-out facilities. An im};X:>rtant feature of CP/M is that it can be easily altered to execute with any computer configuration which uses an Intel 8080 (or Ziloq Z-80) Central Processing Unit, and has at least 16K bytes of main rrernory with up to four IBM-compatible diskette drives. A detailed discussion of the ITOdifications required for any particular hardware environment is given in the Digital Research doclUllent entitled "CP/M System Alteration Guide." Although the standard Digital Research version operates on a single-density Intel MIS 800, several different hardware manufacturers support their own input-output drivers for CP/M. The CP/M m::mitor provides rapid access to programs through a The file subsystem supports a named comprehensive file management package. file structure, allowing dynamic allocation of file space as well as sequential and random file access. Using this file system, a large number of distinct programs can be stored in both oource and machine executable form. CP/M also sup};X:>rts a powerful context editor, Intel-compatible assembler, and debugger subsystems. Optional software includes a powerful Intel-compatible macro assembler, symbolic debugger, along with various high-level languages. When coupled with CP/M's Console Command Processor, the resulting facilities equal or excel similar large computer facilities. CP/M is logically divided into several distinct parts: BIOS Basic I/O System (hardware dependent) BOOS Basic Disk Operating System CCP Console Command Processor TPA Transient Program Area The BIOS provides the primitive operations necessary to access the diskette drives and to interface standard peripherals (teletype, CRr, Paper Tape Reader/Punch, and user-defined peripherals), and can be tailored by the user for any particular hardware environment by "patching" this JX>rtion of CP/M. The BOOS provides disk management by controlling one or rrore disk drives containing independent file directories. The BOOS implements disk allocation strategies \'.hich provide fully dynamic file construction while minimizing head rrovement across the di sk dur ing access. Any particular· file may contain any number of records, not exceeding the size of any single disk. In a standard CP/M system, each disk can contain up to 64 distinct files. The 1 • BIXlS has entry p::>ints \\bich include the following can be p[ogrammatically accessed: pI' imi tive operations which SEARCH Look for a particular disk file by name. OPEN Open a file for further operations. CLOSE Close . RENAME a file after pcocessing. Change the name of a particular file • READ Read a record from a particular file. WRITE write a record onto the disk. SELEcr Select a particular disk drive for further operations. The CCP provides symbolic interface between the user's console and the remainder of the CP/M system. The CCP reads the console device and processes commands \\bich include listing the file directory, pr inting the contents of files, arid controlling the operation of transient programs, such as assemblers, editors, and debuggers. The standard commands which are available in the CCP are listed in a following section • . The last s~ment of CP/M is the area called the Transient Program Area (TPA) • The TPA holds programs which are loaded from the disk under command of the CCP. Durinq p:-ogram editing, for example, the TPA holds the CP/M text edi tor ITB.chine code and data areas. Similarly, programs created under CP/M can be checked out by loading and executing these programs in the TPA. It should be mentioned that any or all of the CP/M comp::ment subsystems can be "overlayed" by an executing program. That is, once a user's program is loaded into the TPA, the CCP, BOOS, and BIOS areas can be used as the program's data area. A "bootstrap" loader is programmatically accessible whenever the BIOS p::>rtion is not overlayed: thus, the user p[ogram need only branch to the bootstrap loader at the end of execution, and the complete CP/M monitor is reloaded from disk. It should be reiterated that the CP/M operating system is partitioned into distinct nodules, including the BIOS p::>rtion \\tlich defines the hardware environment in \\bich CP/M is executing. Thus, the standard system can be easily nodified to any non-standard environment by dlanging the peripheral drivers to handle the custom system. 2 2. ruN:TIONAL DESCRIPI'ION OF CP/M. The user interacts with CP/M primarily through the CCP, \>thich reads and interprets commands entered through the console. In general, the CCP addresses one of selTeral disks \>thich are online (the standard system crldresses up to four different disk drives). These disk drives are labelled A, B, C, and D. A disk is "logged in" if the CCP is currently crldressing the disk. In order to clearly irrlicate \>thich disk is the currently logged disk, the CCP always prompts the ~erator wi th the disk name followed by the symbol ")" indicatinj that the CCP is ready for another canmand. Upon initial start up, the CP/M system is brought in from disk A, and the CCP displays the message xxK CP/M VER m.m where xx is the rremory size (in kilobytes) which this CP/M system manages, and m.m is the CP/M version number. All CP/M systems are initially set to operate in a 16K .memory space, but can be easily reconfigured to fit any memory size on the host system (see the IDVCPM transient command). Followinj system signon, CP/M automatically logs in disk A, prompts the user wi th the symbol "A)" (indicating that CP/M is currently addressing disk "A"), and waits for a command. The commands are implemented at two levels: built-in commands and transient commands. 2.1. GENERAL CDMMAND STRUCI'URE. Built-in commands are a part of the CCP program itself, \>thile transient commarrls are loaded into the TPA from disk and executed. The built-in commands are ERA Erase specified files. DIR List file names in the directory. REN Rename the specified file. SAVE Save memory contents in a file. TYPE Type the contents of a file on the logged disk. Nearly all of the commands reference a particular file or group of files. form of a file reference is specified below. The 2.2. PI LE REFERENCES. A file reference identifies a particular file or group of files on a particular disk attached to CP/M. These file references can be either "unambigoous" (ufn) or "ambiguous" (afn). An unambiguous file reference uniquely identifies a single file, \>thile an ambiguous file reference may be 3 satisfied by a number of different files. File references consist of two parts: the primary name and the secondary name. Although the secondary name is optional, it usually is generic; that is, the secondary name "ASM," for example, is used to denote that the file is an assembly language source file, mile the primary name distinguishes each particular source file. The two names are separated by a "." as shown below: PPPPPPPP.sss where pppppppp represents the lX'irnary name of eight characters or less, and sss is the secondary nane of no trore than three characters. As Irentioned above, the name pppppppp is also allowed am is Equivalent to a secondary name consisting of three blanks. The characters used in s~cifying an unambiguous file reference cannot contain any of the special characters [ <>.,;:= ? * [ ] ] while all alphanumerics and remaining s~cial characters are allowed. An ambigoous file reference is used for directory search and pattern matching. The form of an ambiguous file reference is similar to an unambigoous reference, except the symbol "?" may be interspersed throughout the 12' irnary and secondary names. In various canrnands throughout CP/M, the "?" symbol matches any character of a file name in the "?" position. Thus, the arnbigoous reference X?Z.C?M is satisfied by the unarnbigoous file names XYZ.OOM and X3Z.CAM Note that the ambigoous reference *.* is Equivalent to the ambigoous file reference ............ ???????? ??? while 4 and PPPPPPPP.* *.sss are abbreviations for PPPPPPPP.??? and ???????? .sss respectively. As an example, DIR *.* is interpreted by the CCP as a canmand to list the names of all disk files in the directory, While DIR X.Y searches only for a file by the name X.Y Similarly, the command DIR X?Y.C?M causes a search for all (unambiguous) file names on the disk Which satisfy this ambiguous reference. The fOllowing file names are valid unambiguous file references: x XYZ GAMMA X.Y XYZ.CDM GAMMA. I As an crlded convenience, the programmer can generally specify the disk drive name along with the file name. In this case, the drive name is given as a letter A through Z follow=d by a colon (:). The specified drive is then "logged in" before the file operation occurs. Thus, the fOllowing are valid file names with disk name prefixes: A:X.Y B:XYZ C:GAMMA Z:XYZ .CDM B:X.A?M C:*.ASM It should also be noted that all alphabetic lower case letters in file and drive names are always translated to upper case \>A1en they are T;rocessed by the CCP. 5 3. SWITCHING DISKS. The cperator can switch the currently logged disk by typing the disk drive nane (A, B, C, or D) followed by a colon (:) when the CCP is waiting for console irput. Thus, the sequence of pranpts and canrnands shown below might occur after the CP/M system is loaded from disk A: 16K CP/M VER 1.4 A>DIR List all files on disk A. SAMPLE AStf SAMPLE PRN A>B: Switch to disk B. B>DIR *.ASM List all "ASM" files on B. DUMP FILES B>A: Switch back to A. 6 4. THE FORM CF BUILT-IN CDMWoNOO. The file arrl device reference forms described above can now be used to fully st:ecify the structure of the built-in canmands. In the description below, assume the followin;J abbreviations: ufn unambiguous file reference afn ambiguous file reference cr carriage return Fur ther, recall that the CCP always translates lower case characters to u];:.Per case characters internally. Thus, lower case alphabetics are treated as if they are upper case in command names arrl file references. 4.1 ERA afn cr The ERA (erase) canmand ranoves files fran the currently logged-in disk (i.e., the disk nane currently pranpted by CP/M precedin;J the ">"). The files which are erased are toose \\hich satisfy the ambiguous file reference afn. The followil'lJ examples illustrate the use of ERA: ERA X.Y The file named X.Y on the currently logged disk is ranoved fran the disk directory, and the space is returned. ERA X.* All files wi th pr imary name X are removed fran the current disk. ERA *.ASM All files. wi th secondary name ASM are removed fran the current disk. ERA X?Y.C?M All files on the current disk Which satisfy the ambiguous reference X?Y.C?M are deleted. Erase all files on the current disk (in this case the CCP pranpts the console with the message "ALL FILES (Y!N)'?" Which requires a Y response before files are actually removed). ERA B:*.PRN All files on drive B Which satisfy the ambiguous reference ????????PRN are deleted, independently of the currently logged disk. 7 • 4.2. OIR afn cr The orR (directory) canmand causes the names of all files \>tlich satisfy the anbiguous file name afn to be listed at the console device. As a s};:ecial case, the canmand OIR lists the files on the currently logged disk (the canmand "OrR" is Equivalent to the canmand "OIR *.*"). Valid orR canmands are shown below. orR X.Y OIR X?Z.C?M orR ??Y Similar to other CCP canmands, the afn can be J;receded by a drive name. The followirq OIR canmands cause the selected drive to be crldressed before the directory search takes place. OIR B: orR B:X.Y OIR B:*.A?M If no files can be found on the selected diskette \>tlich satisfy the directory request, then the IIEssage "Nor FOUND" is ty};:ed at the console. 4.3. REN ufnl=ufn2 cr The REN (rename) canmand allows the user to change the names of files on disk. The file satisfyin;J' ufn2 is chan;J'ed to ufnl. The currently logged disk is assumed to contain the file to rename (ufnl). The CCP also allows the user to ty};:e a left-directed arrow instead of the equal sign, if the user' s console supports this graphic character. Examples of the REN canmand are REN X.Y=Q.R The file Q.R is changed to X. Y. REN XYZ.OOM=XYZ.XXX The file XYZ.XXX is changed to XYZ.(X)M. The operator can p::ecede either ufnl or ufn2 (or both) by an optional drivecrldress. Given that ufnl is preceded by a drive name, then ufn2 is assumed to exist on the same drive as ufnl. Similarly, if ufn2 is J;receded by a drive nane, then ufnl is assumed to reside on that drive as ~ll.~;~rf both ufnl am ufn2 are preceded by drive names, then the same drive must be 8 sp:!cified in both cases. The following REN canmands illustrate this format. REN A:X.ASM = Y.ASM The file Y.ASM is changed to X.ASM on drive A. REN B:ZAP.BAS=ZOT.BAB The file ZOT.BAB is changed to ZAP.BAS on drive B. REN B:A.ASM = B:A.BAK The file A.BAK is renamed to A.ASM on drive B. If the .file ufnl is already IXesent, the REN canmand will respond with ~:~ the error "FILE EXISTS" and not p.=rform the change. If ufn2 does not exist on the sp2cified diskette, then the rressaqe "NOI' roUND" is pr inted at the console. 4.4. SAVE n ufn cr The SAVE canmarrl places n pages (256-byte blocks) onto disk fran the TPA and nanes this file ufn. In the CP/M distribution system, the TPA starts at HH!JH (hexadecimal), mich is the second page of memory. Thus, if the user's program occupies the area fran l00H through 2FFH, the SAVE command must specify 2 pages of rremory. The machine code file can be subsequently loaded and executed. Examples are: SAVE 3 X.CDM COpies l00Hthrough 3FFH to X.CDM. SAVE 40 COpies l00H through 28FFH to Q (note that 28 is the page count in 28FFH, and that 28H = 2*16+8 = 40 decimal). SAVE 4 X.Y Q COpies l00H through 4FFH to X.Y. The SAVE canmand can also sp2cify a disk drive in the afn p::>rtion of the canmand, as shown below. SAVE 10 B:ZOT.CX)M Copies 10 pages (100H through 0AFFH) to the file ZOT.OOM on drive B. 4.5. TYPE ufncr 'l~ The TYPE canmand displays the contents of the ASCII source file ufn on I'~'\,the rurrently logged disk at the console device. Valid TYPE canrnands are TYPE X.Y 9 ~'f 'Ii TYPE X.PJ:M TYPE XXX The TYPE canrnarrl expands tabs (clt-I characters), assumming tab lX>sitions are set at fNery eighth colUIm. The ufn can also reference a drive name as shown below. TYPE B:X.PRN The file X.PRN from drive B is displayed. Ie, 5. LINE EDITING AND OUl'PUl'rtion of CP/M. Thus, the logical RDR: device, for example, could actually be a high speed reader, Teletype reader, or cassette tape. In order to allow rome flexibility in device naming and assignment, several physical devices are defined, as shown below: 14 T'lY: Teletype device (slow speed console) CRr: Cathode ray tube device (high speed console) BAT: Batch processing (console is current RDR:, output qoes to current LST: device) UCl: User-defined console Pl'R: Paper tape reader (high speed reader) URI: User-defined reader #1 UR2: User-defined reader #2 Pl'P: Paper tape punch (high speed punch) UPl: User-defined punch #1 UP2: User-defined punch #2 LPl': Line printer ULl: user-defined li.st device #l • It must be emphasized that the physical device names mayor may not actually corres~nd to devices which the names imply. That is, the PTP: device may be implemented as a cassette write operation, if the user wishes. The exact corres~ndence and driving subroutine is defined in the BIOS portion of CP/M. In the standard distribution version of CP/M, these devices correspond to their names on the MDS 800 development system. The p:>ssible logical to physical device assignments can be displayed by typing STAT VAL: cr 7~'" The STAT pr ints the p::>ssible values which can be taken on for each logical device: fiN. RDR: PUN: LST: = TTY: = TTY: = TTY: = TTY: CRr: Pl'R: PI'P: CRr: BAT: URI: UPl: LPI': UCl: UR2: UP2: ULl: In each case, the logical device shown to the left can take any of the four physical assignments shown to the right on each line. The current logical to physical mapping is displayed by typing the command STAT lEV: cr 15 ~:( which produces a listing of each logical device to the left, and the current corresponding physical device to the right. For example, the list might appear as follows: CON: = CRr: RDR: = URI: PUN: = PI'P: LST: ..;!~ ,1 = TTY: The current logical to physical device assignment can be changed by typing a STAT command of the form STAT ldl = pdl, ld2 = pd2 , ••• , ldn = pdn cr where ldl compatible the "VAL:" change the through ldn are logical device names, and pdl through pjn are physical device names (i.e., ldi and pji appear on the same line in canmand shown above). The following are valid STA'I' canrnands which current logical to physical device assignments: STAT CDN:=CRl': cr STAT PUN: = TTY: ,IST:=LPl':, RDR:=TTY: cr 6.2. ASM ufn cr The ASM canrnand loads and executes the CP/M 8080 assembler. The ufn specifies a s::>urce file containing assembly language statements where the secondary name is assumed to be ASM, and thus is not specified. The following ASM canmands are valid: ASM X ASM GAMMA The two-pass assembler is automatically executed. If assembly errors occur during the second pass, the errors are printed at the console. ~~! 1.'+ The assembler produces a file x.PRN where x is the pr imary name specified in the ASM command. The PRN file contains a listing of the source program (with imbedded tab characters if present in the s::>urce program), along with.the machine code generated for each statement and diagnostic error messaqes, if any. The PRN file can be listed 16 at the console usi~ the TYPE canmand, or sent to a }:eripheral device using PIP (see the PIP canmand structure below). Note also that the PRN file contains the original s:>urce program, augmented by miscellaneous assembly information in the leftIoost 16 columns (program crldresses and hexadecimal machine code, for example). Thus, the PRN file can serve as a backup for the original source file: if the s:>urce file is accidently removed or destroyed, the· PRN file can be edited (see the ED operator's guide) by removing the leftIoost 16 characters of each line (this can be done by issuing a single editor "nacro" canmand). The resulting file is identical· to the original source file and can be renamed (REN) fran PRN to ASM for subsequent editing and assembly. The file x.HEX is also produced \'thich contains 8080 machine language in Intel "hex" format sui table for sli:>sequent loading and execution (see the LON) canrnand). For canplete details of CP/M's assembly language program, see the "CP/M Assembler language (ASM) User's Guide." Similar to other transient canrnands, the S)urce file for assembly can be taken fran an a..ternate disk by prefixing the assembly language file name by a disk drive name. Thus, the canmand ASM B:ALPHA cr loads the assembler fran the currently logged drive and operates up:m the source program ALPHA.ASM on drive B. The HEX and PRN files are also placed on drive B in this case. 6.3. LQl\J) ufn cr The LON) canmand reads the file ufn, \\hich is assumed to contain "hex" format machine code, and produces a memory image file \'thich can be subsequently executed. The file name ufn is assumed to be of the form x.HEX and thus only the name x need be specified in the canmand. creates a file named x.CDM which narks it as containing nachine executable code. . The file is actually loaded into memory and executed \'then the user types the file name x inunediately after the pranptingcharacter ")" printed by the CCP. In general, the .CCP reads the name x following the pranpting character and looks for a built-in fmction name. If no fmction name is found, the CCP searches the system disk directory fora file by the name 17 x.Q)M If found, the machine code is loaded into the TPA, and the program executes. Thus, the user need only LOAD a hex file once: it can be subseg:uent1y executed any number of times by simply typing the primary name. In this way, the user can "invent" new ccrnrnands in the CCP. (Initialized disks contain the transient canmands as CDM files, which can be deleted at the user's option.) The operation can take place on an alternate drive if the file name is prefixed by a drive name. Thus, LOAD B:BETA brings the LOAD program into the TPA from the operates upon drive B after execution begins. currently logged disk and It must be noted that the BETA.HEX file must contain valid Intel format hexadecimal machine code records (as produced by the ASM program, for example) which beqin at 100H, the beginning of the TPA. Further, the addresses in the hex records must be in ascending order: gaps in unfilled memory regions are filled with zeroes by the LOAD ccrnrnand as the hex records are read. Thus, ?~~LOAD must be used only for creating CP/M standard "Q)M" files which operate in the TPA. Proqrams v.hich occupy regions of memory other than the TPA can be loaded under DDI'. 6.4. PIP cr PIP is the CP/M Peripheral Interchange Program which implements the basic media conversion operations necessary to load, print, punch, copy, and combine disk files. The PIP program is initiated by typing one of the following forms (1) PIP cr (2) PIP "canmand line" cr In both cases, PIP is loaded into the TPA and executed. In case (1), PIP reads command lines directly from the console, prompted with the "*,, character, until an empty command line is typed (i.e., a single carriage return is issued by the operator). Each successive ccrnrnand line causes rome media conversion to take place according to the rules shown below. Form (2) of the PIP command is equivalent to the first, except that the single command line given with the PIP command is automatically executed, and PIP terminates immediately wi th no further prompting of the console for input command lines. The form of each command line is destination = source#l, rource#2, ••• , rource#n cr where "destination" is the file or peripheral device to receive the data, and 18 "oource#l, ••• , source#n" represents a series of one or rrore files or devices which are copied from left to right to the destination. When multiple files are given in the canmand line (i.e, n > 1), the individual files are assumed to contain ASCII characters, with an assumed CP/M end-of-file character (ctl-Z) ~t the end of each file (see the 0 parameter to override this assumption). The equal symbol (=) can be replaced by a left-oriented arrow, if your console supports this ASCII character, to improve readability. Lower case ASCII alphabetics are internally translated to upper case to be consistent with CP/M file and device name conventions. Finally, the -total command line length cannot exceed 255 characters (ctl-E can be used to force a physical carriage return for lines Which exceed the console width) • The destination and source elements can be unambiguous references to CP/M source files, with or without a precedirtJ disk drive name. That is, any file can be referenced with a freceding drive name (A:, B:, C:, or D:) which defines the particular drive Where the file may be obtained or stored. When the drive name is not included, the currently logged disk is assumed. Further, the destination file can also appear as one or rrore of the oource files, in which case the source file is not altered until the entire concatenation is canplete. If the destination file already exists, it is removed if the command line is properly formed (it is not removed if an error condi tion arises). The following canmand lines (with explanations to the right) are valid as input to PIP: x = Y cr Copy to file X from file Y, Where X and Yare unambiguous file names; Y remains unchanged. X = Y,Z cr Concatenate files Y and Z and copy to file X, with Y and Z unchanged. ·X.ASM=Y.ASM,Z.ASM,FIN.ASM cr Create the file X.ASM from the concatenation of the Y, Z, and FIN files with type ASM. NEW.ZOT = B:OLD.ZAP cr Move a copy of OLD.ZAP from drive B to the currently logged disk; name the file NEW.ZOT. B:A.U = B:B.V,A:C.W,D.X cr Concatenate file B. V from drive B with C.W from drive A and D.X. from the logged disk; create the file A.U on drive B. For rrore convenient use, PIP allows abbreviated commands for transferring files between disk drives. The abbreviated forms are 19 • PIP x:=afn cr PIP x:=y:afn cr PIP ufn = y: cr PIP x:ufn = y: cr The first form copies all files from the currently loqged disk which satisfy the afn to the same file names on drive x (x = A••• Z) • The second form is equivalent to the first, where the source for the copy is drive y (y = A••• Z) • The third form is equivalent to the command "PIP ufn=y: ufn cr" which copies the file given by ufn from drive y to the file ufn on drive x. The fourth form is equivalent to the third, where the source disk is explicitly given by y. Note that the source and destination disks must be different in all these cases. If an afn is specified, PIP lists each ufn which satisfies afn as it is beinq copied. If a file exists by the same name as destination file, it is renoved uron successful completion of the copy, replaced by the copied file. The followinq operations: PIP commands qive examples of valid disk-to-disk of the the and copy B:=*.CDM cr Copy all files which have the secondary name "ooM" to drive B from the current drive. A:=B:ZAP.* cr Copy all files which have the primary name "ZAP" to drive A from drive B. ZAP.ASM=B: cr Equivalent to ZAP.ASM=B:ZAP.ASM B:ZOT.mM=A: cr Equivalent to B:ZOT.OOM=A:ZOT.ooM B:=GAMMA.BAS cr Same as B:GAMMA.BAS=GAMMA.BAS B:=A:GAMMA.BAS cr Same as B:GAMMA.BAS=A:GAMMA.BAS PIP also allows reference to physical and logical devices which are attached to the CP/M system. The device names are the same as given under the STAT command, along with a number of specially named devices. The ICXJical devices given in the STAT command are ooN: (console), RDR: (reader), PUN: (punch), and IST: (list) while the physical devices are 20 TTY: (console, reader, pLmch, CRr: (console, or list) , PI'R: (reader) , URI: (reader), PI'P: (pLmch) , UPl: (pLmch), UIJ.: (list) LPl': (list) , or list) UCl: (console) UR2: (reader) UP2: (punch) (Note that the "BAT:" physical device is not included, since this assignment is used only to indicate that the RDR: and 1ST: devices are to be used for console input/output.) The RDR, 1ST, PUN, and OON devices are all defined wi thin the BIOS portion of CP/M, and thus are easily altered for any particular I/O system. (The current physical device mapping is defined by IOBYI'E; see the "CP/M Interface Guide" for a discussion of this function). The destination device must be capable of receiving data (i.e., data cannot be sent to the pLmch), and the source devices must be capable of generating data (i.e., the LST: device cannot be read). • The additional device names which can be used in PIP commands are NUL: Send 40 "nulls" (ASCII 0 's) to the device (this can be issued at the end of pLmched output). EOF: Send a CP/M end-of-file (ASCII ctl-Z) to the destination device (sent automatically at the end of all ASCII data transfers through PIP) • INP: Srecial PIP input source which can be "patched" ~ into the PIP program itself: PIP gets the input data character-by-character by CALLing location 103H, with data returned in location 109H (parity bit must be zero). \)St;P it\) (' ON (l &>4",. COM fH,~<:r Tt'Q.()4.rQ our: Srecial PIP output destination which can be patched into the PIP program: PIP CALLs location 106H with data in register C for each character to transmit. Note that locations 109H throuqh IFFH of the PIP memory image are not used and can be replaced by special purpose drivers using DDT (see the DDT operator's manual). PRN: Same as LST:, except that tabs are expanded at every eighth character position, lines are numbered, and page ejects are inserted every 60 lines, with an initial eject (same as [tBnp]). File and device names can be intersrersed in the PIP commands. In each case, the sp:!cific device is read Lmtil end-of-file (ctl-Z for ASCII files, and a real end of file for non-ASCII disk files). Data from each device or file is concatenated from left to riqht until the last data source has been 21 -Ie r. read. The destination device or file is written using the data from the source files, and an end-of-file character (ctl-Z) is appended to the result for ASCII files. Note if the destination is a disk file, then a temtx>rary file is created ($$$ secondary name) which is chanqed to the actual file name only up::m soccessful completion of the copy. Files with the extension "CDM" are always .assumed to be non-ASCII. The copy operation can be aborted at any time by depressing any key on the keyboard (a rubout suffices). PIP will respond with the message "AOOro'EDII to indicate that the operation was not completed. Note that if any operation is aborted, or if an error occurs dur inq processing, PIP removes any };Ending commands which were set up while usinq the SUBMIT command. It sh:>uld also be noted that PIP performs a sp:cial function if the destination is a disk file wi. th type "HEX" (an Intel hex formatted machine code file), and the source is an external p:ripheral device, such as a paper tape reooer. In this case, the PIP program checks to ensure that the source file contains a {Xoperly formed hex file, with legal hexadecimal values and checksum records. When an invalid input record is found, PIP reports an error message at the console and waits for corrective action. It is usually sufficient to open the reader and rerun a section of the tape (pull the tape back about 20 inches). When the tape is ready for the re-read, type a single carriage return at the console, and PIP will attempt another read. If the tape lX'sition cannot be properly read, simply continue the read (by typing a return followin:J the error message), and enter the record manually wi th the ED program after the disk file is constructed. For convenience, PIP allows the end-of-file to be entered fran the console if the source file is a RDR: device. In this case, the PIP program reads the device and rronitors the keyboard. If ctl-Z is typed at the keyboard, then the read operation is terminated normally. Valid PIP commands are shown below. PIP 1ST: = X.PRN Copy X.PRN to the 1ST device and terminate the PIP program. cr PIP cr *CDN:=X.ASM,Y.ASM,Z.ASM Start PIP for a sequence of commands (PIP prompts with "*"). Concatenate three ASMfiles and copy to the CON device. cr *X.HEX=CON:,Y.HEX,PTR: cr Create a HEX file by readinq the CDN (until a ctl-Z is typed), followed by data fran Y.HEX, followed by data from PTR until a ctl-Z is encountered. *cr Single carriage return stops PIP. 22 Send 4~ nulls to the punch device: then copy the X.ASM file to the punch, followed by an end-of-file (ctl-Z) and 4~ more null characters. PIP PUN:=NUL:,X.ASM,EOF:,NUL: cr The user can also specify one or trore PIP parameters, enclo!:!ed in left and right square brackets, separated by zero or IlPre blanks. Each parameter affects the copy operation, and the enclosed list of parameters must immediately follow the affected file or device. Generally, each parameter can be followed by an q:>tional decimal integer value (the Sand 0 parameters are exceptions). The valid PIP parameters are listed below. B Block mode transfer: data is buffered by PIP until an ASCII x-off character (ctl-S) is received from the source device. This allows transfer of data to a disk file from a continuous reading device, such as a cassette reader. Upon receipt of the x-off, PIP clears the disk buffers and returns for trore input data. The amount of data which can be buffered is dependent upon the memory size of the host systew (PIP will issue an error message if the buffers overflow). On Delete characters which extend past column n in the transfer of data to the destination from the character source. This parameter is used IlPst often to truncate long lines which are sent to a (narrow) printer or console device. E Echo all transfer operations to the console as they are being performed. F Fi! ter form feeds from the file. All imbedded form feeds are removed. The P parameter can be used simultaneously to insert new form feeds. H Hex data transfer: all data is checked for proper Intel hex file format. Non-essential characters between hex records are removed during the copy operation. The console will be prompted for corrective action in case errors occur. I Ignore 1t:~~1t records in the transfer of Intel hex format file (the I parameter automatically sets the H parameter). L Translate upper case alphabetics to lower case. N Add line numbers to each line transferred to the destination starting at one, and incrementing by 1. Leading zeroes are suppressed, and the number is followed by a colon. If N2 is specified, then leading zeroes are included, and a tab is inserted followirg the number. The tab is expanded if T is 23 set. o Object file (non-ASCII) transfer: file is ignored .. Pn Include page ejects at every n lines (with an initial page eject). If n = 1 or is excluded altogether, page ejects occur every 60 lines. If the F parameter is used, form feed suppression takes place before the new page ejects are inserted. Qstz Quit copying from the source device or file when the string s (terminated by ctl-Z) is encountered. Sstz Start copying from the source device when the string s is encountered (terminated by ctl-Z). The Sand Q parameters can be used to "abstract" a particular section of a file (such as a subroutine). The start and quit strings are always included in the copy operation. the normal CP/M end of NOTE - the strings following the s and q parameters are translated to upper case by the CCP if form (2) of the PIP canmand is used. Form (1) of the PIP invocation, however, does not perform the automatic upper case translation. (1) PIP cr (2) PIP "command line" cr Tn Expand tabs (ctl-I characters) to every nth column during the transfer of characters to the destination from the source. U Translate lower case alphabetics to upper case during the the copy operation. V verify that data has been copied correctly by rereading after the write operation (the destination must be a disk file) • Z Zero the parity bit on input for each ASCII character. The following are valid PIP commands which specify parameters in the file transfer: PIP X.ASM=B: [v] cr Copy X.ASM from drive B to the current drive and verify that the data was properly copied. PIP LPT:=X.ASM[ntSu] cr Copy X.ASM to the LPT: device; number each line, expand tabs to every eighth column, and translate lower case alphabetics to upper case. 24 PIP PUN:=X.HEX[i] ,Y.ZOT[h] cr First copy X.HEX to the PUN: device and ignore the trailing ":00" record in X.HEX: then continue the transfer of data by reading Y.ZOT, which contains hex records, including any ":00" records which it contains. PIP X.Lm = Y.ASM [ sSUBRl:t z qJMP L31'z ] cr Copy from the file Y.ASM into the file X.LIB. Start the copy when the string "SUBRl:" has been found, and quit copyin:} after the string "JMP L3" is encountered. PIP PRN:=X.ASM[p50] 6.5. Send X.ASM to the 1ST: device, with line numbers, tabs expanded to every eighth column, and page ejects at every 50th line. Note that nt8p60 is the assumed parameter list for a PRN file: p50 overrides the default value. ED ufn cr The ED program is the CP/M system context editor, ¥.bich allows creation and alteration of ASCII files in the CP/M environment. Complete details of operation are given the ED user's manual, "ED: a Context Editor for the CP/M Disk System." In general, ED allows the operator to create and operate up:m source files \\hich are organized as a sequence of ASCII characters, separated by end-of-line characters (a carriage-return line-feed sequence). There is no practical restriction on line length (no single line can exceed the size of the worki~ memory), \\hich is instead defined by the number of characters typed between cr's. The ED program has a number of commands for character string searching, replacement, and insertion, ¥.bich are useful in the creation and correction of programs or text files Lmder CP/M. Although the CP/M has a limited memory work space area (approximately 5000 characters in a 16K CP/M system), the file size ¥.bich can be edited is not limited, since data is easily "paged" through this work area. Upon initiation, ED creates the s:p=cified source file, if it does not exist, and opens the file for access. The programmer then "appends" data from the oource file into the work area, if the source file already exists (see the A canrnand), for editing. The appended data can then be displayed, altered, and written from the work area back to the disk (see the W command). Particular p:>ints in the program can be automatically paged and located by context (see the N command), allowin:} easy access to particular }X)rtions of a large file. Given that the operator has typed ED X.ASM cr 25 the ED program creates an intermediate work file with the name X.$$$ to hold the edited data during the ED run. Upon canpletion of ED, the X.ASM file (original file) is renamed to X.BAK, and the edited work file is renamed to X.ASM. Thus, the X.BAR file contains the original (unedited) file, and the X.ASM file contains the newly edited file. The operator can always return to the previous version of a file by ranoving the fOC)st recent version, and renamim the .,;revious version. Suppose, for example, that the current X.ASM file was improperly edited: the sequence of CCPI camnand shown below would reclaim the backup file. DIR X.* Check to see that BAR file is available. ERA X.ASM Erase fOC)st recent version. REN X.ASM=X. BAK Rename the BAK file to ASM. Note that the operator can abort the edit at any };X)int (reboot, };X)wer failure, ctl-C, or Q canmand) without destroying the original file. In this case, the BAR file is not created, and the original file is always intact. The ED program also allows the user to "ping-pong" the oource and create backup files between two disks. The form of the ED canmand in this case is ED ufn d: where ufn is the nane of a file to edit on the currently logged disk, and d is the nane of an alternate drive. The ED program reads and processes the oource file, and writes the new file to drive d, using the name ufn. Upon canpletion of processing, the original file becomes the backup file. Thus, if the operator is addressing disk A, the following canmand is valid: ED X.ASM B: which edits the file X.ASM on drive A, creating the new file X.$$$ on drive B. Upon canpletion of a successful edit, A:X.ASM is renamed to A:X.BAK, and B: X. $$$ is renamed to B: X.ABM. For user convenience, the cur rentl y logged disk becanes drive B at the end of the edit. Note that if a file by the name B:X.ASM. exists before the editing begins, the message FILE EXISTS is printed at the console as a precaution aqainst accidently destroying a source file. In this case, the operator must first ERAse the existing file and then restart the edit operation. 26 Similar to other transient canmands, editing can take place on a drive different fran the OJrrently l03ged disk by preceding the rource file name by a drive mme. Examples of valid edit requests are soown below ED A:X.ASM Edit the file X.ASM on drive A, with new file and backup on drive A. ED B:X.ASM A: Edit the file X.ASM on drive B to the temporary file X.$$$ on drive A. On termination of editing, change X.ASM on drive B to X.SAK, and chanqe X.$$S on drive A to X.ASM. 6.6. SYSGEN cr The SYSGEN transient command allows generation of an initialized diskette containing the CP/M operating system. The SYSGEN program prompts the console for commands, with interaction as shoWn below. SYSGEN cr Initiate the SYSGEN program. SYSGEN VERSION m.m SYSGEN sign~on message. SOURCE IlUVE NAME (OR RETURN TO SKIP) Respond with the drive name (one of the letters A, B, C, or D) of the disk containing a CP/M system: usually A. If a copy of CP/M already exists in memory, due to a MOVCPM command, type a cr only. Typing a drive name x will cause the response: SOURCE ON x THEN TYPE REI'URN Place a diskette containing the CP/M operating system on drive x (x is one of A, B, C, or D). Answer with cr when rea9Y. FUNCTION OOMPLETE System is copied to memory. SYSGEN will then prompt with: DESTINATION mIVE NAME (OR RETURN TO REBOOI') If a diskette is being initialized, place the new disk into a drive and answer with the drive name. Otherwise, type a cr and the system will reboot from drive A. Typing drive name x will cause SYSGEN to pr ompt 27 with: DESTINATION ON x THEN TYPE RETURN Place new diskette into drive x: type return when ready. New diskette is initialized in drive x. FUNCTION CDMPLETE The "DESTINATION" pranpt will be repeated tntil a single carriage return is typed at the console, so that more than one disk can be initialized. Upon canpletion of a successful system generation, the new diskette contains the operating system, and only the built-in canmands are available. A factory-fresh IBM-compatible diskette appears to CP/M as a diskette with an empty directory: therefore, the operator must copy the appropriate OOM files fran an existing CP/M diskette to the newly constructed diskette using the PIP transient. The user can copy all files fran an existing diskette by typing the PIP canmand PIP B: = A: *.*[vJ cr which copies all files fran disk drive A to disk drive B, and verifies that each file has been copied correctly. The name of each file is displayed at the console as the copy operation proceeds. It should be noted that a SYSGEN does not destroy the files which already exist on a diskette: it results only in construction of a new operating system. Further, if a diskette is being used only on drives B through D, and will never be the source of a bootstrap operation on drive A, the SYSGEN need not take place. In fact, a new diskette needs absolutely no initialization to be used with CP/M. . 6.7. SUBMIT ufu parm#! ••• parm#n cr The 9.JBMIT canmand allows CP/M canmands to be batched toqether for autanatic trocessing. The ufn given in the SUBMIT cormnand must be the filename of a file which exists on the currently logged disk, with an assumed file type of "SUB. The SUB file contains CP/M prototype canmands, with possible parameter stDstitution. The actual. parameters parm#! ••• parm#n are substituted into the lX'ototype canmands, and, if no errors occur, the file of substituted commands are processed sequentially by CP/M. II 28 The prototype canrnand file is created interspersed "$" parameters of the form $1 $2 $3 ••• using the ED program, with $n correspondin;J to the number of actual parameters which will be included when the file is smmi tted for execution. When the SUBMIT transient is executed, the actual parameters parmU ••• parm#n are paired with the formal parameters $1 ••• $n in the prototype canrnands. If the number of formal and actual parameters does not correspond, then the submit ftmction is aborted with an error message at the console. The SUBMIT ftmction creates a file of substituted commands with the name $$$.SUB on the logged disk. When the system reboots (at the termination of the SUBMIT), this canmand file is read by the CCP as a oource of input, rather than the console. If the SUBMIT function is ~rformed on any disk other than drive A, the commands are not processed until the disk is inserted into drive A and the system reboots. Further, the user can abort canmand processing at any time by typirg a rubout when the camnand is read and echoed. In this case, the $$$.SUB file is removed, and the subsequent canrnands come from the console. Command processing is also aborted if the CCP detects an error in any of the commands. Programs which execute tmder CP/M can abort ~ocessing of canrnand files when error conditions occur by simply erasing any existing $$$.SUB file. In order to introduce dollar signs into a SUBMIT file, the user may type a "$$" which reduces to a single "$" wi thin the command file. Further, an up-arrow symbol "f" may precede an alphabetic character x, which produces a single ctl-x character within the file. The last command in a SUB file can initiate another SUB file, allowing chained batch canrnands. Su~se thus the file ASMBL.SUB exists on disk and contains the prototype commands A~ $1 DIR $1.* ERA *.BAK PIP $2:=$1.PRN ERA $l.PRN and the command SUBMIT ASMBL X PRN cr is issued by the operator. The SUBMIT program reads the ASMBL.SUB file, smstituting "X" for all occurrences of $1 and "PRN" for all occurrences of $2, resulting in a $$$.SUB file containing the commands 29 • A~ X DIR ERA PIP ERA X.* *.BAK PRN:=X.PRN X.PRN which are executed in sequence by the CCP. The SUBMIT function can access a SUB file \\hich is on an alternate drive by trecedi~ the file name by a drive name. Sutmitted files are only acted u!X)n, however, when they appear on drive A. Thus, it is !X)ssible to create a submitted file on drive B \\hich is executed at a later time \\hen it is inserted in drive A. 6.8. DUMP ufn cr The DUMP program types the contents of the disk file (ufn) at the console in hexadecimal form. The file contents are listed sixteen bytes at a time, with the absolute byte address listed to the left of each line in hexadecimal. Lorg typeouts can be aborted by pushing the rubout key dur ing printout. (The rource listing of the DUMP program is ~given in the "CP/M Interface Guide" as an example of a program written for the CP/M environment.) 6.9. MJVCPM cr The M)VCPM p:-ogram allows the user to reconfigure the CP/M system for any particular rremory size. Two optional parameters may be used to indicate (1) the desired size of the new system and (2) the dist;X>sition of the new system at p:-ogram termination. If the first parameter is anitted or a u*" is given, the M)VCPM program will reconfigure the system to its maximum size, based u~n the kilobytes of contiguous RAM in the host system (starting aat 0000H). If the second parameter is ani tted, the system is executed, but not permanently recorded: if "*,, is given, the system is left in memory, ready for a SYSGEN operation. The M)VCPM program relocates a memory image of CP/M and places this image in memory in preparation for a system generation operation. The canrnand forms are: MOVCPM cr Relocate and execute CP/M for management of the current memory configuration (memory is examined for contiguous RAM, starting at l00H). Upon completion of the relocation, the new ' system is executed but not permanently recordeq on the diskette. The system which is constructed contains a BIOS for the Intel MDS 800. 30 MOVCPM n cr KlVCPM Create a relocated CP/M system for management of an n kilobyte system (n must be in the range 16 to 64), and execute the system, as described above. ** cr Construct a relocated memory image for the current memory configuration, but leave the memory image in memory, in preparation for a SYSGEN operation. * cr Construct a relocated memory image for an n kilobyte memory system, and leave the memory image in preparation for a SYSGEN operation. MOVCPM n The canrnand MOVCPM * * for example, constructs a new version of the CP/M system and leaves it in memory, ready for a SYSGEN operation. The message READY FOR "SYSGEN" OR "SAVE 32 CPMxx.cDM" is J;rinted at the console up:m completion, where xx is the current memory size in kilobytes. The operator can then type SYSGEN cr Start the system generation. SOURCE DRIVE NAME (OR RETURN TO SKIP) Respond with a cr to skip the CP/M read operation since the system is already in memory as a result of the previous MOVCPM operation. DESTINATION [RIVE NAME (OR RETURN T0 REBOOI') Respond with B to write new system to the diskette in drive B. SYSGEN will prompt wi th: DESTINATION ON B, THEN TYPE RETURN Ready the fresh diskette on drive B and type a return when ready. Note that if you respond with "A" rather than "B" above, the system will be written to drive A rather than B. SYSGEN will continue to ~ the prompt: DESTINATION [RIVE NAME (OR RETURN TO REBOOr) Lmtil the operator responds with a single carriage return, which stops the 31 SYSGEN program with a system reboot. The user can then go through the reboot process with the old or new diskette. Instead of performinq the SYSGEN operation, the user could have typed SAVE 32 CPMxx.ffiM at the canpletion of the M)VCPM function, ltilich would place the CP/M memory image on the currently logged disk in a form which can be "ra tched." This is necessary when operating in a non-standard environment ltilere the BIOS must be altered for a particular peripheral device configuration, as described in the"CP/M System Alteration Guide." Valid MOVCPM commands are given below: Construct a 48K verskon of CP/M and start execution. MOVCPM 48 cr MOVCPM 48 * cr Construct a 48K version of CP/M in preparation for permanent recording; response is READY FOR "SYSGEN" OR "SAVE 32CPM48.ffiM" MOVCPM * * cr Construct a maximum memory version of CP/M and start execution. It is imrnrtant to note that the newly created system is serialized with the number attached to the or ig inal di skette and is subject to the condi tions of the Digital Research Software Licensing Agreement. 32 .( 7. BDOS ERROR MESSAGES. There are three error situations which the Basic Disk Operating System intercepts dur ill3 file lXocesssill3. When one of these conditions is detected, the BOOS prints the message: BOOS ERR ON x: error where x is the drive name, and "error" is one of the three error messages: BAD SECl'OR SELECI' READ ONLY The "BAD SECl'OR" message indicates that the disk controller electronics has detected an error condition in readill3 or writing the diskette. This condition is generally due to a malfunctioning disk controller, or an extremely worn diskette. If you find that your system reports this error more than once a month, you should check the state of your controller electronics, and the condition of your media. You may also encounter this condition in readill3 files generated by a controller produced by a different manufacturer. Even ttnugh controllers are claimed to be IBM-canpatible, one often finds small di fferences in recording formats. The MIl3-800 controller, for example, requires two bytes of one's followill3 the data CRC byte, which is not required in the IBM format. As a result, diskettes generated by the Intel MOO can be read by almost all other IBM-canpatible systems, while disk files generated on other manufacturer's equipment will produce the "BAD SECl'OR" message when read by the MIl3. In any case, recovery fran this condition is accomplished by typill3 a ctl-C to reboot (this is the safest!), or a return, which simply ignores the bad sector in the file operation. Note, however, that typing a return rey destroy your diskette integrity if the operation is a directory write, so make sure you have adequate backups in this case. The "SELEcr" error occurs when there is an attempt to address a drive beyond the A through D r all3e. In this case, the value of x in the error message gives the selected drive. The system reboots following any input from the console. The "READ ONLY" message occurs men there is an attempt to write to a diskette which has been designated as read-only in a STAT canmand, or has been set to read-only by the BOOS. _In general, the operator should reboot CP/M either by usill3 the v.e.rm start procedure (ctl-C) or by performing a cold start whenever the diskettes are changed. If a changed diskette is to be read but not wr itten, BOOS allows the diskette to be changed without the warm or cold start, but internally marks the drive as read-only. The status of the drive is subsequently charged to read/write if a v.e.rm or cold start occurs. Upon issuill3 this message, CP/M waits for input fran the console. An automatic warm start takes place following any input. 33 • 8. OPERATION OF CP/M ON THE MrS. This section gives cperating procedures for using CP/M on the Intel MIS microcomputer development system. A basic knowledge of the MIS hardware and software systems is assumed. CP/M is initiated in essentially the same manner as Intel's ISIS operating system. The disk drives are labelled 0 through 3 on the MrS, corresp:mdi~ to CP/M drives A through D, respectively. The CP/M system diskette is inserted into drive 0, and the roar and RESE"I' switches are depressed in sequence. The interrupt 2 light should go on at this pJint. The space bar is then depressed on the device v.bich is to be taken as the system console, and the light srould go out (if it does not, then check connections and baud rates). The roar switch is then turned off, and the CP/M signon message srould appear at the selected console device, followed by the lOA>" system p:-anpt. The user can then issue the various resident and transient commands The CP/M system can be restarted (warm start) at any time by pushing the INT 0 switch on the front panel. The built-in Intel ROM monitor can be initiated by pushing the INT 7 switch (which generates a RST 7), except v.hen operating under DDT, in v.hich case the DDT program gets control instead. Diskettes can be renoved from the drives at any time, and the system can be shut down during operation without affecting data integrity. Note, however, that the user must not remove a diskette and replace it with another . wi thout rebooting the system (cold or warm start), unless the inserted diskette is "read only." Due to hardware hang-ups or malfunctions, CP/M may type the message BDOS ERR ON x: BAD SECl'OR where x is the drive v.bich has a permanent error. This error may occur v.hen drive doors are cpened and closed- randomly, followed by disk operations, or may be due to a diskette, drive, or controller failure. The user can optionally elect to ignore the error by typing a single return at the console. The error may produce a bad data record, requiring re-initialization of up to 128 bytes of data. The operator can reboot the CP/M system and try the cperation again. Termination of a CP/M session requires no special action, except that it is necessary to renove the diskettes before turning the {:Ower off, to avoid random transients v.hich often make their way to the drive electronics. It srould be noted that factory-fresh IBM-compatible diskettes should be used rather than diskettes v.bich have previously been used with any ISIS version. In particular, the ISIS "FORMAT" cperation produces non-standard sector numbering throughout the diskette. This non-standard numbering seriously degrades the performance of CP/M, and will operate noticeably slower 34 than the distribution version. If it becomes necessary to reformat a diskette (which smuld not be the case for standard diskettes). a program can be written mder CP/M v.hich causes the MI:6 800 controller to reformat with sequential sector numbering (1-26) on each track. Note: "MIS 800" aoo "ISIS" are registered trademarks of Intel Corporation • • I OPERATION OF THE CP/M CONTEXT EDITOR 01 [)~(j~Tf1l RE~Ef1Rr:H Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896 ED: A CONTEXT EDITOR FOR THE CP/M DISK SYSTEM USER'S MANUAL COPYRIGHT (c) 1976, 1978 DIGITAL RESEARCH Copyright (c) 1976, 1978 by Digital Research. All rights reserved. No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system, or translated into any lm;tguage or computer language, in any form or by any means, 'electronic, mechanical, magnetic, optical,' chemical, manual or otherwise,without the prior written permission of Digital Research, Post Office Box 579, Pacific Grove, California 93950. Disclaimer Digital Research makes no representations or warranties with respect to the contents hereof and specifically disclaims any implied warranties of merchantability or fitness for any particular purpose. Further, Digital Research reserves the right to revise this publication and to make changes from time to time -in the content hereof without obligation of Digital Research to .notify .any person of such revision or changes. Table of Contents 1. ED TUTORIAL . ... .. . ··· ···· 1 1.1 Introduction to ED 1.2 ED Operation 1.3 Text Transfer Functions 1 1.4 Memory Buffer 5 1.5 Memory Buffer 1.6 Command Strings 7 1.7 Text Search and Alteration 8 1.8 Source Libraries . · 1.9 Repetitive Command Execution • . · . 12 . .. 1 . .· . · ··· Organization · Operation · ·· · . . · . 1 5 . 11 2. ED ERROR CONDITIONS . . 3. CONTROL CHARACTERS AND COMMANDS • • . • • • . 14 · . . . . . .13 ii ED USER'S MANUAL 1. ED TUTORIAL 1.1. Introduction to ED. ED is the context editor for CP/M, and is used to create and alter CP/M source files. ED is initiated in CP/M by typing { ED } . In general, ED reads segments of the source file given.by or • into central memory, where the file is manipulated by the operator, and subsequently written back to disk after alterations. If the source file does not exist before editing, it is created by ED and initialized to empty. The overall operation of ED is shown in Figure 1. 1.2. ED Operation ED operates upon the source file, denoted in Figure 1 by x.y, and passes all text through a memory buffer where the text can be viewed or altered (the number of lines which can be maintained in the memory buffer varies with the line length, but has a total capacity of about 6000 characters in a 16K CP/M system). Text material which has been edited is written onto a temporary work file under command of the operator. Upon termination of the edit, the memory buffer is written to the temporary file, followed by any remaining (unread) text in the source file. The name of the original file is changed from x.y to x.BAK so that the most recent previously edited source file can be reclaimed if necessary (see the CP/M commands ERASE and RENAME). The temporary file is then changed from x.$$$ to x.y which becomes the reSUlting edited file. The memory buffer is logically between the source file and working file as shown in Figure 2. 1.3. Text Transfer Functions Given that n is an integer value in the range o through 65535, the following ED commands transfer lines of text from the source file through the memory buffer to the temporary (and eventually final) file: Figure 1. Overall ED Operation Source Libraries Source File Append (R) Write (W) (A) Temporary File Memory Buffer After Edit After Edit (E) (E) Type Insert (I) (T) Backup New File Source File x.y x.BAK Note: the ED program accepts both lower and upper case ASCII characters as input from the console. Single letter commands can be typed in either case. The U command can be issued to cause ED to translate lower case alphabetics to upper case as characters are filled to the memory buffer from the console. Characters are echoed as typed without translation, however. The -u command causes ED to revert to "no translation" mode. ED starts with an assumed-U in effect. 2 Figure 2. Memory Buffer Source File 1 2 3 .' Hemory Buffer Organization ., Temporary File 1 .' First Line" 1 '\ F:irst Line" -,,'Appended," . , , ,- 2 ~Buffered ~ 2 "Text ",,"- -7-."~'" - ' " -,-,'" 3 \ Processed' ," -" '\"Text '" '-'\ - F~rst L~ne "Lines" , ~ ,,2- ""-,- Memory TP ... -, '\"" Memo ry Buffer --------- -------- current line CL ------~------ last line -------- 3 , \ -' Space _______I Logical Organization of Memory Buffer first line \ Free File Next Write L Figure 3. \ .. nA * - append the next n unprocessed source lines from the source file at SP to the end of the memory buffer at MP. Increment SP and MP by n. nW write the buffer to Shift the MP to the Increment first n lines of the memory the temporary file free space. remaining lines n+l through top of the memory buffer. TP by n. E end the edit. Copy all buffered text to temporary file, and copy all unprocessed source lines to the temporary file. Rename files as described previously. H move to head of new file by performing automatic E command. Temporary file becomes the new source file, the memory buffer is emptied, and a new temporary file is created (equivalent to issuing an E command, followed by a reinvocation of ED using x.y as the file to edit). O return to original file. The memory buffer is emptied, the temporary file id deleted, and the SP is returned to position I of the source file. The effects of the previous editing commands are thus nullified. Q quit edit with no file alterations, return to CP/M.-- There are a number of special cases to consider. If the integer n is omitted in any ED command where an integer is allowed, then I is assumed. Thus, the commands A and Wappend one line and write I line, respectively. In addition, if a pound sign (#) is given in the place of n, then the integer 65535 is assumed (the largest value for n which is allowed). Since most reasonably sized source files can be contained entirely in the memory buffer, the command #A is often issued at the beginning of the edit to read the entire source file to memory. Similarly, the command #Wwrites the entire buffer to the temporary file. Two special forms of the A and W * represents the carriage-return key 4 commands are provided as a convenience. The command OA fills the current memory buffer to at least half-full, while OW writes lines until the buffer is at least half empty. It should also be noted that an error is issued if the memory buffer size is exceded. The operator may then enter any command (such as W) which does not increase memory requirements. The remainder of any partial line read during the overflow will be brought into memory on the next successful append. 1.4. Memory Buffer Organization The memory buffer can be considered a sequence of source lines brought in with the A command from a source file. The memory buffer has an associated (imaginary) character pointer CP which moves throughout the memory buffer under command of the operator. The memory buffer appears logically as shown in Figure 3 where the dashes represent characters of the source line of indefinite length, terminated by carr~e return «cr» and line-feed «If» characters, and cp represents the imaginary character pointer. Note that the CP is always located ahead of the first character of the first line, behind the last character of the last line, or between two characters. The current line CL is the source line which contains the CPo 1.5. Memory Buffer Operation Upon initiation of ED, the memory buffer is empty (ie, CP is both ahead and behind the first and last character). The operator may either append lines (A command) from the source file, or enter the lines directly from the console with the insert command I ED then accepts any number of input terminates with a (the is until a control-z (denoted by tz is The CP is positioned after the last sequence lines, where each line supplied automatically), typed by the operator. character entered. The I NOW IS THE TIME FOR ALL GOOD MEN tz leaves the memory buffer as shown below 5 NOW IS THE TIME FOR ALL GOOD MEN - move CP to beginning of memory buffer if +, and to bottom if -. ±nC - move CP by ±n characters (toward front of buffer if +), counting the as two distinct characters ±nD - delete n characters ahead of CP if plus and behind CP if minus. ±nK - kill (ie remove) ±n lines of source text using CP as the current reference. If CP is not at the begi~ning of the current line when K is issuec, then the characters before CP remain if + is specified, while the characters after CP remain if is given in the command. ±nL - if n=O then move CP to the beginning .of the current line (if it is not already there) if nFO then first move the CP to the beginning of the current line, and then move it to the beginning of the line which is n lines down (if +) or up (if -). The CP will stop at the top or bottom of the memory buffer if too large a value of n is specified. 6 ±nT - If n=O then type the contents of the current line up to CPo If n=l then type the contents of the current line from CP to the end of the line. If n>l then type the current line along with n-l lines which follow, if + is specified. Similarly, if n>l and - is given, type the previous n lines, up to the CPo The break key can be depressed to abort long type-outs. ±n - equivalent to ±nLT, which moves up or down and types a single line 1.6. Command Strings Any number of commands can be typed contiguously (up to the capacity of the CP/M console buffer), and are executed only after the is typed. Thus, the operator may use the CP/M console command functions to manipulate the input command: Rubout remove the last character Control-U delete the entire line Control-C re-initialize the CP/M System Control-E return carriage for long lines without transmitting buffer (max 128 chars) Suppose the memory buffer contains the characters shown in the previous section, with the CP following the last character of the buffer. The command strings shown below produce the results shown to the right Command String Effect B2T move to beginning of buffer and type 2 lines: "NOW IS THE TIME FOR" 1. 2. 5COT move CP 5 characters and type the beginning of the line "NOW I" 7 Resulting Memory Buffer L~NOW l3?J TIME IS THE FOR ALL GOOD MEN NOW I~~ ~ S THE • 3. 2L-T NOW IS THE move two lines down and type previous TIME FOR line "TIME FOR" ~ALL GOOD MEN l5:J 4. -L#K move up one line, delte 65535 lines which follow NOW IS THE 5. I TIME TO INSERT tz insert two lines of text NOW IS THE -2L#T move up two lines, and type 65535 lines ahead of CP "NOW IS THE" NOW IS THE move down one line and type one line " INSERT" NOW IS THE 6. 7. C.2:J TIME TO INSERT ~ ~ TIME TO ~ ~ INSERT TIME TO INSERT 1.7. ~ ~~ ~ Text Search and Alteration ED also has a command which locates strings within the memory buffer. The command takes the form where cl through ck represent the characters to match followed by either a or control -z*. ED starts at the current position of CP and attempts to match all k characters. The match is attempted n times, and if successful, the CP is moved directly after the character ck. If the n matches are not successful, the CP is not moved from its initial position. Search strings can include-rr (control-l), which is replaced by the pair of symbols . *The control-z is used if additional commands will be typed following the tz. 8 The following commands illustrate the use of the F command: Command String 1. B#T Effect move to beginning and :type entire buffer Resulting Memory Buffer .-6 NOW IS THE ~ TIME FOR ALL GOOD MEN 2. FS T find the end of the string ItS T" NOW IS T@1 HE 3. FltzOTT find the next "I" and type to the CP then type the remainder of the current line: "TIME FOR" NOW IS THE TI ~ME FOR cp ALL OOD MEN An abbreviated form of the insert command is also allowed, which is often used in conjunction with the F command to make simple textual changes. The form is: c n where cl through c n are characters to insert. If the insertion string is terminated by a tz, the characters cl through c n are inserted directly following the CP, and the CP is moved directly after character c n " The action is the same if the command is followed by a except that a is automatically inserted into the text following character cn. Consider the following command sequences as examples of the F and I commands: Command String BITHIS· IS tz Resulting Memory Buffer Effect Insert "THIS IS " at the beginning of the text THIS IS~OW THE ~ TIME FOR ALL GOOD MEN 9 FTIMEtz-4DIPLACEtz THIS IS NOW THE PLACE ~ FOR ALL GOOD MEN find "TIME" and delete it; then insert "PLACE" 3FOtz-3D5DICHANGESt THIS IS NOW THE PLACE FOR find third occurrence of "0" (ie the second "0" in GOOD), delete previous 3 characters; then insert "CHANGES" -8CISOURCE ALL move back 8 characters and insert the line "SOURCE " CHANGES~ ~ THIS IS NOW THE PLACE FOR ALL SOURCE ~CHANGES I.5:J ED also provides a single command which combines .the F ·and I commands to perform simple string substitutions. The command takes the form and has exactly the same effect as applying the command string a total of n times. That is, ED searches the memory buffer starting at the ~urrent position of CP and successively substitutes the second string for the first string until the end of buffer, or until the substitution has been performed n times. As a convenience, a command similar to F is provided by ED which automatically appends and writes lines as the search proceeds. The form is n N c l c 2 •.• c k { ctrz } which searches the entire source file for the nth occurrence of the string clc2 •.. ck (recall that OF fails if the string cannot be found in the current buffer). The operation of the 10 ~~ command is precisely the same as F except in the case that the string cannot be found within the current memory buffer. In this case, the entire memory contents is written (ie, an automatic #W is issued). Input lines are then read until the buffer is at least half full, or the entire source file is exhausted. The search continues in this manner until the string has been found n times, or until the source file has been completely transferred to the temporary file. A final line editing function, called the juxtaposition command takes the form with the following action applied n times to the memory buffer: search from the current CP for the next occurrence of the string clc2 ... ck' If found, insert the string d k d 2 ... ,dm, and move CP to follow dm . Then delete all characters following CP up to (but not including) the string el,e2, ... e q , leaving CP directly after dm. If el,e2, ... e q cannot be fOUnd, then no deletion is made. If the current line is ~ t:E.J NOW IS THE TH1E Then the cormnand JW tzWHATtztl Results in NOW WHAT ~ l.91:l (Recall that tl represents the pair in search and SUbstitute strings). It should be noted that the number of characters allowed by ED in the F,S,N, and J commands is limited to 100 symbols. 1. 8. Source Libraries ED also allows the inclusion of source libraries during the editing process with the R command. The form of this command is 11 where flf2 •• fn is the name of a source file on the disk with as assumed filetype of 'LIB'. ED reads the specified file, and places the characters into the memory buffer after CP, in a manner similar to the I command. Thus, if the command RMACRO is issued by the operator, ED reads from the file MACRO. LIB until the end-of-file, and automatically inserts the characters into the memory buffer. 1.9. Repetitive Command Execution The macro command M allows the ED user to group ED commands together for repeated evaluation. The M command takes the form: where clc2 .•. ck represent a string of ED commands, not including another M command. ED executes the command string n times if n>l. If n=O or 1, the command string is executed repetitively until an error condition is encountered (e.g., the end of the memory buffer is reached with an F command). As an example, the following macro changes all occurrences of GAMMA to DELTA within the current buffer, and types each line which is changed: MFGAMMAtz-SDIDELTAtzOTT or equivalently MSGAMMAtzDELTAtzOTT 12 2. ED ERROR CONDITIONS On error conditions, ED prints the last character read before the error, along with an error indicator: ? unrecognized command > memory buffer full (use one of the commands D,K,N,S, or W to remove characters), F,N, or S strings too long. # cannot apply command the number of times specified (e.g., in F command) o cannot open LIB file in R command Cyclic redundancy check (CRC) information is written with each output record under CP/M in order to detect errors on subsequent read operations. If a CRC error is detected, CP/M will type PERM ERR DISK d where d is the currently selected drive (A,B, ..• ). The operator can choose to ignore the error by typing any character at the console (in this case, the memory buffer data should be examined to see if it was incorrectly read), or the user can reset the system and reclaim the backup file, if it exists. The file can be reclaimed by first typing the contents of the BAK file to ensure that it contains the proper information: TYPE x.BAK where x is the file being edited. file: Then remove the primary ERA x.y and rename the BAK file: REN x.y=x.BAK The file can then be re-edited, starting with the previous version. 13 • 3. CONTROL CHARACTERS AND COMHANDS The following table summarizes the control characters and commands available in ED: Control Character Function tc system reboot te physical (not actually entered in conunand) ti logical tab (cols 1,8, 15, ... ) tl logical in search and substitute strings tu line delete tz string terminator rubout character delete break discontinue command (e~g., stop typing) 14 Function Co nun and nA append lines ±B begin bottom of buffer ±nC move character positions ±nD delete characters E nF end edit and close files (normal end) find string H end edit, close and reopen files I insert characters nJ place strings in juxtaposition ±nK kill lines ±nL move down/up lines nM macro definition nN find next occurrence with autos can o ±nP return to original file move and print pages Q quit with no file changes R read library file nS substitute strings ±nT type lines ± U translate lower to upper case if U, no translation if -u nW write lines nZ sleep ±n move and type 15 (±nLT) • Appendix A: ED 1.4 Enhancements The ED context editor contains a number of commands which enhance its usefulness in text editing. The improvements are found in the addition of line numbers, free space interrogation, and improved error reporting. The context editor issued with CP/M 1.4 produces absolute line number prefixes when the "V" (Verify Line Numbers) command is issued. Following the V command, the line number is displayed ahead of each line in the format: nnnnn: where nnnnn is an absolute line number in the range 1 to 65535. If the memory buffer is empty, or if the current line is at the end of the memory buffer, then nnnnn appears as 5 blanks. The user may reference an absolute line number by preceding any command by a number followed by a colon, in the same format as the line number display. In this case, the ED program moves the current line reference to the absolute line number, if the line exists in the current memory buffer. Thus, the command 345:T is interpreted as "move to absolute line 345, and type the line." Note that absolute line numbers are produced only during the editing process, and are not recorded with the file. In particular, the line numbers will change following a deleted or expanded section of text. The user may also reference an absolute line number as a backward or forward distance from the current line by preceding the absolute line number by a colon. Thus, the command :400T is interpreted as "type from the current line number through the line whose absolute number is 400." Combining the two line reference forms, the command 345::4"'0T for example, is interpreted as "move to absolute line 345, then type through absolute line 4~0." Note that absolute line references of this sort can precede any of the standard ED commands. A special case of the V command, "0V", prints the memory buffer statistics in the form: free/total where "free" is the number of free bytes in the memory buffer (in decimaI), and "total" is the size of the memory buffer. I ED 1.4 also includes a "block move" facility implemented through the "X" (X fer) command. The form nX transfers the next n lines from the current line to a temporary file called X$$$$$$$.LIB which is active only during the editing process. In general, the user can reposition the current line reference to any portion of the source file and transfer lines to the temporary file. The transferred line accumulate one after another in this file, and can be retrieved by simply typing: R which is the trivial case of the library read command. In this case, the entire transferred set of lines is read into the memory buffer. Note that the X command does not remove the transferred lines from the memory buffer, although a K command can be used directly after the X, and the R command does not empty the· transferred line file. That is, given that a set of lines has been transferred with the X command, they can be re-read any number of times back into the source file. The command r1X is provided, however, to empty the transferred line file. Note that upon normal completion of the ED program through Q or E, the temporary LIB file is removed. If ED is aborted through ctl-C, the LIB file will exist jf lines have been transferred, but will generally be empty (a subsequent ED invocation will erase the temporary file). Due to common typographical errors, ED 1.4 requires several potentially disasterous commands to be typed as single letters, rather than in composite commands. The commands E (end), H (head), 0 (originaI), Q (quit) must be typed as single letter commands. ED 1.4 also prints error messages in the form BREAK "x" AT c w here x is the error character, and c is the com mand where the error occurred. CP/M 2.0 USER'S GUIDE FOR CP/M 1.4 OWNERS I 01 [)~[j~Tfll RESEflRl:tf Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896 CP/M 2.0 USER'S GUIDE FOR CP/M 1.4 OWNERS COPYRIGHT (c) 1979 DIGITAL RESEARCH • Copyright Copyright (c) 1979 by Digital Research. All rights reserved. No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system, or translated into any language or computer language. in any form or by any means, electronic, mechanical, magnetic, optical, chemicaJ, manual or otherwise, without the prior written permission of Digital Research, Post Office Box 579, Pacific Grove, California 93950. Disclaimer Digital R.esearch makes no representations or warranties with respect to the contents hereof and specifica]Jy disclaims any implied warranties of merchantability or fitness for any particular purpose. Further, Digital Research reserves the right to revise this publication and to make changes from time to time in the content hereof without obligation of Digital Research to notify any person of such revision or changes. TrRdemarks CP/M is a registered trademark of Digital Research. MAC, and SID are trademarks of Digital Research. MP/M, CP/M 2.0 USER'S GUIDE FOR CP/M 1.4 OWNERS COQyright (c) 1979 Digital Researcn, aox 579 Pacific Grove, California 1. An Overview of CP/M 2.0 Facilities 2. User Interface 3. Console Command Processor (CC?) 4. S~AT 5. PIP Enhancements 6. 8D Enhancements 7• The XSU8 Function 8. 3DOS Interface Conventions • • . 9. CP/M 2.0 Memory Organization Enhancements 10. 3IOS Differences • . • . . . • . . . . . . . 1 3 Intertace • • . • • • • 4 • • 5 . • . 10 . . . . 11 • • 12 • 27 • • 28 1. AL~ OVERVIEw OF cp/r-1 2.0 FACILI'rIES. CP/M 2.0 is a high-performance single-console operating system which uses table driven techniques to allow field reconfiguration to match a wide variety of disk capacities. All of the fundamental, file restrictions are removed, while maintaining upward compatibility from previous versions of release 1. Features of CP/M 2.0 include field specification of one to sixteen logical drives,eacn containing up to eight megabytes. Any particular file can reach the full drive size with the capability to expand to thirty-two megabytes in future releases. The directory size can be field configured to contain any reasonable number of entries, and each file is optionally tagged with read/only and system attributes. Users of CP/M 2.0 are physically separated oy user numbers, with facilities for file copy operations from one user area to another. Powerful relative-record random access functions are present in CP/M 2.0 whlch provide direct access to any of the 65536 records of an eight megabyte file. All disk-dependent portions of CP/M 2.0 are placed into a BIOS-resident "disk parameter block" which is either hand coded or produced automatically using the disk definition macro library provided with CP/M 2.0. The end user need only specify the maximum number of active disks, the starting and ending sector numbers, the data allocation size, the maximum extent of the logical disk, directory size information, and reserved track values. The macros use this information 'to generate the appropriate tables and table references for use during CP/M 2.0 operation. Deblocking information is also provided wnich aids in assembly or disassembly of sector sizes wnich are multioles of tne fundamental 128 byte data unit, and the system. alteration manual includes qeneral~purpose subroutines which use the tnis deblocking information to taKe advantage of larger sector sizes. Use of these subroutines, together with the table driven data access algoritnms, make CP/M 2.0 truly a universal data management system. File expansion is achieved by providing, up to 512 logical file extents, where eaCh logical extent contains 16K bytes of data. CP/M 2.0 is structured, however, so that as much as 128K bytes of data is addressed by a single physical extent (corresponding to a single directory entry), tnus maintaining compatibility with previous versions while taking full advantage of directory space. Random access facilities are present in CP/M 2.0 which allow immediate reference to any record of an eight megabyte file. Using CP/t1's unique data organization, data blocks are only allocated when actually required and movement to a record oosition requires little search time. Sequential file access is upward-compatible from earlier versions to the full ,eight megaoytes, while random access compatibility stops at 5l2K byte files. Due to CP/M 2.0's simpler and faster random access, application programmers are encouraged to alter their programs to take full advantage of the 2.0 facilities. Several CP/M 2.0 modules and utilities have improvements which correspond to the enhanced file system. STA'r and PIP both account for file attributes ~nd user areas, while the CCP provides a "login~ (All Information Contained Herein is Proprietary to Digital Researcn.) 1 I function to change from one user area to anotner. 'i'he CCP also formats directory displays in a more convenient manner and accounts for both CRT and hard-copy devices in its enhanced line editing functions. The sections below point out the inaividual differences between CP/M 1.4 and CP/M 2.0~ with the understanding that the reader is either familiar with CP/M 1.4, or has access to the 1.4 manuals. Additional information dealing with CP/M 2.0 I/O system alteration is presented in the Digital Research manual ~CP/M 2.0 Alteration Gtiide. d (All Information Contained Berein is proprietary to Digital Research.) 2 2. USER INTERFACE. Console line processing takes CRT-type devices into account with three new control characters, shown with an asterisk in the list below (the symbol "ctl" below indicates that the control key is simultaneously depressed) : rub/del ctl-C ctl-E ctl-H ctl-J ctl-M ctl-R ctl-a ctl-X removes and echoes last character reboot when at beginning of line, physical end of line oackspace"one cnaracter position* (line feed) terminates current input* (carriage return) terminates input retype current line after new line remove current line after new line backspace to beginning of current line* In ?articular, note that ctl-H produces the proper backspace overwrite function (ctl-H can be changed internally to another character, such as delete, through a simple single byte change). Further, the line editor keeps track ot the current prompt column position so that· the operator can properly align data input following a ctl-U, ctl-R, or ctl-X command. (All Information Contained Herein is Proprietary to Digital Research.) 3 • 3. CONSOLE COMMAI.~D PROCESSOR (CCP) IN'fERFACE. There are four functional differences between CP/M 1.4 and CP/M 2.0 at the console command processor (CCP) level. 'fheCCP now displays directory information across the screen (four elements per line), the USER command is present to allow maintenance oiseparate files in the same directory, and the actions of the "ERA *.*" and "SAVE" commands have changed. 'l'he altered DIR format is self-explanatory, while the USER command takes the for~: USER n where n is an integer value in the range 0 to 15. Upon cold start, the operator is automatically "logged" into user area number 0, which is compatible with standard CP/M 1.4 directories. The operator may issue the USER command at any time to move to another logical area within the same directory. Drives which are logged-in while addressing one user number are automatically active when the operator moves to another user numoer since a 'user number is simply a prefix which accesses particular directory entries on the active disks. The active user number is maintained until changed by a subsequent USER command, or until a cold start operation when user 0 is again assumed. Due to the fact that user numbers now tag individual directory entries, the ERA *.* command has a different effect. In version 1.4, this command can be used to erase a directory whicn has "garbage" information, perhaps resulting from use of a disKette under another operating system (heaven forbid!). In 2.0, however, the ERA ~.* command affects only the current user number. Thus, it is necessary to write a simple utility to erase a nonsense disk (the program simply writes the hexadecimal pattern E5 throughout the disk). The SAVE command in. version 1.4 allows only a single memory save operation, with the potential of destroying the memory image due to directory operations following extent boundary changes. Version 2.0, nowever~ does not perform directory operations in user data areas after disk writes, and thus the SAVE operation can be used any number of times without altering the memory image. (All Information Contained Herein is Proprietary to Digital Research.) 4 4. STAT ENHANCEMENTS. The STAT program has a number of additional functions which allow disk parameter display, user number display, and file indicator manipulation. The command: s'rA'r VAL: produces a summary of the available status commands, resulting in output: the Temp RIO Disk: d:=R/o Set Indicator: d:filename.typ $R/O $R/w $SYS $DIR Disk status DSK: d:DSK: User Status USR: Iobyte Assign: (list of possible assignments) ~hicn gives an instant summary of the possible command form: STAT d:filename.typ ~S STAT commands. The wnere "d:" is an optional dr ive name, and "filename.typ" is an unambiguous or ambiguous file name, produces the output display format: Size Recs 3ytes Ext Acc 48 48 6k 1 Rio A:ED.COM 55 55 12k 1 RIO (A : f' I P • CO£'1) 65536 128 2k 2 R/W A:X.DA'l' where tne $S parameter causes the "Size" field to be displayed (without the $S, the Size field is skipped, but the remaining fields are displayed). 'rhe Size field lists the virtual file size in records, while the "Recs" field sums the number of virtual records in each extent. For files constructed sequentially, the Size and Recs fields are identical. 'rhe "Bytes" field lists the actual nUr.lber of bytes allocated to the corresponding file. The minimum allocation unit is determined at configuration time, and thus tne number of bytes corresponds to the record count plus the remaining unused space in the last allocated block for sequential files. Random access files are given data areas only when written, so the Bytes field contains the only accurate allocation figure. In the case of random access, the Size field gives the logical end-ot-file record position and the Recs field counts the logical records of each extent (each of these extents, 11Owever, :nay contain unallocated "holes" even though they are added into the record count). The "Ext" field counts the number of logical 16K extents allocated to the file. Unlike version 1.4, the Ext count does not necessarily correspond to the number of directory entries given to the file, since there can be up to 128K oytes (8 logical extents) directly addressed by a single directory entry, de?ending upon allocation size (in a special case, there are actually 256K bytes which can be directly addressed by a physical extent). 'rhe .. Acc" field gives the RiO or R/W access mode, which is changed using 'the commands shown below. Similarly, the parentheses (All Intormation Contained Herein is Proprietary to Digital Research.) 5 shown around the PIP. COM file name indicate that it has the "system" indicator set, so that it will not be listed in OIR commands. The four command forms STAT STAT STAT STAT d:filename.typ ~R/O d:filename.typ $R/~ d:filename.typ $SYS d:filename.typ $DIR set or reset various ?ermanent file indicators. The R/O indicator places the file (or set of files) in a read-only status until changed by a subsequent STAT command. The R/O status is recorded in the directory with tne file so that it remains R/O through intervening cold start operations. The R/W indicator places the file in a ?ermanent read/write status. The SYS indicator attaches the system indicator to the file, while the DIR command removes the system indicator. rrhe "filename. typ" may be ambiguous or unambiguous, but in eitner case, the files whose attributes are changed are listed at the console when the change occurs. The drive name denotea by "d:" is optional. When a file is marked R/O, subsequent attempts to erase or write into the file result in a terminal BOOS message Bdos Err on d: File R/O The BOOS then waits for a console input before performing a subsequent warm start (a "return" is sufficient to continue). The command form s'rAT d: DSK: lists the drive characteristics of the disk named by "d:" which is in the range A:, B:, .•. , P:. The drive characteristics are listed in the format: d: 65536: 8192: 128: 0: 1024: 128: 58: 2: Drive Characteristics 128 Byte record Capacity Kilooyte Drive Capacity 32 Byte Directory Entries Checked Directory Entries Records/ Extent Records/ Block Sectors/ Track Reserved Tracks where "d:" is the selected drive, followed by the total record capacity (65536 is an 8 megabyte drive), followed by the total capacity listed in Kilooytes. The directorv size is listed next, followed by the "checked" entries. The number of checked entries is usually identical to the directory size for removable media, since this mechanism is used to detect changed media during CP/M operation without an intervening warm start. For fixed media, the number is usually zero, since the media is not changed without at least a cold or warm start. The number of records per extent determines the addressing capacity of each directory entry (1024 times 128 bytes, or (All Information Contained Herein is Proprietary to Digital Research.) 6 l28K in the exam?le above). The number of records oer block shows the basic allocation size (in the example, 128 records/block times 128 bytes per record, or 16K oytes per block). The listing is then followed by the number of physical sectors oer track and the number of reserved tracks. For logical drives which share the same physical disk, the number of reserved tracks may be quite large, since this mechanism is used to sKio lower-numbered disk areas allocated to other logical disks. The cbmm~nd form s:rA'r DSK: produces a drive characteristics table drives. The final STAT command form is for all currently active 8'rAT USR: which produces a list of the user numbers which have currently addressed disk. The display format is: files on the Active User : 0 Active Files: 0 1 3 where the first line lists the currently addressed user number, as set by the last CCP USER command, followed by a list of user numbers scanned from the current directory. In the above case, the active user number is 0 (default at cold start), witn three user numbers whicn have active files on the current disk. 'fhe operator can subsequently examine the directories of the other user numbers by logging-in with USER 1, USER 2, or USER 3 commands, followed by a DIR command at the CCP level. (All Information Contained Herein is Proprietary to Digital Research.) 7 • 5. PIP ENHAN'CEMEN'rs. PIP provides three new functions which account tor the features of CP/M 2.0. All three functions take the form of file oarameters which are enclosed in square brackets following the appr.opr late file names. The commands are: Gn Get File from User number n (n in the range 0 - 15) w write over R/O files without console interrogation R Read system files 'rhe G command allows one user area to receive data files from another. Assuming the operator has issued the USER 4 command at the CCP level, the PIP statement PIP X.Y = X.Y[G2] reads file X. Yfrom user number 2 into user command PIP A:=A:*.*[G2] area number 4. 'rhe copies all of the files from the A drive directory for user number 2 into the A drive directory of the currently logged user number~ Note that to ensure file security, one cannot copy files into a different a-rea than the one which is currently a,ddressed by the USER command. Note also that the PIP program itself is initially copied to a user area (so that subsequent files can be copied) using the SAVE command. The sequence of operations shown below effectively moves PIP from one user area to the next. login user 0 load PIP to memory DDT PIP. COM (note PIP size s) return to CCP G0 login user 3 USER 3 SAVE s PIP. CO£¥l USER '" where s is the integral number of memory "pages" (256 byte segments) occupied by PIP. The number s can be determined when PIP. COM is loaded under DDT, by referring to the value under the "NEXT" display. If for example, the next available address is 1000, then PIP.COM requires lC hexadecimal pages (or 1 times 16 + 12 = 28 pages), and thus the value of s is 28 in the subsequent save. Once PIP is cooied in this manner, it can then be copied to another disk belonging to"the same user number through normal pip transfers. Under normal operation, PIP will not overwrite a file which is set to a permanent R/O status. If attempt is made to overwrite a R/O file, the prompt . (All Information Contained Herein is proprietary to Digital Research.) 8 nRSTINATION FILE IS R/O, DELETE (YIN)? is issued. If the operator responds with the character "y" file is overwritten. Otherwise, the response then the ** NOT DELETED ** is issued, the file transfer is skippped, and PIP continues with the next operation in sequence. In order to avoid the prompt and response in the case of RiO file overwrite, the command line can include the w parameter, as shown below PIP A:=B:*.COM[W] which copies all non-system files to. the A drive from the B drive, and overwrites any R/O files in the process. If the operation involves several concatenated files, the w parameter need only be included with the last file in the list, as shown in the following example PIP A.DAT = B.DAT,F:NEW.DAT,G:OLD.DAT[W] Files with the system attribute can be included in PIP transfers if the R parameter is included, otherwise system files are not recognized. The command line PIP ED. COM = B:ED.COM[R] for example,: reads the ED.COM file from the B drive, even if it has been marked as a R/O and system file. The system file attributes are copied, if present. It should be noted that downward compatibility with previous versions of CP/M is only maintained if the file does not exceed one megabyte, no file attributes are set, and the file is created by user 0. If compatibility is required with non-standard (e.g., "double density") versions of 1.4, it may be necessary to select 1.4 compatibility mode when constructing the internal disk parameter block (see the '"CP/M 2.0 Alteration Guide," and refer to Section 10 which describes BIOS differences). (All Information Contained Herein is Proprietary to Digital Research.) 9 6. ED ENHANCEMENTS. The CP/M standard orogram editor provides several new facilities in the 2.0 release. Experience has shown that most operators use the relative line numbering feature of ED, and thus the e~itor has the "v" (Verify Line) option set as an initial value. The operator can, of course, disable line numbering by typing the "-v" command. If you are not familiar with the ED line number mode, you may wish to refer to the Appendix in the ED user's guide, where the "v" command is described. ED also takes file attributes into account. attempts to edit a read/only file, the message ** FILE IS READ/ONL~ If the operator ** appears at the console. The file can be loaded and examined, but cannot be altered in any way. Normally, the operator simply ends the ,edit session, and uses STAT to change the file attribute to R/W. If the edited file has the "system" attribute set, the message "SYSTEM" FILE NOT ACCESSIBLE is displayed at the console, and the edit session is aborted. Again, the STA;f program can be used to change the system' attribute, if desired. Finally, the insert mode ("i") command allows CRT functions, as described in Section 2, above. line editing (All Information Contained Herein is proprietary to Digital Research.) 1" 7. THE XSUB FUNCTION. An additional utility program is supplied with version 2.0 of CP/M, called XSUB, which extends the power of the SUBMIT facility to include line input to programs as well as the console command processor. The XSUB command is included as the first line of your submit file and, when executed, self-relocates directly below the CCP. All subsequent submit command lines are processed by XSUB, so that programs which read buffered console input (BOOS function 10) receive their input directly from the submit file. For example, the file SAVER.SUB could contain the submit lines: XSUB DDT I$l.HEX R G0 SAVE 1 $2.COM with a subsequent SUBMIT command: SUBMIT SAVER X Y which substitutes X for $1 and Y for $2 in the command stream. The XSUB program loads, followed by DD'r which is sent the command lines "IX.HEX" "R" and "G0" thus returning to the CCP. The final command "SAVE 1 Y.COM" is processed by the CCP. The XSUB program remains in memory, and prints the message (xsub active) on each warm start operation to indicate its presence. Subsequent submit command streams do not require the XSUB, unless an intervening cold start has occurred. Note that XSUB must be loaded after DESPOOL, if both are to run simultaneously. (All Information Contained Herein is Proprietary to Digital Research.) 11 8. BOOS INTERFACE CONVENTIONS. CP/M 2.0 system calls take place in exactly the same manner as earlier versions, with a call to location 0005H, function number in register C, and information address in register pair DE. Single byte values are returned in register A, with double byte values returned in HL (for reasons of compatibility, register A = L and register B = H upon return in all cases). A list ot CP/M 2.0 calls is given below, with an asterisk following functions which are either new or revised from version 1.4 to 2.0. Note that a zero value is returned for out-of range function numbers. 0 1 2 3 4 5 6* 7 8 9 10* 11 12* 13 14 15* 16 17* 18* System Reset Console Input Console Output Reader Input PunCh Output List Output Direct Console I/O Get I/O Byte Set I/O Byte Print String Read Console Buffer Get Console Status Return Version Number Reset Disk System Select Disk Open File Close File Search for First Search for Next 19* 20 21 22* 23* 24* 25 26 27 28* 29* 30* 31* 32* 33* 34* 35* 36* Delete f"ile Read Sequential write Sequential Make File Rename File Return Login Vector Return Current Disk Set DMA Address Get Addr (Alloc) Write Protect Disk Get Addr(R/O Vector) Set File Attr ibutes Get Addr(Disk Parms) Set/Get User Code Read Random ~vr i te Random Comoute File Size Set Random Record (Functions 28, 29, and 32 should be avoided in application programs to maintain upward compatibility with MP/M.) The new or revised functions are described below. Function 6: Direct Console I/O. Direct Console I/O is supported under CP/M 2.0 for those applications where it is necessary to avoid the BOOS console I/O operations. Programs whiCh currently perform direct I/O through the BIOS should be changed to use direct I/O under BOOS so that they can be fully supported under future releases of MP/M and CP/M. Upon entry to function 6, register E either contains hexadecimal FF, denoting a console input request, or register E contains an ASCII Character. If the input value is FF, then function 6 returns A = 00 if no character is ready, otherwise A contains the next console input character. If the input value in E is not FF, then function 6 assumes that E contains a valid ASCII character whiCh is sent to the console. (All Information Contained Herein is Proprietary to Digital Research.) 12 Function 10: Read Console Buffer. The console buffer read operation remains unchanged except that console line editing is supported, as described in section 2. Note also that certain functions which return the carriage to the leftmost position (e.g., ctl-X) do so only to the column position where the prompt ended (previously, the carriage returned to the extreme left margin). 'rhis new convention makes operator data input and line correction more legible. Function 12: Return Version Number. Function 12 has been redefined to orovide information which allows version-independent programming (this was previously the "lift head" function which returned HL=0000 in version 1.4, but performed no operation). The value returned by function 12 is a two-byte value, with H = 00 for the CP/M release (H = 01 for MP/M), and L = 00 for all releases previous to 2.0. CP/M 2.0 returns a hexadecimal 20 in register L, with subsequent version 2 releases in the hexadecimal range 21, 22, through 2F. Using function 12, for example, you can write application programs which provide both sequential and random access functions, with random access disabled when operating under early releases of CP/M. In the file operations described below, DE addresses a file control block (FCB). Further, all directory operations take place in a reserved area which does not affect write buffers as was the case in version 1.4, with the exception of Searcn First and Search Next, where compatibility is required. The File Control Block (FCB) data area consists of a sequence of 33 bytes for sequential access, and a series of 36 bytes in the case that the file is accessed randomly. The default file control block normally located at 005CH can be used for random access files, since bytes 00708, 007EH, and 007FH are available for this purpose. For notational purposes, the FCB format is shown with the following fields: (All Information Contained Herein is Proprietary to Digital Research.) 13 • ' Idrlfllf21/ /lf8Itllt2It3Iexlslls2Ircld01/ /ldnlcrlr0lrllr21 00 01 02 ••• 08 09 10 11 12 13 14 15 16 ••• 31 32 33 34 35 where dr drive code (0 - 16) o => use default drive for file 1 => auto disk select drive A, 2 => auto disk select drive B, 16=> auto disk select drive P. fl ••. f8 contain the file name in ASCII upper case, with high 'bit = 0 tl,t2,t3 contain the file type in ASCII upper case, with high bit = 0 tIl, t21, and t3 1 denote the bit of these positions, tIl = 1 => Read/Only file, t2' = 1 => SYS file, no DIR list ex contains the current extent number, normally set to 00 by the user, but in range 0 - 31 during file I/O sl reserved for internal system use s2 reserved for internal system use, set to zero on ~all to OPEN, MAKE, SEARCH rc record count for extent "ex," takes on values from 0 - 128 d0 ••• dn filled-in by CP/M, reserved for system use cr current record to read or write in a sequential file operation, normally set to zero by user r0,rl,r2 optional random record number in the range 0-65535, with overflow to r2, to,rl constitute a 16-bit value with low byte r0, and high byte rl Function 15: Open File. Tne Operi File operation is identical to previous definitions, with the exception that byte s2 is automatically zeroed. Note that previous versions of CP/M defined this byte as zero, but made no (All Information Contained Herein is Proprietary to Digital Research.) \ 14 cnecks to assure compliance. Thus, the byte is cleared to ensure upward compatibility with the latest version"where it is required. Function 17: SearCh for First. Search First scans the directory for a match with the file given by the Fca addressed by DE. The value 255 (hexadecimal FF) is returned if the file is not found, otherwise a value of A equal to 0, 1, 2, or 3 is returned indicating the file is oresent. In the case that the file is found, the current DMA ad~ress is filled with the record containing the directory entry, and the relative starting position is A ~ 32 (i.e., rotate the A register left 5 bits, or ADD A five times). Altnough not normally required for application programs, the airectory information can be extracted from the buffer at this position. An ASCII question mark (63 decimal, 3F hexadecimal) in any position from fl through ex matches the corresponding field of any directory entry on the default or auto-selected disk drive. If the dr field contains an ASCII question mark, then the auto disk select function is disabled, -the default disk is searched, with the search function returning any matched entry, allocated or free, belonging to any user number. This latter function is not normally used by application ~rogr&~s, out does allow complete flexibility to scan all current directory values. If the dr field is not a question mark, the s2 byte is automatically zeroed. Function 18: Search for Next. The Search Next function is similar to the Search First function, except that the directory scan continues from the last matched entry. Similar to function 17, function 18 returns the decimal value 255 in A when no more directory items match. Function 19: Delete File. The Delete File function removes files which match the FCB addressed by DE. The filename and type may contain ambiguous references (i.e., question marks in various positions), but the drive select code cannot be ambiguous, as in the Search and Search Next functions. . Function 19 returns a decimal 255 if the reference file or files could not be found, otherwise a value in the range 0 to 3 is returned. (All Information Contained Herein is Proprietary to Digital Research.) 15 • Function 22: Make File. The Make File operation is identical to previous versions CP/M, except that byte s2 is zeroed upon entry to the BOOS. of Function 23: Rename File. The Actions of the file rename functions are the same as previous releases except that the value 255 is returned if the rename function is unsuccessful (the file to rename could not be found), otherwise a value in the range 0 to 3 is returned. Function 24: Return Login Vector. The login vector value returned by CP/M 2.0 is a 16-bit value in HL, where the least significant bit of L corresponds to the first drive A, and the high order bit of H corresponds to the sixteenth drive, labelled P. Note that compatibility is maintained with earlier releases, since registers A and L contain the same values upon return. Function 28: write Protect Current Disk. The disk write protect function provides tem90rary write protection for the currently selected disk. Any attem9t to write to the disk, before the next cold or warm start operation produces the message Bdos Err on d: R/O Function 29: Get R/O Vector. Function 29 returns a bit vector in register pair HL which indicates drives which have the temporary read/only bit set. Similar to function 24, the least significant bit corresponds to drive A, while the most significant bit corresponds to drive P. The R/O bit is set either by an explicit call to function 28, or by the automatic software mechanisms within CP/M which detect changed disks. Function 30: Set File Attributes. The Set File Attributes function allows programmatic manipulation of permanent indicators attached to file~. In particular, the R/O and System attributes (tl' and t2' above) can be s~t or reset. The DE pair addresses an unambiguous file name with the appropriate attributes set or reset. Function 30 searches for a (All Information Contained Herein is Proprietary to Digital Research.) 16 match, and chanqes the matched directory entry to contain the selected inaicators. Indicators fl' through f4' are not ~resently used, but may be useful for applications programs, since they are not involved in the matching process durin9 file open and close operations. Indicators £5' tnrough f3' and t3' are reserved for future system exr;>ans ion. Function 31: Get Disk Parameter Block Address. ~he address of the BIOS resident disk parameter block is returned in HL as a result of this function call. This address can be used for either of two purposes. First, the disk parameter values can be extracted for display and space .computation purposes, or transient programs can dynamically change the values of current disk 1;)arameters when the disk environment changes, if required. Normally, application programs will not require this facility. Function 32: Set or Get User Code. An application program can change or interrogate the currently active user number by calling function 32. If register E = FF nex3decimal, then tne value of the current user number is returned in register A, where the value is in the range 0 to 31. If register E is not FF, then the current user number is changed to the value of E (modulo 32). Function 33: Read Random. 'rhe Read Random function iss imi la r to the seguen t ial file read operation of previous releases, exce1;)t that the read operation takes place at a particular record number, selected by the 24-bit value constructed from the three byte field following the FCB (byte positions r0 at 33, rl at 34, and r2 at 35). Note that the sequence of 24 bits is stored with least significant byte first (r0), middle byte next (r1), and high byte last (r2). CP/M release 2.0 does not reference byte r2, except in computing the size of a file (function 35). Byte r2 must be zero, however, since a non-zero value indicates overflow past the end of file. Thus, in version 2.0, the r0,rl byte pair is treated as a double-byte, or "word" value, which contains the record to read. This value ranges from 0 to 65535, providing access to any particular record of the 8 megabyte file. In order to orocess a file using random access, the base extent (extent 0) must first be opened. Although the base extent mayor may not contain any allocated data, this ensures that the file is properly recorded in the directory, and is visible in DIR requests. The selected record number is then stored into the random record field (r0,rl), and the SDOS is called to read the record. U1;)on return from the call, register A either contains an (All Information Contained Herein is Proprietary to oigitalResearch.) 17 • error code, as listed below, or the value 00 indicating the operation was successful. In the latter case, the current DMA address contains the randomly accessed record. Note that contrary to the sequential read operation, the record number is not advanced. ThuS, subsequent random read operations continue to read the same record. Upon each random read operation, the logical extent and current record values are automatically set. 'rhus, the file can be sequentially read or written, starting from the current randomly accessed position. Note, however, that in this case, the last randomly read record will be re-read as you switch from random mode to sequential read, and the last record will be re-written as you switch to a sequential write operation. You can, of course, simply advance the random record oosition following each ranaom read or write to obtain the effect of a sequential I/O operation. Error codes returned in register A following a random listed below. 01 02 03 04 05 06 read are reading unwritten data (not returned in random mode) cannot close current extent seek to unwritten extent (not returned in read mode) seek past physical end of disK Error code 01 ana 04 occur when a random read operation accesses a data block which has not been previously written, or an extent which has not been created, which are equivalent conditions. Error 3 does not normally occur under proper system operation, but can be cleared by simply re-reading, or re-opening extent zero as long as the disk is not physically write protected. Error code 06 occurs whenever byte r2 is non-zero under the current 2.0 release. Normally, non-zero return codes can be treated as missing data, with zero return codes indicating operation complete. Function 34: Write Random. The Write Random ooeration is initiated similar to the Read Random call, except that data is written to the disk from the current DMA address. Further, if the disk extent or data block which is the target of the write has not yet been allocated, the allocation is performed before the write operation continues. As in the Read Random operation, the rando~ record number is not changed as a result of the write. The logical extent number and current record positions of the file control block are set to correspond to the random record which is being written. Again, sequential read or write operations can commence following a random write, with the notation that the currently addressed record is either read or rewritten again as the sequential operation begins. You can also simply advance the random record position following each write to get the effect of a sequential write operation. Note that in particular, reading or writing the last record of an extent in random mode does not cause an automatic extent (All Information Contained Herein is proprietary to Digital Research.) 18 switch 2.0. as it does in sequential mode under either CP/M 1.4 or CP/M The error codes returned by a random write are identical to the random read operation with the addition of error code 05, which indicates that a new extent cannot be created due to directory ove rflow. Function 35: Compute Fi~e Size. When computing the size of a file, the DE register pair addresses an FCB in random mode format (bytes r0, rl, and r2 are present). The FCB contains an unambiguous file name which is used in the directory scan. Upon return, the random record bytes contain the "virtual" file size which is, in effect, the record address of" the record following the end of the file. if, following a call to function 35, the high record byte r2 is 01, then the file contains the maximum record count 65536 in version 2.0. Otherwise, bytes r0 and rl constitute a 16-bit value (r0 is the least significant byte, as before) which is the file size. Data can be appended to the end of an existing file by simply calling function 35 to set the random record position to the end of file, tnen performing a sequence of random writes starting at the preset record address. The virtual size of a file corresponds to the physical size when the file is written sequentially. If, instead, the file was created in random mode and .. holes" exi s t in the allocation, then the file may in fact contain fewer records than the size indicates. If, for example, only the last record of an eight megabyte file is written in random mode (i.e., record number 65535), then the virtual size is 65536 records, although only one block of data fs actually allocated. Function 36: Set Random Record. The Set Random Record function causes the BOOS to automatically produce the random record position from a file which has been read or The function can be written sequentially to a particular point. useful in two ways. First, it is often necessary to initially read and scan a sequential file to extract the positions of various "key" fields. As each key is encountered, function 36 is called to compute the random record position for the data corresponding to this key. If the data unit size is 128 bytes, the resulting record position is placed into a table with the key for later retrieval. After scanning the entire file and tabularizing the keys and their record numbers, you can move instantly to a particular keyed record by performing a random read using the corresponding random record number which was saved earlier. The scheme is easily generalized when variable record lengths are (All Information Contained Herein is Proprietary to Digital Research.) 19 • involved since the program need only store the buffer-relative byte position along with the key and record number in order to find the exact starting position of the keyed data at a later time. A second use of function 36 occurs when switching from a sequential read or write over to random read or write. A file is sequentially accessed to a ~articular point in the file, function 36 is called which sets the record number, and subsequent random read and write operations continue from the selected point in the file. This section is concluded with a rather extensive, but comolete example of random access operation. The program listed below performs the simple function of reading or writing random records upon command from the terminal. Given that the program has been created, assembled, and placed into a file labelled RAl~DO!-1..C01'1, the CCl? level command: RAN DO£>1 X. DA'r starts the test program. 'rhe program looks for a file by the name X.DAT (in this particular case) and, if found, proceeds to prompt the console for input. If not found, the file is created before the prompt is given. Each prompt takes the form next command? and is followed by operator input, terminated by The input commands take the form nW nR a carriage return. Q where n is an integer value in the range 0 to 65535, and W, R, and Q are simple command characters corresponding to random write, random read, and quit processing, respectively: If the W command is issued, the RANDOM program issues the prompt type data: The operator then responds by typing up to 127 characters, followed by a carriage return. RANDOM then writes the character string into the X.DAT file at record n. If the R command is issued, RANDOM reads record number n and displays the string value at the console. If the Q command is issued, the X.DAT file is closed, and the program returns to the console command processor. In the interest of brevity (ok, so the orogram's not so brief), the only error message is error, try again The program begins with an initialization section where the input file is opened or created, followed by a continuous loop at the label "ready" where the individual commands are interpreted. 'rhe default file control block at 005CH and the default buffer at 0080H are used in all disk operations. The utility subroutines then follow, (All Information Contained Herein is Proprietary to Digital Research.) 20 which contain the ?rincipal input line processor, 'I'h is ?ar ticular pr og ram shows the elements of processing, and can be used as the basis for deve lopmen t • called "readc." random access further program ,. *************************************************** ,.* * ;* sample random access program for cp/m 2.0 ,.* 0Hl0 ., iiHHl5 = = reboot bdos egu egu 00100h 01005h ;system reboot ;bdos entry point 01001 0002 = = coninp conout T?string rstring version openf closef makef readr writer egu equ egu equ egu equ egu equ egu eau 1 113 12 15 16 34 ;console input function ;console output function ;print string until '$' ;read console buffer ;return version number ;file open function ;close function ;make file function ;read random ;write random fcb ranrec ranovf buff egu egu equ equ 005ch fcb+33 fcb+35 0080h ;default file control block ;randorn record position ;high order (overflow) byte ;buffer address cr If egu egu 0dh 0ah ;carriage return ;line feed 01000 00109 = fHHJa = tHic = o 0100f iO~10 0016 JI{j21 0022 1il05c 007d 01217f 013813 * . ' . * ,.*************************************************** org 100h ;base of tpa = = = = = = = = = 00iOd = 000a = 2 9 22 33 ; ; ,.*************************************************** ., * * ;* load SP, set-up file for random access * * ,.* ,.*************************************************** 0100 31bc0 0103 0105 13108 !610a lxi sP,stack version 2.1O? mvi c,version call bdos cpi .20h ;version 2.0 or better? jnc versok bad version, message and go back lxi d,badver print call jrno reboot 0e0c cd050 fe20 d2160 010d Illb0 0110 cdda0 0113 c3000 versok: correct version for random access (All Information Contained Herein is Proprietary to Digital Research.) 21 0116 10118 0llb 121 lIe 0llf 0e0f 11Se0 cd1350 3c c2370 mvi lxi call inr jnz " 121122 121124 0127 0l2a I2Il2b 0e16 11Sc0 cd050 3c c2370 ; ; ·, 0l2e l13a0 13131 cdda0 0134 c31300 c,openf ;open default fcb d,fcb bdos a ;err 255 becomes zero ready cannot open file, so create it c,makef mvi d, fcb lxi call bdos inr a ;err 255 becomes zero jnz ready cannot create file, directory full lxi d,nospace call orint jmp reboot ;back to ccp ; ,.*************************************************** * ·, * ,.* loop back to "ready" after each command * ,.* * ,.*******w******************************************* ~ ready: file is ready for processing 0137 0l3a 0l3d 12114121 0142 0144 cde50 227d0 217fl2l 360121 fe5l c2S60 ··, , liH47 121149 0l4c I2Il4f 121150 121153 0ell1 11SctO cd059 3c cab99 c3090 call snld lxi mvi cpi jnz readcom ;read next command ranrec ;store input record# h,ranovf m,0 ;clear high byte if set 'Q' ; qui t? notq quit processing, close file mvi c,closef lxi d,fcb call bdos inr ;err 255 becomes 121 a jz error ;error message, retry jmp reboot ; back to ccp ·,,• *************************************************** . ,.* * ;* end of quit command, process write ,.w * * ,.*************************************************** notq: not the quit command, random write? cpi • ~v' jnz notw 0156 fe57 0158 c289121 ; !?l15b l14d0 0l5e cdda0 this is a random write, fill buffer until cr d,datmsg lxi print ;data prompt call (All Information Contained Herein is proprietary to Digital Research.) 22 mvi lxi 0161 eJe7f 0163 218010 r loop: 0166 i2J167 1iJ168 !.116b 016c 016d 016f c5 e5 cdc20 el cl 0172 10173 0174 0175 77 23 0d c2660 fe~jd ca780 ~ c,127 ~ul? to 127 characters h,buff ~destination ~read next character to buff puSh b ~save counter h ~next destination l?ush call getchr ~character to a pop h ~restore counter pop b :restore next to fill cpi cr :end of line? jz er 1000 not end; store character mov m,a inx h :next to fill dcr :counter goes down c jnz rloop :end of buffer? erloop: 0178 3600 end of read loop, store 00 mvi m,0 eJ17a 0.l7c 017f 10182 0183 0166 write the record to selected record number mvi c,writer lxi d,fcb call bdos ora :error code zero? a jnz error : message if not jmp ready :for another record 0e22 115c0 cd0512J b7 c2b90 c3370 : ,.*~~******~******~********************************** ,.* * :* end of write command, ~rocess read * ,.* * ,.*************************************************** notw: 0189 fe52 018b c2b9f2J not a write command, read record? 'R' Cl? i jnz error :skip if not 0l8e 0190 0193 019"6 0197 read random record mvi c,readr lxi d,fcb call bdos ora :return code 00? a jnz error 0e21 115c0 cd050 b7 c2b9!.1 read was successful, write to console call crlf :new line mvi c,128 imax 128 characters lxi h,buff inext to get f2J 19a cdcf0 019d k1e80 1c119f ./21800 wloop: f2Jla2 01a3 f2Jla4 f2l1a6 01a9 01aa 7e 23 e67f ca37f2J c5 e5 mov inx ani jz push push a,m h 7fh ready b h :next character inext to get imask parity :for another command if 1210 :save counter isave next to get (All Information Contained Herein is Proprietary to Digital Research.) 23 01ab 131ad 01b0 01bl II'lb2 01b3 01b6 fe20 d4c80 el cl 13d c2a20 c3370 cpi cnc pop pop dcr jnz jmp ·, igraphic? iskip output if not putchr h b c wloop ready icount=count-l ,.******~***********************************~******** * ·, * i* end of read command, all errors end-uD here * * ,.* , , .*************************************************** error: 01b9 11590 01bc cdda0 01bf c3370 lxi call · jmp d,errmsg print ready , ,.*************************************************** ,.* * i* utility subroutines for console i/o * ,.* * ,.***************************************~*********** getchr: ; read next console character to a c,coninp mvi call bdos ret 01c2 0e0l 01c4 cd050 01c7 c9 putchr: 01c8 01ca 01cb 01ce iwrite character from a to console mvi c, conout mov e,a icharacter to send call bdos ;send character ret 0e02 5f cd050 c9 i cr If: 01cf 01dl 01d4 131d6 131d9 ;send carr iage return line feed mvi a,cr ;carriage return call putchr mvi a,lf ;line feed call Dutchr ret 3e0d cdc80 3e0a cdc80 c9 ; print: 01da 01db elIde 01Cif 01el 01e4 ;print the buffer addressed by de until $ push d call crlf pop d ;new line mvi c, pstring call bdos ;print the string ret d5 cdcf0 dl 0e09 cd0513 c9 readcom: (All Information Contained Herein is Proprietary to Digital Research.) 24 01e5 01e8 vJleb itlled eJlf0 116b0 cdda0 0e0a 117ali.l cd050 01f3 01f6 01f9 01fa 01fb 01fc 210010 117c0 la readc: 13 b7 c8 01fd d630 01£f fe0a 0201 d2130 0204 29 0205 4d 0206 44 0207 29 0208 29 0209 09 020a 85 0200 6t o20c d2f90 ~20t 24 11 210 c3f90 i read the next command line to the conbuf lxi d,prompt call TJrint icommand? c,rstring mvi lxi d ,conbuf call bdos iread command line command line is present, scan it lxi h,0 istart with 0000 lxi d,conlinicommand line Idax d inext command character inx d ito next command position ora a icannot be end of command rz . ? not zero, numerIC. sui '0 ' cpi 10 i car ry if numeric jnc endrd add-in next digi t i1(2 dad h mov c,l mov b,h ibC = value * 2 dad h i*4 dad h i*8 dad b i *2 + *8 = *110 add 1 i+digit mov l,a jnc readc ifor another char inr h ioverflow jmp readc ifor another char • endrd: end of read, restore value in a adi i command • 0' 'a' i translate case? cui rc lower case, mask lower case bits ani 101$111lb ret 0213 c630 0215 fe61 I) 217 dS 0218 e65f 021a c9 i ,.*************************************************** ,.* * i* string data area for console messages * ,.* * ,.*************************************************** nadver: 021b 536f79 o23a o24d db 'sorry, you need cp/m version 2$' db 'no directory spaceS' db 'type data: $' db 'error, try again.S' db 'next command? $' nospace: 4e6f29 da tmsg: 547970 e r rmsg: 0259 457272 prompt: 026b 4e6570 (All Information Contained Herein is Proprietary to Digital Research.) 25 ,.*************************************************** ,.* * i* fixed and variable data area * ,. * * ,.*************************************************** 027a 21 027b 027c 0021 = conbuf: consiz: conlin: conlen 029c db ds ds equ conlen 1 ds 32 ilength of console buffer iresulting size after read ilength 32 buffer 32 $-consiz i 16 level stack stack: 02bc end (All Information Contained Herein is Proprietary to Digital Research.) 26 9• CP/M 2.0 MEMORY ORGANIZA'rION. Similar to earlier versions, CP /(\1 2. fZj is field-altered to fit var ious memory sizes, depending upon the host computer memory configuration. Typical base addresses for popular memory sizes are shown in the table below. Module CCP BDOS BIOS 'rop of Ram 20k 3400H 3C00H 4A00H 4FFFH 24k 4400H 4C00H 5A00H 5FFFH 32k 6400H 6C00H 7A00H 7FFFH 48k A400H AC00H BA00H BFFFH 64k E40liJH EC00H FA00H FFFFH The distribution disk contains a CP/M 2.0 system configured for a 20k Intel MDS-800 with standard IBM 8" floppy disk drives. The disk layout is shown below: Sector 1 2 3 4 5 6 7 t5 Sl Hl 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 'rrack 00 Module (Bootstrap Loader) 3400H CCP + 000H 3480H CCP + 080H 3500H CCP + 100H 3580H CCP + 180H 3600H CCP + 200H 3680H CCP + 280H 37i:1I::lH CCP + 300H 3780H CCP + 380rl 3800rl CCP + 400H 3880H CCP + 4t30H 3900H CCP + 500H 3980H CCP + 580H 3A00H CCP + 600H 3A80H CCP + 680H 3B00H CCP + 700H 3B80H CCP + 780H 3C00H BDOS + 000H 3C80H BOOS + 080H 3D00H BOOS + 100H 3D80H BOOS + lB0H 3E00H BOOS + 200H 3E80H BOOS + 280H 3F00H BOOS + 300H 3F80H BOOS + 380H 4000H BOOS + 400H Track 4080H 4100H 4180H 4200H 42d0H 4300H 4380H 4400H 4480H 4500H 4580H 4600H 4680H 4700H 4780H 4800H 4880H 4900H 4980H 4A00H 4A80H 4B00H 4B80H 4C00H 4C80H 4D00H 01 BDOS BOOS BOOS BOOS BOOS BOOS BOOS BOOS BDOS BOOS BOOS BOOS BOOS BDOS BOOS BDOS BOOS BDOS BOOS BIOS BIOS BIOS BIOS BIOS BIOS BIOS Module 480H 500H 580H 600H 6808 700H 780H 800H 880H 900H 980H A00H A80H B00H B80H C00H C80H D00H D80H 000H 080H 100H 180H 200H 280H 300H + + + + + + + + + + + + + + + + + + + + + + + + + + In particular, note that the CCP is at the same position on the disk, and occupies the same space as version 1.4. The BOOS portion, however, occupies one more 256-byte page and the BIOS portion extends through the remainder of track· 01. Thus, the CCP is 800H (2048 decimal) bytes in length, the BOOS is E00H (3584 decimal) bytes in length, and the BIOS is up to 380H (898 decimal) bytes in length. In version 2.0, the BIOS portion contains the standard subroutines of 1.4, along with some initialized table space, as described in the following section. (All Information Contained Herein is Proprietary to Digital Research.) 27 10. BIOS DIFFERENCES. 'rhe CP/M 2.0 Basic I/O System differs only slightly in concept from its predecesssors. Two new jump vector entry points are defined, a new sector translation subroutine is included, and a disk characteristics table must be defined. The skeletal form of these changes are found in the program shown below. org maclio jmp 1: 2: 3: 4: ; 5: 6: 7: d: 9: bpb 10: rpb 11: maxb 12 : 13 : 14 : 15 : 16 : 17: 18: 19: 20: 21 : 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 410: 41 : 42: 43: 44: 45: 46: 47: 4000h diskdef boot jmp listst :list status jmp sectran :sector translate disks 4 large capacity drive equ 16*1024 :bytes per block equ bpb/128 :records per block 65535/rpb :max block number equ diskdef 0,1,58,3,bpb,maxb+l,128,0,2 diskdef 1,1,58, ,bpb,maxb+l,128,O,2 diskdef 2,0 disKdef 3,1 ; boot: ret listst: xra ret :nop a :nop ; seldsk: :drive number in c lxi h,0 :00010 in hI produces select error mov a,c :a is disk number 0 ••• ndisks-l cpi ndisks :less than ndisks? rnc ;return with HL = 0000 if not proper disk number, return dpb element address mov l,c dad h : *2 dad h ;*4 dad h :*8 dad h : *16 lxi d,dpbase dad d :HL=.dpb ret selsec: :sector number in c lxi h,sector mov m,c ret sectran: :translate sector BC. using table at DE xchg :HL = .tran dad b :single precision tran (All Information Contained Herein is Proprietary to Digital Research.) 28 48: 49: 510: 51 : 52: ., dad b again if double precision tran mov 1, m ionly low byte necessary here fill botn H and L if double precision tran ret iHL = 11ss 53: sector: as 54: endef 55: end I Referring to the program shown above, lines 3-6 represent the BIOS entry vector of 17 elements (version 1.4 defines only 15 jum? vector elements). °rhe last two eleme"nts provide access to the hLISTST" (List Status) entry point for DESPOOL. The use of this particular entry point is defined in the OESPOOL documentation, and is no different than the previous 1.4 release. It should be noted that the 1.4 DESPOOL Drog'ram will not o?erate under version 2.0, but an update version will be available from Digital Research in the near fu tur e. 'rhe "SECTRAN" (Sector Number 'rranslate) entry shown in the jump vector at line 6 provides access to a BIOS-resident sector translation sUbroutine. This mechanism allows the user to specify the sector skew factor and translation for a particular disk s~stem, and is described below. A macro library is shown in the listing,. called DISKDEF, included on line 2, and referenced in 12-15. Although it is not necessary to use the macro liorary, it greatly simplifies the disk definition process. You must have access to the MAC macro assembler, of course, to use the DISKDEF facility, while the macrb library is included with all CP/M 2.0 distribution disks. (See the CP/M 2.0 Alteration Guide for formulas which you can use to hand-code the tables produced by the DISKDEF library). A BIOS disk definition consists of macro statements: !'1ACL IB DISKDEF DISKS DISKDEF DISKDEF o , .•• · . . . .. ·.... . DISKDEF · .. . .. ENOEF the following sequence of n 1 , •.. n-l where the MACLIB statement loads the DISKDEF.LIB file (on the same disk as your BIOS) into MAC's internal tables. The DISKS macro call follows, which specifies the number of drives to be configured with your system, where n is an integer in the range 1 to 16. A series of DISKOEF macro calls then follow which define the characteristics of each logical disk, 0 through n-l (corresponding to logical drives A through P). Note that the DISKS and DISKOEF macros generate in-line (All Information Contained Herein is Pro?rietary to Digital Research.) 29 • fixed data tables, and thus must be placed in a non-executable ?ortion of your BIOS, typically directly following the BIOS jump vector. the The remaining portion of your BIOS is defined following DISKDEF macros, with the ENDEF macro call immediately preceding the (End of Diskdef) macro generates the END statement. The ENDEF necessary uninitialized RAM areas which are located above your BIOS. The form of the DISKDEF macro call is DISKDEf dn,fsc,lsc, [skf] ,bls,dks,dir,cks,ofs, [0] where dn fsc Isc skf bls dir cks ofs [0 ] is is is is is is is is is the logical disk number, 0 to n-l the first physical sector number (0 or 1) the last sector number the optional sector skew factor the data allocation block size the number of directory entries the number of "checked .. directory entries the track offset to logical track 00 an optional 1.4 compatibility flag The value "dn" is the drive number being defined with this DISKDEF mac ro invocation. 'rhe" f sc" pa r arne ter accoun ts for di f fer ing sector number ing systems, and is usually 0 or 1. The" Isc" is the last numbered sector on a track. When present, the "skf" parameter defines the sector skew factor which is used to create a sector translation table according to the skew. If the number of sectors is less than 256, a single-byte table is created, otherwise each translation table element occupies two bytes. No translation table is created if the skf parameter is omitted (or equal to 0). The "bls" parameter specifies the number of bytes allocated to each data block, and takes on the values 1024, 2048, 4096, 8192, or 16384. Generally, performance increases with larger data block sizes since there are fewer directory references and logically connected data records are physically close on the disk. Further, each directory entry addresses more da ta and tl1e BIOS-resident r am space is reduced. 'rhe "dk s" specifies the total disk size in "bls" units. That is, if the bls = 2048 and dks = 1000, then the total disk capacity is 2,048,000 bytes. If dks is greater than 255, then the block size parameter bls must be g rea ter than 1024. 'rhe value of .. di r" is the total number of directory entries which may exceed 255, if desired. The "cks" parameter determines the number of directory items to check on each directory scan, and is used internally to detect changed disks during system operation, where an intervening cold or warm start has not occurred (when this situation is detected, CP/M automatically marks the disk read/only so that data is not subsequently destroyed). Normally the value of cks = dir when the media is easily changed, as is the case with a floppy disk subsystem. If the disk is permanently mounted, then the value of cks is typically 0, since the probability of changing disks without a restart is quite low. The "ofs" value determines the number of tracks to· skip when this particular drive is addressed, which can be used to reserve additional operating system (All Information Contained Herein is Proprietary to Digital Research.) 30 space or to simulate several logical drives on a single large capacity physical drive. Finally, the [0] parameter is included when file compatibility is required with versions of 1.4 which have been modified for higher density disks. This parameter ensures that only 16K is allocated for each directory record, as was the case for previous versions. Normally, this parameter is not included. For convenience and economy of table space, the special form DISKDEF i,j gives disk i the same characteristics as a previously defined drive j. A standard four-drive single density system, which is compatible with version 1.4, is defined using the following macro invocations: DISKS DISKDEF DISKDEF DISKDEF DISKDEF 4 0,1,26,6,1024,243,64,64,2 1,0 2,0 3,0 ENDEF with all disks having the same parameter values of 26 sectors oer track (numbered 1 through 26), with 6 sectors skipped between each access, 1024 bytes per data block, 243 data blocks for a total of 243k byte disk capacity, 64 checked directory entries, and two operating system tracks. The definitions given in the program shown above (lines 12 15) provide access to the largest disks addressable by CP/M 2.0. All disks have identical parameters, except that drives 0 and 2 skip three sectors on every data access, while disks 1 and 3 access each sector in sequence as the disk revolves (there may, however, be a transparent hardware skew factor on these drives). th~ough The DISKS macro generates n "disk header blocks," starting at address DPBASE which is a label generated by the macro. Each disk header block contains sixteen bytes, and correspond, in sequence, to each of the defined drives. In the four drive standard system, for example, the DISKS macro generates a table of the form: DPBASE DPE0: OPEl: DPE2: DPE3: EQU OW OW OW OW $ XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV0,ALV0 XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSVl,ALVl XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV2,ALV2 XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV3,ALV3 where the OPE (disk parameter entry) labels are included for reference purposes to show the beginning table addresses for each drive 0 through 3. The values contained within the disk parameter header are described in detail in the CP/M 2.0 Alteration Guide, but basically address the translation vector for the drive (all reference XLT0, which is the translation vector for drive 0 in the above example), (All Information Contained Herein is Proprietary to Digital Research.) 31 • followed by three 16-bi t "scratch" addresses, followed by the directory buffer address, disk parameter block address, check vector address, and allocation vector address. The check and allocation vector addresses are generated by the ENDEF macro in the ram area following the BIOS code and tables. The SELDSK function is extended somewhat in version 2.0. In particular, the selected disk number is passed to the BIOS in register C, as before, and the SELDSK subroutine performs the appropriate software or hardware actions to select the disk. Version 2.0, however, also requires the SELDSK subroutine to return the address of the selected disk parameter header (DPE0, DPEl, DPE2, or DPE3, in the above example) in register HL. If SELDSK returns the value HL = 0000H, then the BDOS assumes the disk does not exist, and prints a select error ~esage at the terminal. program lines 22 through 36 give a sample CP/M 2.0 SELDSK subroutine, showing only the disk parameter header address calculation. The subroutine SECTRAN is also included in version 2.0 which performs the actual logical to physical sector translation. In earlier versions of CP/M, the sector translation process was a part of the BDOS, and set to skip six sectors between each read. Due differing rotational speeds of various disks, the translation function has become a part of the BIOS in version 2.0. Thus, the BDOS sends sequential sector numbers to SECTRAN, starting at sector number 0. The SECTRAN subroutine uses the sequential sector number to produce a translated sector number which is returned to the SOOS. The BOOS subsequently sends the translated sector number to SELSEC before the actual read or write is performed. Note that many controllers have the capability to record the sector skew on the disk itself, and thus there is no translation necessary. In this case, the "skf" parameter is omitted in the macro call, and SEC/fRAN simply returns the same value which it receives. The table shown below, for example, is constructed when the standard skew factor skf = 6 is specified in ~he DISKDEF macro call: XLT0: DB OB 1,7,13,19,25,5,11,17,23,3,9,15,21 2,8,14,20,26,6,12,18,24,4,10,16,22 If SECTRAN is required to translate a sector, then the following process takes place. The sector to translate is received in register pair BC. Only the C register is significant if the sector value does not exceed 255 (8 = 00 in this case). Register pair DE addresses the sector translate table for this drive, determined by a previous call on SELDSK, corresponding to the first element of a disk parameter header (XL'l'0 in the case shown above). The SECTHAN subroutine then fetches the translated sector number by adding the input sector number to the base of the translate taole, to get the indexed translate table address (see lines 46, 47, and 48 in the above program). The value at this location is then returned in register L. Note that if the number of sectors exceeds 255, the translate table contains 16-bit elements whose value must be returned in HL. areas Following the ENDEF macro call, a number of uninitialized data are defined. These data areas need not be a part of the BIOS (All Information Contained Herein is Proprietary to Digital Research.) 32 which is loaded upon cold start, but must be available between the 3IOS and the ena of memory. The size of the uninitialized RAM area is determined by EQU statements generated by the ENDEF macro. For a standard four-drive system, the ENDEF macro'might oroduce 4C72 = 4D8k1 = = 013C BEGDA'r EQU $ (data areas) ENDDA'r EQO $ DATSIZ EQU $-BEGDAT which indicates that uninitialized RAM begins at location 4C728, ends at 4D80H-l, and occupies 0i3CH bytes. You must ensure that these addresses are free for us~ after the system is loaded. CP/M 2.0 is also easily adapated to disk subsystems size is a multiple of 128 bytes. Information is provided on sector write operations which eliminates the need operations, thus allowing olocking and deblocking to take BIOS level. whose sector by the BOOS for pre-read place at the See the "CP/M 2.0 Alteration Guide" for additional details concerning tailoring your CP/M system to your particular hardware • • (All Information Contained Herein is Proprietary to Digital Research.) 33 OPERATION OF THE CP/M DEBUGGER I ( 01 [)~[j~Tfll RESEflR[H Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896 CP/M DYNAMIC DEBUGGING TOOL USER'S GUIDE COPYRIGHT (c) 1976, 1978 DIGITAL RESEARCH (DDT) • Copyright (c) 1976, 1978 by Digital Research. All rights reserved. No part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system, or translated into any language or computer language, in any form or by any means, electronic, mechanical, magnetic, optical, chemical, manual or otherwise, without the prior written permission of Digital Research, Post Office Box 579, Pacific Grove, Califcrnia 93950. Disclaimer Digital Research makes no representations or warranties with respect to the contents hereof and specifically disclaims any implied warranties of merchantability or fjtness for any particular purpose. Further, Digital Research reserves the right to revise this publication and to make changes from time to time in the content hereof without obligation of Digital Research to notify any person of such revision or changes. Table of Contents Section I. II. Page INrRODUcrION • Dur OOMl'lAN'Il3 0 0 0 0 0 • 0 •• 0 0 ••• 0 0 0 0 0 0 0 0 • 0 0 •• 0 0 ••••••••••••••••••••••• • 0 •••••• 0 •••••••••••• 1. 20 3. The A (Assemble) Command ••••••••••••••••••••• The D (Display) Command •••••••••••••••••••••• The F (Fill) Command .0 ••••••••••••••••••••••• 4. The G (Go) Command •• 50 The I (Input) Command .0 •••••••••••••••••••••• 6. The L (List) Command 7. The M (Move) Command • •••••••••••••••••••••••• 8. The R (Read) Command •••••••• The S (Set) Command 10. The T (Trace) Command 110 The U (Untrace) Command ••• o.o • • • • • • • • • • • • • • ~. 12. The X (Examine) Command III. IMPLEMENTATION NOTES •• IV. AN EXAM.PLE o. 0 0 • • 0 • 0 ••••••••••••••••••• • • • • • • • • 0000 • • • • • • • • • • • • 0 90 •••••••••••••••• 0 0 0 0 • 0 0 • 0 3 3 4 4 4 5 6 6 6 .00 ••••••••••••••••••• 0. 7 7 00.0000 • • • • • • • • • • • • • • • 8 8 0000000000000000 •••• 0.0 •• 0 0 1 000 • • • • 0 • • • • • • • • • • • • • • • • • • • 9 • 10 0 ••••••••• 0 ••••••••••••••• • CP/M Dynamic Debugging Tool (DDT) User's Guide I. Introduction. The DDT program allows dynamic interactive testing and debugging of programs generated in the CP/M environment. The debugger is initiated by typing one of the following commands at the CP/M Console Comrrand level DDT DDr filename.HEX DDr filename.COM ¥.here "filename" is the name of the program to be loaded and tested. In both cases, the DDT program is brought into ·main memory in the place of the Console Canmand Processor (refer to the CP/M Interface Guide for standard memory organization), and thus resides directly below the Basic Disk Operating System portion of CP/M. The BlX)S starting address, ¥.hich is located in the address field of the JMP instruction at location 5H, is altered to reflect the reduced Transient Program Area size. The second and third forms of the DDT command shown above perform the same actions as the first, except there is a subsequent automatic load of the specified HEX or (X)M file. The a.ction is identical to the sequence of commands DDr Ifilename.HEX or Ifilename.COM R where the I and R canmands set up and read the specified program to test (see the explanation of the I and R commands below for exact details). Upon initiation, DDT' prints a sign-on message in the format nnK Dor-s VER m.m where nn is the IlErnary size (which must match the CP/M system being used), s is the hardware system which is assumed, corresponding to the codes D M I o S Digital Research standard version MUS version IMSAI standard version ~on systems Digital Systems standard version and m.m is the revision number. 1 • Following the sign on message, DDT prompts the operator with the character "-" am waits for input canmaods from the console. The operator can type any of several single character canmands, terminated by a carriage return to execute the canmand. Each line of input can be line-edited using the standard CP/M controls rubout ctl-U ctl-C remove the last character typed remove the entire line, ready for re-typing system reboot Any commam can b~ up to 32 characters in lenqth (an automatic carriage return is inserted as the 33rd character), where the first dlaracter determines the comrnam type A D F G I L M R S T U X enter assembly language mnemonics with operands display memory in hexadecimal and ASCII fill memory with constant data begin execution with optional breakpoints set up a standard input file control block list memory usinq assembler mnemonics move a memory segment fran source to destination read program for subsequent testing substitute memory values trace program execution untraced program monitoring examine and optionally alter the CPU state The canmam character, in some cases, is followed by zero, one, two, or three hexadecimal values which are separated by canmas or single blank characters. All DDT numeric output is in hexadecimal form. In all cases, the commands are not executed until the carriaqe return is typed at the end of the command. At any [X>int in the debuq run, the operator can stop execution of DIJI' usinq either a ctl-C or G0 (jmp to location 0000H), am save the current memory image usinq a SAVE canmand of the form SAVE n filename.COM where n is the number of p3ges (256 byte blocks) to be saved on disk. The nwrber of blocks can be determined by taking the high order byte of the top load address am converting this number to decimal. For example, if the highest address in the Transient Program Area is 1234H then the nurrber of pages is l2H, or 18 in decimal. Thus the operator could type a ctl-C during the debug run, returning to the Console Processor level, followed by SAVE 18 X.COM The memory image is saved as X.COM on the diskette, am can be directly executed by simply typing the name X. If further testing is required, the memory image can be recalled bv typinq 2 DIJI' X.COM which reloads p:eviously saved program from loaction l00H through p:ige 18 (12FFH) • The machine state' is not a part of the COM file, and thus the program must be restarted from the beginning in order to properly test it. I I • DIJI' CDMMANDS. 'l'he imi vidual canmands are given below in some detail. In each case, the operator must wait for the prompt character (-) before entering the command. If control is p:issed to a lXogram under test, and the program has not reached a breakr:oint, control can be returned to DIJI' by executing a RST 7 from the front p:inel (note that the rubout key should be used instead if the program is executing a T or U canmand). In the explanation of each command, the command letter is shown in rome cases with nurrbers separated by canmas, \\here the nurrbers are represented by lower case letters. These nurrbers are always assumed to be in a hexadecimal radix, and from one to four digits in length (longer numbers will be automatically truncated on the right). Many of the canmands operate ur:on a "CPU state" which corresp:mds to the program under test. 'I'he CPU state holds the registers of the program being debugged, and initially contains zeroes for all registers and flags except for the frogram counter (P) and stack r:ointer (S), which default to l00H. The program counter is subseguently set to the starting address given in the last record of a HEX file if a file of this form is loaded (see the I and R commands) • 1. The A (Assemble) Command. Dill' allows inline assembly language to be inserted into the current memory image using the A command which takes the form As where s is the hexadecimal starting cddress for the inline assembly. DIJI' prompts the console wi th the cddress of the next instruction to fill, and reads the console, looking for assembly language mnemonics (see the Intel 8080 Assembly Language Reference Card for a list of mnemonics), followed by register references and operands in absolut0 hexadecimal form. Each sucessive load address is printed before reading the console. The A command terminates when the first empty line is input from the console. Upon canpletion of assembly language input, the operator can review the memory segment using the DlJI'disassembler (see the L command). Note that the assembler/disassembler ]Xlrtion of DIJI' can be overlayed by the transient program being tested, in which case the DIJI' program restx>nds wi th an error condition when the A and L commands are used (refer to Section IV) • 3 • 2. The D (Display) Command. The D command allows the operator to view the contents of memory in hexadecimal and ASCII formats. The forms are D Ds Ds,f In the first case, memory is displayed from the current display address (initially 100H), and continues for 16 display lines. Each display line takes the fOrm shown below aaaa bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb cccccccccccccccc where aaaa is the display address in hexadecimal, and bb represents data present in memory starting at aaaa. The ASCII characters starting at aaaa are given to the right (represented by the sequence of c's), ¥.here non-graphic characters are fr inted as a };Eriod (.) symbol. Note that both upper and lower case alphabetics are displayed, and thus will appear as upper case symbols on a console device that supports only ul;Per case. Each display line gives the values of 16 bytes of data, except that the first line displayed is truncated so that the next line begins at an address which is a multiple of 16. The second form of the D canmand shown above is similar to the first, except that the di splay address is first set to address s. The third form causes the display to continue frOm address s through address f. In all cases, the display address is set to the first address not displayed in this command, so that a continuing display can be accomplished by issuing successive D canmands with no explicit addresses. Excessively long displays can be aborted by pushing the rubout key. 3. The F (Fill) Command. The F command takes the form Fs,f,c where s is the starting address, f is the final address, and c is a hexadecimal byte constant. The effect is as follows: DDT stores the constant c at address s, increments the value of s and tests against f. If s exceeds f then the operation terminates, otherwise the operation is repeated. Thus, the fill command can be used to set a memory block to a specific constant value. 4. The G (Go) Command. Pro:Jrarn execution is started using the G cornand, with up to two optional breakpoint addresses. The G command takes one ot the forms G Gs Gs,b 4 Gs,b,c G,b G,b,c The first form starts execution of the program under test at the current value of the p::ogram counter in the current rrachine state, with no breakpoints set (the only way to regain control in DO!' is through a RST 7 execution). The current p::ogram counter can be viewed by typing an X or XP connnand. The second form is similar to the first except that the program counter in the current rrachine state is set to address s before execution begins. The third form is the same as the second, except that program execution stops when address b is encountered (b must be in the area of the program under test). The instruction at location b is not executed when the breakpoint is encountered. The fourth form is identical to the third, except that two breakpoints are s~cified, one at b and the other at c. Encountering either break~int causes execution to stop, and both breakpoints are subsequently cleared. The last blo forms take the program counter fran the current machine state, and set one and two break~ints, res~ctively. Execution continues fran the starting address in real-time to the next breakpoint. That is, there is no intervention between the starting address and the break address by DO!'. Thus, if the program under test does not reach a breakpoint, control cannot return to DO!' without executing a RST 7 instruction. Upon encountering a breakpoint, DO!' stops execution and types *d where d is the stop address. The rrachine state can be examined at this point using the X (Examine) connnand o The operator must s~cify break~ints which differ fran the p::ogram counter address at the beginning of the G camnand. Thus, if the current program counter is 1234H, then the commands G,1234 and G400,400 both produce an imrrediate breaktx>int, whatsoever. without executing any instructions 5. The I (Input) Comrrand. The I canmand allows the operator to insert a file name into the default file control block at SCH (the file control block created by CP/M for transient p::ograms is placed at this location; see the CP/M Interface Guide). The default PCB can be used by the p:-ogram under test as if it hcrl been passed by the CP/M Console Processor. Note that this file name is also used by DO!' for reading additional HEX and COM files. The form of the I command is Ifilename or 5 Ifilename.filetype If the second form is used, and the filetype is either HEX or COM, then subsequent R commands can be used to read the pure binary or hex format machine code (see the R command for further details). 6. The L (List) Commando The L cormnand is used to list assembly language mnemonics in a particular pr09'ram region. The forms are L Ls Ls,f The first canrnand lists twelve lines of disassembled machine code from the current list address. The second form sets the list address to s, and then lists twelve lines of code. The 'last form lists disasserrbled code from s through address f. In all three cases, the list address is set to the next unlisted location in preparation for a subsequent L command. Upon encountering an execution breakpoint, the list address is set to the current value of the };r09'ram counter (see the G and T cormnands). Again, long type outs can be aborted using the rubout key during the list process. 7. The M (Move) Command. The M command allows block movement of pr09'ram or data areas from one location to another in memory. The form is Ms,f,d where s is the start address of the rove, f is the final address of the nove, and d is the destination address. Data is first noved from s to d, and both addresses are incremented. If s exceeds f then the nove operation stops, otherwise the rove operation is repeated. 8. The R (Read) Command. The R command is used in conjunction with the I command to read COM and HEX files from the diskette into the transient pr09'ram area in };reparation for the debug run. The forms are R Rb where b is an optional bias address Vthich is added to each program or data address as it is loaded. The load qJeration must not overwrite any of the system parameters from 000H through 0FFH (i.e., the first page of memory). If b is ani tted, then b=0000 is assumed. The R command requires a };revious I command, specifying the name of a HEX or COM file. The load address for each record is obtained from each individual HEX record, Vthile an assumed load address of 100H is taken for COM files. Note that any number of R commands can be issued following the I command to re-read the program tmder test, 6 assuming the tested program does not destroy the default area at SCH. Further, any file s};ecified with the filetype "COM" is aSSLnned to contain machine code in pure binary form (created with the LOAD or SAVE command), and all others are assumed to contain machine code in Intel hex format (produced, for example, with the ASM command). Recall that the command DDr filename.filetype which initiates the DD[' program is equivalent to the commands DDr -Ifilename.filetype -R Whenever the R command is issued, DDr responds with either the error indicator n?n (file cannot be opened, or a checksLnn error occurred in a HEX file), or with a load message taking the form NEXT PC nnnn PWP where nnnn is the next address following the loaded program, and pppp is the assumed program counter (100H for COM files, or taken from the last record if a HEX file is s};ecified). 9. The 5 (Set) Command. The 5 command allows memory locations to be examined and optionally altered. The form of the command is 5s where s is the hexadecimal starting address for examination and alteration of memory. DDr resp:mds with a numeric prompt, giving the memory location, along with the data currently held in the memory location. If the operator types a carriage return, then the data is not altered. If a byte value is typed, then the value is stored at the prompted address. In either case, DIJI' continues to prompt with successive addresses and values until either a period (.) is typed by the operator, or an invalid input value is detected. 10. The T (Trace) Command. The T command allows selective tracing of program execution for 1 to 65535 program steps. The forms are T Tn In the first case, the CPU state is displayed, and the next program step is executed. The program terminates immediately, with the termination address 7 displayed as *hhhh where hhhh is the next address to execute. The display address (used in the D command) is set to the value of Hand L, and the list address (used in the L command) is set to hhhh. The CPU state at program termination can then be examined using the X command. The second form of the T command is similar to the first, except that execution is traced for n steps (n is a hexadecimal value) before a J;X"ogram breakp::>int is occurs. A breakp::>int can be forced in the trace rode by typing a rubout character. The CPU state is displayed before each program step is taken in trace rode. The format of the display is the same as described in the X canrnand. Note that J;X"ogram tracing is discontinued at the interface to CP/M, and resumes after return from CP/M to the program under test. Thus, CP/M functions which access I/O devices, such as the diskette drive, run in real-time, avoiding I/O timing problems. Programs running in trace rode execute approximately 500 times slower than real time since DDI' gets control after each user instruction is executed. Interrupt processing routines can be traced, but it must be noted that canrnands which use the breakpoint facility (G, T, and U) accomplish the break using a RST 7 instruction, which means that the tested J;X"ogram cannot use this interrupt location. Further, the trace mode always runs the tested J;X"ogram with interrupts enabled, which may cause problems if asynchronous interrupts are received during tracing. Note also that the operator should use the rubout key to get control back to DDI' dur ing trace, rather than executing a RST 7, in order to ensure that the trace for the current instruction is completed before interruption. 11. The U (Untrace) Command. The U command is identical to the T command except that intermediate lXogram steps are not displayed. The untrace rode allows from 1 to 65535 (0FFFFH) steps to be executed in monitored mode, and is used J;X" incipally to retain control of an executing program while it reaches steady state condi tions. All conditions of the T command apply to the U command. 12. The X (Examine) Command. The X command allows selective display and alteration of the current CPU state for the program under test. The forms are X Xr where r is one of the 8080 CPU registers C Z Carry Flag Zero Flag (0/1) (0/1) 8 M E I A B D H S P Minus Flag Even Parity Flag Interdigit Carry Accumulator BC register pair DE register pair HL register p:lir Stack Pointer Program Counter (0/1) (0/1) (0/1) (0-FF) (0-FFFF) (0-FFFF) (0-FFFF) (0-FFFF) (0-FFF'F) In the first case, the CPU register state is displayed in the format CfZfMfEfIf A=bb B=dddd D=dddd H=dddd S=dddd F--dddd inst where f is a 0 or 1 flag value, bb is a byte value, and dddd is a double byte quanti ty corresponding to the register pair. The "inst" field contains the disassembled instruction which occurs at the location addressed by the. CPU state's program counter. The second form allows display ?ind optional alteration of register values, where r is one of the registers given above (C, Z, M, E, I, A, B, D, H, S, or P) • In each case, the flag or register value is first displayed at the console. The DDT program then accepts input from the console. If a carriage return is typed, then the flag or register value is not altered. If a value in the proper range is typed, then the flag or register value is altered. Note that SC, IE, and HL are displayed as register p:tirs. Thus, the operator types the entire register pair when B, C, or the BC pair is altered. I II. IMPLEMENTATION NarES. The organization of DDT allows certain non-essential portions to be overlayed in order to gain a larger transient program area for debugging large programs. The DDT program consists of two parts: the Dill nucleus and the assembler/disassembler nndule. 'rhe DDT nucleus is loaded over the Console Command Processor, and, al though loaded wi th the DDT nucleus, the assembler/disassembler is overlayable unless used to assemble or disassemble. In particular, the BOOS address at location 6H (address field of the JMP instruction at location 5H) is nndified by DDT to address the base location of the DDT nucleus which, in turn, contains a JMP instruction to the BOOS. Thus, progr ams v.hich use this address field to size !Ternory see the logical end of memory at the base of the DDT nucleus rather than the base of the BOOS. The asserrbler/disassembler nndule resides directly below the DDT nucleus in the transient :program area. If the A, L, T, or X commands are used during the debugging process then the DDT program again alters the address field pt 6H to include this nndule, thus further reducing the logical end of memory. If a :program loads beyond the beginning of the assembler/disassembler JIDdule, the A and L canmands are lost (their use produces a "?" in response), and the 9 • trace am display (T and X) cormnands list the "instil field of the display in hexadecimal, rather than as a decoded instruction. IV. AN EXM1PLE. The followin:J example srows an edit, asserrt>le, and debug for a simple program which reads a set of data values and determines the largest value in the set. The largest value is taken from the vector, and stored into "IARGE" at the termination of the p:ogram ; TO NEln ELEMENT il10RE TO SCAtP 3 i 1 ; . 2.~ i J VEeT: LEH LARGE: ~*B0P -,) HFOUHD: J END OF SCAN .• STORE C" iGET LARGEST VAL'IE !iQY.. B..::.f L -. LARGE .§.l8.. 1 ;REBOOT J .JL ill l!,g ~ !.§. SOU(Qe. 'P{~V().tM.. ~ l!w!e,(H4~ C~a (o.clef's 'bl'~c{ ~ 1NCJ8Y"o.rYLm.e( II II yePf~-h f{.1(fio j e. J (t-kt(1I\, . TEST DATA 2 .. 0 .. 4,3,S,6 .. 1 .. 5 J {-VECT iLENGTHJ ~ iLARGEST VALUE ON EXIT) ..ill!,2 ORG "'VI LOOP: FOR A14 Q THE R.1 CV'l!ol-e le0H B,LEN MYI c,e LXI H.YECT A.M iSTART OF TRANSIENT AREA iLEHGTH OF VECTOR TO SCAN iLARGEST VALUE SO FAR iBASE OF VECTOR ;GEl YALUE MOY SUB C i JNC NFOUHD ;JUMP IF LARGER VALUE NOT FOUND LARGER YALLIE INC? HEIII LARGEST VALUE, STORE I T TO C MOil C.' A INX H ;TO NEXT ELEMENT DCR B iMORE TO SCAlP JNZ LOOP ; FOR AI40THER 10 END OF SCAN .. STORE C MOY A,C ;GET LARGEST VALUE STA LARGE ..IMP (3 j REBOOT VECT: LEN TEST DATA 2 .. 0,4 . 3,5,6 . 1 .. 5 DB EQU $-YECT .;LENGTH LARGE: DS ILARGE5T VALUE ENII '~~ Ot~ EX IT ~~d. of tdlt 4-- CP/M ASSEMBLER - VER 1.0 [11 22 002H LISE FACTOR ENII OF ASSE~lBL'y' TYPE SCAI4. - CodeW{~ e 10 €I PRI~ Mo.~mt J ( Sou(re ;RC8~GM Cock ~ 01130 BGes,) ORG ~1Il I 0102 3E00 Mil I 0104 211901 0107 7E un LOOP: MOil 0108 91 SUB 13109 D20DBl .IN C 010C 4F 0UlD 23 010E 135 NEt" ~10 V NFOUIH: It4~: nCR ;START OF TRANSIENT AREA ;LENGTH OF VECTOR TO SCAN ;LARGEST VALUE 50 FAR ce H, 'liE C 'T. ,; BI~SE OF VECTOR I~,M JGET VALUE C ;LARGER VALUE IN C? NFOUND ;JUMP IF LARGER VALUE NOT FOUND LARGEST VALUE, STORE IT TO C (:, A H ;TO NEXT ELEMENT B ;MORE TO SCAN? LOOP ;FOR ANOTHER 100H B) LE I~ 010F C20781 IN Z 0112 79 0113 3221B1 13116 C3~.~0~ I' END OF SCAN, !::TORE C MOV A., C .• LiET LARGEST VALUE STA LARGE JMP 0 ;REBOOT CcJe./dak IU;\1Y1J ; i"Yu«altcf "--"f; TEST DATA 0119 B200040305YECT: DB 2,0,4 .. 3 .. 5;6,1,5 003 8 = LEN 0121 LARGE: EQU DS END $-VEeT 1 e 122 Fi> <:2\ Va\ueq.J fqLUrk It ;LENGTH ;LARGEST YALUE ON EXIT DDT SCAN. HEX ~ 161< DDT VER 1.0 NEXT PC ~ ~ 21\1.....8_°_°_0_ _ lQ..lbt lood CAdMe5~ -I- I r-ktd-l~ -IfI e)(l ((Lit a.t -~ f. CeZ0MBE0I0 A=00 8=0080 D=@00e H=0000 8=0100 P=0000 OUT -XP 7F ?CeO ~ ~J(o.W~ I(~l~~ loJOie de~"e> YU~ -J p=ee0Et 1013 -~ C.!.Lttnjt \.oJL at -~J 'PC- -\0 lOO .rPc. cLA"-~d. VlslSb-6 qfJCt\;'" C0Z0MBE010 A=00 B=0000 D=0000 H=0000 8=0100 F'=0 Hie MVI -L100", B,0S) ~ 1\t4vurkV\ 0100 M'JI B,€I8 0102 M'II I LXI MOl! (:,00 0104 0107 010S 13109 0leC el0D SUB JHC MOil I NX DCR -to 6ceack crl Pl~\OO H .. 0119 A .• M C 010D CIA 1) ~~~!,J M/lc1.I~t Code a~ l{X)~ ~et 'StlJict l.L~h~ JHZ MOil H B 0107 A .• C i!t113 STA €I12i 0116 JMP 0080 0119 011A BTAX B NOP 011 B 13 1 1 C :!~ ~ I NR I N~: B B ~~~ ~. 0 1 €I 121 II CR L XI B If, 2 2 1 H l ' u 13124 LXI H,e200 li 1 €IE e10F e 112 O(~lSO~ -L -~ a1 2 e A lrlte. Wl)ye.. V'Aadt lYle Code. (~ ~ t'(q9m YY\ e.wk, a1 l~c.o:Mn lib _ \ UJl'UAQ~Up+oncooJ . . ' '. e\\..Ie.i 'I\\l~ a~se~~~ \'nod~ 10 e~ 4t:Jt..tf ~ OOQ) I~ (). ~1 1, W~I(1 -R~T "'{ ~ILl CclltSe, -tk Y{~YClY1A UVtdu -f-cot -to '(e.~VV\. it> nvr It \\b\4 -.!Ull 0116 - o1 17~ 'L&.II~j~( - L 11 3" ust l~ eVcw e~c.ukd. rI Ca'lyt'4jC Ctxif yttu.(\\ ~-toVS a~seW\1Je mod.eJ at l\'3~ 40 dAtJ 4WJ ~'S11 was 1iY~c(~ \n~ ~ I~ place cr J'M f o1 1 3 ST A €I1 2 1 0116 RST B7",...-' 0117 8118 8119 ellA ellB BllC HOP NOP STAl< B NOP IHR IHX B B , -It ~ loct a\ VCj lst(S C0Z0MBE010 A=00 B=00B0 D=B000 H=0000 8=0100 -Lt1 &ecu:1c ?vO~(a~ --f" ceZ0M0E010 A=0B 8=00130 -l.J lrtu Odt -ip ~;\1 (M{ Oy\L B.0S J H=0008 8=0100 P=0100 MY] B.08*0102 aLCblJWlitL ~{~kpj)\~t oru ,on ,g) C0Z0MBE0I0 A=0B B=0800 D=0000 H=0000 8=0100 -L; IVtXe MVI i~L~1 CRu cs-ht-le.. ~erv(€ J J\ ~ecu.kd "Skf. D=~0B0 P~0100 P~0102 MYI .J C.00*0104 CIJo.~\f\ (\(~\~~ C ~~ d(1(A(tdJ C0Z0M0E0I0 A=00 8=0800 D=0000 H=0000 8=0100 P=0104 LXI H.0119*019? -llr1\racl. 1"t1vt't ~k{1s C0zeMBE010 A=Be 8=08130 cezeMBE0I0 A=B2 B=0800 C0Z0MEtE0Il A=Et2 B=08e0 -DI1Q' ~~. --=-J 'OlSQto:1 Mt'MfH,S '( ~ e 119 02 IHI 04- 03 05 06 0120 0S 1 1 BB 22 21 130 13130 C2 27 01 C3 03 29 0140 00 00 00 00 00 130 0150 00 00 00 0111 00 130 01613 130 09 00 00 00 90 01713 130 B0 00 e0 00 00 0180 00 00 00 013 00 130 019B 00 00 00 013 130 130 BIAe B0 00 00 013 130 00 e180 130 fJ0 00 eB 0e 00 Ble0 130 130 00 013 130 00 -x-J Cu«~ D=0000 H=0119 8=@100 P=01B7 MOV D=B000 H=01l9 S=01B0 P=0108 SUB D=IH3e0 H=0119 8=01013 P=0109 JHC 7E 00 00 00 00 00 e0 130 8fJ B13 €Ie EB 90 013 130 013 0e 00 00 00 00 013 77 1 3 23 EB 0B 013 00 0fJ 0fJ efJ 0fJ 00 00 00 013 0B e0 BB 00 00 00 00 130 B0 00 00 00 130 e0 e0 130 €Ie 00 00 00 130 Be fJ0 €Ie 00 fJ0 00 130 00 00 013 013 130 013 013 013 013 00 130 0111 00 €Ie D.~ ~ di~V~{d: 0 -us A=02 R=02 A=B2 A=02 R=0B 0 of 0 0 ClI..((e..rt B=08e0 B=08e0 8=07139 B=0700 8=8700 0 0 •• 0 0 ~ H CPU sk.tc, D=13 13 BB D=B000 D=000e D=0000 Il=B000 H=0119 H=011A H=011A H=011A H=011A 8=0100 8=0100 S=0100 8=B100 8=0100 P=010D P=010E P=010F P=01B7 P=0108 0 : :: : :: 0 CPu. 4.-\e, ), -reate s stps ~y~ C0Z0MBE0Il (:0Z0MBE0Il C0Z0MBE0Il C0Z0MBE011 C0Z0M0E011 : :: o ~ 1AIt'ttr 11:I" •. 00 · l\t: 00 130 °l\A. ~ p~l"bo~ 00 :v\o~:'-6"Op~~l: 00 elAoraUcf'$ B0 · ............ , .. B0 · . . . . . . . . . . . . . . C0ZEtM0E0Il A=02 8=0800 D=0e0B H=0119 8=0100 P=010D I N)<: - T S"j 010D*010D 6.t.r\o~ buak'Po,rtr tA1 jOD~--' crt IIqH. 01 ~~~D:~~~ 02 00 0.0 00 00 00 130 00 fJ0 fJ0 fJ0 Ao' M C INX DCR JHZ MOil SUB H B A~~-lti. g"""i..ct oI A.M C:to01B9 - I "tract \.iIl~~O\)-\ \lcfu~ ~\4.:b~.E!d ltdt, ~ks 0 ceZ1MBE111 A=00 B=871HI D=B000 H=011A 8=B100 P=0109 JHC 010D*0108 -K.J CPu. ~k ~t llA&of l.lS I C0Z0MBE111 A=04 8=0680 D=B0Be H=011B 8=0100 P=0108 SliB C • -§...; * €I 1 i 6 - ~-i \?Url ?rDjraY'\ -ttt:W\ CLtfYO.l-t 'Pc \Al\.-nl C/J~~le.hb~ (l~ ~-·h~e.) YJtettk.poiJ Clt ll6~ J COJAf,ltl ~ ~-k~ R<5T 1 \~ ~lt(~e. &d~ C1u ~k at ew).. of p~~m ceZlMBElIl A=00 8=0000 D=8000 H=@121 - 8=0100 P=0116 RST 07 ~l l)c£l.~l~ o.vr1 C,\.wt~l 'Qf~~'()\ Col.t~te< P=0116 IB0; -X -J ceZlMBElIl A= €I 0 8 = 0 €I 0 €I II =1:1 €I 13 €I H=€I 1 21 -T10~ -rw ltr P:=fi~f'0 lO (k~~t) ~s ,fl~t dJ1 ~~tl\,{ ~~ C0Z1MBEIIl C0Z1MBEIIl C0Z1MBEIIl C0Z1MBEIIl ceZlMBElIl C0Z0MBE011 C0zeMBE0Il C0Z0MBE011 C0Z0MBE0Il C0Z0MBE011 C0Z0MBE0Il C0Z1MBEIIl C0Z1MBEIIl C0Z1MBEIIl ceZ0M0El11 ceZBM0El11 -A109 R=1:I0 A=0e A=00 A=00 A=@ A=82 A=B2 A=02 A=02 A=02 A=00 A=00 A=00 A=00 A=013 A=00 8=000€t 8=08013 8=080 B:- ~ =0-e 8=088e 8=0800 8=0800 9=07B13 8=07013 8=137"013 8=€I7B13 B=070e 8=07013 B=1l160e 8=06813 II=0 0 [I 800 =0000 II= =0000 [I=Ba0e ['=0000 D=000e II=000B D=B0e0 II=000e I'=0000 D=000e II=€t000 D=0€100 It=0e00 i S::: €I 1 €I 0 p:= III i 013 MV I ... B., ~8 H=0121 8- .le0 8=0100 8=0100 H=€1119 :::=0100 H=0119 8=0100 H=0119 8=0100 H=e119 8=e100 H=011A 8=0100 H=011A 8=01130 H=011A 8=01130 H=011A 8=0100 H=el1A S=€t100 H=el1A ::;=01013 H=011B 3=13100 H=€tl1B 3=0100 H=0118 S=13100 i6K DDT VER - L 1 ( A=Be A=00 A=0B A=Bf:I A A=B2 A=B2 A=82 A=B2 A=B2 A=82 A=B0 A=FE A=FE A=FE A=FE B~ 8=BeEtB B=88BB 8=138BI:1 8=flSB0 B=e8B~ B SBEt 8=B BEt 8=8 B D =8 €I 0~ H=000~ D=8f:10B D=Eteee D=8f:10B D=Bee'3 D=Be D- ee D=8e0e D=BeeB D=B008 D=B0 ee D=BB 0e D=13 e ae H=e0ee H=IHHH3 H=0119 H=011A H=011A H=011A B=97132 8=B7B2 H=~11A 8=8782 H=0i lA 8=8702 D=iHHH~ H=011A 8=8702 D=B00e H=0t18 8=8602 D=BIHtB H=€illB s=e10e 8=Blt10 8=01ee 8=0100 S=01B0 8=0100 8=0100 ~3=B100 :3=0100 :3=0108 :3=0100 8=0100 =i'11e0 P=B102 P=BIB4 p=131e7 P=i"H 08 P=BIB9 p=Blec P='310D P=B10E P=018F P=€'lB7 P=01B8 P=BIB9 P=8UH P=81BE P=8tBF ~R>~ CIZ0MBEIIl A=FE -G .. 108 cl B~06B2 12UV\ -f~M D=0eee H=8118 8=Bla0 P=0107 CUtv(/A.t 'Pc. aYlJ Iovettkpo~~ . J~ex± ~J~ *0108 -K i at 1'\',1} /'1',1} L XI I'I0Y ~l~k -J J c.; B0 H.• B119 R .• I'I SUB JC C I'I0Y C.' A H B INX DCR •...1 HZ BleD BIB7 !'lOY Ad'! SUB JC INX C 01l!lD H DCR B JNZ 01137*0107 Jief Ib~ ~OY A,M I~H CIZEtMBEIIl A=84 8=8602 D =8 e 00 H=0118 8=13100 P=0108 SUB -T 8 B8 sq fO( a. few ~d~ r '"' CIZ0M0EIIl A=Et4 B=0682. D=Beee H=01 i8 S=01e0 P=B1B8 SUB -T C*0189 C0ZEtl1BE0Il A=B2 8=8682 D=iHHI€1 H=01 i8 8=01013 P=€ili'19 JC BleD.BleC -tl -X -ti CeZEtMBE0Il A=02 8=0682 D=BBe0 H=elll8 8=13100 P=010C MOY - G;; II: t<~ -\0 C,A &(r\pleh~ 0116 -'!:..J CeZlM0ElIl A=03 B=0083 D=6B08 H=0121 S=0100 P=0116 - .§.ll1~ look. tXt \k).llU'cf 1\ LAf(;€ 1/ -t\Ae 8 1 21 83" WV(ft'l'; \,Ulllt- / RST 07 8123 8124 21.1 012500t il 126 B 2J t~d &-II.t S / c"MYIIO..J 01277E~~ -l100 -~ 0100 0102 0104 0107 0108 0109 010C e10D 010E 010F 0112 MYI MVI LXI c,ee H,0119 MOV A .• M SUB C JC MOV INX el0D c, A ~ DCR H B JHZ 0107 MOV -L -J 0113 0116 STA RST 0117 NOP HOP 0118 0119 8121 87 STAX B ellA NOP i311B INR INX B B DCR B B,81 B 01lC 1311£1 011E £1120 -xp MYI DCR -~ P =0 1 1 6 1 £I €I -J Qeset ~e 'Pc. -1.; S\~lt"S\w I lb'ld ~d,l dak Vo..llt25 ceZ1M0EIIl A=e3 8=00133 D=0e00 H=0121 8=9100 P=0100 MVI -T 8 .. 138*0102 C0Z1MeEII1 A=03 8=08133 D=B009 H=9121 S=0100 P=01(12 MVI -T COI.I.t\+ DDT S CAN. COM e7 16K DDT \o'ER 1. €I NEXT PC £1200 e100 -~- P=01 e0~ - .!:...!..l.§..? 0116 0117 0118 0119 0l1A RBT 97 HOP HOP STAX B look- a.t ~ HOP (lO\\g +0 ~e 'tf i+ WCts \'''D?&~ LDct&.ed 1h~Ou.t alo~t Ull~ YoJoM) - (~~0Ckt) - G., 1.1 () i ((U~ ~V{N\Il lo()\.t +0 (tYl\vlt+l6~ HI116 -~~ Ci loo~ Qt Cc,~ (c.ctLde~1 bpO) ~ . -15..i loot a.t C.fu. ~L CIZIM0E111 A=06 B=0006 D=0000 H=0121 8=0100 P=0116 RST -~~ loo~ at'" 0121 La'fjt.. 0 - it afP(d{S +0 ~ Csrrtct B6J £1122 00 J 0123 22 e'; ED SCAN. ASM ---~-; ;LARGER VALUE IN C? ;LARGER VALUE IN C? NFOUND ;JUMP IF LARGER VALUE NOT FOUND NFOUND iJUMP IF LARGER VALUE NOT FOUND I 'i 07 til 22: 0€12H USE FACTOR fN:O OF ASSEMBLY i 61< II[1T "iER IiE:X:T PC ~j121 0000 1. ~3 -Ll1\; o1 it: ,.11'1 P £1119 STA~: €lilA NOP (1118 INR _. (y~) -G100, i >I; (111 6 16,., \3 00 0 B ckeck -\0 f.JASuVt t~cllS <;-t-°lll ttt II b~ 8 Go -trCMA klj~""V\o\~j Wl~ IoY(tt~vo',~t t4± ewi loveo.~P{)l~ r!O.C~ed :::~ ~2~:~ E~~7CA:7~ EB 08 78 B1 0130 C2 27 01 C3 03 29 00 00 00 00 00 o €i 8€1 0E! t10 00 0140 00 00 00 00 00 00 00 00 00 00 00 00 813 0f:t I!:H} 00 - LYL'olo.l.lt) . ~ "! ) Ill. i . ) .. ,',' • OPERATION OF THE CP/M ASSEMBLER UI []~[j~Tfll RESEflR[H Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896 CP/M ASSEMBLER (ASM) USER'S GUIDE COPYRIGHT (c) 1976, 1978 DIGITAL RESEARCH Copyright (c) 1976, 1978 by Digital Research. All rights reserved. No part of this publication may be reproduced, transmitted, transcribed, stored ina retrieval system, or translated into any language or computer language, in any form or by any means, electronic, mechanical, magnetic, optical, chemical, manual or otherwise, without the pritional decimal integer value representing the source program line number, which is allowed on any source line to maintain compatibili ty wi th the Processor Technology format. In general, these line nurrbers will be inserted if a line-oriented editor is used to construct the original program, and thus ASM ignores this field if present. The label field takes the form identifier or identifier: and is optional, except where noted in particular statement types. The identifier is a seguence of alphanumeric characters (alphabetics and numbers), where the first character is alphabetic. Identifiers can be freely used by the programmer to label elements such as program steps and assembler directives, but cannot exceed 16 characters in length. All characters are significant in an identifier, except for the embedded dollar symbol ($) which can be used to improve readability of the name. Further, all lower case alphabetics become are treated as if they were upper case. Note that the ":" following the identifier in a label is optional (to maintain compatibility between Intel and Processor Technology) Thus, the following are all valid instances of labels 0 x x: xy XIY2 Xlx2 yxl: long$name longer$named$data: x234$5678$9012$3456: The operation field contains either an assembler directive, or pseudo operation, or an 8080 machine operation code. The pseudo operations and machine operation codes are described below. The ·operand field of the statement, in general, contains an expression formed out of constants and labels, along with arithmetic and logical operations on these elements. Again, the complete details of properly formed expressions are given below. The canment field contains arbitrary characters following the .. i" symbol until the next real or logical end-of-line. 'rhese characters are read, listed, and otherwise ignored by the assembler. In order to maintain compatability with the Processor Technology assembler, the CP/M assembler also treat statements v.hich begin with a "*" in column one as comment statements, which are listed and. ignored in the assembly process o Note that the Processor 3 • Technology assembler has the side effect in its operation of ignoring the characters after the operand field has been scanned. This causes an ambiguous situation when attempting to be compatible with Intel's language, since arbi trary expressions are allowed in this case. Hence, programs which use this side effect to introduce corrunents, must be edited to place a "; before these fields in order to assemble correctly. II The assembly language program is formulated as a sequence of statements of the above form, terminated optionally by an END statement. All statements following the END are ignored by the assembler. 3. ~ FORMING THE OPERAND. In order to completely describe the operation codes and pseudo operations, it is necessary to first present the form of the operand field, since it is used in nearly all statements. Expressions in the operand field consist of simple operands (labels, constants, and reserved words), combined in properly formed subexpressions by arithmetic and logical operators. The expression computation is carried out by the assembler as the asserrbly proceeds. Each expression must produce a 16-bit value during the assembly. Further, the nurrber of significant digits in the result must not exceed the intended use. That is, if an expression is to be used in a byte nove immediate instruction, then the most significant 8 bits of the expression must be zero. The restrictions on the expression significance is given with the individual instructions. 3.1. labels. As discussed above, a label is an identifier which occurs on a particular statement. In general, the label is given a value determined by the type of statement which it precedes. If the label occurs on a statement which generates machine code or reserves memory space (e.g, a MOV instruction, or a DS pseudo operation), then the label is given the value of the program address which it labels. If the label precedes an EQU or SE'I', then the label is given the value which results from evaluating the operand field. Except for the SET statement, an identifier can label only one statement. Wnen a label appears in the operand field, its value is substituted by the assembler. 'l'his value can then be combined with other operands and operators to form the operand field for a particular instruction. 3.2. Numeric Constants. A numeric constant is a l6-bi t value in one of several bases. The base, called the radix of the constant, is denoted by a trailing radix indicator. The radix indicators are B o binary constant (base 2) octal constant (base 8) 4 Q o H octal constant (base 8) decimal constant (base 10) hexadecimal constant (base 16) Q is an alternate radix indicator for octal nuOOers since the letter 0 is easily confused with the digit 0. Any numeric constant which does not terminate with a radix indicator is assumed to be a decimal constant. A constant is thus comp:>sed as a sequence of digits, followed by an optional radix indicator, vvhere the digits are in the appropriate range for the radix. That is binary constants must be composed of 0 and 1 digits, octal constants can contain digits in the range 0 - 7, vvhile decimal constants contain decimal digits. Hexadecimal constants contain decimal digits as well as hexadecimal digits A (100), 8 (110), C (120), 0 (130), E (140), and F (150) • Note that the leading digi t of a hexadecimal constant must be a decimal digi t in order to avoid confusing a hexadecimal constant with an identifier (a leading 0 will always suffice). A constant comp:>sed in this manner must evaluate to a binary nurrber which can be contained within a 16-bit counter, otherwise it is truncated on the right by the assembler. Similar to identifiers, imbedded "$" are allowed wi thin constants to improve their readabili ty. Finally, the radix indicator is translated to upper case if a lower case letter is encountered. The following are all valid instances of numeric constants 1234 1234H 33770 3.3. 12340 0FFEH 0fe3h 11008 1111$0000$1111$00008 33$77$22Q 0ffffh 33770 1234d Reserved Words. There are several reserved character sequences which have predefined meanings in the operand field of a statement. The names of 8080 registers are given below, which, when encountered, produce the value shown to the right A 7 8 C 0 1 2 3 4 D E H L 5 M 6 6 6 SP PSW (again, lower case names have the same values as their upper case equivalents). Machine instructions can also be used in the operand field, and evaluate to their internal codes. In the case of instructions which require o-perands, where the s-pecific operand becomes a p3.rt of the binary bit pattern 5 oF- -rite instruction (e.g, IDV A,B), the value of the instruction (in this case is the bit p3ttern of the instruction with zeroes in the optional fields (e.g, IDV produces 40H). When the symbol "$" occurs in the operand field (not irrbedded within identifiers and numeric constants) its value becomes the address of the next instruction to generate, not including the instruction contained wi thing the current logical line. MJV) 3.4. String Constants. String constants represent sequences of ASCII characters, and are represented by enclosing the characters wi thin apostrophe symbols ('). All strings must be fully contained within the. current physical line (thus allowing "!" symbols wi thin strings), arrl must not exceed 64 characters in length. The apostrophe character itself can be- included within a string by representing it as a double apostrophe (the two keystrokes "), which becomes In nost cases, the string a single apostrophe when read by the assembler. length is restricted to either one or two characters (the DB pseudo operation is an exception), in which case the string becomes an 8 or 16 bit value, respectively. Two character strings become a 16-bit constant, with the second character as the low order byte, and the first character as the high order byte. The value of a character is its corresponding ASCII code. There is no case translation within strings, and thus both upper and lower case characters can be represented. Note however, that only graphic (printing) ASCII characters are allowed within strings. Valid strings are , c' 'AB' , , , II ' a 'Walla Walla Wash. ' 'She said "Hello" to me. ' 'I said "Hello" to her.' 3.5. Arithmetic and Logical Operators. The cperands described above can be combined in normal algebraic notation using any canbination of properly formed operands, operators, and parenthesized expressions. Tqe operators recognized in the operand field are a +b a - b +b -b a * b a / b a IDD b Nor b unsigned arithmetic sum of a and b unsigned arithmetic difference between a and b unary plus (produces b) unary minus (identical to 0 - b) unsigned magnitude multiplication of a and b unsigned magnitude division of a by b remainder after a / b logical inverse of b (all 0's become l's, l's become 0's), where b is considered a 16-bit value 6 a a a a AND b OR b XORb SHL b a SHR b bit-by-bit logical and of a and b bit-by-bit logical or of a and b bit-by-bit logicl exclusive or of a and b the value which results from shifting a to the left by an amount b, with zero fill the value which results from shifting a to the right by an amount b, with zero fill In each case, a and b represent simple operands (labels, numeric constants, reserved words, and one or two character strings), or fully enclosed parenthesized subexpressions such as 10+20 10h+37Q Ll /3 (L2+4) SHR 3 ('B' +B) OR (PSW+M) ( 'a' and 5fh) + '0' (1+(2+c)) shr (A-(B+l)) Note that all canputations are ~rformed at assembly time as 16-bit lll1signed operations. Thus, -1 is canputed as 0-1 which results in the value 0ffffh (i.e., alII's). The resulting expression must fit the O?eration code in , which it is used. If, for example, the expression is used in a ADI (add7 ' ' 'J m.;Sr immediate) instruction, then the high order eight bits of the expression mustS r;7~;" ,)/).:'be zero. As a result, the operation "ADI -I" produces an error message (-1 .!:?yrrt l0H. The statement defining TTY could be changed to TIY EX;)U FALSE and, in this case, the p:ogram would assemble for a CRT based at port 20H. 4.6. The DB Directive. The DB directive allows the programmer to define initialize storage areas in single p:ecision (byte) format. The statement form is label DB e#l, e#2, ••• , e#n v.here e#1 through e#n are either expressions which evaluate to 8-bit values (the high order eight bits must be zero), or are ASCII strings of length no greater than 64 dlaracters. There is no practical restriction on the nurrber of expressions included on a single source line. The expressions are evaluated and placed sequentially into the machine code file following the last program address generated by the assembler. String characters are similarly placed into memory starting with the first character and ending with the last character. Strings of length greater than two characters cannot be used as operands in more complicated expressions (i.e., they must stand alone between the commas). Note that ASCII characters are always placed in memory with the p3.rity bit reset (0). Further, recall that there is no translation from lower to u}:Per case wi thin strings. The C{)tional label can be used to reference the data area throughout the remainder of the program. Examples of 11 valid DB statements are data: DB DB signon; DB DB 4.7. 0',1,2,3,4,5 data and 0ffh,5,377Q,1+2+3+4 'please type your name',cr,lf,0 'AB' SHR 8, 'C', 'DE' AND 7FH The DW Directive. The DW statement is similar to the DB statement except double precision (two byte) words of storage are initialized. The form is label DW e#l, e#2, ••• , e#n where e#l through e#n are expressions which evaluate to 16-bit results. Note that ASCII strings of length one or two characters are allowed, but strings longer than two cilaracters disallowed. In all cases, the data storage is consistent with the 8080 processor: the least significant byte of the 'expression is stored forst in rremory, followed by the most significant byte. Examples are doub: ow DW 4.8. 0ffefh,doub+4,signon-$,255+255 'a', 5, 'ab', 'CD', 6' shl 8 or 110 'rheDS Directive. 'l'he DS statement is used to reserve an area of unini tialized memory, and takes the form label os expression where the label is optional. The assembler begins subsequent code generation after the area reserved by the DS. 'lhus, the DS statement given above has exactly the same effect as the statement label: 5. EOU ORG $ iLABEL VALUE IS CURRENT mDE LOCATION $+expression iMOVE PAST RESERVED AREA OPERATION cxmES. Assembly language operation codes form the principal part of assembly language programs, am 'form the operation field of the instruction. In general, AEM accepts all the standard mnemonics for the Intel 8080 microcomputer, Yilich are given in detail in the Intel manual "8080 Assembly Language Programmim Manual." Labels are optional on each input line and, if 'included, take the' value of the instr;uction address immediately before the instruction is issued. The individual operators are listed breifly in the 12 following sections for completeness, although it is understood that the Intel manuals should be referenced for exact operator details. In each case, e3 represents a 3-bit value in the range 0-7 which can be one of the predefined registers A, B, C, D, E, H, L, M, SP, or PSW. e8 represents an 8-bit value in the range 0-255 e16 represents a l6-bit value in the range 0-65535 which can themselves be formed from an arbitrary combination of operands and operators. In some cases, the operands are restricted to p3.rticular values wi thin the allowable range, such as the PUSH instruction. These cases will be noted as they are encountered. In the sections \'oihich follow, each operation codes is listed in its most general form, along wi th a s};ecific example, wi th a short explanation and special restrictions. 501. Jumps, Calls, and Returns. The Jump, Call, am Return instructions allow several di fferent forms which test the condition flags set in the 8080 microcomputer CPU. The forms are JMP JNZ JZ JNC JC J:EO JPE JP JM e16 e16 e16 e16 e16 e16 e16 e16 e16 JMP Ll JMP L2 JMP l00H JNC Ll+4 JC L3 Joo $+8 JPE L4 JP GAMMA JM al Jump Jump Jump Jump Jump Jump Jump Jump Jump unconditionally to label on non zero condition to label on zero condition to label no carry to label on carry to label on parity odd to label on even parity to label on positive result to label on minus to label CALL CNZ CZ CNC CC CPE CP CM e16 e16 e16 e16 e16 e16 e16 e16 e16 CALL Sl CNZ S2 CZ l00H mc 81+4 CC S3 COO $+8 CPE S4 CP GAMMA CM bl$c2 Call Call Call Call Call Call Call Call Call subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine subroutine RST e3 RST Programmed "restart", equivalent to CALL 8*e3, except one byte call COO 0 13 Lmconditionally if non zero flag on zero flag if no carry set if carry set if parity odd if parity even if positive result if minus flag • RET Return Return Return Return Return Return Return Return Return RNZ RZ RNC RC RPO RPE RP RM 5.2. from subroutine if non zero flag set if zero flag set if no carry if carry flag set if parity is odd if p3rity is even if positive result if minus flag is set Immediate Operand Instructions. Several instructions are available which load single or double precision registers, or single precision memory cells, with constant values, along with instructions which ~rform immediate arithmetic or logical operations on the accumulator (register A) • MVI e3,e8 t-lVI ADI ACI SUI SBI ANI ADI ACI B,255 Move immediate data to register A, B, C, D, E, H, L, or M (memory) I Add immediate operand to A without carry 0FFH Add immediate operand to A with carry Subtract from A without borrow (carry) L + 3 L N'JD 11B Subtract from A with borrow (carry) $ AND 7FH Logical "and" A with immediate data 1111$0000B "Exclusive or" A with immediate data L AND 1+1 Logical "or" A wi th immediate da ta a Compare A with immediate data (same as SUI except register A not changed) e8 e8 e8 e8 e8 XRI e8 ORI e8 CPI e8 CPI LXI e3,e16 LXI B,100H 5.3. SOl SBI ANI XRI ORI Load extended immediate to register pair (e3 must be equivalent to B,D,H, or SP) Increment and Decrement Instructions. Instructions are provided in the 8080 repetoire for incrementing or decrementing single and double precision registers. The instructions are 5.4. INR e3 INR E OCR e3 OCR A INX e3 INX SP OCX e3 OCXB Single precision increment register (e3 produces one of A, B, C, D, E, H, L, M) Single precision decrement register (e3 produces one of A, B, C, D, E, H, L, M) Double precision increment register pair (e3 must be equivalent to B,D,H, or SP) Double precision decrement register pair (e3 must be equivalent to B,D,H, or SP) Data Movement Instructions. 14 Instructions which rrove data from rremory to the CPU and from CPU to memory are given below r!{)V e3,e3 IDV A,B LQl\X e3 LI:lPJ{ STAX e3 STAX D LHLD el6 LHLD IJ. SHLD e16 SHLD L5+x LQl\ e16 STA e16 EOP e3 LQl\ Gamma. STA X3-5 EOP PSW PUSH e3 PUSH B IN e8 our e8 IN B 0 our 255 XTHL PCHL SPHL XCHG 5.5. Move data to leftmost element from rightrrost element (e3 produces one of A,B,C D,E,H,L, or M). IDV M,M is disallowed Load register A from computed address (e3 must produce either B or D) Store register A to computed address (e3 must produce either B or D) Load HL direct from location e16 (double precision load to Hand L) Store HL direct to location e16 (double precision store from Hand L to memory) Load register A from address e16 Store register A into memory at e16 Load register pair from stack, set SP (e3 must produce one of B, D, H, or PSW) Store register pair into stack, set SP (e3 must produce one of B, D, H, or PSW) Load reqister A with data from port e8 Send data from register A to port e8 Exchange data from top of stack with HL Fill program counter with data from HL Fill stack pointer with data from HL Exchange DE pair with HL pair Arithmetic Logic Unit Operations. Instructions which a'ct upon the single precision accumulator to perform arithmetic and logic operations are ADD e3 ADD B e3 SUB e3 AOC SBB e3 SBB ANA XRA ORA CMP e3 e3 e3 e3 ANA 1+1 XRA A ORA B CMP H ADC DI\A CMA. S'IC L SUB H 2 Add register given by e3 to accumulator without carry (e3 must produce one of A, B, C, D, E, H, or L) Add register to A with carry, e3 as above Subtract req e3 from A without carry, e3 is defined as above Subtract register e3 from A with carry, e3 defined as above IDgical "and" reg with A, e3 as above "Exclusive or" with A, e3 as above Logical "or" with A, e3 defined as above Compare reqister with A, e3 as above Deciroal adjust register A based upon last arithmetic logic unit operation Complement the bits in register A Set the carry flag to 1 15 • Complement the carry flag Rotate bits left, (re)set carry as a side effect (high order A bit becomes carry) Rotate bits right, (re)set carry as side effect (low order A bit becomes carry) Rotate carry/A register to left (carry is involved in the rotate) Rotate carry/A register to right (carry is involved in the rotate) Cr.'C RLC RAL RAR mn e3 5.6. :eN) B Double precision add register pair e3 to HL (e3 must produce S, D, H, or SP) Control Instructions. The four remaining instructions are categorized as control instructions, and are listed below HLT DI EI Halt the 8080 processor Disable the interrupt system Enable the interrupt system No operation NOP 6. ERROR MESSAGES. wnen errors occur within the assembly language program, they are listed as single character flags in the leftmost tx>sition of the source listing. The line in error is also echoed at the console so that the source listing need not be examined to determine if errors are present. The error codes are D Data error: element in data statement cannot be placed in the specified data area E Expression error: expression is ill-formed and cannot be computed at assembly time L Label error: label cannot appear in this context (may be duplicate label) N Not implemented: features which will appear in future ASM versions (e.g., macros) are recognized, but flagged in this version) o Overflow: expression is too complicated (i.e., too many pending operators) to computed, simplify it P phase error: label does not have the same value on two subsequent p3sses through the program 16 Several conditions 7. R Register error: the value specified as a register is not compatible with the operation code v Value error: operand encountered in expression is improperly formed error message are printed which are due to terminal error NO SOURCE FILE PRESENT The file specified in the ASM command does not exist on disk NO DIRECTORY SPACE The disk directory is full, erase files which are not needed, and retry SCXJRCE FI LE NAME ERROR Improperly formed ASM file name (e.g., it is specified with "?" fields) SOURCE FILE READ ERROR Source file cannot be read properly by the assembler, execute a TYPE to determine the "(;Dint of error ourpur FI LE WR.I'rE ERROR Output files cannot be written properly, most likely cause is a full disk, erase and retry CAt'mar CLOSE FI LE Output file. cannot be closed, check to see if disk is write protected A SAMPLE SESSION. The following session shows interaction with the assembler and debugger in the development of a simple assembly language program o 17 • ASMSORT~ CP/M ASSEMBLER - YER 1.0 ~ 1 SC \A4¥:t £t 0 3 H -Fre~ atl..d.vess % of USE FA CT(I R END OF AS'SE t1 BL Y +It~le USeJ 00 To PF (~d.ecl~ ) DIRS 0 RT. *,; SORT ASH S;dW'(~ fll~ SORT BA K Io~J~"" ltt~ ~~fSO R T P R H 'P"'~ C(QII\:tul~ -fr;L, S 0 R T H E X WIO..c.lc.,~ c:odL .h~ f,1tz A}TVPE SORT. clNu~) PR~ S'~(t..l~ r~------~--------~' waclu~ Cotk lo~ 0109 i .-J k' ; . ~~~~Ctde 0100 2146el~ SORT: 0103 3601 9105 2147'01 0le8 3600 COMP, £IleA 7E £1108 FEe9 €tIeD D219ili SORT PROGRAM IN CP/M ASSEMBLY LANGUAGE START AT THE BEGINHING OF THE TRANSIENT PROGRAM AR ORG le9H LXI H. SW Mill 11, 1 un H, I ,ADDRESS Mill 11, 13 ; I = 0 COMPARE MOV CPI JHC I ;ADDRESS SWITCH TOGGLE ;SET TO 1 FOR FIRST ITERATION INDEX WITti -ARRAV SIZE A, M ; A N- 1 iCY S.E T IF I CONT REGISTER = I < ( N -_1 ) ,CONTINUE IF I <= ( N- 2 ) 911£1 214601 0113 7'E87C29991 END OF OjiE PASS THROUGH DATA LX I H, Sill ; CHECK FOR ZERO SWITCHES MOV A.M! ORA A! .JNZ SORT iEND OF SORT IF S lit =B 0118 FF RST 7 C"·tll-ki i e119 5F1600214BCOtH, e 121 4E792346 ;GO TO THE DEBUGGER INSTEAD nF REi- COHTI HUE THI S PASS ADDRESSING I, SO LOAD AY ( I) INTO REGISTERS MOV LA! MVI D,e! LXI Hd~V ! DAD D! DAD D MOV C, M ! MOV A, C! lUX H! t'lOV B .. M LOW ORDER BinE IN A AIH C, HIGH ORDER BYTE IH B MOY HAND L TO ADDRESS AYCI+l) 0125 23 I I~ X 0126 965778239E COMPARE VALUE WITH REGS CONTAINING AY(l) SUB Ii! MOV D, A! MOV A, B! INX H! SB8 11 iSUBTRACT BORRO~I 0128 DA3FBl JC H IF AV(I+l) ) AV(I) INCI ,SKIP IF IN PROPER ORDER S~T CHECK FOR EQUAL VALUES 012E B2CA3F01 ORA D! JZ HIe! iS~:IP IF AY(I) = AY(J+t) MOV It .. M! t1 0 II MOV t1, C ! !lex 0132 56702B5E 0136 7128722873 11., B! H! DCX H! 110 'V r'l. D ! MOV E, 11 D (;:.c: H! 11011 M. E j e13B 21460134 IHCREMENT SWITCH COUNT LXI H,SlJ! IHR 11 013F 21470134C311'-1CI: un IHCREMENT I 9146 0e 9147 SW: I: 0148 050064e01EAV: eeeA = N e 15 C It.- e~ ~ va.tIAL A >n'PE SORT. HEX..? H.. I ! I NR M! JMP CO t1P DATA DEFINITION SECTION DB 0 ;RESERVE SPACE FOR SWITCH COUNT DS 1 ;SPACE FOR INDEX Dhi 5.100,30.50,211, '7, 1!HHL 3'313 .. 1130. -3276'7 EQU ($-AV)/2 ;CDMPUTE H IHSTEAD OF PRE EHD : 1001Be09214601360121470136007EFE09D2190140 rle0110002146017EB7C2B001FF5F16002148011988 : 10012B00194E79234623965778239EDA3F01B2CAA7 : 10e130ee3F0156702B5E712B722B732146013421C7 : 07014ee04?0134C30A01006E : 10014800050064801E0B320014000700ESB32C01BB :04015B0B640001B0BE : 00IH:lf:J(1000Et A> DD T S OR T. HEX; s-k~ 'rUV\.. MI.(., 161< DDT VER 1. e ~;~6 0:~B dhwtt a&bess Ll'\6 addy~ ~ BJD ~-b..~(W.+) -Xp.-) 1 Be~ CWJ.~e. p = e0 13 0 -UFFFFJ fe- -fo (00 a~ (;,;l4!-, u..~~ -r~ 6~3')" s-te.ps {yu.bot.Ct CeZ0M13E010 A=00 8=00130 Ii=13ee9 H=0Et00 8=0100 P=0100 LXI - T 10.,; -h-oa to c;+~f'S" ,I. C0ZBI1BEeIe CeZBM8E0Ie CeZ(1MBEele C0Z0M13E010 CeZ0M13E010 C0Z011BE010 CIZ0M1EeI0 CIZ0M1E010 CIZeM1EfJI0 CIZ0MIE010 C0zeMBEeI0 cezel1BE010 C0ZBMBE010 C0Z0MBEele C0Z0MBE0I0 ceZ0M8E010 A=Bl A=81 A=01 A=01 A=01 A=00 A=00 A=00 A=a0 A=01 A=el A=01 A=Bl A=Bl A=01 A=01 8=0139£1 8=00130 8=001311, 8:::00813 8=00130 8:::IH300 8::00130 8=00130 B =0 €Ie e 8=09139 8=01380 8=130813 8=1391313 8=001313 8=013139 B:=13013·e D=Seee D=13a00 D=0a00 D=0 a 00 D=0900 D=0e00 D=13000 D=8 0 00 D=0 0 00 D=0ea8 D=13 a 130 D=1390e D::::IHH3e Ii =13 €I e0 D=13 0 e0 D=0 0 00 H=0146 H=0146 H=0146 H=0147 H=014? H=014? H=014? H=0147 H=0146 H=0146 H=0146 H=0146 H=0146 H=0146 H::.0147 H::: 0.1 47 ~A10D 91eD 01 10 ~ JC 11 9; c~~(.. -fc a .j'u-'1 On Ct1~ S=010e 8=0100 8=0100 8=,011210 8=0112113 8=@100 8=0100 p::010£1 P=0103 P::0105 P::0108 P::010A S=0100 8=0100 S=0100 8=010'0 3=011210 3=0100 S=01e0 P:::0114 P::0115 p=010e p=ele3 11 VI P=0105 LXI LXI 11 V I LXI MVI NOll P::0H1B CPI P=01E1D ,..\ Ne 8=0100 P:::0110 LXI 8=01121121 P::0113 110 Ii ORA J ~~l LXI H.• 0 146:1< €I 1 iii 11 H,0146 11. 13 1 H.Et147 11, 0 €I A, 11 09 (3 11 9 H.. 0146 A) 11 A 0100 H,0146 M) e 1 H.0147 P::0108 MV I 11, (1 P::01!~A A)I1*010FJ 11011 €I ~d.rt.-J I "'f3H 19 -XP; P=010B 10~ ye~+ 1YOj~o.""," (\?~~ b~£.l-b _Tie +nue ~-ttD~ -tw J2 B=090'0 B=00130 B=0e9& B=0000 B=00130 B=0080 B=0099 B=B0ge B=0eee B=801;0 8=0090 8=0900 B=0eee B=00BS B=eees B=0e05 C0ZEcl19E010 C0Z0M9E0I0 C9Z0MBE0I0 C9Z0M9E9I0 C0ZBM0E0I0 C0Z0M0E0I0 C1 Z0 HI E010 C1Z0111E010 C1ZeM1E0I0 CIZ0111E0I0 CIZ0MIE919 .~ 9 Z e M1 Eel €I 020MIE010 C9Z0t11E0I9 C0Z0MIE0Ie ceZ0MIE0Ie -L lIH,21 A=00 A=0 €I A=00 A=13e A=B0 A=80 A=09 A=00 A=B0 A=IHl A=8e A=00 A=00 A=e0 A=135 A=B5 9100 9183 9105 911313 910A 918B 919£1 13119 0113 B 114 €I 1 15 H,e146 M, 131 H.0147 M,0e A,M 99 0119 H,0146 A,M LXI MVI LXI MYI MOV CP I JC LXI MOV ORA A JNZ 13100 13118 RST 97 9119 9llA BIle MOV 11\11 LXI E,A (01-1 ~e.J·lr'l~I~ cf-projra.vn.. S-kps II=B099 D=ge90 D=8000 D=8000 D=13000 D=8€100 D=B00e II=000€t D=9000 D=0000 D=0009 D=9000 D=IHt'00 D=00013 D=1313ge D=009B H=0147 H=0146 H=0146 H=0147 H=0147 H=0147 H=0147 H=0147 H=0147 H=0147 H=0148 H=014B H=@148 H=014B H=014B H=0149 8=0100 s= €I.100 S=eJl€10 $=0100 8=0100 S=eJl€10 8=0100 8=0100 8=0100 S=0100 5=0100 S='.3100 s=ei eH3 s=e100 5=0100 S=0100 P=0100 P::0103 P=0105 P=0108 P=010A P::0108 P==1ZI10D P==0119 LXI H,Bl46 11 V I LXI MVI 110V CPI JC 110V p,:allA MVI P::011C un P= €I 11 F DAII p::e120 DAD P=0121 t·l0\/ D D L r1 A,C: P=0122 110V P=0123 I NX P=0124 H B,M*012:5 MOV ~. At.doy'\l\Q.~h c.. bf"~fO ~lA.t t\St S"OIM.C code ~ lDOI-( -L~ D.l39 H,9148 - abwf h~+ w~~ Y-(.A.L,~ - G, 1 t B; '" 812 7 ~L.l r ~rl VY~V'I.1LU. -t (V~ '5-bpf1!6 w~~ - T4~ \ oo~ at loot'l~ C9Z9119E0I9 C0Z0MBE010 Ce20MBE019 C0Z0MBE010 -D148 A=38 A=38 A=00 A=00 Q.\.\.. ~ -pc. (ol2-S"l-i) ClVl({ 'fulL eK-\e.v~l \~YU.p+ 7 l'YOYAIM. l'" -\-vere rook "+ B=9964 8=0964 B=0064 8=13064 D=8906 [1=3806 D=3806 D=3806 H=0156 H=0156 H=0156 H=0157 . l\.i\ V'eo-\ +.1VV\e -To II.t3H I -trtMA ~V'(AI\..+ ?c",~.e{ ('PY~Yl1w. was lO'fll'lj \Vvj~·h~l+e.~) 5=9109 P=0127 MOV 5=9199 P=0128 MOV £=0100 P~0129 INK 8=0100 P~012A SBB D,A A,B H M*8128 ~~+a. l~ sw-kd, b~ 'fyojY"aw Joes ~t s~ . 1;148 95 0e 97 09 14 90 1 E 00 0150 32 B0 64 09 64 90 2C 01 EB f1 3 B 1 813 09 'lie '210 09 2. D. D. , . . . . . . . . . 9169 013 130 00 08 00 00 00 00 00 I;:, !.I eo 00 00 1210 01~ 00 . . . . . . . . . . . . . . 20 -G"~ DDj ye-t-u.('V\. -h> CP/M. SO R T . HEX J2 161<. DDT VER HEXT PC ret 00.& -tke memovj I fl'\A~ 1. €I else e(!leB -xp p =e0 13 e 1 €I €I; Sci "Pc. -\0 bl?jl ~11:~ of t~Y1AXYt l\..::k b~ Ofcod.t - L 1 €I Djl BleD JHC 0119/ 0110 LXI H,0146 - o.~+ ll~ IAI~~ fuloOt.l.t - A 10 D; el0D a.S~wJo\L vte.w q'c.otle. JC 11~ 011~ - L 1B €I; 010e B1e3 0105 13108 h~\- cs\u~ S'e~of 1vo:Jv-aw.. LXI MYI LXI MYl H,0146 M,a1 H,0147 • MIEle - /lloov\: l\st V\I~~ ~\'4\l.t - A1€I 3;. dco.~· \~sw'l-hl/ ~IA.:-hjl~~ {, ¢r1 01133 HVI H, 0~ 01 I!! 5,2 _,., (; rl.-b..."" -10 ev/~ \Allkt, dr-£:. (G~ vJlN~ SAVE "StAVe 1 SORT. COM; 1 fo~t (1..t;b r.e-S-\tt.v DDT SO RT. COM~ CIS WE' l...ave. 1)'0, w~ 0'1'· dis/£, \~ C"~L- -to -re.lt)od. lcJ-ef' So.IIl4 ~e.V'I\Ov~ \V"\~e 161( DDT VER 1. 0 NEXT PC' B2 e€I 0 1 €I €I "CoM" -ttll. a..lwo.js -G.2 rlA"'--\"ke. 1'~"jyt:l1M II< 0 11 a 1'V'Oc?fo."""VI'\t!cl +nI'P\ . s~v-ts Wl-t\,. o,.dJ.'«SI$ 1001-1 1'C-=loOI-{ ~-\z,p (~S r 11 elile.o I).\'\.tu-ed "'D148 014B 135 0e e7 00 14 B0' 1 E 13150 32 0e 64 13£1 64 as 2C €I 1 E.8 8160 Et0 00 013 00 1013 013 09 €Ie a8 13170 IH1 00 130 t:le 08 130 130 00 03 -G~ r~V'~ 40 C?X/M.. 03 B 1 B0 00 lOB 00 ee 2. D. D. .. GB [10 (10 1313 eEt 00 013 00 8e (lIj 00 013 130 00 ) . . . . . . . .. l{ ;5ET TO 1 FOR FIRST ITERATION ;ADDRESS INDEX iZERO SUI H I iADDRESS J IHDE>: ;C6NTIHUE IF I (= eN-2) CP/M ASSEMBLER - VER 1.0 f:t 1 5 C ~t aJt!ytt,S 10 as~" B€t"3H USE FACTOR EWD OF ASSEMBLY 11 DT SO RT . H~ KAi M -pv"'r~ cUCl~t.S 16K DDT VEl< 1.0 PC NE:~T 015C O'HtB - (; 1 0 €I,; "'0118 r - D148) d6-~ 501'tal 914B 85 130 .137 e8 14 013 1 E 00 . . . . . . . . 13150 32 013 64 01l 64 80 2C 01 EB 03 9180 0160 ee 00 eo ee 138130 ee.2.D.D.J . . . . . . . . . 00 00 013 00 00 00 130 09 00 00 130 00 80 . . . . . . . . . . . . . . . . - tAbbY1: l.u\~rlAlo'v.t 22. CP/M 2.~O INTERFACE GUIDE '~THE Post Office Box 579, Pacific Grove, California 93950, (408) 649-3896 CP/M 2.0 INTERFACE GUIDE Copyright (c) 1979 DIGITAL RESEARCH • Copyright (c) 1979 by Digital Research. All rights reserved. No ,part of this publication may be reproduced, transmitted, transcribed, stored in a retrieval system, or translated into any language or computer language, in any form or by any means, electronic, mechanical, magnetic, optical,. chemical, manual or otherwise, without the prior written permission of Digital Research, Post Office Box 579, Pacific Grove, California 93950. Disclaimer Digital Research makes no representations or warranties with respect to the contents hereof and specifically disclaims any implied warranties of merchantability or fitness for any particular purpose. Further, Digital Research reserves the right to revise this publication and to make changes from time to time in the content hereof without obligation - of Digital Research to notify any person of such revision or changes. CP/M 2.0 INTERFACE GUIDE Copyright (c) 1979 Digital Research, Box 579 Pacific Grove, California 1. Introduction • . 2. Operating System Call Conventions 3. A Sample File-to-File Copy Program • 4. A Sample File Dump Utility • 34 5. A Sample Random Access Program . • 6. System Function Summary • • • 46 . DOD D 1 3 • 29 • 37 1. INTRODUCTION. This manual describes CP/M, release 2, system organization including the structure of memory and system entry points. The intention is to provide the necessary information required to write programs which operate under CP/M, and which use the peripheral and disk I/O facilities of the system. CP/M is logically divided into four parts, called the Basic I/O System (BIOS), the Basic. Disk Operating System (BDOS), the Console command processor (CCP), and the Transient Program Area (TPA). The BIOS is a hardware-dependent module which defines the exact low level interface to a particular computer system which is necessary for peripheral device I/O. Although a standard BIOS is supplied by Digital Research, explicit instructions are provided for field reconfiguration of the BIOS to match nearly any hardware environment (see the Digital Research manual entitled "CP/M Alteration Guide") • The BIOS and BDOS are logically combined into a single module with a common entry point, and referred to as the FDOS. The CCP is a d i st inct prog r am wh ich uses the FDOS to pr ovide a human-or iented interface to the information which is cataloged on the backup storage device. The TPA is an area of memory (i.e., the portion which is not used by the FDOS and CCP) where various non-resident operating system commands and user programs are executed. The lower portion of memory is reserved for system information and is detailed later sections. Memory organization of the CP/M system in shown below: high memory FDOS (BDOS+BIOS) FBASE: • CCP CBASE: TPA TBASE: system parameters BOOT: The exact memory addresses corresponding to BOOT, TBASE, CBASE, and FBASE vary from version to version, and are described fully in the "CP/M Alteration Guide. All standard CP/M versions, however, assume BOOT = 0000H, which is the base of random access memory. The machine code found at location BOOT performs a system "warm start" which loads and initializes the programs and variables necessary to return control to the CCP. Th'us, transient programs need only jump to location BOOT II (All Information Contained Herein is Proprietary to Digital Research.) 1 to return control to CP/M at the command level. Further, the standard versions assume TBASE = BOOT+0l00H which is normally location 0l00H. The pr incipal entry point to the FDOS is at location BOOT+0005H (normally 00 05H) where a jump to FBASE is found. The address field at BOOT+0006H (normally 0006H) contains the value of FBASE and can be used to determine the size of available' memory, assuming the CCP is being overlayed by a transient program. Transient programs are loaded into the TPA and executed as follows. The operator communicates with the CCP by typing command Each command line takes one of the lines following each prompt. forms: command command f ilel command filel file2 where "command" is either a built-in function such as DIR or TYPE, or the name of a transient command or program. If the command is a built-in function of CP/M, it is executed immediately. Otherwise, the CCP searches the currently addressed disk for a file by the name comma nd. COM If the file is found, it is assumed to be a memory image of a program which executes in the TPA, and thus implicitly originates at TBASE in memory. The CCP loads the COM file from the disk into memory starting at TBASE and possibly extending up to CBASE. If the command is followed by one or two file specifications, the CCP prepares one or two file control block (FCB) names in the These optional FCB's are in the form necessary system parameter area. to access files through the FDOS, and are described in the next section. The transient program receives control from the CCP and begins execution, perhaps using the I/O facilities of the FDOS. The transient program is "called" from the CCP, and thus can simply return to the CCP upon completion of its processing, or can jump to BOOT to pass control back to CP/M. In the first case, the transient program must not use memory above CBASE, while in the latter case, memory up through FBASE-I is free. The transient program may use the CP/M I/O facilities to communicate with the operator's console and peripheral devices, including the disk subsystem. The I/O system is accessed by passing a "function number" and an "information address" to CP/M through the FDOS entry point at BOOT+0005H. In the case of a disk read, for example, the transient program sends the number corresponding to a disk read, along with the address of an FCB to the CP/M FDOS. The FDOS, in turn, performs the operation and returns with either a disk read completion indication or an error number indicating that the disk read was unsuccessful. The function numbers and errOr indicators are given in below. (All Information Contained Herein is Proprietary to Digital Research.) 2 2. OPERATING SYSTEM CALL CONVENTIONS. The purpose of this section is to provide detailed information for performing direct operating system calls from user programs. Many of the functions listed below, however, are more simply accessed through the I/O macro library provided with the MAC macro assembler, and listed in the Digital Research manual entitled "MAC Macro Assembler: Language Manual and Appl ications Guide. II CP/M facilities which are available for access by transient programs fall into two general categories: simple device I/O, and disk file I/O. The simple device operations include: Read a Console Character write a Console Character Read a sequential Tape Character write a Sequential Tape Character write a List Device Character Get or Set I/O Status Print Console Buffer Read Console Buffer Interrogate Console Ready The FDOS operations which perform disk Input/Output are Disk System Reset Drive Selection File Creation File Open File Close Directory Search File Delete File Rename Random or Sequential Read Random or Sequential write Interrogate Available Disks Interrogate Selected Disk Set DMA Address Set/Reset File Indicators As mentioned above, access to the FDOS functions is accomplished by passing a function number and information address through the primary entry point at location BOOT+0005H o In general, the function number is passed in register C with the information address in the double byte pair DE. Single byte values are returned in register A, with double byte values returned in HL (a zero value is returned when the function number is out of range). For reasons of compatibility, register A = L and register B = H upon return in all cases. Note that the register passing conventions of CP/M agree with those of Intel's PL/M systems programming language. The list of CP/M function numbers is given below. (All Information Contained Herein is Proprietary to Digital Research.) 3 • 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 System Reset Console Input Console Output Reader Input Punch Output List Output Di rect Console I/O Get I/O Byte Set I/O Byte Pr int Str ing Read Console Buffer Get Console Status Return Version Number Reset Disk System Select Disk Open File Close File Search for First Search for Next 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 Delete File Read Sequenti.3.l write Sequential Make File Rename File Return Login Vector Return Current Disk Set DMA Address Get Addr (Alloc) write Protect Disk Get R/O vector Set File Attributes Get Addr(Disk Parms) Set/Get User Code Read Random write Random Compute File Size Set Random Record (Functions 28 and 32 should be avoided in maintain upward compatibility with MP/M.) application programs to Upon entry to a transient program, the CCP leaves the stack pointer set to an eight level stack area with the CCP return address pushed onto the stack, leaving seven levels before overflow occurs. Although this stack is usually not used by a transient program (Le., most transients return to the CCP though a jump to location 0000H), it is sufficiently large to make CP/M system calls since the FDOS swi tches to a . local stack at system entry. The following assembly language program segment, for example, reads characters continuously until an asterisk is encountered, at which time control returns to the CCP (assuming a standard CP/M system with Boo'r = 0000H): BDOS CON IN NEXTC: EQU EQU 0005H 1 j ORG MVI CALL CPI JNZ RET END 0l00H C,CONIN BDOS jBASE OF TPA iREAD NEXT CHARACTER jRETURN CHARACTER IN jEND OF PROCESSING? jLOOP IF NOT i RE'rURN TO CCP I * I NEXTC STANDARD CP/M ENTRY jCONSOLE INPUT FUNCTION /' CP/M implements a named file structure on each disk, providing a logical organization which allows any particular file to contain any number of records from completely empty, to the full capacity of the drive. Each drive is logically distinct with a disk directory and file data area. The disk file names are in three parts: the drive select code, the file name consisting of one to eight non-blank characters, and the file type consisting of zero to three non-blank characters. The file type names the generic category of a particular file, while the file name distinguishes individual files in each category. The file types listed below name a few generic categories (All Information Contained Herein is Proprietary to Digital Research.) 4 which have been established, although they are generally arbitrary: ASM PRN HEX BAS INT COM Assembler Source Pr inter Listing Hex Machine Code Basic Source File Intermediate ,Code CCP Command File PLI REL TEX BAK SYM $$$ PL/I Source File Relocatable Module TEX Formatter Source ED Source Backup SID Symbol File Temporary File Source files are treated as a sequence of ASCII characters, where each "line" of the source file is followed by a carriage-return line-feed sequence (0DH followed by 0AH). Thus one 128 byte CP/M record could contain several lines of source text. The end of an ASCII file is denoted by a control-Z character (lAH) or a real end of file, returned by the CP/M read operation. Control-Z characters embedded within machine code files (e.g., COM files) are ignored, however, and the end of file condition returned by CP/M is used to terminate read operations. Files in CP/M can be thought of as a sequence of up to 65536 records of 128 bytes each, numbered from 0 through 65535, thus allowing a maximum of 8 megabytes per file. Note, however, that although the records may be considered logically contiguous, they may not be physically contiguous in the disk data area. Internally, all files are broken into 16K byte segments called logical extents, so that counters are easily maintained as 8-bit values. Although the decomposition into extents is discussed in the paragraphs which follow, they are of no particular consequence to the programmer since each extent is automatically accessed in both sequential and random access modes. In the file operations starting with function number 15, DE usually addresses a file control block (FCB). Transient programs often use the default file control block area reserved by CP/M at location BOOT+005CH (normally 005CH) for simple file operations. The basic unit of file information is a 128 byte record used for all file operations, thus a default location for disk I/O is provided by CP/M at loca,tion BOOT+0080H (normally 0080H) which is the initial default DMA address (see function 26). All directory operations take place in a reserved area which does not affect write buffers as was the case in release 1, with the exception of Search First and Search Next, where compatibility is required. The File Control Block (FCB) data area consists of 33 bytes for sequential access and a series of 36 bytes that the file is accessed randomly. The default file normally located at 005CH can be used for random access the three bytes starting at BOOT+007DH are available for The FCB format is shown with the following fields: a sequence of in the case control block files, since this purpose. (All Information Contained Herein is Proprietary to Digital Research.) 5 • -----------------------------------------------------------Idrlfllf21/ /lf8Ibllt2It3Iexlslls2Ircld01/ /ldnlcrlr0lrllr21 -----------------------------------------------------------00 01 02 ••• 08 09 10 11 12 13 14 15 16 ••• 31 32 33 34 35 where dr drive code (0 - 16) o => use default drive for file 1 => auto disk select drive A, 2 => auto disk select drive B, . .. 16=> auto disk select drive P. fl ••• f8 contain the file name in ASCII upper case, with high bit = 0 tl,t2,t3 contain the file type in ASCII upper case, with high bit = 0 tl', t2', and t3' denote the bit of these positions, tl' = 1 => Read/Only file, t2' = 1 => SYS file, no DIR list ex contains the current extent number, normally set to 00 by the user, but in range 0 - 31 during file I/O sl reserved for internal system use s2 reserved for internal system use, set to zero on call to OPEN, MAKE, SEARCH rc record count for extent "ex," takes on values from 0 - 128 filled-in by CP/M, reserved for system use current record to read or write in a sequential file operation, normally set to zero by user . d0 ••• dn cr r0,rl,r2 optional random record number in the range 0-65535, with overflow to r2, r0,rl constitute a 16-bit value with low byte r0, and high byte rl Each file being accessed through CP/M must have a corresponding FCB which provides the name and allocation information for all subsequent file operations. When accessing files, it is the programmer's responsibility to fill the lower sixteen bytes of the FCB and initialize the "cr" field. Normally, bytes 1 through 11 are set to the ASCII character values for the file name and file type, while all other fields are zero. (All Information Contained Herein is Proprietary to Digital Research.) 6 FCB's are stored in a directory area of the disk, and are brought into central memory before proceeding with file operations (see the OPEN and MAKE functions). The memory copy of the FCB is updated as file operations take place and later recorded permanently on disk at the termination of the file operation (see the CLOSE command) • The CCP constructs the first sixteen bytes of two optional FCB's for a transient by scanning the remainder of the line following the transient name, denoted by Iff ilel" and f ile2" in the prototype command line described above, with unspecified fields set" to ASCII blanks. The first FCB is constructed at location BOOT+005CH, and can be used as-is for subsequent file operations. The second FCB occupies the d0 ••• dn portion of the first FCB, and must be moved to another area of memory before use. If, for example, the operator types II PROGNAME B:X.ZOT Y.ZAP the file PROGNAME.COM is loaded into the TPA, and the default FCB at BOOT+005CH is initialized to drive code 2, file name "X" and file type "ZOT". The second dr ive code takes the defaul t value 0, which is placed at BOOT+006CH, with the file name "Y" placed into location BOOT+006DH and file type "ZAP" located 8 bytes later at BOOT+0075H. All remaining fields through "cr" are set to zero. Note again that it is the programmer's responsibility to move this second file name and type to another area, usually a separate file control block, before opening the file which begins at BOOT+005CH, due to the fact that the open operation will overwrite the second name and type. If no file names are specified in the original command, then the fields beginning at BOOT+005DH and BOOT+006DH contain blanks. In all cases, the CCP translates lower case alphabetics to upper case to be consistent with the CP/M file naming conventions. As an added convenience, the default buffer area at location BOOT+0080H is initialized to the command line tail typed by the operator following the program name. The first position contains the number of characters, with the characters themselves following the character count. Given the above command 1 ine, the area beg inning at BOOT+0080H is initialized as follows: Boo'r+0 0 8 0H : +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 +10 +11 +12 +13 +14 14 B X" Z 0 Til.. .. Y Z.. A P .. II I. I. 11 I I . II .. II. U U It It II I' II h i t . It II U U II where the characters are translated to upper case ASCII with uninitiaiized memory following the last valid character. Again, it is the responsibility of the programmer to extract the information from this buffer before any file operations are performed, unless the default DMA address is explicitly changed. The individual functions are described in detail which follow. in the pages (All Information Contained Herein is Proprietary to Digital Research.) 7 • *************************************** * * * * * * *************************************** * Entry Parameters: * * FUNCTION fij: Register System Reset C: * 00H *************************************** The system reset function returns control to the CP/M operating system at the CCP level. The CCP re-initializes the disk subsystem by selecting and logging-in disk drive A. This function has exactly the same effect as a jump to location BOOT. *************************************** * * * FUNc'rION 1: CONSOLE INPUT * ***************************************** * * * * * Entry Parameters: Register C: 01H Returned Value: Register A: ASCII Character * * * * * *************************************** The console input function reads the next console character to register A. Graphic characters, along with carriage return, line feed, and backspace "(ctl-H) are echoed to the console. Tab characters (ctl-I) are expanded in columns of eight characters. A check is made for start/stop scroll (ctl-S) and start/stop printer echo (ctl-P). The FDOS does not return to the calling program until a character has been typed, thus suspending execution if a character is not ready. *************************************** * * FUNCTION 2: * * .* CONSOLE OUTPUT * *************************************** * * * En t ry Par am e t e r s: Register C: Register E: 02H ASCII Character * * * * * *************************************** The ASCII character from register E is sent to the console device. Similar to function 1, tabs are expanded and checks are made for start/stop scroll and printer echo. (All Information Contained Herein is Proprietary to Digital Research.) 8 *************************************** * * * FUNCTION 3: * * Entry Parameters: Register C: * Returned * * READER INPUT * *************************************** * * * * * * 03H Value: * Register A: ASCII Character *************************************** The Reader Input function reads the next character from the logical reader into register A (see the IOBYTE definition in the "CP/M Alteration Guide"). Control does not return until the character has been read. *************************************** * * FUNCTION 4: * * PUNCH OUTPUT * * *************************************** * * * Entry Parameters: Register C: Register E: 04H ASCII Character * * * * * *************************************** The Punch Output function sends the character from register E to the logical punch device. *************************************** * * FUNCTION 5: * * LIST OUTPUT * * *************************************** * * * * Entry Parameters: Register C: Register E: 05H ASCII Character * * * * *************************************** The List Output function sends the ASCII character in register E to the logical listing device. (All Information Contained Herein is Proprietary to Digital Research.) 9 *************************************** * * * FUNCTION 6: DIRECT CONSOLE I/O * * * *************************************** * Entry Parameters: * Register C: ~6H * * Register E: ~FFH (input) or * * char (output) * * * ** Returned Value: * Register A: char or status * * (no value) * *************************************** Direct console I/O is supported under CP/M for those specialized applications where unadorned console input and output is required. Use of this function should, in general, be avoided since it bypasses all of CP/M1s normal control character functions (e.g., control-S and control-P). Programs which perform direct I/O through the BIOS under previous releases of CP/M, however, should be changed to use direct I/O under BDOS so that they can be fully supported under future releases of MP/M and CP/M. Upon entry to function 6, register E either contains hexadecimal FF, denoti~ a console input request, or register E contains an ASCII character. If the input value is FF, then function 6 returns A = ~~ if no character is ready, otherwise A contains the next console input character. If the input value in E is not FF, then function 6 assumes· E contains a valid ASCII character which is sent to the console. that (All Information Contained Herein is Proprietary to Digital Research.) 10 *************************************** * * FUNCTION 7: * * * GET I/O BYTE * *************************************** * * * * * Entry Parameters: Register C: Returned Value: Register A: * 07H * * * I/O Byte Value * *************************************** The Get I/O Byte function returns the current value of IOBYTE in register A. See the "CP/M Alteration Guide" for IOBYTE definition. *************************************** * * FUNc'rION 8: * SET I/O BYTE * * * *************************************** * * Entry Parameters: Register C: Register E: 08H I/O Byte Value * * * * * * *************************************** The Set I/O Byte function changes the that given in register E. system IOBYTE value to ~************************************** * * FUNCTION 9: * * * PRINT STRING * *************************************** * * * * Entry Parameters: Register C: Registers DE: 09H Str ing Address * * * * *******************~******************* The Print String function sends the character string stored in memory at the location given by DE to the console device, until a "$" is encountered in the string. Tabs are expanded as in function 2, and checks are made for start/stop scroll and printer echo. (All Information Contained Herein is Proprietary to Digital Research.) 11 • *************************************** * * FUNCTION 10: READ CONSOLE BUFFER * * * * *************************************** * Entry Parameters: * * * * * * Register C: Registers DE: 0AH Buffer Address Returned Value: Console Characters in Buffer * ** * * *************************************** The Read Buffer function reads a line of edited console input into a buffer addressed by registers DE. Console input is terminated when either the input buffer overflows. The Read Buffer takes the form: DE: +0 +1 +2 +3 +4 +5 +6 +7 +8 +n Imxlnclcllc21c31c41c51c61c71 I??I where "mx" is the maximum number of characters which the buffer will hold (1 to 255), "nc" is the number of characters read (set by FDOS upon return), followed by the characters read from the console. if nc < mx, then uninitialized positions follow the last character, denoted by "??" in the above figure. A number of control functions are recognized during line editing: rub/del ctl-C ctl-E ctl-H ctl-J ctl-M ctl-R ctl-U ctl-x removes and echoes the last character reboots when at the beginning of line causes physical end of line backspaces one character position (line feed) terminates input line (return) terminates input line retypes the current line after new line removes currnt line after new line backspaces to beginning of current line Note also that certain functions which return the carriage to the leftmost position (e.g., ctl-X) do so only to the column position where the prompt ended (in earlier releases, the carriage returned to the extreme left margin). This convention makes operator data input and line correction more legible. (All Information Contained Herein is Proprietary to Digital Research.) 12 *************************************** ** * ** FUNC'rION 11: GET CONSOLE S'fATUS * *************************************** * Entry Parameters: * * * * * Register C: Returned Value: Register A: 0BH Console Status * * * * *************************************** The Console Status function checks to see if a character has been typed at the console. If a character is ready, the value 0FFH is returned in register A. Otherwise a 00H value is returned. *************************************** * * * * *************************************** * Entry Parameters: * * * * * * * FUNCTION 12: RETURN VERSION NUMBER Register C: * 0CH * * Returned Value: Registers HL: Version Number * *************************************** Function 12 provides information which allows version independent programming. A two-byte value is returned, with H = 00 designating the CP/M release·· (H = 01 for MP/M), and L = 00 for all releases previous to 2.0. CP/M 2.0 returns a hexadecimal 20 in register L, with subsequent version 2 releases in the hexadecimal range 21, 22, through 2F. Using function 12, for example, you can write application programs which provide both sequential and random access functions, wi th 'random access disabled when operating under early releases of CP/M. ' (All Information Contained Herein is Proprietary to Digital Research.) 13 • *************************************** ** * * FUNCTION 13: RESET DISK SYSTEM * * *************************************** * * Entry Parameters: Register C: * * * 0DH * *************************************** The Reset Disk Function is used to programmatically restore the file system to a reset state where all disks are set to read/write (see functions 28 and 29), only disk drive A is selected, and the default DMA address is reset to BOOT+0080H. This function can be used, for example, by an application program which requires a disk change without a system reboot. *************************************** * * * FUNCTION 14: SELECT DISK * Entry Parameters: Register C: Register E: * * * *************************************** * * * 0EH Selected Disk * * * * *************************************** The Select Disk function designates the disk drive named in register E as the default disk for subsequent file operations, with E = 0 for drive A, 1 for drive B, and so-forth through 15 corresponding to drive P in a full sixteen drive system. The drive is placed in an "on-line H status which, in particular, activates its directory until the next cold start, warm start, or disk system reset operation. If the disk media is changed while it is on-line, the drive automatically goes to a read/only status in a standard CP/M environment (see function 28). FCB's which specify drive code zero (dr = 00H) automatically reference the currently selected default drive. Drive code values between 1 and 16, however, ignore the selected default drive and directly reference drives A through P. (All Information Contained Herein is Proprietary to Digital Research.) 14 *************************************** * * * FUNCTION 15: OPEN FILE * * * Entry Parameters: Register C: Registers DE: * * * *************************************** ** Returned * 0FH FCB Address * * * * Value: * Register A: Directory Code * *************************************** The Open File operation is used to activate a file which currently exists in the disk directory for the currently adtive user number. The FDOS scans the referenced disk directory for a match in positions 1 through 14 of the FCB referenced by DE (byte sl is automatically zeroed), where an ASCII question mark (3FH) matches any directory character in any of these positions. Normally, no question marks are included and, further, bytes "ex" and "s2" of the FCB are zero. If a directory element is matched, the relevant directory information is copied into bytes d0 through dn of the FCB, thus allowing access to the files through subsequent read and write operations. Note that an existing file must not be accessed until a sucessful open operation is completed. Upon return, the open function returns a "directory code" with the value 0 through 3 if the open was s uc c e s s f ul , o r (1 F F H ( 2 5 5 dec irn a 1 ) i f the f i 1 e can not be f 0 u n d • I f question marks occur in the FCB then the first matching FCB is activa ted. Note that the cur rent record ("cr") must be zeroed by the program if the file is to be accessed sequentially from the first record. (All Information Contained Herein is Proprietary to Digital Research.) 15 • *************************************** * * * FUNCTION 16: CLOSE FILE * * * *************************************** * * * * * * Entry Parameters: Register C: Registers DE: l0H FCB Address Returned Value: Register A: * * * * Directory Code * * *************************************** The Close File function performs the inverse of the open file function. Given that the FCB addressed by DE has been previously activated through an open or make function (see functions 15 and 22), the close function permanently records the new FCB in the referenced disk directory. The FCB matching process for the close is identical to the open function. The directory code returned for a successful close operation is 0, 1, 2, or 3, while a 0FFH (255 decimal) is returned if the file name cannot be found in the directory. A file need not be closed if only read operations have taken place. If write operations have occurred, however, the close operation is necessary to permanently record the new directory information. (All Information Contained Herein is Proprietary to Digital Research.) 16 *************************************** * * * FUNCTION 17: SEARCH FOR FIRST * * * *************************************** * Entry Parameters: * * * * * * Reg i s t e r C: Registers DE: Returned Value: Register A: * * 11 H FCB Address * * * Directory Code *************************************** Search First scans the directory for a match with the file given by the FCB addressed by DE. The value 255 (hexadecimal FF) is returned if the file is not found, otherwise 0, 1, 2, or 3 is returned indicating the file is present. In the case that the file is found, the current DMA address is filled with the record containing the directory entry, and the relative starting position is A * 32 (i.e., rotate the A register left 5 bits, or ADD A five times). Although not normally required for application programs, the directory information can be extracted from the buffer at this position. An ASCII question mark (63 decimal, 3F hexadecimal) in any position from "fl" through "ex" matches the corresponding field of any directory entry on the default or auto-selected disk drive. If the "dr" field contains an ASCII question mark, then the auto disk select function is disabled, the default disk is searched, with the search function returning any matched entry, allocated or free, belonging to any user number. This latter function is not normally used by application programs, but does allow complete flexibility to scan all curr~nt directory values. If the "dr" field is not a question mark, the "s2" byte is automatically zeroed. *************************************** * * * FUNCTION 18: SEARCH FOR NEXT * ! * * Entry Parameters: Register C: 12H Returned Value: Register" A: Directory Code * * * *************************************** * ! * * *************************************** The Search Next function is similar to the Search First function, except that the directory scan continues from the last matched entry. Similar to function 17, function 18 returns the decimal value 255 in A when no more directory items match. (All Information Contained Herein is Proprietary to Digital Research.) 17 • *************************************** * * * * FUNCTION 19: DELETE FILE * * *************************************** * * Entry Parameters: Register C: Registers DE: * Returned Value: Register A: * * * * * l3H FCB Address * Directory Code * ** *************************************** The Delete File function removes files which match the FCB addressed by DE. The filename and type may contain ambiguous references (i.e., question marks in various positions), but the drive select code cannot be ambiguous, as in the Search and Search Next functions. Function 19 returns a decimal 255 files cannot be found, otherwise a returned. if the referenced file or value in the range 0 to 3 is *************************************** * * * * FUNCTION 20: READ SEQUENTIAL * * * * * Entry Parameters: Register C: Registers DE: * * *************************************** Returned * l4H FCB Address * * * * Value: * Register A: Directory Code * *************************************** Given that the FCB addressed by DE has been activated through an open or make function (numbers 15 and 22), the Read Sequential function reads the next 128 byte record from the file into memory at the current DMA address. the record is read from position "cr" of the extent, and the ncr" field is automatically incremented to the next record position. If the "cr" field overflows then the next logical extent is automatically opened and the "cr" field is reset'to zero in preparation for the next read operation. The value 00H is returned in the A register if the read operation was successful, while a non-zero value is returned if no data exists at the next record position (e.g., end of file occurs). (All Information Contained Herein is Proprietary to Digital Research.) 18 *************************************** * * FUNCTION 21: WRITE SEQUENTIAL * * * * *************************************** * Entry Parameters: * * Register C: ISH * * * * * Registers DE: Returned Value: Register A: FCB Address Directory Code * * * * *************************************** Given that the FCb addressed by DE has been activated through an open or make function (numbers 15 and 22), the Write Sequential function writes the 128 byte data record at the current DMA address to the file named by the FCB. the record is placed at position ncr" of the file, and the "cr" field is automatically incremented to the next record position. If the Iocr" field overflows then the next logical extent is automatically opened and the hcr" field is reset to zero in preparation for the next write operation. Write operations can take place into an existing file, in which case newly written records overlay those which already exist in the file. Register A = 00H upon return from a successful write operation, while a non-zero value indicates an unsuccessful write due to a full disk. *************************************** ** FUNCTION 22: MAKE FILE * * * * *************************************** * Entry Parameters: * Register C: 16H * * Registers DE: FCB Address * * * * * * Returned Value: Register A: Directory Code * * *************************************** The Make File operation is similar to the open file operation except that the FCB must name a file which does not exist in the currently referenced disk directory (i.e., the one named explicitly by a non-zero "dr" code, or the default disk if "dr" is zero). The FDOS creates the file and initializes both the directory and main memory value to an empty file. The programmer must ensure that no duplicate file names occur, and a preceding delete operation is sufficient if there is any possibility of duplication. Upon return, register A = 0, 1, 2, or 3 if the operation was successful and 0FFH (255 decimal) if no more directory space is available. The make function has the side-effect of activating the FCB and thus a subsequent open is not necessary. (All Information Contained Herein is Proprietary to Digital Research.) 19 • *************************************** * * * FUNCTION 23: RENAME FILE * * * *************************************** * * * * * * Entry Parameters: Register C: Registers DE: 17H FCB Address Returned Value: Register A: Directory Code * * * * * * *************************************** The Rename function uses the FCB addressed by DE to change all occurrences of the file named in the first 16 bytes to the file named in the second 16 bytes. The drive code "dr" at position 0 is used to select the drive, while the drive code for the new file name at position 16 of the FCB is assumed to be zero. Upon return, register A is set to a value between 0 and 3 if the rename was successful, and 0FFH (255 decimal) if the first file name could not be found in the directory scan. *************************************** * * FUNC'r ION 24: RETURN LOGIN VECTOR * * * * *************************************** * * * * * Entry Parameters: Register C: 18H Returned Value: Registers HL: Login Vector * * * * * *************************************** The login vector value returned by CP/M is a 16-bit value in HL, where the least significant bit of L corresponds to the first drive A, and the high order bit of H corresponds to the sixteenth drive, labelled P. A "0" bit indicates that the drive is not on-line, while a "I" bit marks an drive that is actively on-line due to an explicit disk drive selection, or _an implicit drive select caused by a file operation which specified a non-zero "dr" field. Note that compatibility is maintained with earlier release~, since registers A and L contain the same values upon return. (All Information Contained Herein is Proprietary to Digital Research.) 20 *************************************** * * * FUNCTION 25: RETURN CURRENT DISK * * * *************************************** * Entry Parameters: * * Register C: 19H * * * * Returned Value: * * Register A: . Current Disk * I ****************************~********** Function 25 returns the currently selected default disk ~umber in register A. The disk numbers range from 0 through 15 corresponding to dr ives A through P. *************************************** * * * FUNCTION 26: SET DMA ADDRESS * * * *************************************** * Entry Parameters: * * Register C: lAH * * Registers DE: DMA Address * * * *************************************** 'IDMA" is an acronym for Direct Memory Address, which is often used in connection with disk controllers which directly access the memory of the mainframe computer to transfer data to and from the disk subsystem. Al though many computer systems use non-DHA access (i. e. , the data is transfered through programmed I/O operations), the DMA address has, in CP/M, come to mean the address at which the 128 byte data record resides before a disk write and after a disk read. Upon coid start, warm start, or disk system reset, the DMA address is automatically set to BOOT+0080H. The Set DMA function, however, can be used to change this defaul t value to address another area of memory where the data records reside. Thus, the DMA address becomes the value specified by DE until it is changed by a subsequent Set DMA function, cold start, warm start, or disk system reset. (All Information Contained Herein is Proprietary to Digital Research.) 21 *************************************** * * * * FUNCTION 27: GET ADDR(ALLOC) * * *************************************** * Entry Parameters: * * Register * * * Returned Value: Registers HL: C: * * IBH ALLOC Address * * *************************************** An "allocation vector" is maintained in main memory for each on-line disk drive. Various system programs use the information provided by the allocation vector to determine the amount of remaining storage (see the STAT program). Function 27 returns the base address of the allocation vector for the currently selected disk drive. The allocation information may, however, be invalid if the selected disk has been marked read/only • Although this function is not normally used by application programs, additional details of the allocation vector are found in the "CP/M Alteration Guide. h *************************************** * * * FUNCTION 28: WRITE PROTECT DISK * * * Entry Parameters: Register C: * * * *************************************** * * ICH * *************************************** The disk write protect function provides temporary write protection for the currently selected disk. Any attempt to write to the disk, before the next cold or warm start operation produces the message Bdos Err on d: R/O (All Information Contained Herein is Proprietary to Digital Research.) 22 *************************************** * * * FUNCTION 29: GET READ/ONLY VECTOR * * * *************************************** * * * * * Entry Parameters: Register C: IDH Returned Value: Registers HL: R/O Vector Value* * * * * ****************************~********** Function 29 returns a bit vector in register pair HL which indicates drives which have the temporary read/only bit set. Similar to function 24, the least significant bit corresponds to drive A, while the most significant bit corresponds to drive P. The R/O bit is set either by an explicit call to function 28, or by the automatic software mechanisms within CP/M which detect changed disks. *************************************** * * * * * *************************************** * Entry Parameters: * * Register C: IEH * FUNCTION 30: SET FILE ATTRIBUTES * * * * * Registers DE: Returned Value: Register A: FCB Address * Directory Code * * * *************************************** The Set File Attributes function allows programmatic manipulation of permanent indicators attached to files. In particular, the R/O and Syst~ attributes (tl' and t2') can be set or repet. The DE pair addresses an unambiguous file name with the appropriate attributes set or reset. Function 30 searches for a match, and changes the matched directory entry to contain the selected indicators. Indicators fl' through f4' are not presently used, but may be useful for applications programs, since they are not involved in the matching process during file open and close operations. Indicators f5' through fS' and t3' are reserved for future system expansion. (All Information Contained Herein is Proprietary to Digital Research.) 23 • *************************************** * * * * * * * FUNCTION 31: GET ADDR(DISK PARMS) * * * *************************************** * Entry Parameters: Register C: Returned Value: Registers HL: * IFH * DPB Address * * * *************************************** The address of the BIOS resident disk parameter block is returned in HL as a result of this function call. This address can be used for either of two purposes. First, the disk parameter values can be extracted for display and space computation purposes, or transient programs can dynamically change the values of current disk parameters when the disk environment changes, if required. Normally, application programs will not require this facility. *************************************** * * * * * * *************************************** * Entry Parameters: * * Register C: 20H * * Reg i s t e r . E : 0 F F H (g e t) 0 r * * * * * * FUNCTION 32: SET/GET USER CODE User Code (set) Returned Value: Register A: * * * * Current Code or (no value) * *************************************** An application program can change or interrogate the currently active user number by calling function 32. If register E = 0FFH, then the value of the current user number is returned in register A, where the value is in the range 0 to 31. If register E is not 0FFH, then the current user number is changed to the value of E (modulo 32). (All Infdrmation Contairied Herein is Proprietary to Digital Research.) 24 **************************************~ * * FUNCTION 33: READ RANDOM * * * *************************************** * Entry Parameters: * Reg i s t e r C : 21 H * * * Registers DE: FCB Address * * * * * Returned Value: Reqister A: * * * Return Code *************************************** The Read Random function is similar to the sequential file read operation of previous releases, except that the read operation takes place at a particular record number, selected by the 24-bit value constructed from the three byte field following the FCB (byte positions rIO at 33, rl at 34, and r2 at 35). Note that the sequence of 24 bits is stored with least significant byte first (rIO), middle byte next (rl), and high byte last (r2). CP/M does not reference byte r2, except in computing the size of a file (function 35). Byte r2 must be zero, however, since a non-zero value indicates overflow past the end of file. Thus, the rIO, rl byte pair is treated as a double-byte, or "word" value, which contains the record to read. This value ranges from 10 to 65535, providing access to any particular record of the 8 megabyte file. In order to process a file using random access, the base extent (extent (0) must first be opened. Although the base extent mayor may not contain any allocated data, this ensures that the file is properly recorded in the directory, and is visible 'in DIR requests. The selected record number is then stored into the random record field (rIO, rl), and the BDOS is called to read the record. Upon return from the call, register A either contains an error code, as listed below, or the value 010 indicating the operation was successful. In the latter case, the current DMA address contains the randomly accessed record. Note that contrary to the sequential read operation, the record number is not advanced. Thus, subsequent random read operations continue to read the same record. Upon each random read operation, the logical extent and current record values are automatically set. Thus, the file can be sequentially read or written, starting from the current randomly accessed position. Note, however, that in this case, the last randomly read record will be re-read as you switch from random mode to sequential read, and the last record will be re-written as you switch to a sequential write operation. You can, of course, simply advance the random record position following each random read or write to obtain the effect ofa sequential I/O operation. Error codes returned in register A following a random listed below. read are (All Information Contained Herein is Proprietary to Digital Research.) 25 • 01 02 03 04 05 06 reading unwritten data (not returned in random mode) cannot c}ose current extent seek to unwritten extent (not returned in read mode) seek past physical end of disk Error code 01 and 04 occur when a random read operation accesses a data block which has not been previously written, or an extent which has not been created, which are equivalent conditions. Error 3 does not normally occur under proper system operation, but can be cleared by simply re-reading, or re-opening extent zero as long as the disk is not physically write protected. Error code 06 occurs whenever byte r2 is non-zero under the current 2.0 release. Normally, non-zero return codes can be treated as missing data, with zero return codes indicating operation complete. (All Information Contained Herein is Proprietary to Digital Research.) 26 *************************************** * * * FUNCTION 34: WRITE RANDOM * * * *************************************** * Entry Parameters: * * Register C: Registers DE: 22H FCB Address * * Returned Value: Register A: Return Code * * * * * * * *************************************** The Write Random operation is initiated similar to the Read Random call, except that data is written to the disk from the current DMA address. Further, if the disk extent or data block which is the target of the write has not yet been allocated, the allocation is performed before the write operation continues. As in the Read Random operation, the random record number is not changed as a result of the write. The logical extent number and current record positions of the file control block are set to correspond to the random record which is being written. Again, sequential read or write operations can commence following a random write, with the notation that the currently addressed record is either read or rewritten again as the sequential operation begins. You can also simply advance the random record position following each write to get the effect of a sequential write operation. Note that in particular, reading or writing the last record of an extent in random mode does not cause an automatic extent switch as it does in sequential mode. The error codes returned by a random write are identical to the random read operation with the addition of error code 05, which indicates that a new extent cannot be created due to directory overflow. (All Information Contained Herein is Proprietary to Digital Research.) 27 *************************************** ** FUNCTION 35: COMPUTE FILE SIZE ** ***************************************** * Entry Parameters: * * Register C: 23H * * Registers DE: FCB Address * * * * Returned Value: * * Random Record Field Set * *************************************** When computing the size of a file, the DE register pair addresses an FCB in random mode format (bytes r0, rl, and r2 are present). The FCB contains an unambiguous file name which is used in the directory scan. Upon return, the random record bytes contain the "virtual" file size which is, in effect, the recbrd· address of the record following the end of the file. if, following a call to function 35, the high record byte r2 is 01, then the file contains the maximum record count 65536. Otherwise, bytes r0 and rl constitute a l6-bit value (r0 is the least significant byte, as before) which is the 'file size. Data can be appended to the end of an existing file by simply calling function 35 to set the random record position to the end of file, then performing a sequence of random writes starting at the preset record address. The virtual size of a file corresponds to the physical size when the file is written sequentially. If, instead, the file was created in random mode and "holes" exist in the allocat'ion, then the file may in fact contain fewer records than the size indic,ates. If, for example, only the last record of an eigh t megabyte file is wr i tten in random mode (i.e., record number 65535), then the virtual size is 65536 records, although only one block of data is actually allocated. (All Information Contained Herein is Proprietary to Digital Research.) 28 *************************************** * * * * FUNCTION 36: SET RANDOM RECORD * * *************************************** * Entry Parameters: * Register C: 24H * * Registers DE: FCB Address * * * ** Returned Value: * Random Record Field Set * * *************************************** The Set Random Record function causes the BDOS to automatically produce the random record position from a file which has been read or written sequentially to a particular point. The function can be useful in two ways. First, it is often necessary to initially read and scan a sequential file to extract the positions of various "key" fields. As each key is encountered, function 36 is called to compute the random record position for the data corresponding to this key. If the data unit size is 128 bytes, the resulting record position is placed into a table with the key for later retrieval. After scanning the entire file and tabularizing the keys and their record numbers, you can move instantly to a particular keyed record by performing a random read using the corresponding random record number which was saved earlier. The scheme is easily generalized when variable record lengths are involved since the program need only store the buffer-relative byte position along with the key and record number in order to find the exact starting position of the keyed data at a later time. A second use of function 36 occurs when switching from a sequential read or write over to random read or write. A file is sequentially accessed to a particular point in the file, function 36 is called which sets the record nu~ber, and subsequent random read and write operations continue from the selected point in the file. (All Information Contained Herein is Proprietary to Digital Research.) 29 • 3. A SAMPLE FILE-TO-FILE COpy PROGRAM. The program shown below provides a relatively simple example of file operations. The program source file is created as COPY.ASM using the CP/M ED program and then assembled using ASM or MAC, resulting in a "HEX" file. The LOAD program is the used to produce a COPY.COM file which executes directly under the CCP. The program begins by setting the stack pointer to a local area, and then proceeds to move the second name from the default area at 006CH to a 33-byte file control, block called DFCB. The DFCB is then prepared for file operations by clearing the current record field. At this point, the source and destination FCB's are ready for processing since the SFCB at 005CH is properly set-up by the CCP upon entry to the COpy progr~u. That is, the first name is placed into the default fcb, with the proper fields zeroed, including the current record field at 007CH. The program continues by opening the source file, deleting any exising destination file, and then creating' the destination file. If all this is successful, the program loops at the label COpy until each record has been read from the source file and placed into the destination file. Upon completion of the data transfer, the destination file is closed and the program returns to the CCP command level by jumping to BOOT. ·, ~ sample file-to-file copy program at the ccp level, the command ; , · 0000 0005 005c 005c 006c 0080 0100 = = = = = = = ·, boot bdos fcbl sfcb fcb2 dbuff tpa copy a:x.y b:u.v copies the file named x.y from drive a to a file named u.v on drive b. ; system reboot bdos entry point first file name source fcb second file name ; defaul t buffer beg inning of tpa equ equ equ equ equ equ equ 0000h 0005h 005ch fcbl 006ch 0080h 0100h equ equ equ equ equ equ equ 15 16 19 20 21 22 org lxi tpa beginning of tpa sp,stack; local stack ; 0009 000f 0010 0013 0014 0015 0016 = = = = = = = 0100 0100 3llb02 printf openf closef deletef readf writef makef ; · , 0103 0e10 print buffer func# open file func# close file func# delete file func# sequential read sequential write make file func# 9 move second file name to dfcb mvi c,16 ; half an fcb (All Information Contained Herein is Propr ietary to big i tal Research.) 30 131135 131138 r31Qlb QlIQlc QlIQld 01Qle 01Qlf 131113 116cr3r3 21dar31 la mfcb: 13 77 23 r3d c2r3br31 13113 af 0114 32far31 ,· lxi lxi Idax inx mov inx dcr jnz d,fcb2 h,dfcb d d m,a h c mfcb source of move destination fcb ; source fcb ready next dest fcb ready next count 16 ••• 0 loop 16 times name has been moved, zero cr xra a ; a = 00h sta dfcbcr; current rec = 13 source and destination fcb's ready Qll17115cr3r3 011a cd6901 r311d 1187131 131213 3c 13121 cc6101 lxi call lxi inr cz 13124 Ilda01 13127 cd73r31 source file open, prep destination lxi d,dfcb destination call delete remove if present 012a 012d 01313 0133 0134 Ilda01 cd8201 119601 3c cc6101 ,· lxi call lxi inr cz d, sfcb source file open ; error if 255 d,nofile; ready message 255 becomes 13 a finis done if no file d,dfcb make d,nodir a finis destination create the file ready mes sage 255 becomes 0 done if no dir space source file open, dest file open copy until end of file on source ; 0137 r313a 013d 013e 115c00 copy: cd7801 b7 c251r31 · , ; 0141 13144 13147 014a r314b ,014e IldaQll cd7d0l lla9 £11 b7 c46101 c33701 lxi call ora jnz d,sfcb read not end lxi call lxi ora cnz j mp of file, write the record d,dfcb destination write write record d,space ready message 00 if write ok a finis end if so loop un til eo f copy a eofile source read next record end of file? skip write if so ; 0151 13154 0157 Ql15a Ql15b Ilda01 cd6e01 21bb01 3c cc6101 eofile: ; end of file, close destination d,dfcb destination lxi close ; 255 if error call lxi h,wrprot; ready message inr 255 becomes 130 a shouldn't happen finis cz copy operation complete, end (All Information Contained Herein is Proprietary to Digital Research.) 31 015e 11cc01 ·, finis: 0161 0e09 0163 cd0500 0166 c30000 lxi d,normal~ ~ write mvi call jmp message given by de, reboot c,printf bdos ~ write message boot ~ reboot system ready message system interface subroutines (all return directly from bdos) 0169 0e0f open: 016b c30500 mvi jmp c,openf bdos 016e 0e10 close: 0170 c30500 mvi jmp c,closef bdos ·, ·, 01730e13 delete: mvi 0175 c30500 jmp c,deletef bdos 0178 0e14 read: 017a c30500 mvi jmp c, readf bdos mvi jmp c,writef bdos 0182 0e16 make: 0184 c30500 mvi jmp c,makef bdos 0187 0196 01a9 01bb !{llcc console db db db db db mes sages 'no source file$' 'no directory spaceS' 'out of data space$' 'write protected?$' 'copy complete$' ·, ~ 017d 0e15 write: 017f c30500 ~ 01da 01fa 6e6f20fnofile: 6e6f209nodir: 6f7574fspace: 7772695wrprdt: 636f700normal: = dfcb: dfcbcr 01fb stack: 021b data areas ds 33 ; destination fcb equ dfcb+32 ; current record as 32 16 level stack end Note that there are several simplifications in this particular program. First, there are no checks for invalid file names which could, for example, contain ambiguous references. This situation could be detected by scanning the 32 byte default area starting at location 005CH for ASCII question marks. A check should also be made to ensure that the file names have, in fact, been included (check locations 005DH and 006DH for non-blank ASCII characters). Finally, a check should be made to ensure that the source and destination file names are different. A speed improvement could be made by buffering more data on each read operation. One could, for example, determine (All Information Contained Herein is Proprietary to Digital Research.) 32 the size of memory by fetching FBASE from location 0006H and use the entire remaining portion of memory for a data buffer. In this case, the programmer simply resets the DMA address to the next successive 128 byte area before each read. Upon writing to the destination file, the DMA address is reset to the beginning of the buffer and incremented by 128 bytes to the end as each record is transferred to the destination file. • (All Information Contained Herein is Proprietary to Digital Research.) 33 4. A SAMPLE FILE DUMP UTILITY. The file dump program shown below is slightly more complex than the :simple copy program given in the previous section. The dump program reads an inputf ile, specified in the CCP command line, and displays the content of each record in hexadecimal format at the console. Note that the dump program saves the CCp's stack upon entry, resets the stack to a local area, and restores the CCp's stack before returning directly to the CCP. Thus, the dump program does not perform and warm start at the end of processing. ; DUMP program reads input file and displays hex data = pr~ntf = = brkf openf readf org equ equ equ equ equ equ equ fcb buff equ equ cr If non graphic characters egu 0dh ;carriage return equ 0ah ;line feed fcbdn fcbfn fcbft fcbrl fcbrc fcbcr fcbln file control block definitions equ fcb+0 ;disk name equ fcb+l ;file name equ fcb+9 ;disk file type (3 characters) equ fcb+12 ;file's current reel number equ fcb+15 ;file's record count (13 to 128) equ fcb+32 ;current (next) record number (0 equ fcb+33 ; fcb length 0HH} 13005 0001 0002 0009 000b 000f 0014 = = = = 005c = 0080 = 000d = 13 00a = o05c = 013 5d = 01365 = 0068 = 006b = 007c = 0137d = bdos cons typef ., ., 1130h 13 0 05h 11 15 213 ;dos entry point ; read console ;type function ;buffer print entry ;break key function (true if char ;file open ;read function 5ch 813h ;file control block address ;input disk buffer address 1 2 9 cd cl 0 1 f e ff 010f c21b01 set up stack lxi h,0 dad sp entry stack pointer in hI from the ccp shld oldsp set sp to local stack area (restored at finis) lxi sp,stktop read and print successive buffers call setup ;set up input file cpi 255 ;255 if file not present jnz openok ;skip if open is ok 0112 Ilf301 0115 cd9c01 0118 c35101 file not there, give error message and return d,opnmsg lxi call err jmp finis ito return 0100 210000 01133 39 0104 221502 0107 3157132 o1 0a o10d (All Information Contained Herein is Proprietary to Digital Research.) 34 openok: 011b 3e80 011d 321302 0120 210000 ;open operation ok, set buffer index to end mvi a,80h ;set buffer pointer to 80h sta ibp hI contains next address to print lxi h,0 ;start with 0000 ; gloop: 0123 0124 0127 0128 012b e5 cda201 el da5101 47 push h ;save line position call gnb pop ;recall line position h ;carry set by gnb if end file finis jc mov b,a print hex values check for line fold mov a,l ani 0fh ;check low 4 bits jnz nonum print line number call crlf 012c 7d 012d e60f 012f c24401 0132 cd7201 0138 0f 0139 da5101 check for break key call break accum lsb = 1 if character ready rrc ;into carry jc finis ;don't print any more 013c 013d 0140 0141 mov call mov call a,h phex a,l phex inx mvi call mov call j mp h 0135 cd5901 7c cd8f01 7d cd8f01 nonum: 0144 0145 0147 014a 014b 014e 23 3e20 cd6501 78 cd8f01 c32301 . a,' ito next line number , pchar a,b phex gloop • I finis: end of dump, return to ccp (note that a jmp to 0000h reboots) cr If call lhld oldsp sphl stack pointer contains ccp's stack location ret ito the ccp 0151 cd7201 0154 2a1502 0157 f9 0158 c9 . sub r ou tin e s break: ;check break key (actually any key will do) push h! push d! push b; environment saved mvi c,brkf call bdos pop b! pop d! pop h; environment restored I 0159 015c 015e 0161 e5d5c5 0e0b cd0500 cldlel (All Information Contained Herein is Proprietary to Digital Research.) 35 ret 0164 c9 i pchar: 0165 0168 0l6a 0l6b 0l6e 0171 e5d5c5 0e02 Sf cd0500 cldlel c9 iprint a character push h! push d! push bi saved c, typef mvi mov e,a bdos call pop b! pop d! pop hi restored ret i cr If: 0172 0174 0177 0179 017c mvi call mvi call ret 3e0d cd6501 3e0a cd650l c9 a,cr pchar a,lf pchar i pnib: 0184 c630 0186 c38b01 iprint nibble in reg a 0fh ani i low 4 bits cpi 10 jnc p10 less than or equal to 9 10' adi prn jmp 0189 c637 p10: 0l8b cd6501 prn: 0l8e c9 greater or equal to 10 adi 10 I a • pchar call ret 0l7d e60f 017f fe0a 0181 d28901 i 0l8f 0190 0191 0192 0193 0194 0197 0198 019b - phex: iprint hex char in reg a push psw rrc rrc rrc rrc pnib call iprint nibble pop psw call pnib ret err: iprint error message d,e addresses message ending with "$10 c,printf iprint buffer function mvi bdos call ret f5 0f 0f 0f 0f cd7d0l fl cd7d0l c9 019c 0e09 01ge cd0500 01al c9 ., gnb: 01a2 3a1302 01a5 fe80 01a7 c2b301 i get next byte Ida ibp cpi 80h jnz g0 read another buf'fer (All Information Contained Herein is Proprietary to Digital Research.) 36 ; 9laa cdce9l 9lad b7 9lae cab39l call ora ; 9lbl 37 9lb2 c9 diskr a ;zero value if read ok jz gf{J ;for another byte end of data, return with carry set for eof stc ret ; g9: 9lb3 9lb4 9lb6 9lb7 5f 1699 3c 321392 · I 9lba 218999 9lbd 19 ; 9lbe 7e ; 9lbf b7 9lc9 c9 · ;read the byte at buff+reg a mov e,a ;ls byte of buffer index mvi d,f{J ;double precision index to de inr a ;index=index+l sta ibp ;back to memory pointer is incremented save the current file address lxi h,buff dad d absolute character address is in hI mov a,m byte is in the accumulator ora a ;reset carry bit ret I setup: ; f{Jlcl af f{Jlc2 327cf{J9 ; set up file open the file for input xra a i zero to accum sta fcbcr iclear current record ; f{Jlc5 11Sc00 0lc8 ge0f 0lca cd0500 ; 0lcd c9 d,fcb lxi c,openf mvi bdos call 255 in accum if open error ret ; diskr: 9lce 0ldl 0ld4 9ld6 0ld9 0ldc e5d5c5 l15c90 ge14 cd0509 cldlel c9 ·; ;read disk file record push h! push d! push b lxi d,fcb mvi c" r.eadf call bdos pop b! pop d! pop h ret I fixed message area 0ldd 46494c0signon: db 'file dump version 2.0$' 0lf3 ~d9a4e90pnmsg: db cr,lf,'no input file present on disk$' 0213 0215 ·, ibp: oldsp: var iable area ds 2 ds 2 ;input buffer pointer :entry sp value from ccp stack area ds 64 ireserve 32 level stack ; 9217 f{J257 stktop: end (All Information Contained Herein is Proprietary to Digital Research.) 37 • 5. A SAMPLE RAND 4AlEiHo 4A21H+o 4A24H+b 4A27f1+b 4A2A1Hb 4A2ofI+b 4A30H+b JMP BOO'l' J i'1P WBOOrl' Jll1p CONST J-t-lP COlUN J I'll' CONOlJT Jtv1i? LIST J~P PUNCH Jt'1P READER JMP HOME Jr·1P SELDSK J~1P SET'rRK J!\1..i? SE'rSEC J Hi? S E'rDfJIA J r.1i? READ JMP ~I)'RI'rE J £vIP L I S'rS'I' JMP S ECrRAN where the ARRIVE HERE FROM COLD START LOAD ARRIVE HERE FOR WAR!"1 S'rART CHECK FOR CONSOLE CHAR READY READ CONSOLE CHARACTER IN ~VRI'rE CONSOLE CHARAC'rER ou'r WRITE LISTING CHARACTER OUT WRI'l'E CHARACTER 'ro PUNCH DEVICE READ READER DEVICE MOVE TO TRACK 00 ON SELECTED DISK SELECT DISK DRIVE SE'I' 'fRACK NUMBER SET SECTOR NUMBER S E'r Drv1A ADDRESS READ SELECTED SECTOR WRITE SELECTED SECTOR RETURN LIST STATUS SECTOR TRANSLATE SUBROUTINE 8ach jumo address corresponds to a particular subroutine which performs tne specific function, as outlined below. There are three major divisions in the jump table: the system (re) initialization whicn results from calls on BOOT and WBOOT, simple character I/O performed by calls on CONST, CONIN, CONOU'I', LIST, PUNCH, READER, and LISTS'r, and diskette I/O performed by calls on HOME, SELDSK, SET'rRK, SETSEC, SETOMA, READ, WRITE, and SECTRAN. All simple character I/O operations are assumed to be performed in ASCII, upper and lower case, with high order ("parity bit) set to zero. An end-of-file condition for an input device is given by an ASCII control-z (lAH). Peripheral devices are seen by CP/M as "logical" devices, and are assigned to physical devices within the BIOS. In order to operate, the BOOS needs only the CONST, CONIN, and CONOU'r subroutines (LIST, PUl~CH, and READER may be used by PIP, but not the BOOS). Further, the LISTST entry is used currently only by DESPOOL, and thus, the initial version of CBIOS may have empty subroutines for the remaining ASCII devices • ...... (All Information Contained Herein is Proprietary to Digital Research.) 14 The characteristics of each device are CONSOLE The ?rincipal interactive console which communicates with the operator, accessed through CaNST, CONIN, and CONOUT. Typically, the CONSOLE is a device such as a CRT or Teletype. LIST The principal listing device, if it exists on your system, which is usually a hard-copy device, such as a printer or Teletype. PUNCH. The principal tape punching device, if it exists, which is normally a high-speed paper tape punch or Teletype. READER The principal tape reading device, optical readei or Teletype. such as a simple Note that a single ?eripheral can be assigned as the LIS'r, PUNCH, and READER dev ice s imul taneousl y. If no peri?heral device is assigned as the LIST, PUNCH, or READER device, the CBIOS created by the user may give an appropriate error message so that the system does not "hang" if the device is accessed by PIP. or some other user program. Alternately, the PUNCH and LIST routines can just simply return, and the READER routine can return with a lAH (ctl-Z) in reg A to indicate immediate end-of-file. For added flexibility, the user can, optionally implemen t the "IOBY'rE" function wh ich allows reassignment of physical and logical devices. The IOBYTE function creates a mapping of logical to physical devices which can be altered during CP/M processing (see the STAT commanc). 'rhe definition of the IOBYTE function corresponds to the Intel standard as follows: a single location in memory (currently location 0003H) is maintained, called IOBYTE, which defines the logical to ?hysical device mapping Which is in effect at a particular time. The mapping is performed by splitting the IOBYTE into four distinct fields of two bits each, called the CONSOLE, READER, PUNCH, and LIST fields, as shown below: most significant IOBYTE AT 0003H I LIST bits 6,7 I PUl'-JCH bits 4,5 least significant I READER bits 2,3 I CONSOLE I bits 0,1 The value in each field can be in the range 0-3, defining the assigned source or destination of each logical device. The values which can be assigned to each field are given below (All Information Contained Herein is 15 Pro~rietary to Digital Research.) CONSOLE field (bits 0,1) o - console is assigned to the console printer device (TTY:) I console is assigned to the CRT device (CRT:) 2 - batch mode: use the READER as the CONSOLE input, and the LIST device as the CONSOLE output (BAT:) 3 - user defined console device (UCl:) READER field (bits 2,3) - READER is the 'reletype device (TTY:) 1 READER is the high-speed reader device (RDR:) 2 user defined reader # 1 (URI:) 3 user defined reader # 2 (UR2:) '" PUNCH field (bits 4,5) o - PUNCH is the 1 - PUNCH is the 2 - user defined 3 user defined Teletype device (TTY:) high speed punch device (PUN:) punch # 1 (UPl:) punch # 2 (UP2:) LIST field (bits 6,7) o - LIST is the Teletype device (TTY:) 1 - LIST is the CRT device (CRT:) 2 - LIST is the line printer device (LPT:) 3 - u~er defined list device (ULl:) Note again that the implementation of the IOBYTE is optional, and affects only the organization of your CBIOS. No CP/M systems use the IOBYTE (although they tolerate the existence of the IOBYTE at location 0~03H), except for PIP which allows access to the physical devices, and S'rA'l' which allows logical-physical assignments to be made and/or displayed (for more information, see the "CP/M Features and Fac il i ties Gu ide") • In any case, the 10BY'rE implementation should be omitted until your basic CBIOS is fully imolemented and tested: then add the 10BYTE to increase your facilities. Disk I/O is always performed through a sequence of calls on the various disk access subroutines which set u~ the disk number to access, the track and sector on a particular disk, and the direct memory access (DMA) address involved in the I/O operation. After all these parmneters have been set up, a call is made to the READ or WRITE function to oeriorm the actual I/O operation. Note that there is often a single call to SELDSK' to select a disk drive, followed by a number of read or write operations to the selected disk before selecting another drive for subsequent operations. Similarly, there may be a single call to set the DMA address, followed by several calls which read or write from the selected DMA address before the DMA address is changed. The track and sector sUbroutines are always called before tne READ or WRI'rE operations are performed. (All Information Contained Herein is Proprietary to Digital Research.) 16 Note that the READ and WRITE routines should perform several retries (10 is standard) before reporting the error condition to the BOOS. If the error condition is returned to the BOOS, it will report the error to the user. The HOME subroutine mayor may not actually perform the track 00 seek, depending upon your controller characteristics; the important point is that track 00 has been selected for the next operation, and is often treated in exactly the same manner as SET'rRK with a parameter of 00. The exact responsibilites subroutine are given below: of eacn entry point Boo'r The BOOT entry point gets control from the cold start loader' and is responsible for basic system initialization, including sending a signon message (which can be omitted in the first version). ' If the IOBYTE function is implemented, it must be set at this point. 'rhe var ious system parameters which are set by the wBOOT entry point must be initialized, and control is transferred to the CCP at 3400H+b for further processing. Note that reg C must be set to zero to select dr ive A. WBoo'r The WBOOT entry point gets control when a warm start occurs. A warm start is performed whenever a user r;>rogram branches to location 0000H, or when the CPU is reset from the front panel. 'rhe CP/i"1 system must be loaded from the first two tracks of drive A up to, but not including, the BIOS (or CBIOS, if you have completed your patch). System parameters must be initialized as shown below: location 0,1,2 set to JHP WBOO'f for warm starts (0000H: JHP 4A03H+b) if location 3 set initial value of IOBYTE, implemented in your CBIOS location 5,6,7 set to Jr.lP BOOS, which is the primary entry point to CP/M for (0005H: JMP transient programs. 3C06H+b) (see Section 9 for complete details of page zero use) Upon completion of the initialization, the WBOOT program must branch to the CCP at 3400H+b to (re)start the system. Upon entry to the CCP, register C is set to the drive to select after system initialization. CONST Sample the device and ready to characters status of the currently assigned console return 0FFH in register A if a character is read, and 00H in register A if no console are ready. CONIN Read the next console character into register A, and (All Information Contained Herein is Proprietary to Digital Research.) 17 • set the parity oit (high order bit) to zero. If no console character is ready, wait until a character is typed oetore returning. CONOUT Send the character from register C to the console output device. The character is in ASCII, with high order parity bit set to zero. You may want to include a time-out on a line feed or carriage return, if your console device requires some time interval at the end of the line (sucn as a TI Silent 700 terminal). You can, if you wish, filter out control characters which cause your console device to react in a strange way (a control-z causes the Lear Seigler terminal to clear the screen, for examole). LISlr Send the character from register C to the currently assigned listing device. The character is in ASCII with zero parity. PUNCH Send the cnaracter from register C to the currently assigned punch device. The character is in ASCII with zero parity. READER Read the next character from the currently assigned reader device into register A with zero parity (high order bit must be zero), an end of file condition is reported by returning an ASCII control-z (lAH). HOME Return the disk head of the currently selected disk (initially disk A) to the track 00 position. If your controller allows access to the track 0 flag from the drive, step the head until the track 0 flag is detected. If your controller does not support this feature, you can translate the HOME call into a call on SE'II'rRK witn a parameter of 0. SELDSK Select the disk drive given by register C for further operations, wnere register C contains 0 for drive A, 1 for drive' 8, and so-forth up to 15 for drive P (the standard CP/M distribution version supports four drives). On each disk select, SELDSK must return in HL the base address of a 16-byte area, called the Disk Parameter Header, described in the Section 10. For standard floppy disk drlves, the contents of the header and associated tables does not change, and thus the program segment included in the sample C8IOS performs this operation automatically. If there is an attempt to select a non-existent drive, SELDSK returns HL=0000H as an error indicator. Although SELDSK must return the header address on each call, it is advisable to postpone the actual physical disk select operation until an I/O function (seek, read or write) is actually performed, since disk selects often occur without utimately performing any disk I/O, and ~many controllers will unload the head of the current disk (All Information Contained Herein is Proprietary to Digital Research.) 18 before selecting the new drive. This would excessive amount of noise and disk wear. cause an SE'l'TRK Register BC contains the track number for subseauent disk accesses on the currently selected drive. You can choose to seek the selected track at this time, or delay the seek until the next read or write actually occurs. Register BC can take on values in the range 0-76 corresponding to valid track numoers for standard floppy disk drives, and 0-65535 for non-standard disk subsystems. SE'l'SEC Register BC contains the sector number (1 through 26) for subsequent disk accesses on the currently selected drive. You can choose to send this information to the controller at this point, or instead delay sector selection until a read or write operation occurs. SE'rOMA Register BC contains the OMA (disk memory access) address for subsequent read or write operations. For example, if B = 00H and C = 80H when SETOMA is called, then all subsequent read operations read their data into 80H through 0FFH, and all subsequent write operations get their data from 80d through 0FFH, until the next call to SETDMA occurs. The initial DMA address is assumed to be 80H. Note that the controller need not actually support direct memory access. If, for example, all data is received and sent through I/O ports, the CBIOS which you construct will use the 128 byte area starting at the selected DMA address for the memory buffer during the following read or write operations. READ Assuming the drive has been selected, the track has been set, the sector has been set, and the DMA address has been specified, the READ subroutine attempts to read one sector based upon these parameters, and returns the following error codes in register A: o 1 no errors occurred non-recoverable error condition occurred Currently, CP/M responds only to a zero or non-zero value as tne return code. That is, if the value in register A is 0 then CP/M assumes that the disk operation completed properly. If an error occurs, however, the CBIOS should attempt at least 10 retries to see if the error is recoverable. When an error is reported the BOOS will print the message "BOOS ERR ON x: BAD SECTOR". The operator then has the option of typing to ignore the error, or ctl-C to abort. ~vRITE write the data from the currently selected OMA address to the currently selected drive, track, and sector. 'r he d a t a s h 0 u 1 d be mar ked as" non del e ted d a t a " to (All Information Contained Herein is Proprietary to Digital Research.) 19 .. maintain compatibility with other CP/l'-l systems. The error codes given in the READ command are returned in register A, with error recovery attempts as described above. Return the ready status of the list device. Used by the DESPOOL program to improve console response during its operation. The value 00 is returned in A if the list device is not ready to accept a character, and 0FFH if a character can be sent to the printer. Note that a 00 value always suffices. SEC'l'RAN Performs sector logical to physical sector translation in order to impro~e the over~ll response of CP/M. Standard CP/M systems are shipped with a "skew factor" of 6, where six physical sectors are skipped between each logical reaa operation. This skew factor allows enough time between sectors for most programs to load their buffers without missing the next sector. In particular computer systems which use fast processors, memory, and disk subsystems, the skew factor may be changed to improve overall response. Note, however, that you should maintain a single density IBM compatible version of CP/M for information transfer into and out of your computer system, using a skew factor of 6. In general, SECTRAN receives a logical sector number in BC, and a translate table address in DE. The sector number is used as an index into the translate table, with the resulting physical sector number in HL. For stanaard systems, the tables and indexing code is orovided in the CBIO~ and need not be changed. (All Information Contained Herein is Proprietary to Digital Research.) 20 7. A SAMPLE BIOS 'rhe program sho\vn in A.ppendix C can serve as a basis for your first BIOS. The simolest functions are assumed in this BIOS, so that you can enter it through the front panel, if absolutely necessary. Note that the user must alter and insert code into the subroutines for CONS;r, CONIN, CONOUT, READ, WRITE, and WAITIO subroutines. Storage is reserved for user-supplied code in these regions. The scratch area reserved in ?age zero (see Section 9) for the BIOS is used in this program, so that it could be implemented in ROM, if desired. Once operational, this skeletal version can be enhanced to print the initial sign-on message and perform better error recovery. The subroutines for LIST, PUNCH, and READER can be filled-out, and the IOBYTE function can be implemented. • (All Information Contained Herein is proprietary to Digital Research.) 21 8. A SAM.PLE COLO S'rAR'r LOADER 'rhe program shown in Appendix D can serve as a basis for your cold start loader~ The disk read function must be supplied by the user, ana the program must be loaded somehow starting at location 0000. Note tnat space is reserved for your patch so that the total amount of storage required for the cold start loader is 128 bytes. Eventually, you will probably want to get this loader onto the first disk sector (track 0, sector 1), and cause your controller to load it into memory automatically upon system start-up. Alternatively, you may wish to place tne cold start loader into ROM, and place it above the CP/M system. In this case, it will be necessary to originate the program at a higher address, and key-in a jump instruction at system start-up which branChes to the loader. Subsequent warm starts will not require this key-in operation, since the entry point 'WBOOT ' gets control, thus bringing the system in from disk automatically. Note also that the skeletal cold start loader has minimal error recovery, which may be enhanced on later versions. (All Information Contained Herein is Proprietary to Digital Research.) 22 9. RESERVED LOCATIONS IN PAGE ZERO Main memory page zero, between locations 00H ana 0FFH, contains several segments of code and data which are used during CP/M processing. The code and data areas are given below for reference puq)oses. Locations from to 00008 - 0002H Contents Contains a jump instruction to the warm start entry point at location 4A03H+b. This allows a simple programmed restart (JHP 01tJ0LiiH) or manual restart from the front Danel. 0003H - 000 3H Contains the Intel standard I08YTE, optionally included in tne user's described in Section 6. 1010 10 48 - 000 4H Current default drive number (0=A, ••• ,15=.!?). 0005H - 0007H Contains a jump instruction to the ODOS,and serves two purposes: JMP 0005H provides the primary entry point to the BOOS, as described in the manual "CP/M Interface Guide," and LHLO 01tJ06H brings the address field of the instruction to the tiL register pair. This value is the lowest aadress in memory used by CP/M (assuming the CCP is being overlayed). Note that the DD'r ?rogram will change the address field to reflect the reduced memory size in debug mode. 0008H - 0027H (interrupt locations 1 through 5 not used) 01030H - 1tJ037H (interrupt location reserved) 1tJ1038H - 1tJ03AH Restart 7 - Contains a jum? instruction into the DDT or SID ?rogram when running in debug mode for programmed breakpoints, but is not otherwise used by cp/rvJ.. 003BH - 003FH (not currently used - reserved) 0i040H - 1i.104FH 16 byte area reserved for scratch by CBIOS, but is not used for any purpose in the distribution version of CP/M 1tJ050H - 005BH (not currently used - reserved) 005CH - 1007CH default file control block produced for a Command transient program by the Console .!?rocessor. 0070H - 007FH Optional default random record position 6, not which is CBIOS, as currently used (All Information Contained Herein is Proprietary to Digital Research.) 23 • 0080H - 00FFH default 12d byte disk buffer (also filled with the command line when a transient is loaded under the CCP). Note that this information is set-up for normal operation under the CP/M system, but can be overwritten by a transient program if the BDOS tacilities are not required by the transient. If, for example, a particular program performs only simple I/O and must begin execution at location 0, it can be first loaded into the ~PA, using normal CP/M facilities, with a small memory move progr~ which gets control when loaded (the memory move program must get control from location 0100H, which is the assumed beginning of all transient programs). The move program can then proceed to mo~e the entire memory image down to location 0, and pass control to the starting address of the memory load. Note that if the BIOS is overwritten, or if location 0 (containing the warm start entry point) is overwritten, then the progr~mer must bring the CP/M system back into memory with a cold start sequence. (All Information Contained Herein is Proprietary to Digital Research.) 24 H'J. DISK PARAMETER TABLES. Tables are included in the BIOS which describe the particular characteristics of the disk subsystem used with CP/M. These tables can be either hand-coded, as shown in the sample CBIOS in Appendix C, or automatically generated using the DISKDEF macro library, as shown in Appendix B. The purpose here is to describe the elements of these tables. In general, each disk drive has an associated (16-byte) disk parameter header which both contains information about the disk dr ive and provides a scratchpad area for certain BDOS operations. The format of the disk parameter header for each drive is shown below Disk XLT 16b Parameter I 0000 I 0000 I 0000 IDIRBUFI 16b 16b 16b 16b Header DPB CSV ALV 16b 16b 16b where each element is a word (16-bit) value. Parameter Header (DPH) element is XLT The meaning'of each Disk Address of the logical to physical translation vector, if used for this particular drive, or the value 0000H if no sector translation takes place (i.e, the physical and logical sector numbers are the same). Disk drives with identical sector skew factors share the same translate tables. Scratchpad values for use value is unimportant). within the BDOS (initial DIRBUF Address of a 128 byte scratchpad area for directory operations within BDOS. All DPH's address the same scratchpad area. DPB Address of a disk parameter block for this drive. Drives with identical disk characteristics address the same disk parameter block. CSV Address of a scratchpad area used for software check for changed disks. This address is different for each DPH. ALV Address of a scratchpad area used by the BDOS to keep disk storage allocation information. This address is different for each DPH. - Given n disk drives, the DPH's are arranged in a table whose first row of 16 bytes corresponds to drive 0, with the last row corresponding to drive n-l. The table thus appears as (All Information Contained Herein is Proprietary to Digital Research.) 25 • DPBASE: 00 IXLT 001 0000 1 0000 1 0000 IDIRBUFIDBP 001csv 001ALV 001 01 IXLT 011 0000 1 0000 1 0000 IDIRBUFloBP 0llcsv 0llALV 011 (and so-forth through) n-IIXLTn-ll 0000 1 0000 1 0000 1DIRBUFIDBPn-1ICSVn-IIALVn-l1 where the label DPBASE defines the base address of the DPH table. A responsibility of the SELDSK subroutine is to return the base address of the DPH for the selected drive. The following sequence of operations returns the table address, with a 0000H returned if the selected drive does not exist. NDISKS EQU 4 iNUMBER OF DISK DRIVES SELDSK: iSELECT DISK GIVEN BY BC LXI H,0000H iERROR CODE MOV A,C iDRIVE OK? CPI NDISKS iCY IF SO RNC iRET IF ERROR iNO ERROR, CONTINUE MOV L,C iLOW(DISK) MOV H,B iHIGH(DISK) DAD H i*2 DAD H i*4 DAD H i*8 DAD H i*16 LXI D,DPBASE iFIRST DPH DAD D i DPH (DISK) RET The translation vectors (XLT 00 through XLTn-l) are located elsewhere in the BIOS, and simply correspond one-for-one with the logical sector numbers zero through the sector count-I. The Disk Parameter Block (DPB) for each drive is more complex. A particular OPB, which is addressed by one or more DPHls, takes the general form SPT l6b IBSHIBLMIEXMI 8b 8b 8b DSM DRM l6b l6b IAL01ALII 8b 8b where each is a byte or word value, as shown indicator below the field. by CKS OFF l6b l6b the SPT is the total number of sectors per track BSH is the data allocation block shift by the data block allocation size. .18b" factor, or "16b" determined (All Information Contained Herein is proprietary to Digital Research.) 26 EXM is the extent mask, determined by the data allocation size and the number of disk blocks. DSM determines the total storage capacity of the disk drive DRM determines the total number of directory entries which can be stored on this drive AL0,ALI determine reserved directory blocks. CKS is the size of the directory check vector OFF is the number of reserved tracks at the (logical) disk. the block beginning of The values of BSH and BLM determine (implicitly) the data allocation size BLS, which is not an entry in the disk parameter block. Given that the designer has selected a value for BLS, the values of BSH. and BLM are shown in the table below BLS 1,024 2,048 4,096 8,192 16,384 BSH 3 4 5 6 BLM 7 15 31 63 127 7 where all values are in decimal. The value of EXM depends upon both the BLS and whether the DSM value is less than 256 or greater than 255, as shown in the following table BLS 1,024 2,048 4,096 8,192 16,384 DSM < 256 DSM > 255 N/A 0 1 3 0 1 3 7 15 7 The value of DSM is the maximum data block number supported by this particular drive, measured in BLS units. The product BLS times (DSM+l) is the total number of bytes held by the drive and, of course, must be within the capacity of the Dhysical disk, not counting the reserved operating system tracks. .. The DRM entry is the one less than the total number of directory entries, which can take on a 16-bit value. The values of AL0 and ALl, however, are determined by DRM. The two values AL0 and ALI can together be considered a string of l6-bits, as shown below. (All Information Contained Herein is Proprietary to Digital Research.) 27 • AL0 ALI --------------------------------------~---------- 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 where position 00 corresponds to the high order bit of the byte labelled AL0, and 15 corresponds to the low order bit of the byte labelled ALI. Each bit position reserves a data block for number of directory entries, thus allowing a total of 16 data blocks to be assigned for directory entries (bits are assigned starting at 00 and filled to the right until position 15). Each directory entry occupies 32 bytes, resulting in the following table BLS 1,024 2,048 4,096 8,192 16,384 Directory 32 times 64 times 128 times 256 times 512 times Entries # bits # bits # bits # bits # bits Thus, if DRM = 127 (128 directory entries), and BLS = 1024, then there are 32 directory entries per block, requiring 4 reserved blocks. In this case, the 4 high order bits of AL0 are set, resulting in the value~ AL0 = 0F0H and ALI = 00H. The CKS value is determined as follows: if the disk drive" media is removable, then CKS = (DRM+l)/4, where DRM is the last directory entry number. If the media is fixed, then set CKS = 0 (no directory 'records are checked in this case). Finally, skipped at the automatically mechanism for partitiQning a the OFF field determines the number of tracks which are beginning of the physical disk~ This value is added whenever SETTRK is called, and can be used as a skipping reserved operating system tracks, or for large disk into smaller segmented sections. To complete the discussion of the DPB, recall that several DPH's can address the same DPB if their drive characteristics are identical. Further, the DPB can be dynamically changed when a new drive is addressed by sim?ly changing the pointer in the DPH since the BDOS copies the DPB values to a local area whenever the SELDSK function is invoked. Returning back to the DPH for a particular drive, note that the two address values csv and ALV remain. Both addresses reference an area of un initialized memory following the BIOS. The areas must be unique for each drive, and the size of each area is determined by the values in the DPB. The size of the area addressed by CSV is CKS bytes, which is sufficient to hold the directory check information for this particular drive. If CKS = (DRM+l)/4, then you must reserve (DRM+l)/4 bytes for directory check use. If CKS = 0, then no storage is reserved. (All Information Contained Herein is Proprietary to Digital Research.) 28 The size of the area addressed by ALV is determined by the maximum number of data blocks all~ed for this particular disk, and is computed as (DSM/8)+I. The CBIOS shown in Appendix C demonstrates an instance of these tables for standard 8" single density drives. It may be useful to examine, this program, and compare the tabular values with the definitions given above. • (All Information Contained Herein is Proprietary to Digital Research.) 29 11. THE DISKDEF MACRO LIBRARY. A macro library is shown in Appendix F, called DISKDEF, which greatly simplifies the table construction process. You must have access to the MAC macro assembler, of course, to use the DISKDEF facility, while the macro library is included with all CP/M 2.0 distribution disks. A BIOS disk definition consists of macro statements: MACLIB DISKDEF DISKDEF DISKDEF o , ••• · . . . .. DISKS · . . . .. DISKDEF · ..... ENDEF the following sequence of n 1 , ... n-l where the MACLIB statement loads the DISKDEF.LIB 'file (on the same disk as your BIOS) into MAC's internal tables. The DISKS macro call follows, which specifies the number of drives to be configured with your system, where n is an integer in the range 1 to 16. A series of DISKDEF macro calls then follow which define the characteristics of each logical disk, 0 through n-l (corresponding to logical drives A through P). NJte that the DISKS and DISKDEF macros generate the in-line fixed data tables described in the previous section, and thus must be placed in a non-executable portion of your BIOS, typically directly following the BIOS jump vector. The remaining portion of your BIOS is defined following the DISKDEF macros, with the ENDEF macro call immediately preceding the END statement. The ENDEF (End of Diskdef) macro generates the necessary uninitialized RAM areas which are located in memory above your BIOS. The form of the DISKDEF macro call is DISKDEF dn,fsc,lsc, [skf] ,bls,dks,dir,cks,ofs, [0] where dn fsc Isc skf bls dir cks ofs [0 ] is is is is is is is is is the logical disk number, 0 to n-l the first physical sector number (0 or I) the last sector number the optional sector skew factor the data allocation block size the number of directory entries the number of "checked ll directory entries the track offset to logical track 00 an optional 1.4 compatibility flag The value "dnll is the drive number being defined with this DISKDEF (All Information Contained Herein is Proprietary to Digital Research.) 30 macro invocation. The "fsc" parameter accounts for differing sector number ing systems, and is usually 0 or 1. The "lsc" is the last numbered sector on a track. When present, the "skf" parameter defines the sector skew factor which is used to create a sector translation table according to the skew. If the number of sectors is less than 256, a single-byte table is created, otherwise each translation table element occupies two bytes. No translation table is created if the skf parameter is omitted (or equal to 0). The "bls" parameter specifies the number of bytes allocated to each data block, and takes on the values 1024, 2048, 4096, 8192, or 16384. Generally, performance increases with larger data block sizes since there are fewer directory references and logically connected data records. are physically close on the disk. Further, each directory entry.addresses more data and the BIOS-resident ram space is reduced. The "dks" specifies the total disk size in "bls" units. That is, if the bls = 2048 and dks = 1000, then the total disk capacity is 2,048,000 bytes. If dks is greater than 255, then the block size parameter bls must be greater than 1024. The value of "dir" is the total number of directory entries which may exceed .255, if desired. The licks" parameter determines the number of directory items to check on each directory scan, and is used internally to detect changed disks during system operation, where an intervening cold or warm start has not occurred (when this situation is detected, CP/M automatically marks the disk read/only so that data is not subsequently destroyed). As stated in the previous section, the value of cks = dir when the media is easily changed, as is the case with a floppy disk subsystem. If the disk is permanently mounted, then the value of cks is typically 0, since the probability of changing disks without a restart is quite low. The "ofs" value determines the number of tracks to skip when this particular drive is addressed, which can be used to reserve additional operating system space or to simulate several logical drives on a single large capacity physical drive. Finally, the [0] parameter is included when file compatibility is required with versions of 1.4 which have been modified for higher density disks. This parameter ensures that only 16K is allocated for each directory record, as was the case for previous versions. Normally, this parameter is not included. For convenience and economy of table space, the special form DISKDEF i, j gives disk i the same characteristics as a previously defined drive j. A standard four~drive single density system, which is compatible with version 1~4, is defined using the following macro invocations: (All Information Contained Herein is Proprietary to Digital Research.) 31 • DISKS DISKDEF DISKDEF DISKDEF DISKDEF 4 0,1,26,6,1024,243,64,64,2 1,0 2,0 3,0 ENDEF with all disks having the same parameter values of 26 sectors per track (numbered 1 through 26), with 6 sectors skipped between each access, 1024 bytes per data block, 243 data blocks for a total of 243k byte disk capacity, 64 checked directory entries, and two operating system tracks. The DISKS macro generates n Disk Parameter Headers (DPH's), starting at the DPH table address DPBASE generated by the macro. Each disk header block contains sixteen bytes, as described above, and correspond one-for-one to each of the defined drives. In the four drive standard system, for example, the DISKS macro generates a table of the form: DPBASE DPE0 : DPEl: DPE2 : DPE3 : EQU DW DW DW DW $ XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV0,ALV0 XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSVl,ALVl XL'N} ,00 00H, 00 00H, 00 00H ,DIRBUF ,DPB0 , CSV2, ALV2 XLT0,0000H,0000H,0000H,DIRBUF,DPB0,CSV3,ALV3 where the DPH labels are included for reference purposes to show the beginning table addresses for each drive 0 through 3. The values contained within the disk parameter header are described in detail in the previous section. The check and allocation vector addresses are generated by the ENDEF macro in the ram area following the BIOS code and tables. Note that if the "skf" (skew factor) parameter is omitted (or equal to 0), the translation table is omitted, and a 0000H value is inserted in the XLT position of the disk parameter header for the disk. In a subsequent call to perform the logical to physical translation, SECTRAN receives a translation table address of DE = 0000H, and simply returns the original logical sector from BC in the HL r eg i s t e r p air. A t ran s 1 ate tab 1 e i s con s t r u c ted when the s-k f parameter is present, and the (non-zero) table address is placed into the corresponding DPH's. The table shown below, for example, is· constructed when the standard skew factor skf = 6 is specified in the DISKDEF macro call: XLT0: DB DB 1,7,13,19,25,5,11,17,23,3,9,15,21 2,8,14,20,26,6,12,18,24,4,10,16,22 Following the ENDEF macro call, a number of uninitialized data areas are defined. These data areas need not be a part of the BIOS which is loaded upon cold start, but must be available between the BIOS and the end of memory. The size of the un initialized RAM area is determined by EQU statements generated by the ENDEF macro. For a standard four-drive system, the ENDEF macro might produce (All Information Contained Herein is Proprietary to Digital Research.) 32 BEGDAT EQU $ (da ta areas) ENDDA'I' EQU $ DATSIZ EQU $-BEGDAT 4C72 = 4DB0 = 013C = which indicates that uninitialized RAM begins at location 4C72H, ends at 4DB0H-l, and occupies 013CH bytes. You must ensure that these addresses are free for use after the system is loaded. After modification, you can use the STAT program to check your drive characteristics, since STAT uses the disk parameter block to decode the drive information. The STAT command form STAT d:DSK: decodes the disk parameter block for drive d (d=A, ••• ,P) and the values shown below: r: k: d: c: e: b: s: t: 128 Byte Kilobyte 32 Byte Checked Records/ Records/ Sectors/ Reserved displays Record Capacity Drive Capacity Directory Entries Directory Entries Extent Block Track Tracks Three examples of DISKDEF macro invocations are corresponding STAT parameter values (the last 8-megabyte system). shown below produces a with full DISKDEF 0,1,58,,2048,256,128,128,2 r=4096, k=512, d=128, c=128~ e=256, b=16, s=58, t=2 DISKDEF 0,1,58,,2048,1024,300,0,2 r=16384, k=2048, d=300, c=0, e=128, b=16, s=58, t=2 DISKDEF 0,1,58,r16384,512,128,128,2 r=65536, k=8192, d=128, c=128, e=1024, b=128, s=58, t=2 (All Information Contained Herein is Proprietary to Digital Research.) 33 • 12. SECTOR BLOCKING AND DEBLOCKING. Upon each call to the BIOS WRITE entry point, the CP/M BDOS includes information which allows effective sector blocking and deblocking where the host disk subsystem has a sector size which is a multiple of the basic 128-byte unit. The purpose here is to present a general-purpose algorithm which can be included within your BIOS which uses the BDOS information to perform the operations automatically. Upon each call to WRITE, information in register C: o 1 2 = = = the BDOS provides the following normal sector write write to directory sector write to the first sector of a new data block Condition 0 occurs whenever the next write operation is into a previously written area, such as a random mode record update, when the write is to other than the first sector of an unallocated block, or when the write is not into the directory area. Condition 1 occurs when a write into the directory area is performed. Condition 2 occurs when the first record (only) of a newly allocated data block is written. In most cases, application programs read or write multiple 128 byte sectors in sequence, and thus there is little overhead involved in either operation when blocking and deblocking records since pre-read operations can be avoided when writing records. Appendix G lists the blocking and deblocking algorithms in skeletal form (this file is included on your CP/M disk). Generally, the algorithms map all CP/M sector read operations onto the host disk through an intermediate buffer which is the size of the host disk sector. Throughout the program, values and variables which relate to the CP/M sector involved in a seek operation are prefixed by "sek," while those related to the host disk system are prefixed by "hst." The equate statements beginning on line 29 of Appendix G define the mapping between CP/M and the hos t system, and mu s t be changed if other than the sample host system is involved. The entry points BOOT and WBOOT must contain the initialization code starting on line 57, while the SELDSK entry point must be augmented by the code starting on line 65. Note that although the SELDSK entry point computes and returns the Disk Parameter Header address, it does not physically selected the host disk·at this point (it is selected later at READHST or WRITEHST). Further, SETTRK, SETTRK, and SETDMA simply store the values, but do not take any other action at this point. SECTRAN performs a trivial trivial function of returning the physical sector number. The principal entry points are READ and WRITE, starting on lines 110 and 125, respectively. These subroutines take the place of your previous READ and WRITE operations. The actual physical read or write takes place at either WRITEHST or READHST, where all values have been prepared: hstdsk is the host (All Information Contained Herein is Proprietary to Digital Research.) 34 disk number, hsttrk is the host track number, and hstsec is the host sector number (which may require translation to a physical sector number) • You must insert code at this point which performs the full host sector read or write into, or out of, the buffer at hstbuf of length hstsiz. All other mapping functions are performed by the algorithms. This particular algorithm was tested using an 80 megabyte hard disk unit which was originally configured for 128 byte sectors, producing approximately 35 megabytes of formatted storage. \r\lhen configured for 512 byte host sectors, usable storage increased to 57 megabytes, with a corresponding 400% improvement in overall response. In this situation, there is no apparent overhead involved in deblocking sectors, with the advantage that user programs still maintain the (less memory consuming) 128-byte sectors. This is primarily due, of course, to the information provided by the BDOS which eliminates the necessity for pre-read operations to take place • • (All Information Contained Herein is Proprietary to Digital 35 Re~earch.) APPENDIX A: THE MDS COLD START LOADER MDS-800 Cold Start Loader for CP/M 2.0 Version 2.0 August, 1979 0000 ffff 0000 = = = false egu true egu testing egu bias 0000 = bias 0000 0806 1880 1600 1603 = = = = = cpmb bdos bdose boot rboot 3000 1880 13002 0031 0019 0018 f800 ff0f 0078 0079 007b 007f 0078 0079 007a 00ff 0003 0004 0100 = = = = = = = = = = = = = = = = = = if egu endif if egu endif egu egu egu egu egu o not false false testing 03400h not testing 0000h bias 806h+bias 1880h+bias 1600h+bias boot+3 ;base of dos load ;entry to dos for calls ;end of dos load ;cold start entry point ;warm start entry point ;loaded here by hardware ., org 3000h bdosl ntrks bdoss bdos0 bdosl Gil egu egu egu egu eou bdose-cpmb mon8e! rmon80 base rtype rbyte reset egu egu egu egu egu egu 0f800h 0ff0fh 078h base+l base+3 base+7 ;intel monitor base irestart location for mon80 i 'base' used by controller iresult type ;result byte ireset controller dstat ilow ihigh bsw recal readf stack egu egu egu egu egu egu egu base base+l base+2 0ffh 3h 4h 100h idisk status port ilow iopb address ;high iopb address iboot switch ;recalibrate selected drive idisk read function ;use end of boot for stack ., 2 bdosl/128 25 bdoss-bdos0 ; tracks to read ;# sectors in bdos ;# on track 0 i# on track 1 rstart: 3000 310001 3003 db79 3005 db7b 30137 dbff 1~~6 e~~130 lxi sp,stackiin case of call to mon80 clear disk status in rtype in rbyte check if boot switch is off coldstart: in bsw ani 02b d t t·switch on? coT s ar Jnz 36 clear the controller out reset ilogic cleared 300e d37f 3010 0602 3012 214230 mvi 'lxi b,ntrks inumber of tracks to read h, iopb0 start: j~t¥ ~~~g30 read first/next track into cpmb mov a,l out ilow mov a,h ou t ihigh in dstat ani 4 Jz wai to 3022 db79 3024 e603 3026 fe02 check disk status in rtype ani lIb cpi 2 3015 3016 3018 3019 30lb 7d d379 7c d37a db78 wai to: i 3028 d20030 302b db7b 302d 302e 3031 3032 17 dc0fff If e6le 3034 c20030 if cnc endif if jnc endif testing rmon80 igo to monitor if 11 or 10 not testing rstart iretry the load in rbyte ii/o complete, check status if not ready, then go to mon80 ral cc rmon80 inot ready bit set rar irestore ani lll10b ioverrun/addr err/seek/crc if cnz endif if jnz endif testing rmon80 igo to monitor ,not testing rstart iretry the load 3037'110700 303a 19 303b 05 303c c2l530 lxi dad dcr jnz 303f c300l6 jmp boot, print message, set-up jmps jmp boot d,iopbl ilength of iopb d iaddressing next iopb b icount down tracks start parameter blocks 37 • 3042 3043 3044 3045 3046 3047 0007 80 04 19 00 02 0000 iopb0: = iopbl 3049 304a 304b 304c 304d 304e 3050 80 04 18 01 01 800c iopbl: db db db db db dw egu 80h readf bdos0 11 2 cpmb $-iopb0 i iocw, no update i read function i# sectors to read trk db db db db db c1w end 80h readf bdosl isectors to read on track 1 1 itrack 1 1 isector 1 cpmb+bdos0*128 ibase of second rd " itrack 0 istart with sector 2, trk 0 istart at base of bdos i 38 APPENDIX B: THE MDS BASIC I/O SYSTEM (BIOS) mds-800 i/o drivers for cp/m 2.0 (four drive single density version) version 2.0 august, 1979 0014 = vers equ 20 ;version 2.0 copyright (c) 1979 digital research box 579, pacific grove california, 93950 4a00 3400 = 3c06 = 1600 = 002c = 0002 = 0004 = 0080 = 000a = cpmb bdos cpml nsects offset cdisk buff retry org equ egu equ equ equ equ equ equ 4a00h ;base of bios in 20k system 3400h ;base of cpm ccp 3c06h ;base of bdos in 20k system $-cpmb ;length (in bytes) of cpm system cpml/128;number of sectors to load 2 ;number of disk tracks used by cp 0004h ;address of last logged disk 0080h ;default buffer address 10 ;max retries on disk i/o before e perform following functions boot cold start wboot warm start (save i/o byte) (boot and wboot are the same for mds) const console status reg-a = 00 if no character ready reg-a = ff if character ready conin console character in (result in reg-a) conout console character out (char in reg-c) list list out (char in reg-c) punch punch out (char in reg-c) reader paper tape reader in (result to reg-a) move to track 00 horne (the following calls set-up the io parameter bloc mds, which is used to perform subsequent reads an seldsk select disk given by reg-c (0,1,2 ••• ) settrk set track address (0, ••• 76) for sub r/w setsec set sector address (1, ••• ,26) setdma set subsequent dma address (initially 80h read/write assume previous calls to set i/o parms read read track/sector to preset dma address write write track/sector from preset dma addres 4a00 4a03 4a06 4arii9 4a0c jump vector for indiviual routines jmp boot c3b34a c3c34a wboote: jmp wboot c36l4b jmp const jmp conin c3644b jmp conout c36a4b 39 • 4a0f 4a12 4a15 4a18 4alb 4ale 4a2l 4a24 4a27 4a2a 4a2d 4a30 c36d4b c3724b c3754b c3784b c37d4b c3a74b c3ac4b c3bb4b c3c14b c3ca4b c3704b c3b14b 4a33+= 4a33+824a00 4a37+000000 4a3b+6e4c73 4a3f+0d4dee 4a43+824a00 4a47+000000 4a4b+6e4c73 4a4f+3c4dld 4a53+824a00 4a57+000000 4a5b+6e4c73 4a5f+6b4d4c 4a63+824a00 4a67+000000 4a6b+6e4c73 4a6f+9a4d7b 4a73+= 4a73+la00 4a75+03 4a76+07 4a77+00 4a78+f200 4a7a+3f00 4a7c+c0 4a7d+00 4a7e+1000 4a80+0200 4a82+= 4a82+0l 4a83+07 4a84+0d 4a85+l3 4a86+l9 4a87+05 4a88+0b 4a89+ll 4a8a+17 4a8b+03 dpbase dpe0: dpel: dpe2: dpe3 : dpb0 xlt0 jmp jmp jmp jmp jmp jmp jml? jmp jmp jmp jmp jmp list punch reader home seldsk settrk setsec setdma read write listst ;list status sectran maclib disks egu dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw dw diskdef equ dw db db db dw dw db db dw dw egu db db db db , db db db db db db diskdef ;load the disk definition library 4 ;four disks $ ;base of disk parameter blocks xlt0,0000h ;translate table 0000h,0000h ;scratch area dirbuf,dpb0 ;dir buff,parm block csv0,alv0 ;check, alloc vectors xltl,0000h ;translate table 0000h,0000h ;scratch area dirbuf,dl?bl ;dir buff,parm block csvl,alvl ;check, alloc vectors xlt2,0000h ;translate table 0000h,0000h ;scratch area dirbuf,dpb2 idir buff,parm block csv2,alv2 ;check, alloc vectors xlt3,0000h ;translat€ table 0000h,0000h ;scratch area dirbuf,dpb3 ;dir buff,parm block csv3,alv3 ;cheek, alloe vectors 0,1,26,6,1024,243,64,64,offset $ ; di s k parm block 26 ;sec per track 3 iblock shift 7 ;block mask o iextnt mask 242 ;disk size-l 63 ;directory max 192 ;alloe0 o ;allocl 16 icheck size 2 ;offset $ itranslate table 1 7 13 19 25 5 11 17 23 3 40 4a8c+09 4aSd+0f 4aSe+15 4aSf+02 4a90+08 4a91+0e 4a92+14 4a93+1a 4a94+06 4a95+0c 4a96+12 4a97+1S 4a9S+04 4a99+0a 4a9a+110 4a9b+16 4a73+= 001f+= 0010+= 4aS 2+= dpbl alsl cssl xltl 4a73+= 001f+= 00HJ+= 4aS2+= dpb2 als2 css2 xlt2 4a73+= 001f+= 001121+= 4aS2+= dpb3 als3 css3 xlt3 db 9 db 15 db 21 db 2 db 8 db 14 db 20 db 26 db 6 db 12 db IS db 24 db 4 db 10 db 16 db 22 diskdef 1,10 equ dpb0 equ als0 equ css0 xlt0 equ diskdef 2,0 equ dpb0 equ als0 equ css0 equ xlt0 diskdef 3,0 dpb0 equ equ als0 equ , css0 equ xlt0 endef occur s at iequivalent parameters isame allocation vector size isame checksum vector size i same translate table iequivalent parameters isame allocation vector size isame checksum vector size i same translate table ieguivalent parameters isame allocation vector size isame checksum vector size isame translate table end of assembly end of controller - independent code, the remaini are tailored to the particular oper.ating environm be altered for any system which differs from the the following code assumes the mds monitor exists and uses the i/o subroutines within the monitor ., 00fd 00fc 00f3 007e = = = = revrt intc icon inte fS00 ff0f fS03 fS06 fS09 fS0c fS0f fS12 = = = = = = = = monS0 rmonS0 ci ri co po ., 10 csts we also equ equ equ equ assume the mds system has four disk drive 0fdh iinterrupt revert port 0fch iinterrupt mask port 0f3h iinterrupt control port 0111$1110bienable rst o (warm boot) ,rst 7 mds monitor equates equ 0f800h ;mds monitor equ 0ff0fh irestart monS0 (boot error) equ 0fS03h ;console character to reg-a equ 0fS06h ireader in to reg-a 0fS09h ;console char from c to console 0 equ equ 0fS0ch ;punch char from c to punch devic 0fS0fh ilist from c to list device equ 0fS12h ;console status 00/ff to register equ 41 • disk ports and commands . ;base of disk command io ports equ 78h ;disk status (input) equ base equ base+l ;result type (input) equ base+3 ;result byte (input) 101078 = 101078 = 101079 = IOf07b = base dstat rtype rbyte = = ilow ihigh equ equ base+l base+2 ;iopb low address (output) ;iopb high address (output) 1010104 = 1010106 = 00103 = 1010104 = f00fOd = fOfOfOa = readf writf recal iordy cr If equ equ equ egu equ equ 4h 6h 3h 4h 0dh 0ah ;read function ;write function ;recalibrate drive ;i/o finished mask ;carriage return ;line feed 4a9c 4a9f 4aal 4aad 4ab0 s ignon: ; s ignon db db db db db 101079 fOI07a 0dfOa0a 32310 6b20.43f 32 2e3 0 fOd0af00 ; ., boot: 4ab3 4ab6 4ab9 4abc 4abd 4acfO 31010101 219c4a cdd34b af 3204100 c30f4b message: xxk cp/m vers y.y cr,lf,lf 120 1 ;sample memory size Ik cp/m vers I vers/lfO+lfO l , 1 . 1 ,vers mod 10+ 110 1 cr,lf,0 ;print signon message and go to ccp (note: mds boot initialized iobyte at 0003h) lxi sp,buff+80h lxi h,signon call prmsg ;print message xra a fclear accumulator cdisk ;set initially to disk a sta jmp gocpm ;go to cp/m wboot:; loader on track 0, sector 1, which will be skippe read cp/m from disk - assuming there is a 128 byt star t. 4ac3 31810100 lxi sp,buff ;using dma - thus 810 thru ff ok f 4ac6 0e0a 4ac8 c5 mvi c,retry ;max retries push b wboot0: ;enter here on error retries 4ac9 01101034 lxi b,cpmb ;set dma address to start of disk 4acc cdbb4b call setdma 4acf 0efOIO q1vi c,0 ;boot from drive 10 4adl cd7d4b call seldsk 4ad4 0e00 mvi c,1O 4ad6 cda74b call settrk ;start with track 10 4ad9 0elO2 mvi c,2 ;start reading sector 2 4adb cdac4b call setsec 4ade cl 4adf 062c read sectors, count nsects to zero pop b ;10-error count mvi b,nsects 42 rdsec: 4ael 4ae2 4ae5 4ae8 4aeb 4aee 4aef 4af0 4afl 4af4 4af7 4af9 c5 cdc14b c2494b 2a6c4c 118000 19 44 4d cdbb4b 3a6b4c fela da054b 4afc 4aff 4b00 4b01 4b04 4b05 4b06 4b07 '4b0a 4 b0 b 4b0c 3a6a4c 3c 4f cda74b af 3c rdl: 4f cdac4b cl 05 c2e14a gocpm: 4b0f 4b10 4b12 4b14 4b15 4b17 4b19 4blb 4blc f3 3e12 d3fd af d3fc 3e7e d3fc af 03f3 4ble 018000 4b21 cdbb4b 4b24 4b26 4b29 4b2c 4b2f 4b32 4b35 4b38 4b3b 4b3e 3ec3 320000 21034a 220100 320500 21063c 220600 323800 2100f8 223900 iread next sector push b isave sector count call read jnz booterr iretry if errors occur Ihld iod ;increment dma address lxi d,128 isector size dad d iincremented dma address in hI mov b,h c,l mov iready for call to set dma setdma call Ida ios isector number just read cpi 26 iread last sector? jc rdl must be sector 26, zero and go to next track Ida iot iget track to register a inr a mov c,a iready for" call call settrk xra a iclear sector number inr a ito next sector mov c,a iready for call call setsec pop b irecall sector count dcr b i done? jnz rdsec done with the load, reset default buffer address i (enter here from cold start boot) enable rst0 and rst7 di mvi a ,12h iinitialize command out revrt xra a out intc icleared mvi a,inte irst0 and rst7 bits on out intc xra a icon ;interrupt control out set default buffer address to 80h lxi b,buff call setdma reset monitor entry points mvi a, j mp sta 0 lxi h,wboote shld 1 ijmp wboot at location 00 sta 5 lxi h,bdos shld 6 ijmp bdos at location 5 sta 7*8 ijmp to mon80 (may have been chan lxi h,mon80 shld 7*8+1 leave iobyte set 43 • 4b4l 4b44 4b45 4b46 3a04flfl 4f fb c30034 ·, previously selected disk was b, send parameter to Ida cdisk :last logged disk number mov c,a :send to ccp to log it in ei jmp cpmb : error condition occurred, print message and retry booterr: 4b49 cl 4b4a 0d 4b4b ca524b pop b :recall counts dcr c jz booterfl try again push b jmp wboot0 4b4e c5 4b4f c3c94a booter0: 4b52 2l5b4b 4b55 cdd34b 4b58 c30fff ·, otherwise too many retries lxi h,bootmsg call prmsg jmp rmon80 :mds hardware monitor bootrnsg: 4bSb 3f626f4 db : '?boot',0 const: :console status to reg-a (exactly the same as mds call) jmp csts conin: :console character to reg-a call ci ani 7fh :remove parity bit. ret 4b6l c3l2f8 4b64 cd03f8 4b67 e67f 4b69 c9 ; conout: ;console character from c to console out 4b6a c309f8 jmp co ·, list: 4b6d c30ff8 ;list device out (exactly the same as mds call) jmp 10 ; listst: ;return list status xra a ret :always not ready 4b70 af 4b7l c9 ; punch: 4b72 c30cf8 ·, ;punch device out (exactly the same as mds call) jmp po reader: ;reader character in to reg-a (exactly the same as mds call) 4b75 c306f8 jmp ri ; horne: ;move to horne position 44 ; 4b78 0e00 4b7a c3a74b treat as track 00 seek mvi c,0 jmp settrk ; se1dsk: ;se1ect 4b7d 210000 1xi 4b80 79 mov 4b81 fe04 cpi 4b83 d0 rnc disk given by register c h,0000h ireturn 0000 if error a,c ndisks itoo large? ;leave hI = 0000 4b84 4b86 4b89 4b8a 4b8c 4b8d 4b90 10b i00 00 for drive 0,1 and 10 10 fo dbank ito select drive bank arC i00, 01, 10, 11 1b imds has 0,1 at 78, 2,3 at 88 a iresu1t 00? setd rive a,00110000b ;se1ects drive 1 iri bank e602 32664c 79 e601 b7 ca924b 3e30 ani sta mov ani ora jz mvi setdrive: 4b92 47 mov 4b93 21684c 1xi 4b96 7e mov 4b97 e6cf ani 4b99 b0 ora 4b9a 77 mov mov ~B~8 ~~00 mvl. 4bge 29 dad 4b9f 29 dad 4ba0 29 dad dad 4ba1 29 1xi 4ba2 11334a 4ba5 19 dad ret 4ba6 c9 b,a isave the function h,iof iio function a,m 11001111b ;mask out disk number b ;mask in new disk number m,a ;save it in iopb ~~~ ;h1=disk number i*2 ;*4 ;*8 ;*16 h h h h d,dpbase d ;h1=disk header table address ., 4ba7 216a4c 4baa 71 4bab c9 settrk: ;set track address given by c 1xi h,iot mov m,c ret setsec: ;set sector number given by c 1xi h,ios mov m,c ret sectran: ;trans1ate sector bc using table at de 4bb1 0600 mvi b,0 idoub1e precision sector number i 4bb3 eb xchg itrans1ate table address to hI 4bb4 09 b dad ;trans1ate(sector) address 4bb5 7e mov a,m itrans1ated sector number to a 4bb6 326b4c sta ios 1,a i return sector number in 1 mo~ ~gg~ re 4bac 216b4c 4baf 71 4bb0 c9 gg ., setdma: ;set dma address given by regs b,c 45 4bbb 4bbc 4bbd 4bc0 mov mov shld ret 69 6r.1 226c4c c9 l,c h,b iod ; read: 4bcl 4bc3 4bc6 4bc9 r.1er.14 cde04b cdfr.14b c9 ; read next disk mvi c,readf setfunc call waitio call ret record (assuming disk/trk/sec/dma ;set to read function ;perform read function ;may have error set in reg-a ; write: 4bca 4bcc 4bcf 4bd2 r.1er.16 cder.14b cdfr.14b c9 prmsg: 4bd3 7e 4bd4 b7 4bd5 c8 4bd6 4bd7 4bd8 4bdb 4bdc 4bdd e5 4f cd6a4b el 23 c3d34b ;disk write function mvi c,writf call setfunc :set to write function waitio call ret ;may have error set utility subroutines :print message at h,l to 0 mov a,m ora a : zero? rz more to print push h mov c,a call conout pop h inx h jmp prmsg : setfunc: 4ber.1 4be3 4be4 4be6 4be7 21684c 7e e6f8 bl 77 4be8 4bea 4bed 4bee 4bef e620 216b4c b6 77 c9 set function for next i/o (command in reg-c) lxi h,iof :io function address mov a,m :get it to accumulator for maskin 11111000b :remove previous command ani ora :set to new command c mov m,a ;replaced in iopb the mds-800 controller req's disk bank bit in sec mask the bit from the current i/o function ani 00100000b :mask the disk select bit lxi h,ios ;address the sector selec ora m :select proper disk bank mov m,a ;set disk select bit on/o ret ; waitio: 4bf0 0e0a mvi c,retry :max retries before perm error rewai t: 4bf2 cd3f4c 4bf5 cd4c4c start the i/o function and wait for completion call intype :in rtype call inbyte :clears the controller 4bf8 3a664c Ida dbank ;set bank flags 46 4bfb 4bfc 4bfe 4c00 4c03 4c05 4c06 4c08 b7 3e67 064c c20b4c d379 78 d37a c3H'4c ·, iodrl: 4c0b d389 4c0d 78 4c0e d38a ora mvi mvi jnz 'out mov out jmp ;zero if drive 0,1 and nz a a,iopb and 0ffh ; low address for iopb b, iopb shr 8 ; high address for iopb iodrl ;drive bank I? ilow ;low address to controlle a,b ihigh ; high address wait0 ito wait for complete ; dr ive bank 1 out ilow+10h mov a,b ihigh+10h out ;88 for drive bank 10 ; 4c10 cd594c wai to: 4c13 e604 4c15 ca104c call ani jz instat iordy wait0 ;wait for completion ;ready? 4clb fe02 4cld ca324c check io completion ok call intype ;must be io complete (00) 00 unlinked i/o complete, 01 linked i/o comple 10 disk status changed 11 (not used) cpi 10b ;ready status change? jz wready 4c20 b7 4c21 c2384c must be 00 in the accumulator ora a ;some other condition, re jnz werror 4c24 4c27 4c28 4c2b 4c2c 4c2e check i/o error bits . inbyte call ral jc wready rar 11111110b ani jnz werror 4c18 cd3f4c cd4c4c 17 da324c If e6fe c2384c 4c31 c9 ·, ;unit not ready ;any other errors? read or write is ok, accumulator contains zero ret wready: ;not ready, treat as error for now 4c32 cd4c4c call inbyte ;clear result byte 4c35 c3384c jmp trycount werror: ;return hardware malfunction (crc, track, seek, e the mds controller has returned a bit in each pos of the accumulator, corresponding to the conditio o - deleted data (accepted as ok above) ; , 1 - crc error 2 - seek error 3 - address error (hardware malfunction) 4 - data over/under flow (hardware malfunct 5 - write protect (treated as not ready) 6 - write error (hardware malfunction) I 7 - not ready ; · · 47 (accumulator bits are numbered 7 6 5 4 3 2 1 0) it may be useful to filter out the various condit but we will get a permanent error message if it i recoverable. in any case, the not ready conditio treated as a separate condition for later improve trycount: register c contains retry count, decrement 'til z 4c38 0d dcr c jnz rewait ;for another try 4c39 c2f24b cannot recover from error mvi a,l ;error code ret 4c3c 3e01 4c3e c9 4c3f 4c42 4c43 4c46 4c48 4c49 4c4b intype, 3a664c intype: Ida b7 ora c2494c jnz db79 in c9 ret db89 intypl: in c9 ret inbyte, instat read drive bank 00 or 10 dbank a intypl ;skip to bank 10 r type 4c4c 4c4f 4c50 4c53 4c55 4c56 4c58 3a664c inbyte: Ida ora b7 jnz c2564c in db7b c9 ret db8b inbytl: in c9 ret dbank a inbytl rbyte 4c59 4c5c 4c5d 4c60 4c62 4c63 4c65 3a664c instat: Ida b7 ora c2634c jnz db78 in c9 ret db88 instal: in c9 ret rtype+10h ;78 for 0,1 88 for 2,3 rbyte+10h ; ,. 4c66 00 dbank: iopb: 4c67 4c68 4c69 4c6a 4c6b 4c6c 80 04 01 02 01 8000 iof: ion: iot: ios: iod: dbank a instal dstat dstat+10h data areas (must be in ram) db ;disk bank 00 if drive 0,1 0 10 if drive 2,3 ;io parameter block db 80h ;normal i/o operation db readf ;io function, initial read db 1 ;number of sectors to read db offset ;track number db 1 ;sector number dw buff do address define ram areas for bdos operation 48 4c6e+= 4c6e+ 4cee+ 4d0d+ 4dld+ 4d3c+ 4d4c+ 4d6b+ 4d7b+ 4d9a+ 4daa+= 013c+= 4daa endef begdat equ di rbuf: ds ds al v0: ds csv0: ds alvl: ds csvl: ds alv2 : csv2: ds alv3: ds csv3: ds enddat equ da tsiz equ end $ 128 31 16 31 ~directory IE? 31 16 31 16 $ $-begdat 49 access buffer APPENDIX C: A SKELETAL CBIOS skeletal cbios for first level of cp/m 2.0 alter a 0014 = msize egu icp/m version memory size in kilo 20 "bias" is address offset from 3400h for memory sy than 16k (referred to as lib" throughout the text) 0000 3400 3c06 4a00 0004 0003 = = = = = = bias ccp bdos bios cdisk iobyte egu equ equ egu equ equ (msize-20) *1024 3400h+bias ibase of ccp ccp+806h ibase of bdos ccp+1600h ibase of bios 0004h ;current disk number 0=a, ••• ,15=p 0003h iintel i/o byte 4a00 002c = nsects org equ bios iorigin of this program ($-ccp)/128 iwarm start sector count 4a00 4a03 4a06 4a09 4a0c 4a0f 4a12 4alS 4a18 4alb 4ale 4a21 4a24 4a27 4a2a 4a2d 4a30 jump vector for individual subroutines c39c4a jmp boot icold start c3a64a wboote: jmp wboot iwarm start c3114b jmp const iconsole status c3244b jmp conin ;console character in c3374b jmp conout ;console character out c3494b jmp list ;list character out jmp c34d4b ;punch character out punch ;reader character out jmp reader c34f4b ;move head to home positi c3S44b jmp home jmp c3Sa4b seldsk ;select disk settrk ;set track number jmp c37d4b ;set sector number jmp c3924b setsec c3ad4b jmp setdma iset dma address c3c34b jmp read ;read disk c3d64b write ;write disk jmp c34b4b jmp listst ;return list status jmp c3a74b sectran ;sector translate fixed data tables for four-drive standard ibm-compatible 8" disks disk parameter header for disk 00 4a33 734a00 dpbase: dw trans,0000h 4a37 000000 dw 0000h,0000h 4a3b f04c8d dw dirbf,dpblk 4a3f ec4d70 dw chk00,al100 disk parameter header for disk 01 4a43 734a00 dw trans,0000h 4a47 000000 dw 0000h,0000h 4a4b f04c8d dw dirbf,dpblk 4a4f fc4d8f dw chk01,al101 disk parameter header for disk 02 4aS3 734a00 dw trans,0000h 4aS7 000000 dw 0000h,0000h 4aSb f04c8d dw dirbf,dpblk 4aSf 0c4eae dw chk02,al102 50 4a63 4a67 4a6b 4a6f disk parameter header for disk 03 dw trans,0000h 0000h,0000h dw dirbf,dpblk dw dw chk03,al103 734a00 000000 f04c8d lc4ecd i ~~11 4a7b 4a7f 4a83 4a87 4a8b ~9~~~g trans: 170309 150208 141a06 121804 1016 dpblk: 4a8d la00 4a8f 03 4a91O 07 4a91 00 4a92 f200 4a94 3f00 4a96 c0 4a97 1010 4a98 1000 4a9a 0200 sector translate vector gg db db db db db ~5:5~rl~17 23,3,9,15 21,2,8,14 20,26,6,12 18,24,4,10 16,22 isectors isectors isectors isectors isectors isectors isectors 5~g~1~~ 9,10,11,12 13,14,15,16 17,18,19,20 21,22,23,24 25,26 idisk parameter block, common to all disks dw 26 isectors per track db 3 iblock shift factor db 7 iblock mask (0 db inull mask dw 242 idisk size-l dw idirectory max 63 192 ialloc 0 db Ii) db ialloc 1 icheck size dw 16 itrack offset ow 2 end of fixed tables i boot: 4a9c 4a9d 4aa0 4aa3 af 320300 320400 c3ef4a i wboot: 4aa6 4aa9 4aab 4aae 318000 0e00 cd5a4b cd544b 4abl 062c 4ab3 0e00 4ab5 1602 4ab7 210034 10adl: 4aba 4abb 4abc 4abd 4abe 4acl c5 d5 e5 4a cd924b cl individual subroutines to perform each function isimplest case is to just perform parameter initi xra a izero in the accum sta iobvte iclear the iobyte sta cdisk iselect disk zero jmp gocpm iinitialize and go to cp/ isimplest case is to read the disk until all sect lxi sp,80h iuse space below buffer f mvi c,0 iselect disk Ii) call seldsk call home ;go to track 00 mvi b,nsects ib counts # of sectors to mvi c,0 iC has the current track mvi d,2 ;d has the next sector to note that we begin by reading track 0, sector 2 s ~ontains the cold start loader, which is skipped lxi h,ccp ibase of cp/m (initial 10 i load one more sector isave sector count, current track push b d isave next sector to read push h isave dma address push iget sector address to register c mov c,d call setsec iset sector address from register pop b irecall dma address to b,c 51 • 4ac2 c5 4ac3 cdad4b push call b setdma ;replace on stack for later recal ;set dma address from b,c 4ac6 cdc34b 4ac9 fe00 4acb c2a64a drive set to 10, track set, sector set, dma addres call read ;any errors? cpi 100h jnz wboot ;retry the entire boot if an erro 4ace 4acf 4ad2 4ad3 4ad4 4ad5 4ad6 el 1180100 19 dl cl 05 caef4a no error, move to next sector pop h ;recall dma address lxi d,128 ;dma=dma+128 dad d ;new dma address is in h,l pop d ;recall sector address pop b ;recall number of sectors remaini dcr b ;sectors=sectors-l gocpm ;transfer to cp/m if all have bee jz 4ad9 4ada 4adb 4add 14 7a felb daba4a more sectors remain to load, check for track chan inr d mov ;sector=27?, if so, change tracks a,d cpi 27 jc loadl ;carry generated if sector<27 4ae0 1601 4ae2 0c end of current track, go to next track mvi d,l ;begin with first sector of next inr c ;track=track+l 4ae3 4ae4 4ae5 4ae6 4ae9 4a,ea 4aeb 4aec save register state, and change tracks push b push d push h settrk ;track address set from register call pop h pop d pop b jmp loadl ;for another sector c5 d5 e5 cd7d4b el dl cl c3ba4a end of load operation, set parameters and go to c gocpm: 4aef 4afl 4af4 4af7 3ec3 32101000 21034a 220100 rnvi sta lxi shld a,0c3h ;c3 is a jmp instruction 10 ;for jmp to wboot h,wboote ;wboot entry point 1 ;set address field for jmp at 10 4afa 320500 4afd 21063c 4b00 220600 sta lxi shld 5 h,bdos 4b03 1018101010 4blO6 cdad4b lxi call b,8lOh setdma ;default dma address is 810h 4blO9 4b0a 4b0d 4b0e ei Ida mov jmp cdisk c,a ccp ;enable the interrupt system ;get current disk number ;send to the ccp ;go to cp/m for further processin fb 3alO401O 4f c3101034 6 52 ;for jmp to bdos ;bdos entry point ;address field of jump at 5 to bd i i ; ·, simple i/o handlers (must be filled in by user) in each case, the entry point is provided, with s to insert your own code const: iconsole status, return 0ffh if character ready, ds 10h ispace for status subroutine mvi a, 00h ret conin: iconsole character into register a ds 10h ispace for input routine ani 7fh istrip parity bit ret 4bll 4b21 3eliH' 4b23 c9 4b24 4b34 e67f 4b36 c9 i 4b37 79 4b38 4b48 c9 conout: iconsole character output from register c mov a,c iget to accumulator ds 10h ispace for output routine ret i list: 4b49 79 4b4a c9 4b4b af 4b4c c9 ·, ;list character from register c a,c ;character to register a mov ret inul1 subroutine listst: ;return list status (0 if not ready, I if ready) xra a ;0 is always ok to return ret ·, punch: 4b4d 79 4b4e c9 ;punch character from register Co mov a,c ;character to register a ret ;null subroutine ; 4b4f 3ela 4b51 e67f 4b53 c9 reader: ;read character into register a from reader devic mvi a,lah ;enter end of file for now (repla ani 7fh ;remember to strip parity bit ret ; , ·home: 4b54 0e00 4b56 cd7d4b 4b59 c9 4b5a 4b5d 4b5e 4b61 210000 79 32ef4c fe04 , ·seldsk: i/o drivers for the disk follow for now, we will simply store the parameters away in the read and write subroutines ;move to the track 00 position of current drive translate this call into a settrk call with param mvi c,0 ;select track 0 call settrk ret ;we will move to 00 on first read ;select lxi mov sta cpi disk given by register c h,0000h ;error return code a,c diskno 4 ;must be between 0 and 3 53 4b63 d0 rnc ino carry if 4,5, ... disk number is in the proper range ds 10 ispace for disk select compute proper disk parameter header address Ida diskno mov l,a il=disk number 0,1,2,3 mvi h,0 ihigh order zero dad h i*2 dad h i*4 dad h i *8 dad h i*16 (size of each header) lxi d,dpbase dad d ihl=.dpbase(diskno*16) ret 4b64 4b6e 4b71 4b72 4b74 4b75 4b76 4b77 4b78 4b7b 4b7c 3aef4c 6f 2600 29 29 29 29 11334a 19 c9 4b7d 79 4b7e 32e94c 4b81 4b91 c9 settrk: iset track given by register c mov a,c sta track ds 10h ispace for track select ret i setsec: iset sector given by register c mov 4b92 79 a,c 4b93 32eb4c sta sector 4b96 ds 10h ispace for sector select 4ba6 c9 ret sectran: 4ba7 4ba8 4ba9 4baa 4bac eb 09 6e 2600 c9 . itranslate the sector given by bc using the ; transla te table given by de xchg ;hl=.trans dad b ;hl=.trans(sector) mov I,m ;1 = trans(sector) mvi h,0 ;hl= trans(sector) ret iwith value in hI I setdma: ;set dma address given by registers band c 4bad 69 mov l,c ;low order address 4bae 60 h,b ;high order address mov 4baf 22ed4c shld dmaad isave the address 4bb2 ds 10h ;space for setting the dma add res 4bc2 c9 ret read: 4bc3 4bd3 c3e64b ;perform read operation {usually this is similar so we will allow space to set up read command, th common code in write) ds 10h ;set up read command jmp waitio ito perform the actual i/o i write: 4bd6 ;perform a write operation ds 10h iset up write commanu i waitio: ;enter here from read and write to perform the ac operation. return a 00h in register a if the ope properly, and 01h if an error occurs during the r 54 in this case, we have saved the disk number in 'd the track number in I track I (0-76 the sector number in I sector I (1the dma address in I dmaad I (II' -655 ds 256 ;space reserved for i/o drivers mvi a,l ;error condition ;replaced when filled-in ret 4be6 4ce6 3efill 4ce8 c9 the remainder of the cbios is reserved uninitiali data area, and does not need to be a part of the system memory image (the space must be available, however, between "begdat" and "enddat"). 4ce9 4ceb 4ced 4cef 2 track: sector: dmaad: diskno: ds ds ds ds 1 scratch equ ds ds ds ds ds ds ds ds ds ram area for bdos use $ ; beginning of data 128 ;scratch directory 31 ;allocation vector 31 ;allocation vector 31 ;allocation vector 31 ;a11ocation vector 16 ; check vector 0 16 ;check vector 1 ; check vector 2 16 ; check vector 3 16 equ equ end ;end of data area $ $-begdat; size of data area 4cf0 4cf0 4d70 4d8f 4dae 4dcd 4dec 4dfc 4e0c 4elc = begdat dirbf: al100 : al101: al102 : alHl3: chk00 : chk01: chk02: chk03: 4e2c 013c 4e2c = = enddat datsiz ;two bytes for expansion ;two bytes for expansion ;direct memory address ;disk number 0-15 2 2 area area 0 1 2 3 ; • 55 APPENDIX D: A SKELETAL GETSYS/PUTSYS PROGRAM combined getsys and putsys programs from Sec 4. Start the programs at the base of the TPA 0100 0014 = msize org 0100h equ 20 size of cp/m in Kbytes "bias" is the amount to add to addresses for > 20k (referred to as lib" throughout the text) 0000 3400 3c00 4a00 = = = = bias ccp bdos bios equ ,equ equ equ (msize-20)*1024 34013h+bias ccp+0800h ccp+1600h getsys programs tracks 0 and 1 to memory at 3880h + bias register a usage (scratch register) track count (0 ••• 76) sector count (1. •• 26) (scratch register pair) load address set to stack address b c d,e h,l sp gstart: 0100 318033 0103 218033 0106 13600 lxi lxi mvi sp,ccp-013813h h,ccp-01380h b,0 mvi c,l call 1xi dad inr mov cpi jc read$sec 0,128 rd$trk: 0108 13e01 start of getsys ; convenient p1ac set initial loa start with trac read next track each track star rd$sec: 0113a 010d 13110 0111 0112 13113 0115 cd131303 1181300 19 13c 79 fe1b da0a01 d c a,c 27 rdsec get the next se offset by one s (h1=h1+128) next sector fetch sector nu and see if la <, do one more arrive here at end of track, move to next track 13118 0119 011a 011c 04 78 fe02 da0801 inr mov cpi jc b a,b 2 rd$trk track check track <, do = track+l for last = 2 ? another arrive here at end of load, halt for lack of anything b 011f fb 0120 76 ei hIt 56 putsys program, places memory image starting at 3880h + bias back to tracks 0 and 1 start this program at the next page boundary 0200 org ($+0100h) and 0ff00h 1xi 1xi mvi sp,ccp-0080h h,ccp-0080h b,0 convenient p1ac start of dump start with trac mvi c,l start with sect call 1xi dad inr mov cpi jc write$sec d,128 write one secto length of each =
+ 128
= + 1 see if past end of t no, do another put$sys: 0200 318033 0203 218033 0206 0600 wr$trk: 0208 0e01 wr$sec: 020a 020d 0210 0211 0212 cd0004 118000 19 0c 79 ~213 fe1b 0215 da0a02 d c a,c 27 wr$sec arrive here at end of track, move to next track 0218 0219 021a 021c 04 78 fe02 da0802 inr mov cpi jc b a,b 2 wr$trk track = track+1 see if last track no, do another done with putsys, halt for lack of anything bette 021f fb 0220 76 ei hIt user supplied subroutines for sector read and write move to next page boundary 0300 org ($+0100h) and 0ff00h read$sec: read the next sector track in , sector in dmaaddr in 0300 c5 0301 e5 0302 0342 el 0343 c1 push push b h user defined read operation goes here ds 64 pop pop h b 57 0344 c9 ret 0400 org ($+0100h) and 0ff00h write$sec: . I 0400 c5 0401 e5 0402 0442 e1 0443 c1 0444 c9 same parameters as read$sec push push b h user defined write operation goes here ds 64 pop pop ret h b end of getsys!putsys program 0445 end 58 another page bo APPENDIX E: A SKELE'rAL COLD START LOADER this is a sample cold start loader which, when modified resides on track 00, sector 01 (the first sector on the diskette). we assume that the controller has loaded this sector into memory upon system start-up (this program can be keyed-in, or can exist in read/only memory beyond the address space of the cp/m version you are running). the cold start loader brings the cp/m system into memory at "10adp" (3400h + "bias"). in a 20k memory system, the value of "bias" is 0000h, with large values for increased memory sizes (see section 2). afte loading the cp/m system, the clod start loader branches to the "boot" entry point of the bios, which begins at "bios" + "bias." the cold start loader is not used until the system is powered u? again, as long as the bios is not overwritten. the origin is assumed at 0000h, an must be changed if the controller brings the cold start loader into another area, or if a read/only memory area is used. 0000 org 0 base of ram in cp/m liH1l4 = msize equ 20 min mem size in kbytes 0000 3400 4a00 0300 4a00 1900 0032 bias ccp bios biosl boot size sects egu equ egu egu egu egu equ (msize-20)*1024 3400h+bias ccp+1600h 0300h bios bios+biosl-ccp size/128 offset from 20k system base of the ccp base of the bios length of the bios = = = = = = = size of cp/m system # of sectors to load begin the load operation cold: lxi mvi lxi 0000 010200 0003 1632 0005 210034 Isect: ., b,2 d,sects h,ccp b=0, c=sector 2 d=# sectors to load base transfer address load the next sector insert inline code at this point to read one 128 byte sector from the track given in register b, sector given in register c, into the address given bybranch to location "cold" if a read error occurs 59 • ************************************************* * * user supplied read operation goes here ••• * ************************************************* 0008 c36b00 000b jmp ds past$patch 60h ., remove this when patche past$patch: ; go to next sector if load is incomplete 006b 15 dcr d ; sects=sects-l , head for the bios 006c ca004a jz boot . more sectors to load we aren't using a stack, so useas scratch registe to hold the load address increment 006f 318000 0072 39 lxi dad sp,128 sp 128 bytes per sector =+ 128 0073 0074 0075 0077 inr mov cpi jc c a,c 27 Isect sector = sector + 1 0c 79 felb da0800 last sector of track? no, go read another end of track, increment to next track 007a 0e01 007c 04 007d c30800 0080 mvi inr jmp end sector = 1 track = track + 1 for another group of boot loader c,l b Isect 60 APPENDIX F: CP/M DISK DEFINITION LIBRARY 1: 2: CP/M 2.0 disk re-definition library 3: ; 4: ; 5: 6: 7: Copyright (c) 1979 Digital R=bearch Box 579 Pacific Grove, CA 93950 8: 9: ; 110: 11: 12: 13: 14: 15 : 16: 17: 18: 19: 20: 21: ; ; ; ; ; ; 22: ; 23: ; 24: 25: 26: 27: 28: 29: ; 30: ; 31: 32: ; 33: 34: 35: 36: 37: 38: 39: 410: 41: ; ; ; ; ; ; CP/M logical disk drives are defined using the macros given below, where the sequence of calls is: disks n diskdef ?arameter-list-0 diskdef 9arameter-list-l diskdef parameter-list-n endef where n is the number of logical disk drives attached to the CP/M- system, and parameter-list-i defines the ,characteristics of the ith drive (i=0,1, ••. ,n-l) each parameter-list-i takes the form dn,£Qc,lsc, [skf] ,bls,dks,dir,cks,ofs, [0] where dn is the disk number Ii) ,1, ••• ,n-l fsc is tile first sector number (usually 0 or 1) lsc is ti1e last sector number on a track skf is ofjtional iiskew factor" for sector translate bls is tne data block size (1024,2048, ••• ,16384) dks is tnt:: disk size in bls increments (word) dir is tn€: number of directory elements (word) cks is th~ number of dir elements to checksum ofs is the number of tracks to skip (word) [0] is an opt.ional 0 which forces 16K/directory en for convenience, the form dn,dm defines disk dn as having the same characteristics as a previously defined disk dm. 42: ; 43: ; 44: ; 45: 46: 47: 48: 49: 50: 51: 52: 53: ; ; ; ; ; ; a standard four disks diskdef dsk set rept dsk set diskdef endm endei drive CP/M system is defined by 4 10,1,26,6,1024,243,64,64,2 o 3 dsk+1 %dsk,0 the value of "begdat" at the end of assembly defiries t 61 • 54: 55: 56: 57: 58: 59: 610: 61: 62: 63: 64: 65: 66: 67: 68: 69: ; ,. dskhdr macro dn define a single disk header list dpe&dn: dw xlt&dn,00100h. ;translate table dw 0000h,0000h ;scratch area dw dirbuf,dpb&dn ;dir buff,parm block dw csv&dn,alv&dn ;check, ailoc vectors endm ;; ; 70: disks 71: 72: 73: 74: ;; ndisks dpbase ; ; "15: dsknxt 76: 77: 78: 79: 80: 81: 82: a 3: 84: 85: 136: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101 : 102: dsknxt ., dpbhdr dpb&dn ,. ddb ; ; ; ; gcd ;; ;; ., ., gcdm gcdn gcdr 1103: 108: macro nd define nd disks ;;for later reference set nd ;base of disk parameter blocks equ $ generate the r~d elements set 0 rept nd dskhdr %dsknxt dsknxc+l set endm endm macro equ endm dn ;disk parm block $ macro da ta, cornmen t define a db statement db data endm comment ; ddw 104: gcdx 105: gcdr 1106: 1107: beginning of the uninitialize ram area above the bios, while the valve of "enddat" defines the next location followinq the end of the data area. the size of this area is ~iven by the value of "datsiz" at the end of t assembly. note that the allocation vector will be qui large if a large disk size is defined with a small blo size. macro da ta, commen t define a dw statement dw data endm comment macro m,n greatest common divisor of m,n produces value gcdn as result (used in sector translate table generation) set m ;;variable for m set n ;;variable for n set 0 ;;variable for r rept 65535 set gcdm/gcdn set gcdm - gcdx*gcdn if gcdr = 0 exitm endif 62 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128 : 129 : 1310: 131 : 132 : 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 1510: 151 : 152: 153 : 154: 155: 156: 157: 158: 159 : 160: 161: 162 : 163: gcdm gcdn set set endm endm gcdn gcdr : diskdef macro dn,fsc,lsc,skf,bls,dks,dir,cks,ofs,k16 ;; generate the set statements for later tables if nul lsc ;; current disk dn s~me as orevious fsc dpb&dn equ dpb&fsc ;8quivalent parameters als&dn equ als&fsc ;same allocation vector size css&dn equ css&fsc ;same checksum vector size xlt&dn equ xlt&fsc ;same translate table else secmax set lsc-{fsc) ;;sectors 0 •.• secmax sectors set secmax+l;;number of sectors als&dn set (dks)/8 ;;size of allocation vector if ({dks) mod 0) ne f2J als&dn set als&dn+l endif css&dn set (cks) /4 ; inumber of checksum elements generate the block shift value I I bls/128 ;;number of sectors/block blkval set blkshf set 0 ;;counts right 0's in blkval 0 ;;~ills with l's from right blkmsk set rept 16 ;i~nce for each bit position if blkval=l exitm endif ;; otherwise, high ord~r 1 not found yet blkshf set blkshf+l blkmsk set (blkmsk shl 1) or 1 blkval set blkval/2 endm ,, generate the extent mask byte blkval set bls/1024 iinumber of kilobytes/block extmsk set 0 iifill from right with l's rept 16 if blkval=l exitm endif otherwise more to shift ; ; extmsk set (extmsk shl 1) or 1 blkval set blkval/2 endm may be double byte ~llocation ;; if (dks) > 256 extmsk set (extmsk shr 1) endif ;; may be optional [0] in last position if not nul k16 extmsk set k16 endif now generate directory reservation bit vector ; ; set dir dirrem ii# remaining to process .. .. 63 • 164: dirbks 165: dirblk 166: 167: 168: 169: 170: ii 171 : 172 : 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: ; ; dirblk dirrem dirrem 190: ii 191: 192: xlt&dn 193: 194: 195: xlt&dn 196: 197: ii 198: 199: 200: 201 : 202: nxtsec nxtbas 203: 2104: ii ,. ,. neltst ;; 2105: nelts 206: xlt&dn 207: 208: 209: 210: 211 : 212 : 213: nxtsec 214: 215: nxtsec 216: 217: nelts 218: bls/32 ;;nuffiber of entries per block set set i;f111 with l's on each loop o rept 16 if dirrem=0 exitm endif not complete, iterate once again shift right and add 1 high order bit set (dirblk shr i) or 8000h if dirrem > dirbks set dirrem-di~bks else set endif endm dpbhdr dn ;;ge~erate equ $ ddw %sectors,<;sec per track> ddb %blkshf,ddb %blkmsk, ddb %extmsk, ddw %(dks)-l,<;oisk size-I> ddw %(dir)-l,<;airectory max> ddb %dirblk shr &,<;alloc0> ddb %dirblk ana 0ffh,<;allocl> ddw %(cks)/4~ ddw %ofs, generate the translate table, if requested if nul skf equ 0 ino xlate table else if skf = g ino xlate table equ o else generate the translate taole set (1 iiaext sector to fill set 0 iifficves by one on overflow gcd %sectors,skf gcdn = gcd(sectors,skew) set sectors/gcdn neltst is number of elements to generate before we overlap orevious elements set ne1tst iicounter equ $ itranslate table rept sectors i ionce for each sector if sectors < 256 ddb %nxtsec+(fsc) else ddw %nxtsec+(fsc) endif set nxtsec+(skf) if nxtsec >= sectors nxtsec-sectors set endif set nelts-l if nelts = 0 64 219 : 220: 221 : 222 : 223: 224: 225: 226: 227: 228: 229 : 230: 231 : 232 : 233: 234: 235: 236: 237: 238: 239: 240: 241: 242 : 243 : 244: 245: 246: 247: 248: 249: nxtbas nxtsec nelts set set set endif endm endif endif endm nxtbas+l nxtbas neltst macro as endm lab,space space macro aefds endm Ib,dn,val Ib&dn,%val&dn ;;end of nul fac test ;;end of nul bls test ; aefas lab: ·, Ids ·, ·, ., begdat endef macro generate the nec~ssary ram data areas egu $ ;directory access buffer dirbuf: ds 128 dsknxt set 0 rept ndisks ;;once for eacn disk Ids alv,%dsknxt,als Ids csv,%dsknxt,css dsknxt set dsknxt+l endm enddat egu $ $-begdat datsiz egu ;; db 0 at this point forces hex record endm • 65 APPENDIX G: 1: 2: 3: 4: 5: ;***************************************************** 1* ;* ;* Sector Deblocking Algorithms for CP/M 2.0 * * * ;***************************************************** 6: 7: ; 8: smask 9: ;; 10 : BLOCKING AND DEBLOCKING ALGORITHMS. ; ; 11 : @y 12 : @x 13: ;; 14: 15 : 16: 17: ·. 18: , , 19: @y 20: @x 21: 22 : utility macro to compute sector mask macro hblk compute log2(hblk), return @x as result (2 ** @x = hblk on return) set hblk set 0 count right shifts of @y until = 1 rept 8 if @y = 1 exi tm endif. @y is not 1, shift right one position . set @y shr 1 set @x + 1 endm endm 23: ; . 24: ,.***************************************************** , 25: · * '* 26 : ,· * CP/M to host disk constants * 27: ,· * * . 28: ,.***************************************************** 29: blksiz equ 2048 ;CP/M allocation size 30: hstsiz equ 512 ;host disk sector size 31 : hstspt equ 20 ;host disk sectors/trk 32: hstblk equ hstsiz/128 ;CP/M sects/host buff 33: cpmspt equ hstblk * hstspt ;CP/Msectors/track 34: secmsk equ hstblk-l ;sector mask hstblk ;compute sector mask 35: smask ;log2(hstblk) 36: secshf equ @x 37: 38: 39: 40: 41: 42: 43: 44: ; ,.***************************************************** * ,.* ,.* BOOS constants on entry to write * ,.* * ,.***************************************************** o wrall wrdir 45 : wrual equ equ equ 46: 47: 48: 49: 50: 51: 52: 53: The BOOS entry points given below show the code which is re-levant to deblocking only. ;write to allocated ;write to directory ;write to unallocated 1 2 , ·;***************************************************** ,.* ;* ;* ,.* * * * * ,.***************************************************** 66 54: 55: 56: 57: 58: 59: 60: 61 : 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: HHJ: 101: 102: 103: ·, ·, boot: dpbase DISKDEF macro, or hand coded tables go here egu ;disk param block base $ wboot: :enter here on system boot to initialize xra a ; 0 to accumulator sta hstact ;host buffer inactive sta unacnt ;clear unalloc count ret ; seldsk: ·, set trk: :select mov sta mov mvi rept dad endm lxi dad ret disk a,c sekdsk l,a h,0 :selected disk number ;seek disk number :disk number to HL 4 :multiply by 16 h d,dpbase d ;base of parm block ;hl=.dpb(curdsk) ;set track given by registers Be mov h,b mov l,c shld sektrk itrack to seek ret setsec: ·, ;set sector given by register c mov a,c :sector to seek sta seksec ret setdma: ·, iset dma address given by mov h,b mov l,c shld dmaadr ret sectran: ;translate sector number mov h,b mov l,c ret 67 Be Be • lrl14: .***************************************************** I 1 rlI 5: .* I lrl1 6: ·I * lrl17: . * I The READ entry point takes the place of the previous BIOS defintion for READ • * 1 rlI8: .* I * 1 rlI9: .***************************************************** I llrl1 : read: Ill: 112: 113: 114: 115: 116: 1read the selected CP/M sector mvi a,l readop sta 1read operation rsflag sta 1must read data mvi ·a ,wrual sta wrtype 1treat as unalloc jmp rwoper 1to perform the read 117: 118: I 119 : I.***************************************************** · 12rl1 : 121: 122: 123: 124: 125: 126: 127: .* I .* I ·.** I I * * * * .***************************************************** I write: 128: 129 : 13rl1: 131: 132: 133: 1 134: 135: 136: 137 : 138: 139: 140 : 141: 142: The WRITE entry point takes the place of the previous BIOS defintion for WRITE. · 1write the selected CP/M sector xra 1rl1 to accumulator a readop 1not a read operation sta rnov a,c 1write type in c sta wrtype cpi wrual 1write unallocated? jnz chkuna 1check for unalloc write to unallocated, set parameters mvi a,blksiz/128 1next unalloc recs st.a unacnt Ida sekdsk 1disk to seek sta unadsk 1unadsk = sekdsk Ihld sektrk shld unatrk 1unatrk = sectrk Ida seksec sta unasec 1unasec = seksec 143: I 144: chkuna: 145: 1check for write to unallocated sector 146: Ida unacnt 1any unalloc remain? 147: ora a 148: jz alloc 1skip if not 149: 15rl1: 1 151: 152: 153: 154: 155: 156: 157: 1 158: 1 more unallocated records remain dcr a ;unacnt = unacnt-l sta unacnt Ida sekdsk ;same disk? lxi h,unadsk cmp m 1sekdsk = unadsk? jnz alloc ;skip if not disks are the same 68 159: 1610: 161: 162 : 163: 164 : 155: 166: 167: 168: 169: 1710: 171: 172: 173: 174: 175: 176: 177: 178: 179: 1810: 181: 182: 183: 184: 185: 186: 187: 188: 189: 1910: 191: 192: 193: 194: 195: 196: 197: 198: 199: 21010: 2101: 202: 20~: 2104: 2105: 2106: 2107: 2108: 2109: 2110: 211: 212: 213: 1xi call jnz h,unatrk sektrkcmp a110c ;sektrk = unatrk? ;skip if not tracks are the same Ida seksec 1xi h,unasec CPO m jnz a110c ;same sector? ;seksec = una sec? ,skip if not match, move to next sector for future ref inr m ;unasec = unasec+1 mov a,m ;end of track? cpi cpmspt ;count CP/M sectors jc noovf ;skip if no overflow overflow to next track mvi m,e 1h1d unatrk inx h sh1d unatrk ;unasec = 10 ;unatrk = unatrk+1 noovf: ;match found, mark as unnecessary read xra a ;10 to accumulator rsf1ag ; rsf1ag = 10 sta jmp rwoper ito perform the write ; a11oc: ., ;not an unallocated record, requires pre-read xra a ; 10 to accum unacnt sta ;unacnt = 10 inr a ;1 to accum rsf1ag. sta ; rsf1ag = 1 . ,• ***************************************************** * ,.* ;* Common code for READ and WRITE follows * .* * I .***************************************************** I rwoper: ;enter here to perform the read/write xra a ;zero to accum sta erf1ag ;no errors (yet) Ida seksec ;compute host sector rept secshf ora ;carry = 10 a rar ;shift right endm sta sekhst ;host sector to seek active host sector? 1xi h,hstact mov a,m mvi m,l 69 ;host active flag ;a1ways becomes 1 • 214: 215: 216: 217: 218: 219 : 2210: 221: 222 : 223: 224: 225: 226: 227: 228: 229: 2310: 231 : 232: 233: 234: 235: 236: 237: 238 : 239: 2410: 241: 242: 243: 244: 245: 246: 247: 248: 249: 2510: 251: 252: 253: 254: 255: 256: 257 : 258: 259: 260: 261: 262 : 263: 264: 265: 266: 267: 268: ora jz ; ;was it already? ;fill host if not a filhst host buffer active, same as seek buffer? sekdsk Ida ;same disk? lxi h ,hstdsk ;sekdsk = hstdsk? cmp m nomatch jnz same disk, same track? lxi h,hsttrk call sektrkcmp nomatch jnz ;sektrk = hsttrk? same disk, same track, same buffer? Ida sekhst lxi h,hstsec ;sekhst = hstsec? cmp m ;skip if match jz match ; nomatch: ;proper Ida ora cnz disk, but not correct sector hstwrt ;host written? a ;clear host buff writehst ; filhst: ;may have to fill the host buffer Ida sekdsk sta hstdsk Ihld sektrk shld hsttrk Ida sekhst hstsec sta ;need to read? Ida rsflag ora a cnz readhst ; ye s, if 1 xra ;/0 to accum a sta hstwr t ;no pending write ; match: ;copy data to or from buffer Ida seksec ;mask buffer number ani secmsk ;least signif bits mov l,a ;ready to shift mvi h,/O ;double count rept 7 ;shift left 7 dad h endm hI has relative host buffer address lxi d,hstbuf dad d ;hl = host address xchg ;now in DE Ihld dmaadr ;get/put CP/M data mvi c,128 ;length of move 710 269 :, 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: , 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301 : 302: 303 : 304 : 305: 306: 307: 308 : 309: 310: 311: 312: 313 : 314: 315 : 316 : 317: 318: 319 : 320: Ida ora jnz readop a rwmove iwhich way? iskip if read write operation, mark and switch direction mvi a,l sta hstwrt i hstwr t = 1 xchg isource/dest swap rwmove: ;C initially 128, DE is source, HL is dest Idax d ;source character inx d mov m,a ito dest inx h dcr c ; loop 128 times jnz rwmove .. data' has been moved to/from host buffer Ida wrtype iwrite type cpi wrdir ito directory? Ida erf1ag ;in case of errors rnz inO further processing clear host buffer for directory write ;errors? ora a iskip if so rnz xra i0 to accum a hstwr t ibuffer written sta call writehst Ida erflag ret ·,,.***************************************************** ,.* * ,· * utility subroutine for 16-bit compare * ,· * * ,.***************************************************** sektrkcmp: ;HL = .unatrk or .hsttrk, compare with sektrk xchg lxi h,sektrk Idax d ;low byte compare cmp m i same? rnz ireturn if not low bytes equal, test high Is inx d inx h d 1dax cmp m i sets flags ret 71 • 321: 322: 323: 324 : 325: 326: 327: 328 : 329 : 3310: 331 : 332: 333: 334: 335: 336: 337: 338: 339: 3410: 341 : 342: 343: 344: 345: 346: 347 : 348: 349: 3510: 351 : 352: 353 : 354: 355: 356: 357: 358: 359: 3610: 361: 362: 363: 364: 365: 366: 367: 368: 369: 3710: ,.***************************************************** ,.* ,· * ,· * ,· * ·, * . WRITEHST perf~rms the physical write to the host disk, READHST reads the physical disk. * "It * * * ,. ***************************************************** writehst: ihstdsk = host disk #, hsttrk = host track #, ihstsec = host sect i. write "hstsiz h bytes ifrom hstbuf and return error flag in erflag. ;return erflag non-zero if error ret ·, readhst: ihstdsk = host disk #, hsttrk = host track i, ihstsec = host sect i. read "hstsiz" bytes iinto hstbuf and return error flag in erflag. ret ·,,.***************************************************** i * * ,· * unitialized RAM data areas * ,· * * ,.*************************************n******~******** ·, sekdsk: ds sektrk: ds seksec: ds 1 iseek disk number iseek track number iseek sector number 1 2 1 ihost disk number ihost track number ihost sector number 1 1 1 iseek shr secshf ihost active flag ihost written flag 1 2 i hstdsk: ds hsttrk: ds hstsec: as i sekhst: ds hstact: ds hstwr t: ds i unacnt: unaask: unatrk: unasec: ds as ds ds 1 1 2 1 iunalloc rec cnt ilast unalloc disk ilast unalloc track ilast unalloc sector erflag: rsflag: readop: w:type: dmaadr: hstbuf: ds ds ds as ds ds 1 1 1 1 2 ;error reporting iread sector flag ;1 if read operation ;write operation type ;last dma address ;host buffer hstsiz 72 371: ,.***************************************************** 372: ,. * * 373: ., * The ENDEF macro invocation goes here * * 374: ,.* 375: ,.***************************************************** end 376: • 73 MICROSOFT BASIC 80 REFERENCE MANUAL I [1YA][]©OO©®©[P1J rn3£®[]© c ®@ release 5.0 • Revision 1 ~ Microsoft, 1979 Introduction BASIC-80 is the most extensive implementation of BASIC available for the 8080 and Z80 microprocessors. In its fifth major release (Release 5.0), BASIC-80 meets the ANSI qualifications for BASIC, as set forth in document BSRX3.60-1978. Each release of BASIC-80 consists of three upward compatible versions: 8K, Extended and Disk. This manual is a reference for all three versions of BASIC-80, release 5.0 and later. This manual is also a reference for Microsoft BASIC-86 and the Microsoft BASIC Compiler. BASIC-86 is currently available in Extended and Disk Standalone. versions, which are comparable to the BASIC-80 Extended and Disk Standalone versions. There are significant differences between the 5.0 release of BASIC-80 and the previous releases (release 4.51 and earlier). If you have programs written under a previous release of BASIC-80, check Appendix A for new features in 5.0 that may affect execution. The manual is divided into three large qhapters plus a number of appendices. Chapter 1 covers a variety of topics, largely pertaining to information representation when using BASIC-BO·. Chapter 2 contains the syntax and semantics of every command and statement in BASIC-BO, ordered alphabetically. Chapter 3 describes all of BASIC-BO's intrinsic functions, also ordered alphabetically. The appendices contain information pertaining to individual operating systems; plus lists of error messages, ASCII codes, and math functions; and helpful information on assembly language subroutines and disk I/O. • BASIC-80 Reference Manual CQNTENTS INTRODUCTION CHAPTER 1 General Information About BASIC-80 CHAPTER 2 BASIC-80 Commands and Statements CHAPTER 3 BASIC-80 Functions APPENDIX A New Features in BASIC-80, Release 5.0 APPENDIX B BASIC-80 Disk I/O APPENDIX C Assembly Language Subroutines APPENDIX 0 BASIC-80 with the CP/M Operating System APPENDIX E BASIC-80 with the ISIS-II Operating System APPENDIX F BASIC-80 with the TEKDOS Operating System APPENDIX G BASIC-80 with the Intel SBC and APPENDIX H Standalone Disk BASIC APPENDIX I Converting Programs to BASIC-80 APPENDIX J Summary of Error Codes and Error Messages APPENDIX K Mathematical Functions APPENDIX L ASCII Character Codes ~DS Systems • CHAPTER 1 GENERAL INFORMATION ABOUT BASIC-SO 1.1 INITIALIZATION The procedure for initialization will vary with different implementations of BASIC-SO. Check the appropriate appendix at the back of this manual to determine how BASIC-SO is initialized with your operating system. 1.2 MODES OF OPERATION When BASIC-SO is initialized, it types· the prompt "Ok". "Ok" means BASIC-SO is at command level, that is,' it is ready to accept commands. At this point, BASIC-SO may be used in either of two modes: the direct mode or the indirect mode. In the direct mode, BASIC commands and statements are not preceded by line numbers. They are executed as they are entered. Results of arithmetic and logical operations may be displayed immediately and stored for later use, but the instructions themselves are lost after execution. This mode is useful for debugging and for . using BASIC as a "calculator" for quick computations that do not require a complete program. The indirect mode is the mode used for entering programs. Program lines are preceded by line numbers and are stored in memory. The program stored in memory is executed by entering the RUN command. 1.3 LINE FORMAT Program lines in a BASIC program have the .(square brackets indicate optional) : following format nnnnn BASIC statement[:BASIC statement ••• ] • GENERAL INFORMATION ABOUT BASIC-80 Page 1-2 At the programmer's option, more than one BASIC statement may be placed on a line, but each statement on a line must be separated from. the last by a colon. A BASIC program line always begins with a line number, with a carriage return, and may contain a maximum of: ends 72 characters in 8K BASIC-80 255 characters in Extended and Disk BASIC-80. In Extended and Disk versions, it is possible to extend a logical line over more than one physical line by use of the terminal's key. lets you continue typing a logical line on the next physical line without entering a . (In the 8K version, has no effect. Every BASIC program line begins with a line number. Line numbers indicate the order in which the program lines are stored in memory and are also used as references when branching and editing. Line numbers must be in the range 0 to 65529. In the Extended and Disk versions, a period C.) may be used in EDIT, LIST, AUTO and DELETE commands to refer to the current line. . GENERAL INFORMATION ABOUT BASIC-SO 1.4 Page 1-3 CHARACTER SET The BASIC-SO character set is comprised of alphabetic characters, numeric characters and special characters. The alphabetic characters in BASIC-SO are the upper case and lower case letters of the alphabet. The numeric characters in BASIC-SO are the digits a through 9. The following special characters recognized by BASIC-SO: Character and terminal keys are Name Brank = + * / f\ ( ) % # $ [ ] & ? < > \ @ Semicolon Equal sign or assignment symbol Plus sign Minus sign Asterisk or multiplication symbol Slash or division symbol Up arrow or exponentiation symbol Left parenthesis Right parenthesis Percent Number (or pound) sign Dollar sign Exclamation point Left bracket Right bracket Comma Period or decimal point Single quotation mark (apostrophe) Colon Ampersand Question mark Less than Greater than Backslash or integer division symbol At-sign Underscore Deletes last character typed. Escapes Edit Mode subcommands. See Section 2.16. Moves print position to next tab stop. Tab stops are every eight columns. Moves to next physical line. Terminates input of a line. • GENERAL INFORMATION ABOUT BASIC-SO 1.4.1 Page 1-4 Control.9haracters The following control characters are in BASIC-80: Control-A Enters Edit Mode on the line being typed. Control-C Interrupts program execution BASIC-80 command level. Control-G Rings the bell at the terminal. Control-H Backspace. Control-I Tab. Control-O Halts program continues. A output. Control-R Retypes typed. Control-S Suspends program execution. Control-Q Resumes program execution after a Control-S. Control-U Deletes typed. 1.5 and returns to Deletes the last character typed. Tab stops are every eight columns. the the line line output second that that while execution Control-O restarts is is currently currently being being CONSTANTS Constants are the actual values BASIC uses during execution. There are two types of constants: string and numeric. A string constant is a sequence of up to 255 alphanumeric characters enclosed in double quotation marks. Examples of string constants: "HELLO" "$25,000.00" "Number of Employees" Numeric constants are positive or negative numbers. ,Numeric constants in BASIC cannot contain commas. There are five types of numeric constants: 1. Integer constants Whole numbers between -32768 and +32767._ Integer constants do not have decimal points. 2. Fixed Point constants Positive or negative real numbers, i.e., numbers that contain decimal points. GENERAL INFORMATION ABOUT BASIC-80 3. Floating Point constants Page 1-5 Positive or negative numbers repre-· sented in exponential form (similar to scientific notation). A floating point constant consists of an optionally signed integer or fixed point number (the mantissa) followed by the letter E and an optionally signed integer (the exponent). The exponent must be in the range -38 to +38. Examples: 235.988E-7 = .0000235988 2359E6 = 2359000000 (Double precision floating point constants use the letter D instead of E. See Section 1.5.1.) 4. Hex constants Hexadecimal numbers with the prefix &H. Examples: &H76 &H32F 5. Octal constants Octal numbers with the prefix &0 or &. Examples: &0347 &1234 1.5.1 Single And Double Precision ~ For Numeric Constants In the 8K version of BASIC-80, all numeric constants are single precision numbers. They are stored with 7 digits of precision, and printed with up to 6 digits. In the Extended and Disk versions, however, numeric constants may be either single precision or double prec1s10n numbers. With double precision, the numbers are stored with 16 digits of precision, and printed with up to 16 digits. • GENERAL INFORMATION ABOUT BASIC-80 A single precision constant is has: Page 1-6 any numeric 1. seven or fewer digits, or 2. exponential form using E, or 3. a trailing exclamation point ( 1 ) A double precision constant is has: any numeric 1. ~ight 2. exponential form using D, or 3. a trailing number sign (# ) constant that con$tant that or more digits, or Examples: Single Precision Constants 46.8 -7.09E-06 3489.0 22.51 1.6 Double Precision Constants 345692811 -1.09432D-06 3489.0# 7654321.1234 VARIABLES Variables are names used to represent values that are used in a BASIC program. The value of a variable may be assigned explicitly by the programmer, or it may be assigned as the result of calculations in the program. Before a variable is assigned a value, its value is assumed to be zero. 1.6.1 Variable Names And Declaration Characters BASIC-80 variable names may be any length, however, in the 8K version, only the first two characters are significant. In the Extended and Disk versions, up to 40 characters are significant. The characters allowed in a variable name are letters and numbers, and the decimal point is allowed in Extended and Disk variable names. The first character must be a letter. Special type declaration characters are also allowed -- see below. A variable name may not be a reserved word. The Extended and Disk versions allow embedded reserved words; the 8K version does not. If a variable begins with FN, it is assumed to be a call to a user-defined function. Reserved words include all BASIC-80 commands, statements, function GENERAL INFORMATION ABOUT BASIC-80 Page 1-7 names and operator names. Variables may represent either a numeric value or a string. String variable names are written with a dollar sign ($) as the last character. For example: A$ = IISALES REPORT II • The dollar sign is a variable type declaration character, that is, it IIdeclares ll that the variable will represent a string. In the Extended and Disk versions, numeric variable names may declare integer, single or double precision values. (All numeric values in 8K are single precision.) The type declaration characters for these variable names are as follows: % Integer variable Single precision variable # Double precision variable The default type for precision. a numeric variable name is single Examples of BASIC-80 variable names follow. In Extended and Disk versions: PI# MINIMUM! LIMIT% declares a double precision value declares a single precision value declares an integer value In 8K, Extended and Disk versions: N$ ABC declares a string value represents a single precision value In the Extended and Disk versions of BASIC-BO, there is a second method by which variable types may be declared. The BASIC-80 statements DEFINT, DEFSTR, DEFSNG and DEFDBL may be inclcded in a program to declare the types for certain variable names. These statements are described in detail in Section 2.12. 1.6.2 Array Variables An array is a group or table of values referenced by the same variable name. Each element in an array is referenced by an array variable that is subscripted with integers or integer expressions. An array variable name has as many subscripts as there are dimensions in the array. For example V(10) would reference a value in a one-dimensional array, T(1,4) would reference a value in a two-dimensional array, and so on. • GENERAL INFORMATION ABOUT BASIC-80 1.7 Page 1-8 TYPE CONVERSION When necessary, BASIC will convert a numeric constant from one type to another. The following rules and examples should be kept in mind. 1. If a numeric constant of one type is set equal to a numeric variable of a different type, the number will be stored as the type declared in the variable name. (If a string variable is set equal to a numeric value or. vice versa, a "~ype mismatch" error occurs.) Example: 10 A% = 23.42 20 PRINT A% RUN 23 2. During expression evaluation, all of the operands in an arithmetic or relational operation are converted to the same degree of precision, i.e., that of the most precise operand. Also, the result of an arithmetic operation is returned to this degree of precision. Examples: 10 D# = 6#/7 The arithmetic was performed 20 PRINT D# in double precision and the RUN result was returned in D# .8571428571428571 as a double precision value. 10 0 = 6#/7 20 PRINT D RUN .857143 The arithmetic was performed in double precision and the result was returned to D (single precision variable), rounded and printed as a single precision value. 3. Logical operators (see Section 1.8.3) convert their operands to integers and return an integer result. Operands must be in the range -32768 to 32767 or an "Overflow" error occurs. 4. When a floating point value is converted integer, the fractional portion is rounded. Example: 10 C% = 55.88 20 PRINT C% RUN 56 to an GENERAL INFORMATION ABOUT BASIC-BO 5. Page 1-9 If a double precision variable is assigned a single value, only the first seven digits, rounded, of the converted number will be valid. This is because only seven digits of accuracy were supplied with the single precision value. The absolute value of the difference between the printed double precision number and the original single precision value will be less than 6.3E-B times the original single precision value. Example: prec~s~on 10 A = 2.04 20 B# = A 30 PRINT A~B# RUN 2.04 2.039999961B53027 1.B EXPRESSIONS AND OPERATORS An expression may be simply a string or numeric constant, or a variable, or it may combine constants and variables with operators to produce a single value. Operators perform mathematical or logical operations on values. The operators provided by BASIC-BO may be divided into four categories: 1.B.1 1. Arithmetic 2. Relational 3. Logical 4. Functional • Arithmetic Operators The arithmetic operators, in order of precedence, are: Operator Operation Sample Expression Exponentiation XAY Negation -X *,/ Multiplication, Floating Point Division X*y X/Y +,- Addition, Subtraction X+Y GENERAL INFORMATION ABOUT BASIC-80 Page 1-10 To change the order in which the operations are performed, use parentheses. Operations within parentheses are performed first. Inside parentheses, the usual order of operations is maintained. Here are some sample algebraic expressions and counterparts. Algebraic Expression X+Y*2 x-..L Z X-Y/Z Z X+Y -Z- (X2) Y yZ X X(-Y) BASIC BASIC Expression X+2Y XY their X*Y/Z (X+Y)/Z (XJ\2) J\Y XJ\(YJ\Z) X*(-Y) Two consecutive operators must be separated by parentheses. 1.8.1.1 Integer Division And Modulus Arithmetic Two additional operators are available in Extended and Disk versions of BASIC-BO: Integer division and modulus arithmetic. Integer division is denoted by the basks lash ('). The (must be in the range operands are rounded to integers -32768 to 32767) before the division is performed, and the quotient is truncated to an integer. For example: 10\4 = 2 . 25. 68\6.99 = 3 The precedence of integer divisionis multiplication and floating point division. just after Modulus arithmetic is denoted by the operator MOD. It gives the integer value that is the remainder of an integer division. For example: 10.4 MOD 4 = 2 (10/4=2 with a remainder 2) 25.68 MOD 6.99 = 5 (26/7=3 with a remainder 5) The precedence of modulus arithmetic is just division. after integer GENERAL INFORMATION ABOUT BASIC-BO Page 1-11 1.8.1.2 Overflow And Division ~ Zero If, during the evaluation of an expression, a division by zero is encountered, the "Division by zero" error message is displayed, machine infinity with the sign of the numerator is supplied as the result of the division, and execution continues. If the evaluation of an exponentiation results in zero being raised to a negative power, the "Division by zero" error message is displayed, positive machine infinity is supplied as the result of the exponentiation, and execution continues. If overflow occurs, the "Overflow" error message is displayed, machine infinity with the algebraically correct sign is supplied as the result, and execution continues. 1.B.2 Relational Operators Relational operators are used to compare two values. The result of the comparison is either "true" (-1) or "false" (0). This result may then used to make a decision regarding program flow. (See IF, Section 2.26.) Relation Tested EXEression = Equality- x=y <> Inequality x<>y < Less than x Greater than x>y <= Less than or equal to X<=Y >= Greater than or equal to X>=y °Eerator (The equal sign is also used to variable. See LET, Section 2.30.) assign a value to a When arithmetic and relational operators are combined in one expression, the arithmetic is always performed first. For example, the expression X+y < (T-1)/Z is true if the value of X plus Y is less than the T-1 divided by Z. More examples: IF SIN(X) 0 THEN K=K+1· value of • GENERAL INFORMATION ABOUT BASIC-SO 1.S.3 Page 1-12 Logical Operators Logical operators perform tests on multiple relations, bit manipulation, or Boolean operations. The logical operator returns a bitwise result which is either "true" (not zero) or "false" (zero). In an expression, logical operations are performed after arithmetic and relational operations The outcome of a logical operation is determined as shown in the following table. The operators are listed in order of precedence. 0 NOT X NOT X a 1 a AND 1 y 1 a o a 1 a X AND Y 1 X Y X OR Y 1 1 1 O· X 1 1 a a a OR 1 1 1 a a o o X Y X XOR Y 1 1 1 XOR 1 a a o 1 o o 1 1 o IMP Y 1 X IMP Y o o o 1 1 1 X Y x EQV Y 1 1 1 X 1 1 a a 1 EQV a a o 1 o 1 o o 1 Just as the relational op~rators can be used to make decisions regarding program flow, logical operators can connect two or more relations and return a true or false value to be used in a decision (see IF, Section 2.26). For GENERAL INFORMATION ABOUT BASIC-80 Page 1-13 example: IF 0<200 AND F<4 THEN 80 IF I>10 OR K < > <= operators >= String comparisons are made by taking one character ,at a time from each string 'and comparing the ASCII codes.' If all the ASCII codes are the same, the strings are equal. If the ASCII codes differ, the lower code number preced~s the higher. If, during string comparison, the end of one string is reached, the shorte~ string ~s said to be smaller. Leading and, trailing blanks are significant. Examples: "M" < "AB" "FILENAME" = "FILENAME" "X&" > "X#" "CL " > "CL" "kg" > "KG" "SMYTH" < "SMYTHE" B$ < "9/12/7~" wher~ B$ = "S/12/7S~ Thus, string comparisons can be used to test string, values or to alphabetize strings., All string constants used in comparison expressions must be enclosed in quotation marks. GENERAL INFORMATION ABOUT BASIC-SO 1.9 Page 1-15 INPUT EDITING If an incorrect character is entered as a line is being typed, it can be deleted with the RUBOUT key or with Control-H. Rubout surrounds the deleted characterCs) with backslashes, and Control-H has the effect of backspacing over a character and erasing it. O~ce a characterCs) has been deleted, simply continue typing the line as desired. To delete a line that is in the process of being typed, type Control-U. A carriage return is executed automatically after the line is deleted. To correct program lines for a program that is currently in memory, simply retype the line using the same line number. BASIC-SO will automatically replace the old line with the new line. More sophisticated editing capabilities are provided in the Extended and Disk versions of BASIC-SO. See EDIT, Section 2. 16. To delete the entire program that is currently residing in memory, enter the NEW command. CSee Section 2.41.) NEW is usually used to clear memory prior to entering a new program. 1.10 ERROR MESSAGES If BASIC-SO d~tects an error that causes program execution to "terminate, an error message is printed. In the SK version, only the error code is printed. In the Extended and Disk versions, the entire error message is printed. For a complete list of BASIC-SO error codes and error messages, see Appendix J. .. CHAPTER 2 BASIC-80 COMMANDS AND STATEMENTS All of the BASIC-80 commands and statements are described in this chapter. Each description is formatted as follows: Format: Shows the correct format for the instruction. See below for format notation. Versions: Lists the versions of BASIC-80 in which the instruction is available. Purpose: Tells what the instruction is used for. Remarks: Describes in detail how the instruction is used. Example: Shows sample programs or program segments that demonstrate the use of the instruction. Format Notation Wherever the format for a statement or command is given, the following rules apply: 1. Items in capital letters must be input as shown. 2. Items in brackets lower « » case letters enclosed in angle are to be supplied by the user. 3. Items in square brackets ([ ]) are optional. 4. All punctuation except angle brackets and square brackets (i.e., commas, parentheses, semicolons, hyphens, equal signs) must be included where shown. 5. Items followed by an ellipsis ( ••• ) may be repeated any number of times (up to the length of the line)'. I BASIC-80 COMMANDS 2.1 A~D STATEMENTS Page 2-2 AUTO Format: AUTO [ [, ]] Versions: Extended, Disk Purpose: To generate a line number every carriage return. Remarks: AUTO begins numbering at and increments each subsequent line number by . The default for both values is 10. If is followed by a comma but is not specified, the last increment specified in an AUTO command is assumed. automatically after If AUTO generates a line number that is already being used, an asterisk is printed after the number to warn the user that any input will replace the existing line. However, typing a carriage return immediately after the asterisk will save the line and generate the next line number. AUTO is terminated by typing Control-C. The line in which Control-C is typed is not saved. After Control-C is typed, BASIC returns to command level. Example: AUTO 100,50 Generates line numbers 100, 150, 200 ••. AUTO Generates line numbers 10, 20, 30, 40 •.• BABIC-80 COMMANDS AND STATEMENTS 2.2 Page 2-3 CALL Format: CALL [«argument list»] Version: Extended, Disk Purpose: To call an assembly language subroutine. Remarks: The CALL statement is one way to transfer program flow to an assembly language subroutine. (See also the USR function, Section 3.40) contains an address that is the starting point in memory of the subroutine. may not be an array variable name. contains the arguments that are passed to the assembly language subroutine. The CALL statement generates the same calling sequence used by Microsoft's FORTRAN, COBOL and BASIC compilers. Example: 110 MYROUT=&HDOOO 120 CALL MYROUT(I,J,K) • BASIC-BO COMMANDS AND STATEMENTS 2.3 Page 2-4 CHAIN Format: CHAIN [MERGE] [, [ ] [,ALL] [,DELETE ]] Version: Disk Purpose: To call a program and pass variables to it the current program. Remarks: is the name of the called. Example: program from that is CHAIN"PROG1" is a line number or an expression that evaluates to a line number in the called program. It is the starting point for execution of the called program. If it is omitted, execution begins at the first line. Example: CHAIN"PROG1",1000 is not command. affected by a RENUM With the ALL option, every variable in the current program is passed to the called program. If the ALL option is omitted, the current program must contain a COMMON statement to list the' variables that are passed. See Section 2.7. Example: CHAIN"PROG1",1000,ALL If the MERGE option is included, it allows a subroutine to be brought into the BASIC program as an overlay. That is, a MERGE operation is performed with the current program and the called program. The called program must be an ASCII file if it is to be MERGEd. Example: CHAIN MERGE"QVRLAY",1000 After an overlay is brought in, it is usually desirable to delete it so that a new overlay may be brought in. To do this, use the DELETE option. Example: CHAIN MERGE"OVRLAY2",1000,DELETE 1000-5000 The line numbers in are affected by RENUM command. the BASIC-SO COMMANDS AND STATEMENTS NOTE: Page 2-5 The Microsoft BASIC compiler does not support the ALL, MERGE, and DELETE options to CHAIN. If you wish to maintain compatibility with the BASIC compiler, it is recommended that COMMON be used to pass variables and that overlays not be used. • BASIC-SO COMMANDS AND STATEMENTS 2.4 Page 2-6 CLEAR . Format: CLEAR [ , [ ] [, ] ] Versions: SK, Extended, Disk Purpose: To set all numeric variables to zero and all string variables to null; and, optionally, to set the end of memory and the amount of stack space. Remarks: is a memory location which, if specified, sets the highest location available . for use by BASIC-SO. sets aside stack space for BASIC. The default is 1000 bytes or one-eighth of the available memory, whichever is smaller. NOTE: In previous versions of BASIC-SO, set the amount of string space and set the end of memory. BASIC-80, release 5.0 and later, allocates string space dynamically. An "Out of string space" error occurs only if there is no free memory left for BASIC to use. Examples: CLEAR CLEAR ,32768 CLEAR,,2000 CLEAR,32768,2000 BASIC-80 COMMANDS AND STATEMENTS 2.5 Page 2-7 CLOAD Formats: CLOAD CLOAD? CLOAD* Versions: 8K (cassette), Extended (cassette) Purpose: To load a program or an array from cassette tape into memory. Remarks: CLOAD executes a NEW command before it loads program from cassette tape. is string expression or the first character of string expression that was specified when program was CSAVEd. the the the the CLOAD? verifies tapes by comparing the program currently in memory with the file on tape that has the same filename. If they are the same, BASIC-80 prints Ok. If not, BASIC-80 prints NO GOOD. CLOAD* loads a numeric array that has been saved on tape. The data on tape is loaded into the array called specified when the array was CSAVE*ed. CLOAD and CLOAD? are always entered at command level as direct mode commands. CLOAD* may be entered at command level or used as a program statement. Make sure the array has been DIMensioned before it is loaded. BASIC-80 always returns to command level after a CLOAD, CLOAD? or CLOAD* is executed. Before a CLOAD is executed, make sure the cassette recorder is properly connected and in the Play mode, and the tape is possitioned correctly. See also CSAVE, Section 2.9. NOTE: CLOAD and CSAVE are not included implementations of BASIC-80. Example: CLOAD "MAX2" Loads file "M" into memory. in all • BASIC-80 COMMANDS AND STATEMENTS 2.6 Page 2-8 CLOSE Format: CLOSE[[#] [,[#] ]] Version: . Disk Purpose: To conclude I/O to a disk file. Remarks: is the number under which the file was OPENed. A CLOSE with no arguments closes all open files. The association between a particular file and file number terminates upon execution of a CLOSE. The file may then be reOPENed using the same or a different file number; likewise, that file number may now be reused to OPEN any file. A CLOSE for a sequential output file writes final buffer of output. the The END statement and the NEW command always CLOSE all disk files automatically. (STOP does not close disk files.) Example: See· Appendix B. BASIc-ao COMMANDS AND STATEMENTS 2.7 Page 2-9 COMMON Format: COMMON Version: Disk Purpose: To pass variables to a CHAINed program. Remarks: The COMMON statement is used in conjunction with the CHAIN statement. COMMON statements may appear anywhere in a program, though it is recommended that they appear at the beginning. The same variable cannot appear in more than one COMMON statement. Array variables are specified by appending "()" to the variable name. If all variables are to be passed, use CHAIN with the ALL option and omit the COMMON statement. Example: 100 COMMON A,B,C,D() ,G$ 110 CHAIN "PROG3", 1 a • • • BASIC-BO COMMANDS AND STATEMENTS 2.B Page 2~10 CONT Format: CONT Versions: BK, Extended, Disk Purpose: To continue program execution after a Control-C has been typed, or a STOP or END statement has been executed. Remarks: Execution resumes at the point where the break occurred. If the break occurred after a prompt from an INPUT statement, execution continues with the reprinting of the prompt (? or prompt string) • CONT is usually used in conjunction with STOP for debugging. When execution is stopped, intermediate values may be examined and changed using direct mode statements. Execution may be resumed with CONT or a direct mode GOTO, which resumes execution at a specified line number. With the Extended and Disk versions, CONT may be used to continue execution after an error. CONT is invalid if the program has been edited during the break. In 8K BASIC-80, execution cannot be CONTinued if a direct mode error has occurred during the break. Example: See example Section 2.61, STOP. Page 2-11 BASIC-80 COMMANDS AND STATEMENTS 2.9 CSAVE Formats: CSAVE
CSAVE* Versions: 8K (cassette), Extended (cassette) Purpose: To save the program or an memory on cassette tape. Remarks: Each program or array saved on tape is identified by a filename. When the command CSAVE is executed, BASIC-80 saves the program currently in memory on tape and uses the first character in as the filename. may be more than one character, but only the first character is used for the filename. array currently in When the command CSAVE* is executed, BASIC-80 saves the specified array on tape. The array must be a numeric array. The elements of a multidimensional array are saved with the leftmost subscript changing fastest. CSAVE may be used as a program statement or as a direct mode command. Before a CSAVE or CSAVE* is executed, make sure the cassette-recorder is properly c6nnected and in the Record mode. See also CLOAD, Section 2.5. NOTE: CSAVE and CLOAD are not included implementations of BASIC-80. Example: CSAVE "TIMER" Saves the program currently in memory on cassette under filename liT". in all • BASIC-80 COMMANDS AND STATEMENTS 2.10 Page 2-12 DATA Format: DATA Versions: SK, Extended, Disk Purpose: To store the numeric and string constants that are accessed by the program's READ statement(s). (See READ, Section 2.54) Remarks: DATA statements are nonexecutable and may be placed anywhere in the program. A DATA statement may contain as many constants as will fit on a line (separated by commas), and any number of DATA statements may be used in a program. The READ statements access the DATA statements in order (by line number) and the data contained therein may be thought of as one continuous list of items, regardless of how many items are on a line or where the lines are placed in the program.
may contain numeric constants in any format, i.e., fixed point, floating point or integer. (No numeric expressions are allowed in the list.) String constants in DATA statements must be surrounded by double quotation marks only if they contain commas, colons or significant leading or trailing spaces. Otherwise, quotation marks are not needed. The variable type (numeric or string) given in the READ statement must agree with the corresponding constant in the DATA statement. DATA statements may be reread from the beginning by use of the RESTORE statement (Section 2.57). Example: See examples in Section 2.54, READ. BASIC-80 COMMANDS AND STATEMENTS 2.11 Page 2.,.13 DEF FN Format: DEF FN
[«parameter list»]= Versions: 8K, Ext-ended, Disk Purpose: To define and name a function that is written by theuser. Remarks: must be a legal variable name. This name, preceded by FN, becomes the name of the function is comprised of those variable names in the function definition that are to be replaced when the function is called. The items in the list are separated by commas. is an expression that performs the operation of the function. It is limited to one line. Variable names that appear in this expression serve only to define the function; they do not affect program variables that have the same name. A variable name used in a function definition mayor may not appear in the parameter list. If it does, the value of the parameter is supplied when the function is called. Otherwise, the current value of the variable is used. 0 The variables in the parameter list represent, on a one-to-one basis, the argument variables or values that will be given in the function call. (Remember, in the 8K version only one argument is allowed in a function call, therefore the DEF FN statement will contain only one variable.) In Extended and Disk BASIC-80, user-defined functions may be numeric or string; in 8K, user-defined string functions are not allowed. If a type is specified in the function name, the value of the expression is forced to that type before it is returned to the calling statement. If a type is specified in the function name and the argument type does not match, a "Type mismatch" error occurs. A DEF FN statement must be executed before the function it defines may be called. If a function is called before it has been defined, an "Undefined user function" error occurs. DEF FN is illegal in the direct mode. • BASIC-80 COMMANDS AND STATEMENTS Page 2-14 Example: • 410 DEF FNAB(X,Y)=XA3/YA2 420 T=FNAB(I,J) • • Line 410 defines the function function is called in line 420. FNAB. The BASIC-80 COMMANDS AND STATEMENTS 2.12 Page 2-15 DEFINT/SNG/DBL/STR Format: DEF where is INT, SNG, DBL, or STR Versions: Extended, Disk Purpose: To declare variable types as integer, precision, double precision, or string. Remarks: A DEFtype statement declares that the variable names beginning with the letter(s) specified will be that ·type variable. However, a type declaration character always takes precedence over a DEFtype statement in the typing of a variable. single If no type declaration statements are encountered, BASIC-80 assumes all variables without declaration characters are single· precision variables. Examples: 10 DEFDBL L-P All variables beginning. with the letters L, M, N, 0, and P will be double precision variables. 10 DEFSTR A All variables beginning with the letter A will be string variables. • BASIC-80 COMMANDS AND STATEMENTS 2.13 Page 2-16 DEF USR Format: DEF USR[ ]= Versions: Extended, Disk Purpose: To specify the starting address of language subroutine. Remarks: may be any digit from 0 to 9. The digit corresponds to the number of the USR routine whose address is being specified. If is omitted, DEF USRO is assumed. The value of is the starting address of the USR routine. See Appendix C, Assembly Languag~ Subroutines. an assembly Any number of DEF USR statements may appear in a program to redefine subroutine starting addresses, thus allowing access to as many subroutines as necessary. Example: 200 DEF USRO=24000 210 X=USRO(YA2/2.89) BASIC-80 COMMANDS AND STATEMENTS 2.14 Page 2-17 DELETE Format: DELETE[ ] [- ] Versions: Extended, Disk Purpose: To delete program lines. Remarks: BASIC-80 always returns to command level after a DELETE is executed. If does not exist, an "Illegal function call" error occurs. Examples: DELETE 40 Deletes line 40 DELETE 40-100 Deletes lines 40 through 100, inclusive DELETE-40 Deletes all lines up to and including line 40 • BASIC-80 COMMANDS AND STATEMENTS 2.15 Page 2-18 DIM Format: DIM