CP/M Features and Facilities The CP/M Editor DIGITAL RESEARCH TM CP/M Operating System Manual
COPYRIGHT Copyright C 1976, 1977, 1978, 1979, 1982, and 1983 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.
Table of Contents 1 CP/M Features and Facilities 1.1 Introduction 1-1 1.2 Functional . . Description . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 1.2.1 . . . . General Command Structure . . . . . . . . . . . . . 1-3 1.2.2 . . . . File References . . . . . . . . . . . . . . . . . . . . . . . . 1-4 1.3 Switching . Disks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 1.4 Built-in . . . Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7 1.4.1 . . . . ERA . . .
Table of Contents (continued) 2.2 2.3 3 2.1.7 Text Search and Alteration . . . . . . . . . . 2.1.8 Source Libraries . . . . . . . . . . . . . . . . . . . 2.1.9 Repetitive Command Execution . . . . . . ED Error Conditions . . . . . . . . . . . . . . . . . . . . . . . Control Characters and Commands 2-11 2-15 2-17 2-18 2-19 CP/M Assembler 3.1 3.2 3.3 3.4 3.5 3.6 3.7 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1 Program Format . . . . . . . . . . . . . . .
Table of Contents (continued) 4 CP/M Dynamic Debugging Tool 4.1 4.2 4.3 4.4 ยท Introduction 4-1 DDT Commands 4-4 4.2.1 The A (Assembly) Command 4-4 4.2.2 The D (Display) Command . . . . . . . . . . . . . . . . . . . 4-5 4.2.3 The F (Fill) Command . . . . . . . . . . . . . . . . . . . . . . . 4-5 4.2.4 The G (Go) Command . . . . . . . . . . . . . . . . . . . . . . . 4-6 4.2.5 The I (Input) Command . . . . . . . . . . . . . . . . . . . . . . 4-7 4.2.6 The L (List) Command . . . . . . . . . . . . . . . . . .
Table of Contents (continued) 6.9 6.10 6.11 6.12 Reserved Locations in Page Zero . . . . . . . . . . . . . . . . . . . . . . . Disk Parameter Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The DISKDEF Macro Library . . . . . . . . . . . . . . . . . . . . . . . . . . Sector Blocking and Deblocking . . . . . . . . . . . . . . . . . . . . . . . . 6-26 6-28 6-34 6-39 Appendixes A B C D E F G H I The MDS Basic 1/0 System (BIOS) . . . . . . . . . . . . . . . . . . . . . . . .
Table of Contents (continued) 3-7 1-1 3-9 3-10 4-1 4-2 4-3 5-1 5-2 5 -3 6-1 6-2 6-3 6-4 6-5 6-6 6-7 6-8 6-9 6-10 Data Movement Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21 Arithmetic Logic Unit Operations . . . . . . . . . . . . . . . . . . . . . . . . . 3-22 Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24 Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Section 1 CP/M Features and Facilities 1.1 Introduction CP/M is a monitor control program for microcomputer system development that uses floppy disks or Winchester hard disks for backup storage. Using a computer system based on the Intel 8080 microcomputer, CP/M provides an environment for program construction, storage, and editing, along with assembly and program checkout facilities.
CP/M also supports ED, a powerful context editor, ASM, an Intel-compatible assembler, and DDT, 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 (CCP), the resulting facilities equal or exceed similar large computer facilities.
1.1 Introduction CP/M Operating System Manual Any or all of the CP/M component subsystems can be overlaid by an executing program. That is, once a user's program is loaded into the TPA, the CCP, BDOS, and BIOS areas can be used as the program's data area. A bootstrap loader is programmatically accessible whenever the BIOS portion is not overlaid; thus, the user program need only branch to the bootstrap loader at the end of execution and the complete CP/M monitor is reloaded from disk.
1.1 Introduction CP/M Operating System Manual Most of the commands reference a particular file or group of files. The form of a file reference is specified in Section 1.2.2. 1.2.2 File References A file reference identifies a particular file or group of files on a particular disk attached to CP/M. These file references are either unambiguous (ufn) or ambiguous (afn).
1.2 Functional Description CP/M Operating System Manual matches the following unambiguous filenames XYZ.COM and X3Z.CAM The wildcard character can also be used in an ambiguous file reference. The * character replaces all or part of a filename or filetype. Note that *.* equals the ambiguous file reference ????????.??? while filename.* and *.typ are abbreviations for filename.??? and ????????.typ respectively.
1.2 Functional Description CP/M Operating System Manual Similarly, the command A>DIR X?Y.C?M causes a search for all unambiguous filenames on the disk that satisfy this ambiguous reference. The following file references are valid unambiguous file references: X X.Y XYZ XYZ.COM GAMMA GAMMA.1 As an added convenience, the programmer can generally specify the disk drive name along with the filename. In this case, the drive name is given as a letter A through P followed by a colon (:).
1.2 Functional Description CP/M Operating System Manual 1.3 Switching Disks The operator can switch the currently logged disk by typing the disk drive name, A through P, followed by a colon when the CCP is waiting for console input. The following sequence of prompts and commands can occur after the CP/M system is loaded from disk A: CP/M VER 2.2 A>DIR List all files on disk A. A:SAMPLE ASM SAMPLE PRN A>B: Switch to disk B. B>DIR *.ASM List all ASM files on B. B:DUMP ASM FILES ASM B>A: Switch back to A. 1.
1.3 Switching Disks CP/M Operating System Manual 1.4.1 ERA Command Syntax: ERA afn The ERA (erase) command removes files from the currently logged-in disk, for example, the disk name currently prompted by CP/M preceding the >. The files that are erased are those that satisfy the ambiguous file reference afn. The following examples illustrate the use of ERA: ERA X.Y The file named X.Y on the currently logged disk is removed from the disk directory and the space is returned. ERA X.
1.4 Built-in Commands CP/M Operating System Manual 1.4.2 DIR Command Syntax: DIR afn The DIR (directory) command causes the names of all files that satisfy the ambiguous filename afn to be listed at the console device. As a special case, the command DIR lists the files on the currently logged disk (the command DIR is equivalent to the command DIR *.*). The following are valid DIR commands: DIR X.Y DIR X?Y.C?M DIR ??.Y Similar to other CCP commands, the afn can be preceded by a drive name.
1.4 Built-in Commands CP/M Operating System Manual 1.4.3 REN Command Syntax: REN ufn1=ufn2 The REN (rename) command allows you to change the names of files on disk. The file satisfying ufn2 is changed to ufn1. The currently logged disk is assumed to contain the file to rename (ufn2). You can also type a left-directed arrow instead of the equal sign if the console supports this graphic character. The following are examples of the REN command: REN X.Y=Q.R The file Q.R is changed to X.Y. REN XYZ.COM=XYZ.
1.4 Built-in Commands CP/M Operating System Manual 1.4.4 SAVE Command Syntax: SAVE n ufn The SAVE command places n pages (256-byte blocks) onto disk from the TPA and names this file ufn. In the CP/M distribution system, the TPA starts at 100H (hexadecimal) which is the second page of memory. The SAVE command must specify 2 pages of memory if the user's program occupies the area from 100H through 2FFH. The machine code file can be subsequently loaded and executed.
1.4 Built-in Commands CP/M Operating System Manual The TYPE command expands tabs, CTRL-I characters, assuming tab positions are set at every eighth column. The ufn can also reference a drive name. TYPE B:X.PRNThe file X.PRN from drive B is displayed. 1.4.6 USER Command Syntax: USER n The USER command allows maintenance of separate files in the same directory. In the syntax line, n is an Integer value in the range 0 to 15.
1.4 Built-in Commands CP/M Operating System Manual CTRL-I Terminates current input (line-feed). CTRL-M Terminates current input (carriage return). CTRL-P Copies all subsequent console output to the currently assigned list device (see Section 1.6.1). Output is sent to the list device and the console device until the next CTRL-P is pressed. CTRL-R Retypes current command line; types a clean line following character deletion with rubouts. CTRL-S Stops the console output temporarily.
1.5 Line Editing and Output Control CP/M Operating System Manual 1.6 Transient Commands Transient commands are loaded from the currently logged disk and executed in the TPA. The transient commands for execution under the CCP are below. Additional functions are easily defined by the user (see Section 1.6.3). Table 1-2.
1.6 Transient Commands CP/M Operating System Manual Transient commands are specified in the same manner as built-in commands, and additional commands are easily defined by the user. For convenience, the transient command can be preceded by a drive name which causes the transient to be loaded from the specified drive into the TPA for execution.
1.6 Transient Commands CP/M Operating System Manual STAT afn The command line can also specify a set of files to be scanned by STAT. The files that satisfy afn are listed in alphabetical order, with storage requirements for each file under the heading: RECS BYTES EXT D:FILENAME.TYP rrrr bbbk ee d:filename.
1.6 Transient Commands CP/M Operating System Manual The actual devices attached to any particular computer system are driven by subroutines in the BIOS portion of CP/M. Thus, the logical RDR: device, for example, could actually be a high speed reader, teletype reader, or cassette tape. To allow some flexibility in device naming and assignment, several physical devices are defined in Table 1-3. Table 1-3.
1.6 Transient Commands CP/M Operating System Manual It is emphasized that the physical device names might not actually correspond to devices that the names imply. That is, you can implement the PTP: device as a cassette write operation. The exact correspondence 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.
1.6 Transient Commands CP/M Operating System Manual The current logical-to-physical device assignment is changed by typing a STAT command of the form: STAT ld1=pd1,ld2=pd2,...,ldn=pdn where ld1 through ldn are logical device names and pd1 through pdn are compatible physical device names. For example, ld1 and pd1 appear on the same line in the VAL: command shown above.
1.6 Transient Commands CP/M Operating System Manual The Ext field counts the number of physical extents allocated to the file. The Ext count corresponds to the number of directory entries given to the file. Depending on allocation size, there can be up to 128K bytes (8 logical extents) directly addressed by a single directory entry. In a special case, there are actually 256K bytes that can be directly addressed by a physical extent.
1.6 Transient Commands CP/M Operating System Manual When a file is marked R/O, subsequent attempts to erase or write into the file produce the following BDOS message at your screen: BDOS Err on d: File R/O lists the drive characteristics of the disk named by d: that is in the range A:, B:,...,P:.
1.6 Transient Commands CP/M Operating System Manual For logical drives that share the same physical disk, the number of reserved tracks can be quite large because this mechanism is used to skip lower-numbered disk areas allocated to other logical disks. The command form STAT DSK: produces a drive characteristics table for all currently active drives. The final STAT command form is STAT USR: which produces a list of the user numbers that have files on the currently addressed disk.
1.6 Transient Commands CP/M Operating System Manual The assembler produces a file: X.PRN where X is the primary name specified in the ASM command. The PRN file contains a listing of the source program with embedded tab characters if present in the source program, along with the machine code generated for each statement and diagnostic error messages, if any. The PRN file is listed at the console using the TYPE command, or sent to a peripheral device using PIP (see Section 1.6.4).
1.6 Transient Commands CP/M Operating System Manual 1.6.3 LOAD Command Syntax: LOAD ufn The LOAD command reads the file ufn, which is assumed to contain HEX format machine code, and produces a memory image file that can subsequently be executed. The filename ufn is assumed to be of the form: X.HEX and only the filename X need be specified in the command. The LOAD command creates a file named X.COM that marks it as containing machine executable code.
1.6 Transient Commands CP/M Operating System Manual Note: the BETA.HEX file must contain valid Intel format hexadecimal machine code records (as produced by the ASM program, for example) that begin at 100H of the TPA. The addresses in the hex records must be in ascending order; gaps in unfilled memory regions are filled with zeroes by the LOAD command as the hex records are read. Thus, LOAD must be used only for creating CP/M standard COM files that operate in the TPA.
1.6 Transient Commands CP/M Operating System Manual When multiple files are given in the command line (for example, n>1), the individual files are assumed to contain ASCII characters, with an assumed CP/M end-of-file character (CTRL-Z) at the end of each file (see the O parameter to override this assumption). 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.
1.6 Transient Commands CP/M Operating System Manual For convenience, PIP allows abbreviated commands for transferring files between disk drives. The abbreviated PIP forms are PIP d:=afn PIP d1:=d2:afn PIP ufn=d2: PlP d1:ufn=d2: The first form copies all files from the currently logged disk that satisfy the afn to the same files on drive d, where d = A...P. The second form is equivalent to the first, where the source for the copy is drive d2 where d2 = A ... P.
1.6 Transient Commands CP/M Operating System Manual PIP allows reference to physical and logical devices that are attached to the CP/M svstem. The device names are the same as given under the STAT command, along with a number of specially named devices.
1.6 Transient Commands CP/M Operating System Manual -OUT: is a special PIP output destination that 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 through 1FFH of the PIP memory image are not used and can be replaced by special purpose drivers using DDT (see Section 4).
1.6 Transient Commands CP/M Operating System Manual The following are valid PIP commands: PIP LST:=X.PRN Copies X.PRN to the LST device and terminates the PIP program. PIP Starts PIP for a sequence of commands. PIP prompts with *. *CON:=X.ASM,Y.ASM,Z.ASM Concatenates three ASM files and copies to the CON device. *X.HEX=CON:,Y.HEX,PTR: Creates a HEX file by reading the CON until a CTRL-Z is typed, followed by data from Y.HEX and PTR until a CTRL-Z is encountered. PIP PUN:=NUL:,X.
1.6 Transient Commands CP/M Operating System Manual Table 1-4. PIP Parameters Parameter Meaning B Blocks mode transfer. Data are buffered by PIP until an ASCII x-off character, CTRL-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 more input data. The amount of data that can be buffered depends on the memory size of the host system.
1.6 Transient Commands CP/M Operating System Manual O Transfers non-ASCII object files. The normal CP/M end-of-file is ignored. Pn Includes 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 form-feed suppression takes place before the new page ejects are inserted. used, QS^Z Quits copying from the source device or file when the string S, terminated by CTRL-Z, is encountered. R Reads system files.
1.6 Transient Commands CP/M Operating System Manual The following examples show valid PIP commands that specify parameters in the file transfer. PIP X.ASM=B:[V] Copies X.ASM from drive B to the current drive and verifies that the data were properly copied. PIP LPT:=X.ASM[NT8U] Copies X.ASM to the LPT: device; numbers each line, expands tabs to every eighth column, and translates lower-case alphabetics to upper-case. PIP PUN:=X.HEX[I],Y.ZOT[H] First copies X.
1.6 Transient Commands CP/M Operating System Manual The file transfer is skipped, and PIP continues with the next operation in sequence. To avoid the prompt and response in the case of R/O file overwrite, the command line can include the W parameter, as shown in this example: PIP A:=B:*.COM[W] The W parameter copies all nonsystem files to the A drive from the B drive and overwrites any R/O files in the process.
1.6 Transient Commands CP/M Operating System Manual 1.6.5 ED Command Syntax: ED ufn The ED program is the CP/M system context editor that allows creation and alteration of ASCII files in the CP/M environment. Complete details of operation are given in Section 2. ED allows the operator to create and operate upon source files that are organized as a sequence of ASCII characters, separated by end-of-line characters (a carriage return/line-feed sequence).
1.6 Transient Commands CP/M Operating System Manual DIR X.*Checks to see that BAK file is available. ERA X.ASMErases most recent version. REN X.ASM=X.BAKRenames the BAK file to ASM. You can abort the edit at any point (reboot, power failure, CTRL-C, or CTRL-Q command) without destroying the original file. In this case, the BAK file is not created and the original file is always intact. The ED program allows the user to edit the source on one disk and create the back-up file on another disk.
1.6 Transient Commands CP/M Operating System Manual Similar to other transient commands, editing can take place on a drive different from the currently logged disk by preceding the source filename by a drive name. The following are examples of valid edit requests: ED A:X.ASMEdits the file X ASM on drive A, with new file and back-up on drive A. ED B:X.ASM A:Edits the file X.ASM on drive B to the temporary file X.$$$ on drive A. After editing, this command changes X.ASM on drive B to X.BAK and changes X.
1.6 Transient Commands CP/M Operating System Manual FUNCTION COMPLETE System is copied to memory. SYSGEN then prompts with the following: DESTINATION DRIVE NAME (OR RETURN TO REBOOT) If a disk is being initialized, place the new disk into a drive and answer with the drive name. Otherwise, press a carriage return and the system reboots from drive A. Typing drive name d causes SYSGEN to prompt with the following message: DESTINATION ON d THEN TYPE RETURN Place new disk into drive d; press return when ready.
1.6 Transient Commands CP/M Operating System Manual 1.6.7 SUBMIT Command Syntax: SUBMIT ufn parm#l ... parm#n The SUBMIT command allows CP/M commands to be batched for automatic processing. The ufn given in the SUBMIT command must be the filename of a file that exists on the currently logged disk, with an assumed file type of SUB. The SUB file contains CP/M prototype commands with possible parameter substitution. The actual parameters parm#1 ...
1.6 Transient Commands CP/M Operating System Manual The last command in a SUB file can initiate another SUB file, allowing chained batch commands. Suppose the file ASMBL.SUB exists on disk and contains the prototype commands: ASM $1 DIR $1.* ERA *.BAK PIP $2:=$1.PRN ERA $1.PRN then, you issue the following command: SUBMIT ASMBL X PRN The SUBMIT program reads the ASMBL.SUB file, substituting X for all occurrences of $1 and PRN for all occurrences of $2. This results in a $$$.
1.6 Transient Commands CP/M Operating System Manual An additional utility program called XSUB extends the power of the SUBMIT facility to include line input to programs as well as the CCP. The XSUB command is included as the first line of the SUBMIT file. When it is executed, XSUB self-relocates directly below the CCP. All subsequent SUBMIT command lines are processed by XSUB so that programs that read buffered console input, BDOS Function 10, receive their input directly from the SUBMIT file.
1.6 Transient Commands CP/M Operating System Manual 1.6.9 MOVCPM Command Syntax: MOVCPM The MOVCPM program allows you to reconfigure the CP/M system for any particular memory size. Two optional parameters can be used to indicate the desired size of the new system and the disposition of the new system at program termination.
1.6 Transient Commands CP/M Operating System Manual For example, the command, MOVCPM * * 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 'SAYE 34 CPMxx.COM' appears at the console upon completion, where xx is the current memory size in kilobytes. You can then type the following sequence: SYSGEN This starts the system generation.
1.6 Transient Commands CP/M Operating System Manual You can then go through the reboot process with the old or new disk. Instead of performing the SYSGEN operation, you can type a command of the form: SAVE 34 CPMxx.COM at the completion of the MOVCPM function, where xx is the value indicated in the SYSGEN message. The CP/M memory image on the currently logged disk is in a form that can be patched.
1.6 Transient Commands CP/M Operating System Manual The BAD SECTOR message indicates that the disk controller electronics has detected an error condition in reading or writing the disk. This condition is generally caused by a malfunctioning disk controller or an extremely worn disk. If you find that CP/M reports this error more than once a month, the state of the controller electronics and the condition of the media should be checked.
1.7 BDOS Error Messages CP/M Operating System Manual 1.8 Operation of CP/M on the MDS This section gives operating procedures for using CP/M on the Intel MDS microcomputer development system. Basic knowledge of the MDS hardware and software systems is assumed. CP/M is initiated in essentially the same manner as the Intel ISIS operating system. The disk drives are labeled 0 through 3 on the MDS, corresponding to CP/M drives A through D, respectively.
1.8 Operation of CP/M on the MDS CP/M Operating System Manual You should use IBM-compatible disks rather than disks that have previously been used with any ISIS version. In particular, the ISIS FORMAT operation produces nonstandard sector numbering throughout the disk. This nonstandard numbering seriously degrades the performance of CP/M, and causes CP/M to operate noticeably slower than the distribution version.
1.8 Operation of CP/M on the MDS CP/M Operating System Manual Section 2 The CP/M Editor 2.1 Introduction to ED ED is the context editor for CP/M, and is used to create and alter CP/M source files. To start ED, type a command of the following form: ED filename or ED filename.typ Generally, ED reads segments of the source file given by filename or filename.typ into the central memory, where you edit the file and it is subsequently written back to disk after alterations.
Figure 2-1. Overall ED Operation The memory buffer is logically between the source file and working file, as shown in Figure 2-2.
2.1 Introduction to ED CP/M Operating System Manual Figure 2-2. Memory Buffer Organization 2.1.2 Text Transfer Functions Given that n is an integer value in the range 0 through 65535, several single-letter ED commands transfer lines of text from the source file through the memory buffer to the temporary (and eventually final) file. Single letter commands are shown in upper-case, but can be typed in either upper- or lower-case. Table 2-1.
2.1 Introduction to ED CP/M Operating System Manual E Ends the edit. Copy all buffered text to temporary file and copy all unprocessed source lines to temporary file. Rename files. H Moves to head of new file by performing automatic E command. The temporary file becomes the new source file, the memory buffer is emptied, and a new temporary file is created. The effect is equivalent to issuing an E followed by a reinvocation of ED, using x.y as the file to edit. command, O Returns to original file.
2.1 Introduction to ED CP/M Operating System Manual The memory buffer appears logically as shown in Figure 2-3, where the dashes represent characters of the source line of indefinite length, terminated by carriage return () and line-feed () 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.
2.1 Introduction to ED CP/M Operating System Manual You can 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. The line denoted by the absolute line number must be in the memory buffer (see the A command).
2.1 Introduction to ED CP/M Operating System Manual 2.1.5 Memory Buffer Operation When ED begins, the memory buffer is empty. You can either append lines from the source file with the A command, or enter the lines directly from the console with the insert command. The insert command takes the following form: I ED then accepts any number of input lines. You must terminate each line with a (the is supplied automatically). A single CTRL-Z, denoted by an up arrow (T)Z, returns ED to command mode.
2.1 Introduction to ED CP/M Operating System Manual Table 2-2. Editing Commands Command Action +-B Move CP to beginning of memory buffer if + and to bottom if +-nC Move CP by +-n characters (moving ahead if +), counting the as two characters. +-nD Delete n characters ahead of CP if plus and behind CP if minus. +-nK Kill (remove) +-n lines of source text using CP as the current reference.
2.1 Introduction to ED CP/M Operating System Manual Table 2-3. Line-editing Controls Command Result CTRL-C Reboots the CP/M system when typed at the start of a line. CTRL-E Physical end of line: carriage is returned, but line is not sent until the carriage return key is depressed. CTRL-H Backspaces one character position. CTRL-J Terminates current input (line-feed). CTRL-M Terminates current input (carriage return).
2.1 Introduction to ED CP/M Operating System Manual Suppose the memory buffer contains the characters shown in the previous section, with the CP following the last character of the buffer. In the following example, the command strings on the left produce the results shown to the right. Use lower-case command letters to avoid automatic translation of strings to upper-case.
2.1 Introduction to ED -2L#T CP/M Operating System Manual Move up two lines and type 65535 lines ahead of CP NOW IS THE. The result in the memory buffer is NOW IS THE ^TIME TO INSERT Move down one line and type one line INSERT. The result in the memory buffer is NOW IS THE TIME TO ^INSERT 2.1.7 Text Search and Alteration ED has a command that locates strings within the memory buffer.
2.1 Introduction to ED CP/M Operating System Manual The following commands illustrate the use of the F command: Command String B#T Effect Move to the beginning and type the entire buffer. The result in the memory buffer is ^NOW IS THE TIME FOR ALL GOOD MEN FS T Find the end of the string S T. The result in the memory buffer is NOW IS T^HE FIs^Z0TT Find the next I and type to the CP; then type the remainder of the current line ME FOR.
2.1 Introduction to ED Command String CP/M Operating System Manual Effect BITHIS IS ^Z Insert THIS IS at the beginning of the text. The result in the memory buffer is THIS IS ^NOW THE TIME FOR ALL GOOD MEN FTIME^Z-4DIPLACE^Z Find TIME and delete it; then insert PLACE.
2.1 Introduction to ED CP/M Operating System Manual ED also provides a single command that combines the F and I commands to perform simple string substitutions. The command takes the following form: nSs1^Zs2 or nSs1^Zs2^Z and has exactly the same effect as applying the following command string a total of n times: Fs1^Z-kDIs2 or Fs1^Z-kDIs2^Z where k is the length of the string.
2.1 Introduction to ED CP/M Operating System Manual A final line editing function, called the Juxtaposition comniand, takes the form nJs1^Zs2^Zs3 or nJs1^Zs2^Zs3^Z with the following action applied n times to the memory buffer: search from the current CP for the next occurrence of the string S1. If found, insert the string S2, and move CP to follow S2. Then delete all characters following CP up to, but not including, the string S3, leaving CP directly after S2.
2.1 Introduction to ED CP/M Operating System Manual where filename is the primary filename of a source file on the disk with an 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.
2.1 Introduction to ED CP/M Operating System Manual 2.1.9 Repetitive Command Execution The macro command M allows you to group ED commands together for repeated evaluation. The M command takes the following form: nMCS or nMCS^Z where CS represents a string of ED commands, not including another M command. ED executes the command string n times if n>1.
2.1 Introduction to ED CP/M Operating System Manual 2.2 ED Error Conditions On error conditions, ED prints the message BREAK X AT C where X is one of the error indicators shown in Table 2-4. Table 2-4. Error Message Symbols Symbol Meaning ? 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 (for example, in F command). O Cannot open LIB file in R command.
2.2 ED Error Conditions CP/M Operating System Manual ED also takes file attributes into account. If you attempt to edit a Read-Only file, the message ** FILE IS READ/ONLY ** appears at the console. The file can be loaded and examined, but cannot be altered. You must end the edit session and use STAT to change the file attribute to Riw. If the edited file has the system attribute set, the following message: 'SYSTEM' FILE NOT ACCESSIBLE is displayed and the edit session is aborted.
2.2 ED Error Conditions CP/M Operating System Manual Table 2-6 summarizes the commands used in ED. Table 2-6. ED Commands Command Function nA Append lines +-B Begin or bottom of buffer +-nC Move character positions +-nD Delete characters E End edit and close files (normal end) nF Find string H End edit, close and reopen files I Insert characters, use i if both upper- and lower-case characters are to be entered.
2.
2.3 Control Characters and Commands CP/M Operating System Manual The commands I, J, M, N, R, and S should be typed as i, j, m, n, r, and s if both upper- and lower-case characters are used in the operation, otherwise all characters are converted to upper-case. When a command is entered in upper-case, ED automatically converts the associated string to upper-case, and vice versa.
2.3 Control Characters and Commands CP/M Operating System Manual Section 3 CP/M Assembler 3.1 Introduction The CP/M assembler reads assembly-language source files from the disk and produces 8080 machine language in Intel hex format. To start the CP/M assembler, type a command in one of the following forms: ASM filename ASM filename.parms In both cases, the assembler assumes there is a file on the disk with the name: filename.ASM which contains an 8080 assembly-language source file.
The form ASM filename parms is used to redirect input and output files from their defaults. In this case, the parms portion of the command is a three-letter group that 'fies the origin of the source file, the destination of the hex file, and the destination of the print file. The form is filename.p1p2p3 where p1, p2, and p3 are single letters. P1 can be A,B,...,P which designates the disk name that contains the source file. P2 can be A,B,...
3.1 Introduction CP/M Operating System Manual The command ASM X.ABX indicates that the source file is to be taken from disk A, the hex file is to be placed on disk B, and the listing file is to be sent to the console. The command ASM X.BZZ takes the source file from disk B and skips the generation of the hex and print files. This command is useful for fast execution of the assembler to check program syntax. The source program format is compatible with the Intel 8080 assembler.
3.1 Introduction CP/M Operating System Manual x xy long$name x: yxl: longer$naned$data: X1Y2 X1x2 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 in Section 3.3. Generally, the operand field of the statement contains an expression formed out of constants and labels, along with arithmetic and logical operations on these elements.
3.2 Program Format CP/M Operating System Manual 3.3.1 Labels A label is an identifier that occurs on a particular statement. In general, the label is given a value determined by the type of statement that it precedes. If the label occurs on a statement that generates machine code or reserves memory space (for example, a MOV instruction or a DS pseudo operation), the label is given the value of the program address that it labels.
3.3 Forming the Operand CP/M Operating System Manual Similar to identifiers, embedded $ signs are allowed within constants to improve their readability. 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 1234D 1100B 1111$0000$1111$0000B 1234H 0FFEH 3377O 33$77$22Q 3377o 0fe3h 1234d 0ffffh 3.3.
3.3 Forming the Operand CP/M Operating System Manual 3.3.4 String Constants String constants represent sequences of ASCII characters and are represented by enclosing the characters within apostrophe symbols. All strings must be fully contained within the current physical line (thus allowing exclamation point symbols within strings) and must not exceed 64 characters in length.
3.3 Forming the Operand CP/M Operating System Manual Table 3-2. Arithmetic and Logical Operators (continued) a*b unsigned magnitude multiplication of a and b a / bunsigned magnitude division of a by b a MOD b remainder after a / b.
3.3 Forming the Operand CP/M Operating System Manual 3.3.6 Precedence of Operators As a convenience to the programmer, ASM assumes that operators have a relative precedence of application that allows the programmer to write expressions without nested levels of parentheses. The resulting expression has assumed parentheses that are defined by the relative precedence. The order of application of operators in unparenthesized expressions is listed below.
3.3 Forming the Operand CP/M Operating System Manual An unparenthesized expression is well-formed only if the expression that results from inserting the assumed parentheses is well-formed. 3.4 Assembler Directives Assembler directives are used to set labels to specific values during the assembly, perform conditional assembly, define storage areas, and specify starting addresses in the program. Each assembler directive is denoted by a pseudo operation that appears in the operation field of the line.
3.3 Forming the Operand CP/M Operating System Manual 3.4.1 The ORG Directive The ORG statement takes the form: label ORG expression where label is an optional program identifier and expression is a 16-bit expression, consisting of operands that are defined before the ORG statement. The assembler begins machine code generation at the location specified in the expression.
3.4 Assembler Directives CP/M Operating System Manual 3.4.3 The EQU Directive The EQU (equate) statement is used to set up synonyms for particular numeric values. The EQU statement takes the form: label EQU expression where the label must be present and must not label any other statement. The assembler evaluates the expression and assigns this value to the identifier given in the label field. The identifier is usually a name that describes the value in a more human-oriented manner.
3.4 Assembler Directives CP/M Operating System Manual 3.4.4 The SET Directive The SET statement is similar to the EQU, taking the form: label SET expression except that the label can occur on other SET statements within the program. The expression is evaluated and becomes the current value associated with the label.
3.4 Assembler Directives CP/M Operating System Manual When encountering the IF statement, the assembler evaluates the expression following the IF. All operands in the expression must be defined ahead of the IF statement. If the expression evaluates to a nonzero value, then statement#l through statement#n are assembled. If the expression evaluates to zero, the statements are listed but not assembled.
3.4 Assembler Directives CP/M Operating System Manual 3.4.6 The DB Directive The DB directive allows the programmer to define initialized storage areas in singleprecision byte format. The DB statement takes the form: label DB e#1, e#2, ... , e#n where e#1 through e#n are either expressions that evaluate to 8-bit values (the highorder bit must be zero) or are ASCII strings of length no greater than 64 characters.
3.4 Assembler Directives CP/M Operating System Manual 3.4.8 The DS Directive The DS statement is used to reserve an area of uninitialized memory, and takes the form: label DS expression where the label is optional. The assembler begins subsequent code generation after the area reserved by the DS. Thus, the DS statement given above has exactly the same effect as the following statement: label: EQU $ ORG $+expression ;LABEL VALUE IS CURRENT CODE LOCATION ;MOVE PAST RESERVED AREA 3.
3.4 Assembler Directives CP/M Operating System Manual 3.5.1 Jumps, Calls, and Returns The Jump, Call, and Return instructions allow several different forms that test the condition flags set in the 8080 microcomputer CPU. The forms are shown in Table 3-4. Table 3-4.
3.5 Operation Codes CP/M Operating System Manual Table 3-4.
3.5 Operation Codes CP/M Operating System Manual 3.5.2 Immediate Operand Instructions Several instructions are available that load single- or double-precision registers or single-precision memory cells with constant values, along with instructions that perform immediate arithmetic or logical operations on the accumulator (register A). Table 3-5 describes the immediate operand instructions. Table 3-5.
3.5 Operation Codes CP/M Operating System Manual 3.5.3 Increment and Decrement Instructions The 8080 provides instructions for incrementing or decrementing single- and double precision registers. The instructions are described in Table 3-6. Table 3-6. Increment and Decrement Instructions Form with Bit Value Example Meaning INR e3 INR E Single-precision increment register. e3 produces one of A, B, C, D, E, H, L, M. DCR e3 DCR A Single-precision decrement register.
3.5 Operation Codes CP/M Operating System Manual 3.5.4 Data Movement Instructions Instructions that move data from memory to the CPU and from CPU to memory are given in the following table. Table 3-7. Data Movement Instructions Form with Bit Value Example Meaning MOV e3,e3 MOV A,B LDAX e3 LDAX B Load register A from computed address. e3 must produce either B or D. STAX e3 STAX D Store register A to computed address. e3 must produce either B or D.
3.5 Operation Codes CP/M Operating System Manual Table 3-7. (continued) Form with Bit Value IN e8 OUT e8 Example Meaning IN 0 Load register A with data from port e8. OUT 255 Send data from register A to port e8. XTHL Exchange data from top of stack with HL. PCHL Fill program counter with data from HL. SPHL Fill stack pointer with data from HL. XCHG Exchange DE pair with HL pair. 3.5.
3.5 Operation Codes CP/M Operating System Manual Table 3-8. (continued) Form with Bit Value Example Meaning ANA e3 ANA 1+1 Logical and reg with A, e3 as above. XRA e3 XRA A Exclusive or with A, e3 as above. ORA e3 ORA B Logical or with A, e3 defined as above. CMP e3 CMP H Compare register with A, e3 as above. DAA Decimal adjust register A based upon last arithmetic logic unit operation. CMA Complement the bits in register A. STC Set the carry flag to 1. CMC Complement the carry flag.
3.5 Operation Codes 3.5.6 CP/M Operating System Manual Control Instructions The four remaining instructions, categorized as control instructions, are the following: -HLT halts the 8080 processor. -DI disables the interrupt system. -EI enables the interrupt system. -NOP means no operation. 3.6 Error Messages When errors occur within the assembly-language program, they are listed as singlecharacter flags in the leftmost position of the source listing.
3.5 Operation Codes CP/M Operating System Manual Table 3-9. (continued) Error Code Meaning R Register error: the value specified as a register is not compatible with the operation code. S Syntax error: statement is not properly formed. Y Value error: operand encountered in expression is improperly formed. Table 3-10 lists the error messages that are due to terminal error conditions. Table 3-10.
3.6 Error Messages CP/M Operating System Manual 3.7 A Sample Session The following sample session shows interaction with the assembler and debugger in the development of a simple assembly-language program. The arrow represents a carriage return keystroke. A>ASM SORT Assemble SORT.ASM CP/M ASSEMBLER - VER 1.0 0015C Next free address 003H USE FACTOR Percent of table used 00 to ff (hexadecimal) END OF ASSEMBLY A>DIR SORT.
3.
3.7 A Sample Session CP/M Operating System Manual :10010000214601360121470136007EFE09D2190140 :100110002146017EB7C20001FF5F16002148011988 :10012000194E79234623965778239EDA3F01B2CAA7 :100130003F0156702B5E712B722B732146013421C7 :070014000470134C3A01006E :10014800050064001E00320014000700E8032C01BB :0401580064000180BE :0000000000000 A>DDT SORT.HEX Start debug run 16k DDT VER 1.
3.
3.
3.7 A Sample Session CP/M Operating System Manual 010D JC 119 0110 -L100 List starting section of program 0100 LXI H,0146 0103 MVI M,01 0105 LXI H,0147 0108 MVI M,00 -Abort list with rubout -a103 Change switch initialization to 00 0103 MVI M,0 105 -^C Return to CP/M with CTRL-C (G0 works as well) SAVE 1 SORT.COM A>DDT SORT.COM Save 1 page (256 pytes, from 100H to 1ffH) on disk in case there is need to reload later Restart DDT with saved memory image 16K DDT VER 1.
3.7 A Sample Session CP/M Operating System Manual a>ED SORT.ASM Make changes to original program (the caret,^, indicates a control *N,0^ZOTT MVI M,0 character) Find next ,0 ;I = 0 *- Up one line in text LXI H,I ;ADDRESS INDEX *- Up another line MVI M, 1 ;SET TO 1 FOR FIRST ITERATION *KT Kill line and type next line LXI H,I ;ADDRESS INDEX *I Insert new line MVI M,0 ;ADDRESS INDEX *NJNC^Z0T JNC*T CONT *-2DIC^Z0LT JC CONT ;CONTINUE IF I <=(N-2) ;CONTINUE IF I <= (N-2) *E A>ASM SORT.
3.7 A Sample Session A>DDT SORT.HEX CP/M Operating System Manual Test program changes 16K DDT VER 1.0 NEXT PC 015C 0000 -G100 *0118 -D148 Data sorted 0148 05 00 07 00 14 00 1E 00 ........ 0150 32 00 64 00 64 00 2C 01 E8 03 01 80 00 00 00 00 2.D.D..,......
3.7 A Sample Session CP/M Operating System Manual Section 4 CP/M Dynamic Debugging Tool 4.1 Introduction The DDT program allows dynamic interactive testing and debugging of programs generated in the CP/M environment. Invoke the debugger with a command of one of the following forms: DDT DDT filename.HEX DDT filename.COM where filename is the name of the program to be loaded and tested.
Following the sign-on message, DDT prompts you with the hyphen character, -, and waits for input commands from the console. You can type any of several singlecharacter commands, followed by a carriage return to execute the command. Each line of input can be line-edited using the following standard CP/M controls: Table 4-1.
4.1 Introduction CP/M Operating System Manual Table 4-2. (continued) Command Character Result A S enters assembly-language mnemonics with operands. substitutes memory values. T traces program execution. U untraced program monitoring. X examines and optionally alters the CPU state. The command character, in some cases, is followed by zero, one, two, or three hexadecimal values, which are separated by commas or single blank characters. All DDT numeric output is in hexadecimal form.
4.1 Introduction CP/M Operating System Manual 4.2 DDT Commands The individual commands are detailed below. In each case, the operator must wait for the hyphen prompt character before entering the command. If control is passed to a program under test, and the program has not reached a breakpoint, control can be returned to DDT by executing a RST 7 from the front panel.
4.2 DDT Commands CP/M Operating System Manual 4.2.2 The D (Display) Command The D command allows you to view the contents of memory in hexadecimal and ASCII formats. The D command takes the forms: D Ds Ds,f In the first form, memory is displayed from the current display address, initially 100H, and continues for 16 display lines.
4.2 DDT Commands CP/M Operating System Manual 4.2.4 The G (Go) Command A program is executed using the G command, with up to two optional breakpoint addresses. The G command takes the forms: G Gs Gs,b Gs,b,c G,b G,b,c The first form executes the program at the current value of the program counter in the current machine state, with no breakpoints set. The only way to regain control in DDT is through a RST 7 execution. The current program counter can be viewed by typing an X or XP command.
4.2 DDT Commands CP/M Operating System Manual where d is the stop address. The machine state can be examined at this point using the X (Examine) command. You must specify breakpoints that differ from the program counter address at the beginning of the G command. Thus, if the current program counter is 1234H, then the following commands: G,1234 G400,400 both produce an immediate breakpoint without executing any instructions. 4.2.
4.2 DDT Commands CP/M Operating System Manual 4.2.7 The M (Move) Command The M command allows block movement of program or data areas from one location to another in memory. The M command takes the form: Ms,f,d where s is the start address of the move, f is the final address, and d is the destination address. Data is first removed from s to d, and both addresses are incremented. If s exceeds f, the move operation stops; otherwise, the move operation is repeated. 4.2.
4.2 DDT Commands CP/M Operating System Manual Whenever the R command is issued, DDT responds with either the error indicator ? (file cannot be opened, or a checksum error occurred in a HEX file) or with a load message. The load message takes the form: NEXT PC nnnn pppp 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 specified). 4.2.
4.2 DDT Commands CP/M Operating System Manual 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 program breakpoint occurs. A breakpoint can be forced in the trace mode by typing a rubout character. The CPU state is displayed before each program step is taken in trace mode. The format of the display is the same as described in the X command.
4.2 DDT Commands CP/M Operating System Manual Table 4-3.
4.2 DDT Commands CP/M Operating System Manual In particular, the BDOS address at location 6H (address field of the JMP instruction at location 5H) is modified by DDT to address the base location of the DDT nucleus, which, in turn, contains a JMP instruction to the BDOS. Thus, programs that use this address field to size memory see the logical end of memory at the base of the DDT nucleus rather than the base of the BDOS.
4.
4.4 A Sample Program CP/M Operating System Manual A>ASM, SCAN CP/M ASSEMBLER - VER 1.
4.4 A Sample Program A>DDT SCAN. HEX CP/M Operating System Manual Start debugger using hex format machine code DDT VER 1.
4.4 A Sample Program CP/M Operating System Manual 0113 0116 0119 011A 011B 011C 011D 011E 0120 0121 0124 -A116 STA 0121 JMP 0000 STAX B A little more machine NOP code. Note that proINR B ram ends at location INX B 116 with a JMP to DCR B 0000. Remainder of MVI B, 01 listing is assembly of DCR B data. LXI D,2200 LXI H,0200 Enter in-line assembly mode to change the JMP to 0000 into a RST7, which will cause the program under test to return to DDT if 116H is ever executed.
4.4 A Sample Program CP/M Operating System Manual Trace one step again (note 08H in B) COZOMOEOIO A=00 B=0800 D=0000 H=0000 S=0100 P=0102 MVI C,00*0104 -T Trace again (Register C is cleared) COZOMEOIO A=00 B=0800 D=0000 H=0000 S=0100 P=0104 LXI H,0119*0107 -T3 Trace three steps COZOMOEOIO A=00 B=0800 D=0000 H=0119 S=0100 P=0107 MOV A,M COZOMOEOIO A=02 B=0800 D=0000 H=0119 S=0100 P=0100 SUB C COZOMOEOI1 A=02 B=0800 D=0000 H=0119 S=0100 P=0109 JNC 010D*010D -D119 Display memory starting at 119H.
4.4 A Sample Program CP/M Operating System Manual CPU state at end of U5 COZOMOE1I1 A=04 B=0600 D=0000 H=001B S=0100 P=0108 SUB C -G Run program from current PC until completion (in real-time) *0116 breakpoint at 116H, caused by executing RST 7 in machine code -X CPU state at end of program COZ1MOE1I1 A=00 B=0000 D=0000 H=0121 S=0100 P=0116 RST 07 -XP Examine and change program counter.
4.
4.4 A Sample Program CP/M Operating System Manual -L100 List some code 0100 0102 0104 0107 0108 0109 010C 010D 010E 010F 0112 -XP MVI B,08 MVI C,00 LXI H,0119 MOV A,M SUB C JC 010D Previous patch is present in X.COM MOV C,A INX H DCR B JNZ 0107 MOV A,C P=0100 -T10 Trace to see how patched version operates.
4.
4.
4.
4.4 A Sample Program 0111 0102 0104 0107 0108 0109 010C 010D 010E 0112 A108 MVI MVI LXI MOV SUB JC MOV INX JNZ MOV 0108 CPM C CP/M Operating System Manual B,08 C,00 H,0119 A,M C <-- This should have been a CMP so that register A 010D would not be destroyed C,A H 0107 A,C Hot pathc at 108H changes SUB to CMP 0109 -G0 Stop DDT for SAVE A>SAVE 1 SCAN.COM Save memory image DDT VER 1.
4.4 A Sample Program CP/M Operating System Manual *0116 -XC C1 -X C1Z1M0E1I1 A=06 B=0006 D=0000 H=0121 S=0100 P=0116 RST 07 -S121 Look at "large" - it appears to be correct. 0121 06 0122 00 0123 22 -G0 Stop DDT A>ED SCAN.ASM Re-edit the source program, and make both changes *NSUB *0LT CTRL-Z SUB C *SSUB^ZCMP^Z0LT CMP D * JNC NFOUND *SNC^ZC^Z0LT JC NFOUND *E ;LARGER VALUE IN C? ;LARGER VALUE IN C? ;JUMP IF LARGER VALUE NOT FOUND ;JUMP IF LARGER VALUE NOT FOUND A>ASM SCAN.
4.4 A Sample Program CP/M Operating System Manual A>DDT SCAN.HEX DDT VER 1.0 NEXT PC 0121 0000 -L116 -116 JMP 0000 0119 STAX B Check to ensure end is still at 116H 011A NOP 011B INR B -(rubout) -G100,116 Go from beginning with breakpoint at end *0116 -D121 Breakpoint reached Look at "LARGE" 0121 06 00 22 21 00 02 7e 77 12 23 eb 0b 78 b1 .. '!... W .#..X. 0130 c2 27 01 c3 03 29 00 00 00 00 00 00 00 00 00 00 .'...)........ 0140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Section 5 CP/M 2 System Interface 5.1 Introduction This chapter describes CP/M (release 2) system organization including the structure of memory and system entry points. This section provides the information you need to write programs that operate under CP/M and that use the peripheral and disk I/O facilities of the system.
5.1 Introduction High Memory FBASE: CBASE: TBASE: BOOT: CP/M Operating System Manual +---------------------------------+ | | | FDOS (BDOS + BIOS) | | | +---------------------------------+ | | | CCP | | | +---------------------------------+ | | | TPA | | | +---------------------------------+ | | | SYSTEM PARAMETERS | | | +---------------------------------+ Figure 5-1.
5.1 Introduction CP/M Operating System Manual Transient programs are loaded into the TPA and executed as follows. The operator communicates with the CCP by typing command lines following each prompt. Each command line takes one of the following forms: command command file1 command file1 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.
5.1 Introduction CP/M Operating System Manual 5.2 Operating System Call Conventions This section provides detailed information for performing direct operating system calls from user programs. Many of the functions listed below, however, are accessed more simply through the I/O macro library provided with the MAC macro assembler and listed in the Digital Research manual entitled, "Programmer's Utilities Guide for the CP/M Family of Operating Systems.
5.
5.2 Call Conventions CP/M Operating System Manual 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 (most transients return to the CCP through a jump to location 0000H) it is large enough to make CP/M system calls because the FDOS switches to a local stack at system entry.
5.2 Call Conventions CP/M Operating System Manual Table 5-1.
5.2 Call Conventions CP/M Operating System Manual 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 divided into 16K byte segments called logical extents, so that counters are easily maintained as 8-bit values.
5.2 Call Conventions CP/M Operating System Manual The following table lists and describes each of the fields in the File Control Block figure. Table 5-2. File Control Block Fields Field dr Definition drive code (0-16) 0 = use default drive for file 1 = auto disk select drive A, 2 = auto disk select drive B, ... 16 = auto disk select drive P. f1...f8 contain the filename in ASCII upper-case, with high bit = 0 t1,t2,t3 contain the filetype in ASCII upper-case, with high bit = 0.
5.2 Call Conventions CP/M Operating System Manual 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 16 bytes of the FCB and initialize the cr field. Normally, bytes 1 through 11 are set to the ASCII character values for the filename and filetype, while all other fields are zero.
5.2 Call Conventions CP/M Operating System Manual 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 line, the area beginning at BOOT+0080H is initialized as follows: BOOT+0080H: +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 + A + B + C + D + E E '' 'B' ':' 'X' '.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 1: CONSOLE INPUT Entry Parameters: RegisterC: 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 back space (CTRL-H) are echoed to the console. Tab characters, CTRL-I, move the cursor to the next tab stop. A check is made for start/stop scroll, CTRL-S, and start/stop printer echo, CTRL-P.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 3: READER INPUT Entry Parameters: Register C: 03H Returned 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 Section 6. Control does not return until the character has been read.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 5: LIST OUTPUT Entry Parameters: Register C: 05H Register E: ASCII Character The List Output function sends the ASCII character in register E to the logical listing device.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 7: GET 1/0 BYTE Entry Parameters: Register C: 07H Returned Value: Register A: 1/0 Byte Value The Get I/O Byte function returns the current value of IOBYTE in register A. See Section 6 for IOBYTE definition. FUNCTION 8: SET I/0 BYTE Entry Parameters: Register C: 08H Register E: 1/0 Byte Value The SET I/O Byte function changes the IOBYTE value to that given in register E.
5.2 Call Conventions CP/M Operating System Manual Entry Parameters: Register C: OAH Registers DE: 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 input buffer overflows or a carriage return or line-feed is typed. The Read Buffer takes the form: DE: +0 +1 +2 +3 +4 +5 +6 +7 +8 ... +n mx nc cl c2 c3 c4 c5 c6 c7 ...
5.2 Call Conventions CP/M Operating System Manual Table 5-3. (continued) Character Edit Control Function CTRL-M (return) terminates input line CTRL-R retypes the current line after new line CTRL-U removes current line CTRL-X same as CTRL-U The user should also note that certain functions that return the carriage to the leftmost position (for example, CTRL-X) do so only to the column position where the prompt ended. In earlier releases, the carriage returned to the extreme left margin.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 12: RETURN VERSION NUMBER Entry Parameters: Register C: 0CH Returned Value: Registers HL: Version Number Function 12 provides information that 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.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 14: SELECT DISK Entry Parameters: Register C: 0EH Register E: 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 on through 15, corresponding to drive P in a full 16 drive system.
5.2 Call Conventions CP/M Operating System Manual If a directory element is matched, the relevant directory information is copied into bytes d0 through dn of FCB, thus allowing access to the files through subsequent read and write operations. The user should note that an existing file must not be accessed until a successful open operation is completed.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 17: SEARCH FOR FIRST Entry Parameters: RegisterC: 11H Registers DE: FCB Address Returned Value: Register A: 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.
5.2 Call Conventions CP/M Operating System Manual 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.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 20: READ SEQUENTIAL Entry Parameters: Register C: 14H Registers DE: FCB Address Returned Value: Register A: Directory Code Given that the FCB addressed by DE has been activated through an Open or Make function, the Read Sequential function reads the next 128-byte record from the file into memory at the current DMA address.
5.2 Call Conventions CP/M Operating System Manual FUNCTION21: WRITE SEQUENTIAL Entry Parameters: Register C: 15H Registers DE: FCB Address Returned Value: Register A: Directory Code Given that the FCB addressed by DE has been activated through an Open or Make function, the Write Sequential function writes the 128-byte data record at the current DMA address to the file named by the FCB.
5.2 Call Conventions CP/M Operating System Manual 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 that does not exist in the currently referenced disk directory (that is, the one named explicitly by a nonzero dr code or the default disk if dr is zero).
5.2 Call Conventions CP/M Operating System Manual FUNCTION 24: RETURN LOG-IN VECTOR Entry Parameters: Register C: 18H Returned Value: Registers HL: Log-in Vector The log-in 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, labeled P.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 26: SET DMA ADDRESS Entry Parameters: Register C: 1AH Registers DE: DMA Address DMA is an acronym for Direct Memory Address, which is often used in connection with disk controllers that directly access the memory of the mainframe computer to transfer data to and from the disk subsystem.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 28: WRITE PROTECT DISK Entry Parameters: Register C: I CH The Write Protect Disk function provides temporary write protection for the currently selected disk.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 30: SET FILE ATTRIBUTES Entry Parameters: Register C: 1EH Registers DE: FCB Address Returned Value: Register A: Directory Code The Set File Attributes function allows programmatic manipulation of permanent indicators attached to files. In particular, the R/O and System attributes (t1' and t2') can be set or reset. The DE pair addresses an unambiguous filename with the appropriate attributes set or reset.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 32: SET/GET USER CODE Entry Parameters: Register C: 20H Register E: OFFH (get) or 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, the value of the current user number is returned in register A, where the value is in the range of 0 to 15.
5.2 Call Conventions CP/M Operating System Manual Thus, the r0, r1 byte pair is treated as a double-byte, or word value, that contains the record to read. This value ranges from 0 to 65535, providing access to any particular record of the 8-megabyte file. To process a file using random access, the base extent (extent 0) must first be opened.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 34: WRITE RANDOM Entry Parameters: Register C: 22H Registers DE: FCB Address Returned Value: Register A: Return Code The Write Random operation is initiated similarly 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 that is the target of the write has not yet been allocated, the allocation is performed before the write operation continues.
5.2 Call Conventions CP/M Operating System Manual 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, r1, and r2 are present). The FCB contains an unambiguous filename that is used in the directory scan.
5.2 Call Conventions CP/M Operating System Manual 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 automatically to produce the random record position from a file that has been read or written sequentially to a particular point. The function can be useful in two ways.
5.2 Call Conventions CP/M Operating System Manual FUNCTION 37: RESET DRIVE Entry Parameters: Register C: 25H Registers DE: Drive Vector Returned Value: Register A: 00H The Reset Drive function allows resetting of specified drives. The passed parameter is a 16-bit vector of drives to be reset; the least significant bit is drive A:. To maintain compatibility with MP/M, CP/M returns a zero value.
5.2 Call Conventions CP/M Operating System Manual 5.3 A Sample File-to-File Copy Program The following program 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 used to produce a COPY.COM file that executes directly under the CCP.
5.3 A Sample Copy Program 0016 = makef CP/M Operating System Manual equ 22; make file func# ; 0100 org tpa ; beginning of tpa 0100 311902 lxi sp,stack ; set local stack 0103 0E10 mvi c,16 ; half an fcb 0105 116C00 lxi d,fcb2 ; source of move 0108 21D901 lxi h,dfcb ; destination fcb 010B 1A mfcb: ldax d ; source fcb 010C 13 inx d ; ready next 010D 77 mov m,a ; dest fcb 010E 23 inx h ; ready next 010F 0D dcr c ; count 16...
5.
5.
5.3 A Sample Copy Program CP/M Operating System Manual 5.4 A Sample File Dump Utility The following file dump program is slightly more complex than the simple copy program given in the previous section. The dump program reads an input file, specified in the CCP command line, and displays the content of each record in hexadecimal format at the console.
5.
5.
5.
5.
5.
5.4 A Sample File Dump Utility CP/M Operating System Manual 5.5 A Sample Random Access Program This section concludes with an extensive example of random access operation. The program listed below performs the simple function of reading or writing random records upon command from the terminal. When a program has been created, assembled, and placed into a file labeled R A N D 0 M . C 0 M , the CCP level command RANDOM X. DAT starts the test program. The program looks for a file by the name X .
5.5 A Sample Random Access Program CP/M Operating System Manual Sample Random Access Program for CP/M 2.
5.
5.
5.
5.
5.
5.5 A Sample Random Access Program CP/M Operating System Manual 0254 6572726F72errmsg: db 'error, try again.$' 0266 6E65787420prompt: db 'next command? $' ; ; fixed and variable data area ; 0275 21 conbuf: db conlen ; length of console buffer 0276 consiz: ds 1 ; resulting size after read 0277 conlin: ds 32 ; length 32 buffer 0021 = conlen equ $-consiz ; 0297 ds 32 stack: 02B7 end Major improvements could be made to this particular program to enhance its operation.
5.5 A Sample Random Access Program CP/M Operating System Manual Instead of reading a number, the QUERY program reads an alphanumeric string that is a particular key to find in the N A M E S . D A T data base. Because the L A S T N A M E . K E Y list is sorted, one can find a particular entry rapidly by performing a binary search, similar to looking up a name in the telephone book.
5.
5.5 System Function Summary Function Number 34 35 36 37 38 39 40 22 23 24 25 26 27 28 CP/M Operating System Manual Function Name Input Output Write Random Compute File SIze Set Random Record Reset Drive Access Drive Free Drive Write Random w/Fill DE = FCB address DE = FCB address DE = FCB address DE = Drive Vector not supported not supported DE = FCB A = error Code r0, r1, r2 r0, r1, r2 A=0 *Note that A=L, and B=H upon return.
5.5 System Function Summary CP/M Operating System Manual Section 6 CP/M 2 Alteration 6.1 Introduction The standard CP/M system assumes operation on an Intel MDS-800 microcomputer development system, but is designed so you can alter a specific set of subroutines that define the hardware operating environment.
6.1 Introduction CP/M Operating System Manual File expansion is achieved by providing up to 512 logical file extents, where each logical extent contains 16K bytes of data. CP/M 2 is structured, however, so that as much as 128K bytes of data are addressed by a single physical extent, corresponding to a single directory entry, iuaintaining compatibility with previous versions while taking advantage of directory space.
6.1 Introduction CP/M Operating System Manual 6.2 First-level System Regeneration The procedure to patch the CP/M system is given below. Address references in each step are shown with H denoting the hexadecimal radix, and are given for a 20K CP/M system. For larger CP/M systems, a bias is added to each address that is shown with a +b following it, where b is equal to the memory size-20K. Values for b in various standard memory sizes are listed in Table 6-1. Table 6-1.
6.2 First-level Regeneration CP/M Operating System Manual 3. Run the GETSYS program using an initialized CP/M disk to see if GETSYS loads CP/M starting at 3380H (the operating system actually starts 128 bytes later at 3400H). 4. Read Section 6.4 and write the PUTSYS program. This writes memory starting at 3380H back onto the first two tracks of the disk. The PUTSYS program should be located at 200H, as shown in Appendix C. 5.
6.2 First-level Regeneration CP/M Operating System Manual 11. Upon completion of step 10, CP/M has prompted the console for a command input. To test the disk write operation, type SAVE 1 X.COM All commands must be followed by a carriage return. CP/M responds with another prompt after several disk accesses: A> If it does not, debug the disk write functions and retry. 12. 13. Test the directory command by typing DIR CP/M responds with A:X COM Test the erase command by typing ERA X.
6.2 First-level Regeneration 18. CP/M Operating System Manual Load and test the debugger by typing DDT See Section 4 for operating procedures. 19. and Before making further CBIOS modifications, practice using the editor (see Section 2), assembler (see Section 3). Recode and test the GETSYS, PUTSYS, and CBIOS programs using ED, ASM, and DDT. Code and test a COPY program that does a sector-to-sector copy from one disk to another to obtain back-up copies of the original disk.
6.2 First-level Regeneration CP/M Operating System Manual To get the memory image of CP/M into the TPA configured for the desired memorv size, type the command: MOVCPM xx* where xx is the memory size in decimal K bytes, for example, 32 for 32K. The response is as follows: CONSTRUCTING xxK CP/M VERS 2.0 READY FOR "SYSGEN" OR "SAVE 34 CPMxx.COM" An image of CP/M in the TPA is configured for the requested memory size.
6.3 Second-level Regeneration CP/M Operating System Manual 3400H + n = 980H, or n = 980H - 3400H Assuming two's complement arithmetic, n = D580H, which can be checked by 3400H+D580H = 10980H = 0980H (ignoring high-order overflow). Note that for larger systems, n satisfies (3400H + b) + n = 980H, or n = 980H - (3400H + b), or n = D580H - b The value of n for common CP/M systems is given below. Table 6-2.
6.3 Second-level Regeneration CP/M Operating System Manual If you want to locate the address x within the memory image loaded under DDT in a 20K systei-n, first type Hx,n Hexadecimal sum and difference and DDT responds with the value of x + n (sum) and x - n (difference). The first number printed by DDT is the actual memory address in the image where the data or code is located.
6.3 Second-level Regeneration CP/M Operating System Manual Examine the CBOOT with L900 You are now ready to replace the CBIOS by examining the area at 1F80H, where the original version of the CBIOS resides, and then typing ICBIOS.HEX Ready the hex file for loading. Assume that the CBIOS is being integrated into a 20K CP/M system and thus originates at location 4A00H. To locate the CBIOS properly in the memory image under DDT, you must apply the negative bias n for a 20K system when loading the hex file.
6.3 Second-level Regeneration CP/M Operating System Manual Place the scratch disk in drive A, then perform a cold start to bring up the newlyconfigured CP/M system. The new CP/M system is then tested and the Digital Research copyright notice is placed on the disk, as specified in the Licensing Agreement: Copyright (c), 1979 Digital Research 6.4 Sample GETSYS and PUTSYS Programs The following program provides a framework for the GETSYS and PUTSYS programs referenced in Sections 6.1 and 6.2.
6.
6.4 Sample GETSYS and PUTSYS CP/M Operating System Manual This program is assembled and listed in Appendix B for reference purposes, with an assumed origin of 100H. The hexadecimal operation codes that are listed on the left might be useful if the program has to be entered through the panel switches. The PUTSYS program can be constructed from GETSYS by changing only a few operations in the GETSYS program given above, as shown in Appendix C.
6.5 Disk Organization CP/M Operating System Manual Table 6-3.
6.5 Disk Organization CP/M Operating System Manual Table 6-3. CP/M Disk Sector Allocation Track Sector Page # ' ' ' 01 07 ' ' ' ' 01 01 02-76 16 20 17 ' 18 21 19 ' 20 22 21 ' 22 23 23 ' 24 24 25 ' 26 25 01-26 Memory Address 4800H + b 4880H + b 4900H + b 4980H + b 4A00H + b 4A80H + b 4B00H + b 4B80H + b 4C00H + b 4C80H + b 4D00H + b CP/M Module name BDOS BIOS BIOS BIOS (directory and data) 6.6 The BIOS Entry Points The entry points into the BIOS from the cold start loader and BDOS are detailed below.
6.
6.6 BIOS Entry Points CP/M Operating System Manual 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 CTRL-Z (1AH). Peripheral devices are seen by CP/M as logical devices and are assigned to physical devices within the BIOS. To operate, the BDOS needs only the CONST, CONIN, and CONOUT subroutines.
6.6 BIOS Entry Points CP/M Operating System Manual The 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-physical device mapping that 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 in the following figure.
6.6 BIOS Entry Points CP/M Operating System Manual Table 6-4.
6.6 BIOS Entry Points CP/M Operating System Manual The READ and WRITE routines should perform several retries (10 is standard) before reporting the error condition to the BDOS. If the error condition is returned to the BDOS, it reports the error to the user.
6.6 BIOS Entry Points CP/M Operating System Manual Table 6-5. (continued) Entry Point Function location 5,6,7 Set to JMP BDOS, which is the primary entry point to CP/M for transient programs. (0005H: JMP 3C06H + b) Refer to Section 6.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 restart the system. Upon entry to the CCP, register C is set to the drive to select after system initialization.
6.6 BIOS Entry Points CP/M Operating System Manual Table 6-5. (continued) Entry Point Function HOME The disk head of the currently selected disk (initially disk A) is moved to the track 00 position. If the controller allows access to the track 0 flag from the drive, the head is stepped until the track 0 flag is detected. If the controller does not support this feature, the HOME call is translated into a call to SETTRK with a parameter of 0.
6.6 BIOS Entry Points CP/M Operating System Manual Table 6-5. (continued) Entry Point Function SETSEC Register BC contains the sector number, 1 through 26, for subsequent disk accesses on the currently selected drive. The sector number in BC is the same as the number returned from the SECTRAN entry point. You can choose to send this information to the controller at this point or delay sector selection until a read or write operation occurs.
6.6 BIOS Entry Points CP/M Operating System Manual Table 6-5. (continued) Entry Point Function WRITE Data is written from the currently selected DMA address to the currently selected drive, track, and sector. For floppy disks, the data should be marked as nondeleted data to maintain compatibility with other CP/M systems. The error codes given in the READ command are returned in register A, with error recovery attempts as described above.
6.6 BIOS Entry Points CP/M Operating System Manual 6.7 A Sample BIOS The program shown in Appendix B can serve as a basis for your first BIOS. The simplest functions are assumed in this BIOS, so that you can enter it through a front panel, if absolutely necessary. You must alter and insert code into the subroutines for CONST, CONIN, CONOUT, READ, WRITE, and WAITIO subroutines. Storage is reserved for user-supplied code in these regions. The scratch area reserved in page zero (see Section 6.
6.7 A Sample BIOS CP/M Operating System Manual 6.9 Reserved Locations in Page Zero Main memory page zero, between locations 0H and 0FFH, contains several segments of code and data that are used during CP/M processing. The code and data areas are given in the following table. Table 6-6. Reserved Locations in Page Zero Locations Contents 0000H-0002H Contains a jump instruction to the warm start entry location 4A03H+b.
6.9 Reserved Locations in Page Zero CP/M Operating System Manual Table 6-6. (continued) Locations Contents 0040H-004FH A 16-byte area reserved for scratch by CBIOS, but is not used for any purpose in the distribution version of CP/M. 0050H-005BH Not currently used; reserved. 005CH-007CH Default File Control Block produced for a transient program by the CCP. 007DH-007FH Optional default random record position.
6.9 Reserved Locations in Page Zero CP/M Operating System Manual 6.10 Disk Parameter Tables Tables are included in the BIOS that 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 B, or automatically generated using the DISKDEF macro library, as shown in Appendix F. The purpose here is to describe the elements of these tables.
6.10 Disk Parameter Tables CP/M Operating System Manual Table 6-7. (continued) Disk Parameter Header Meaning DPB Address of a disk parameter block for this drive. Drives withidentical disk characteristics address the same disk parameter block. CSV Address of a scratch pad area used for software check for changed disks. This address is different for each DPH. ALV Address of a scratch pad area used by the BDOS to keep disk storage allocation information. This address is different for each DPH.
6.10 Disk Parameter Tables CP/M Operating System Manual 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 .......
6.10 Disk Parameter Tables CP/M Operating System Manual The following field abbreviations are used in Figure 6-4: -SPT is the total number of sectors per track. -BSH is the data allocation block shift factor, determined by the data block allocation size. -BLM is the data allocation block mask (2[BSH-1]). -EXM is the extent mask, determined by the data block allocation size and the number of disk blocks. -DSM determines the total storage capacity of the disk drive.
6.10 Disk Parameter Tables CP/M Operating System Manual Table 6-9. EXM Values EXM values BLS DSM<256 DSM>255 1,024 2,048 4,096 8,192 16,384 0 1 3 7 15 N/A 0 1 3 7 The value of DSM is the maximum data block number supported by this particular drive, measured in BLS units. The product (DSM + 1) is the total number of bytes held by the drive and must be within the capacity of the physical disk, not counting the reserved operating system tracks.
6.10 Disk Parameter Tables CP/M Operating System Manual Position 00 corresponds to the high-order bit of the byte labeled AL0 and 15 corresponds to the low-order bit of the byte labeled AL1. 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 tabulation: Table 6-10.
6.10 Disk Parameter Tables CP/M Operating System Manual 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 + 1)/4, you must reserve (DRM + 1)/4 bytes for directory check use. If CKS = 0, no storage is reserved. The size of the area addressed by ALV is determined by the maximum number of data blocks allowed for this particular disk and is computed as (DSM/8) + 1.
6.10 Disk Parameter Tables CP/M Operating System Manual The remaining portion of the 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 that are located in memory above the BIOS. The DISKDEF macro call takes the form: DISKDEF dn,fsc,lsc,[skf],bls dks,dir,cks,ofs,[0] where -dn is the logical disk number, 0 to n - 1. -fsc is the first physical sector number (0 or 1).
6.11 The DISKDEF Macro Library CP/M Operating System Manual 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.
6.11 The DISKDEF Macro Library CP/M Operating System Manual The DISKS macro generates n DPHS, 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.
6.11 The DISKDEF Macro Library CP/M Operating System Manual Following the ENDEF macro call, a number of uninitialized data areas are defined. These data areas need not be a part of the BIOS that is loaded upon cold start, but must be available between the BIOS and the end of memory. The size of the uninitialized RAM area is determined by EQU statements generated by the ENDEF macro.
6.11 The DISKDEF Macro Library CP/M Operating System Manual Three examples of DISKDEF macro invocations are shown below with corresponding STAT parameter values. The last example produces a full 8-megabyte system. 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=16348, k=2048, d=300, c=0, e=128, b=16, s=58, t=2 DISKDEF 0,1,58,,16348,512,128,128,2 r=65536, k=8192, d=128, c=128, e=1024, b=128, s=58, t=2 6.
6.11 The DISKDEF Macro Library CP/M Operating System Manual 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 that is the size of the host disk sector.
6.11 The DISKDEF Macro Library ; ; ; ; ; 0016 = MDS-800 I/O DRIVERS FOR CP/M 2.2 (FOUR DRIVE SINGLE DENSITY VERSION) VERSION 2.2 FEBRUARY, 1980 VERS ; ; ; ; ; ; ; FFFF = 0000 = 0000 = CP/M Operating System Manual EQU 22 ;VERSION 2.
Appendix A : The MDS-800 BIOS CP/M Operating System Manual ; 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) ; HOME MOVE TO TRACK 00 ; ; (THE FOLLOWING CALLS SET-UP THE IO PARAMETER BLOCK FOR ; THE ; MDS, WHICH IS USED TO PERFORM SUBSEQUENT READS AND ; WRITES) ; SELDSK SELECT DISK GIVEN BY REG-C (0,1,2...
Appendix A : The MDS-800 BIOS 1633+= DPBASE 1633+82160000 DPE0: 1637+00000000 163B+6E187316 163F+0D19EE18 1643+82160000 DPE1: 1647+00000000 164B+6E187316 164F+3C191D19 1653+82160000 DPE2: 1657+00000000 165B+6E187316 165F+6B194C19 1663+82160000 DPE3: 1667+00000000 166B+6E187316 166F+9A197B19 1673+= DPB0 1673+1A00 1675+03 1676+07 1677+00 DB 1678+F200 167A+3F00 167C+C0 167D+00 167E+1000 1680+0200 1682+= XLT0 1682+01 1683+07 1684+0D 1685+13 1686+19 1687+05 1688+0B DB 1689+11 168A+17 168B+03 DB 168C+09 DB 168D+
Appendix A : The MDS-800 BIOS 1690+08 1691+0E 1692+14 1693+1A 1694+06 1695+0C 1696+12 1697+18 1698+04 1699+0A 169A+10 169B+16 1673+= 001F+= 0010+= 1682+= 1673+= 001F+= 0010+= 1682+= 1673+= 001F+= 0010+= 1682+= ; ; ; ; ; ; ; ; ; ; ; ; ; ; 00FD = 00FC = 00F3 = 007E = CP/M Operating System Manual DB 8 DB 14 DB 20 DB 26 DB 6 DB 12 DB 18 DB 24 DB 4 DB 10 DB 16 DB 22 DISKDEF 1,0 DPB1 EQU DPB0 ;EQUIVALENT PARAMETERS ALS1 EQU ALS0 ;SAME ALLOCATION VECTOR SIZE CSS1 EQU CSS0 ;SAME CHECKSUM VECTOR SIZE XLT1 EQU XLT0
Appendix A : The MDS-800 BIOS CP/M Operating System Manual ;(MONITOR) ; ; F800 = FF0F = F803 = F806 = F809 = F80C = F80F = F812 = ; ; 0078 = 0078 = 0079 = 007B = MDS MONITOR EQUATES MON80 EQU 0F800H ;MDS MONITOR RMON80 EQU 0FF0FH ;RESTART MON80 (BOOT ERROR) CI EQU 0F803H ;CONSOLE CHARACTER TO REG-A RI EQU 0F806H ;READER IN TO REG-A CO EQU 0F809H ;CONSOLE CHAR FROM C TO ;CONSOLE OUT PO EQU 0F80CH ;PUNCH CHAR FROM C TO PUNCH DEVICE LO EQU 0F80FH ;LIST FROM C TO LIST DEVICE CSTS EQU 0F812H ;CONSOLE STATUS 0
Appendix A : The MDS-800 BIOS CP/M Operating System Manual 16B6 219C16 LXI H,SIGNON 16B9 CDD317 CALL PRMSG ;PRINT MESSAGE 16BC AF XRA A ;CLEAR ACCUMULATOR 16BD 320400 STA CDISK ;SET INITIALLY TO DISK A 16C0 C30F17 JMP GOCPM ;GO TO CP/M ; ; WBOOT:; LOADER ON TRACK 0, SECTOR 1, WHICH WILL BE SKIPPED FOR WARM ; READ CP/M FROM DISK - ASSUMING THERE IS A 128 BYTE COLD START ; START.
Appendix A : The MDS-800 BIOS CP/M Operating System Manual ; MUST BE SECTOR 26, ZERO AND GO TO NEXT TRACK 16FC 3A6A18 LDA IOT ;GET TRACK TO REGISTER A 16FF 3C INR A 1700 4F MOV C,A ;READY FOR CALL 1701 CDA717 CALL SETTRK 1704 AF XRA A ;CLEAR SECTOR NUMBER 1705 3C RD1: INR A ;TO NEXT SECTOR 1706 4F MOV C,A ;READY FOR CALL 1707 CDAC17 CALL SETSEC 170A C1 POP B ;RECALL SECTOR COUNT 170B 05 DCR B ;DONE? 170C C2E116 JNZ RDSEC ; ; DONE WITH THE LOAD, RESET DEFAULT BUFFER ADDRESS GOCPM: ;(ENTER HERE FROM COLD ST
Appendix A : The MDS-800 BIOS CP/M Operating System Manual ; PREVIOUSLY SELECTED DISK WAS B, SEND PARAMETER TO CPM 1741 3A0400 LDA CDISK ;LAST LOGGED DISK NUMBER 1744 4F MOV C,A ;SEND TO CCP TO LOG IT IN 1745 FB EI 1746 C30000 JMP CPMB ; ; ERROR CONDITION OCCURRED, PRINT MESSAGE AND RETRY BOOTERR: 1749 C1 POP B ;RECALL COUNTS 174A 0D DCR C 174B CA5217 JZ BOOTER0 ; TRY AGAIN 174E C5 PUSH B 174F C3C916 JMP WBOOT0 ; BOOTER0: ; OTHERWISE TOO MANY RETRIES 1752 215B17 LXI H,BOOTMSG 1755 CDD317 CALL PRMSG 1758 C
Appendix A : The MDS-800 BIOS CP/M Operating System Manual ; PUNCH: ;PUNCH DEVICE OUT ; (EXACTLY THE SAME AS MDS CALL) 1772 C30CF8 JMP PO ; READER: ;READER CHARACTER IN TO REG-A ; (EXACTLY THE SAME AS MDS CALL) 1775 C306F8 JMP RI ; HOME: ;MOVE TO HOME POSITION ; TREAT AS TRACK 00 SEEK 1778 0E00 MVI C,0 177A C3A717 JMP SETTRK ; SELDSK: ;SELECT DISK GIVEN BY REGISTER C 177D 210000 LXI H,0000H ;RETURN 0000 IF ERROR 1780 79 MOV A,C 1781 FE04 CPI NDISKS ;TOO LARGE? 1783 D0 RNC ;LEAVE HL = 0000 ; 1784 E602 ANI
Appendix A : The MDS-800 BIOS CP/M Operating System Manual ; SETTRK: ;SET TRACK ADDRESS GIVEN BY C 17A7 216A18 LXI H,IOT 17AA 71 MOV M,C 17AB C9 RET ; SETSEC: ;SET SECTOR NUMBER GIVEN BY C 17AC 216B18 LXI H,IOS 17AF 71 MOV M,C 17B0 C9 RET SECTRAN: ;TRANSLATE SECTOR BC USING TABLE AT DE 17B1 0600 MVI B,0 ;DOUBLE PRECISION SECTOR NUMBER IN BC 17B3 EB XCHG ;TRANSLATE TABLE ADDRESS TO HL 17B4 09 DAD B ;TRANSLATE(SECTOR) ADDRESS 17B5 7E MOV A,M ;TRANSLATED SECTOR NUMBER TO A 17B6 326B18 STA IOS 17B9 6F MOV L,A
Appendix A : The MDS-800 BIOS CP/M Operating System Manual 17D5 C8 RZ ; MORE TO PRINT 17D6 E5 PUSH H 17D7 4F MOV C,A 17D8 CD6A17 CALL CONOUT 17DB E1 POP H 17DC 23 INX H 17DD C3D317 JMP PRMSG ; SETFUNC: ; SET FUNCTION FOR NEXT I/O (COMMAND IN REG-C) 17E0 216818 LXI H,IOF ;IO FUNCTION ADDRESS 17E3 7E MOV A,M ;GET IT TO ACCUMULATOR FOR MASKING 17E4 E6F8 ANI 11111000B ;REMOVE PREVIOUS COMMAND 17E6 B1 ORA C ;SET TO NEW COMMAND 17E7 77 MOV M,A ;REPLACED IN IOPB ; THE MDS-800 CONTROLLER REQUIRES DISK BANK BIT I
Appendix A : The MDS-800 BIOS CP/M Operating System Manual 180E D38A OUT IHIGH+10H ; 1810 CD5918 WAIT0: CALL INSTAT ;WAIT FOR COMPLETION 1813 E604 ANI IORDY ;READY? 1815 CA1018 JZ WAIT0 ; ; CHECK IO COMPLETION OK 1818 CD3F18 CALL INTYPE ;MUST BE IO COMPLETE (00) UNLINKED ; 00 UNLINKED I/O COMPLETE, 01 LINKED I/O COMPLETE (NOT USED) ; 10 DISK STATUS CHANGED 11 (NOT USED) 181B FE02 CPI 10B ;READY STATUS CHANGE? 181D CA3218 JZ WREADY ; ; MUST BE 00 IN THE ACCUMULATOR 1820 B7 ORA A 1821 C23818 JNZ WERROR ;SOM
Appendix A : The MDS-800 BIOS CP/M Operating System Manual ; (ACCUMULATOR BITS ARE NUMBERED 7 6 5 4 3 2 1 0) ; ; IT MAY BE USEFUL TO FILTER OUT THE VARIOUS CONDITIONS, ; BUT WE WILL GET A PERMANENT ERROR MESSAGE IF IT IS NOT ; RECOVERABLE.
Appendix A : The MDS-800 BIOS IOPB: CP/M Operating System Manual ;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 ;IO ADDRESS 1867 80 1868 04 IOF: 1869 01 ION: 186A 02 IOT: 186B 01 IOS: 186C 8000 IOD: ; ; ; DEFINE RAM AREAS FOR BDOS OPERATION ENDEF 186E+= BEGDAT EQU $ 186E+ DIRBUF: DS 128 ;DIRECTORY ACCESS BUFFER 18EE+ ALV0: DS 31 190D+ CSV0: DS 16 191D+ ALV1: DS 31 193C+ CSV1: DS 16 19
Appendix A : The MDS-800 BIOS CP/M Operating System Manual ; skeletal cbios for first level of CP/M 2.0 alteration ; msize equ 20 ;cp/m version memory size in kilobytes ; ; "bias" is address offset from 3400h for memory systems ; than 16k (referred to as"b" throughout the text) ; bias equ (msize-20)*1024 ccp equ 3400h+bias ;base of ccp bdos equ ccp+806h ;base of bdos bios equ ccp+1600h ;base of bios cdisk equ 0004h ;current disk number 0=a,...
Appendix B : A Sekletal CBIOS ; ; ; CP/M Operating System Manual disk parameter header for disk 01 dw trans, 0000h dw 0000h, 0000h dw dirbf, dpblk dw chk01, all01 disk parameter header for disk 02 dw trans, 0000h dw 0000h, 0000h dw dirbf, dpblk dw chk02, all02 disk parameter header for disk 03 dw trans, 0000h dw 0000h, 0000h dw dirbf, dpblk dw chk03, all03 ; ; sector translate vector trans: db 1, 7, 13, 19 ;sectors 1, 2, 3, 4 db 25, 5, 11, 17 ;sectors 5, 6, 7, 6 db 23, 3, 9, 15 ;sectors 9, 10, 11, 12 d
Appendix B : A Sekletal CBIOS CP/M Operating System Manual ; wboot: ;simplest case is to read the disk until all sectors loaded lxi sp, 80h ;use space below buffer for stack mvi c, 0 ;select disk 0 call seldsk call home ;go to track 00 ; mvi b, nsects ;b counts * of sectors to load mvi c, 0 ;c has the current track number mvi d, 2 ;d has the next sector to read ; note that we begin by reading track 0, sector 2 since sector 1 ; contains the cold start loader, which is skipped in a warm start lxi h, ccp ;ba
Appendix B : A Sekletal CBIOS inr ; ; save c CP/M Operating System Manual ;track=track+1 register state, and change tracks push b push d push h call settrk ;track address set from register c pop h pop d pop b jmp load1 ;for another sector ; ; end of load operation, set parameters and go to cp/m gocpm: mvi a, 0c3h ;c3 is a jmp instruction sta 0 ;for jmp to wboot lxi h, wboote ;wboot entry point shld 1 ;set address field for jmp at 0 ; sta 5 ;for jmp to bdos lxi h, bdos ;bdos entry point shld 6 ;address
Appendix B : A Sekletal CBIOS ; conout: ; list: CP/M Operating System Manual ;console character output from register c mov a, c ;get to accumulator ds 10h ;space for output routine ret ;list character from register c mov a, c ;character to register a ret ;null subroutine ; listst: ;return list status (0 if not ready, 1 if ready) xra a ;0 is always ok to return ret ; punch: ;punch character from register C mov a, c ;character to register a ret ;null subroutine ; ; reader: ;reader character into register
Appendix B : A Sekletal CBIOS mov mvi dad dad dad dad lxi dad ret l, a h, 0 h h h h d, dpbase 0 CP/M Operating System Manual ;l=disk number 0, 1, 2, 3 ;high order zero ;*2 ;*4 ;*8 ;*16 (size of each header) ;hl=,dpbase (diskno*16) ; settrk: ;set track given by register c mov a, c sta track ds 10h ;space for track select ret ; setsec: ;set sector given by register c mov a, c sta sector ds 10h ;space for sector select ret ; ; sectran: ;translate the sector given by bc using the ;translate table given by de
Appendix B : A Sekletal CBIOS CP/M Operating System Manual write: ;perform a write operation ds 10h ;set up write command ; waitio: ;enter here from read and write to perform the actual i/o ; operation.
Appendix B : A Sekletal CBIOS ; ; ; ; 0100 0014 = 0000 = 3400 = 3C00 = 4A00 = CP/M Operating System Manual COMBINED GETSYS AND PUTSYS PROGRAMS FROM SEC 6.
Appendix C : A Skeletal GETSYS/PUTSYS Program CP/M Operating System Manual ;ARRIVE HERE AT END OF LOAD, HALT FOR LACK OF ANYTHING ;BETTER 011F FB 0120 76 EI HLT ; ; ; ; 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 PUT$SYS: 0200 318033 LXI SP,CCP-0080H ;CONVENIENT PLACE 0203 218033 LXI H,CCP-0080H ;START OF DUMP 0206 0600 MVI B,0 ;START WITH TRACK WR$TRK: 0208 0605 MVI B,L ;START WITH SECTOR
Appendix C : A Skeletal GETSYS/PUTSYS Program CP/M Operating System Manual READ$SEC: ;READ THE NEXT SECTOR ;TRACK IN , ;SECTOR IN ;DMAADDR IN 0300 C5 0301 E5 0302 0342 E1 0343 C1 0344 C9 0400 PUSH B PUSH H ;USER DEFINED READ OPERATION GOES HERE DS 64 POP H POP B RET ORG ($+100H) AND 0FF00H ;ANOTHER PAGE ; BOUNDARY WRITE$SEC: ;SAME PARAMETERS AS READ$SEC 0400 C5 0401 E5 0402 0442 E1 0443 C1 0444 C9 PUSH B PUSH H ;USER DEFINED WRITE OPERATION GOES HERE DS 64 POP H POP B RET ;END OF GETSYS/PU
Appendix C : A Skeletal GETSYS/PUTSYS Program CP/M Operating System Manual title 'mds cold start loader at 3000h' ; ; ; ; ; false true testing ; mds-800 cold start loader for cp/m 2.0 version 2.
Appendix D : MDS-800 Cold Start Loader CP/M Operating System Manual ; rstart: lxi sp,stack; ;in case of call to mon80 ; clear disk status in rtype in rbyte ; check if boot switch is off coldstart: in bsw ani 02h ;switch on? jnz coldstart ; clear the controller out reset ;logic cleared ; ; mvi b,ntrks ;number of tracks to read lxi h,iopbo ; start: ; ; read first/next track into cpmb mov a,l out ilow mov a,h out ihigh waito: in dstat ani 4 jz waito ; ; check disk status in rtype ani 11b cpi 2 ; if testing c
Appendix D : MDS-800 Cold Start Loader rar ani 11110b CP/M Operating System Manual ;restore ;overrun/addr err/seek/crc/xxxx ; if cnz endif if jnz endif testing rmon80 not testing rstart ;go to monitor ;retry the load ; ; lxi dad dcr jnz ; ; ; d,iopbl d b start ;length of iopb ;addressing next iopb ;count down tracks jmp to boot to print initial message, and set up jmps jmp boot ; ; parameter blocks iopbo: db 80h ;iocw, no update db readf ;read function db bdoso ;*sectors to read on track 0 db 0
Appendix D : MDS-800 Cold Start Loader 0000 0014 = 0000 = 3400 = 4A00 = 0300 = 4A00 = 1900 = 0032 = CP/M Operating System Manual ;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).
Appendix E : A Skeletal Cold Start Loader LSECT: CP/M Operating System Manual ;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 BY ;BRANCH TO LOCATION "COLD" IF A READ ERROR OCCURS ; ; ; ; ; USER SUPPLIED READ OPERATION GOES ; HERE...
Appendix E : A Skeletal Cold Start Loader 007A 0E01 007C 04 007D C30800 0080 MVI C,1 INR B JMP LSECT END CP/M Operating System Manual ;SECTOR = 1 ;TRACK = TRACK + 1 ;FOR ANOTHER GROUP ;OF BOOT LOADER E-3
Appendix E : A Skeletal Cold Start Loader ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; CP/M Operating System Manual CP/M 2.0 disk re-definition library Copyright (c) 1979 Digital Research Box 579 Pacific Grove, CA 93950 CP/M logical disk drives are defined using the macros given below, where the sequence of calls is: disks n diskdef parameter-list-0 diskdef parameter-list-1 ...
Appendix F : CP/M Disk Definition Library CP/M Operating System Manual ; dsk set 0 ; rept 3 ; dsk set dsk+1 ; diskdef %dsk,0 ; endm ; endef ; ; the value of "begdat" at the end of assembly defines the ; beginning of the uninitialize ram area above the bios, ; while the value of "enddat" defines the next location ; following the end of the data area. the size of this ; area is given by the value of "datsiz" at the end of the ; assembly.
Appendix F : CP/M Disk Definition Library ddw ;; CP/M Operating System Manual macro data,comment define a dw statement dw data comment endm ; gcd ;; ;; ;; gcdm gcdn gcdr 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 gcdx set gcdm/gcdn gcdr set gcdm - gcdx*gcdn if gcdr = 0 exitm endif gcdm set gcdn gcdn set gcdr endm endm ; diskdef macro dn,fsc,lsc,skf,bls,d
Appendix F : CP/M Disk Definition Library CP/M Operating System Manual exitm endif ;; otherwise, high order 1 not found yet blkshf set blkshf+1 blkmsk set (blkmsk shl 1) or 1 blkval set blkval/2 endm ;; generate the extent mask byte blkval set bls/1024 ;;number of kilobytes/block extmsk set 0 ;;fill from right with 1's rept 16 if blkval=1 exitm endif ;; otherwise more to shift extmsk set (extmsk shl 1) or 1 blkval set blkval/2 endm ;; may be double byte allocation if (dks) > 256 extmsk set (extmsk shr 1)
Appendix F : CP/M Disk Definition Library CP/M Operating System Manual ddb %blkshf,<;block shift> ddb %blkmsk,<;block mask> ddb %extmsk,<;extnt mask> ddw %(dks)-1,<;disk size-1> ddw %(dir)-1,<;directory max> ddb %dirblk shr 8,<;alloc0> ddb %dirblk and 0ffh,<;alloc1> ddw %(cks)/4,<;check size> ddw %ofs,<;offset> ;; generate the translate table, if requested if nul skf xlt&dn equ 0 ;no xlate table else if skf = 0 xlt&dn equ 0 ;no xlate table else ;; generate the translate table nxtsec set 0 ;;next sector to
Appendix F : CP/M Disk Definition Library CP/M Operating System Manual endm ; defds macro lab,space lab: ds space endm ; lds macro lb,dn,val defds lb&dn,%val&dn endm ; endef macro ;; generate the necessary ram data areas begdat equ $ dirbuf: ds 128 ;directory access buffer dsknxt set 0 rept ndisks ;;once for each disk lds alv,%dsknxt,als lds csv,%dsknxt,css dsknxt set dsknxt+1 endm enddat equ $ datsiz equ $-begdat ;; db 0 at this point forces hex record endm ; F-6
Appendix F : CP/M Disk Definition Library 0800 = 0200 = 0014 = 0004 = 0050 = 0003 = 0002 = 0000 = 0001 = 0002 = CP/M Operating System Manual ;***************************************************** ;* * ;* SECTOR DEBLOCKING ALGORITHMS FOR CP/M 2.
Appendix G : Blocking and Deblocking Algorithms CP/M Operating System Manual ; ;***************************************************** ;* * ;* THE BDOS ENTRY POINTS GIVEN BELOW SHOW THE * ;* CODE WHICH IS RELEVANT TO DEBLOC * ;***************************************************** 0000 = WRALL EQU 0 ;WRITE TO ALLOCATED 0001 = WRDIR EQU 1 ;WRITE ; ; DISKDEF MACRO, OR HAND CODED TABLES GO HERE 0000 = DPBASE EQU $ ;DISK PARAM BLOCK BASE ; BOOT: WBOOT: ;ENTER HERE ON SYSTEM BOOT TO INITIALIZE 0000 AF XRA A ;0 T
Appendix G : Blocking and Deblocking Algorithms CP/M Operating System Manual ; SETTRK: ;SET TRACK GIVEN BY REGISTERS BC 0023 60 MOV H,B 0024 69 MOV L,C 0025 226201 SHLD SEKTRK ;TRACK TO SEEK 0028 C9 RET ; SETSEC: ;SET SECTOR GIVEN BY REGISTER C 0029 79 MOV A,C 002A 326401 STA SEKSEC ;SECTOR TO SEEK 002D C9 RET ; SETDMA: ;SET DMA ADDRESS GIVEN BY BC 002E 60 MOV H,B 002F 69 MOV L,C 0030 227501 SHLD DMAADR 0033 C9 RET ; SECTRAN: ;TRANSLATE SECTOR NUMBER BC 0034 60 MOV H,B 0035 69 MOV L,C 0036 C9 RET ; ;*****
Appendix G : Blocking and Deblocking Algorithms CP/M Operating System Manual ;* * ;* THE WRITE ENTRY POINT TAKES THE PLACE OF * ;* THE PREVIOUS BIOS DEFINTION FOR WRITE.
Appendix G : Blocking and Deblocking Algorithms CP/M Operating System Manual 0090 217001 LXI H,UNASEC 0093 BE CMP M ;SEKSEC = UNASEC? 0094 C2AE00 JNZ ALLOC ;SKIP IF NOT ; ; MATCH, MOVE TO NEXT SECTOR FOR FUTURE REF 0097 34 INR M ;UNASEC = UNASEC+1 0098 7E MOV A,M ;END OF TRACK? 0099 FE50 CPI CPMSPT ;COUNT CP/M SECTORS 009B DAA700 JC NOOVF ;SKIP IF NO OVERFLOW ; ; OVERFLOW TO NEXT TRACK 009E 3600 MVI M,0 ;UNASEC = 0 00A0 2A6E01 LHLD UNATRK 00A3 23 INX H 00A4 226E01 SHLD UNATRK ;UNATRK = UNATRK+1 ; NOOVF: ;
Appendix G : Blocking and Deblocking Algorithms CP/M Operating System Manual 00BF+B7 ORA A ;CARRY = 0 00C0+1F RAR ;SHIFT RIGHT 00C1 326901 STA SEKHST ;HOST SECTOR TO SEEK ; ; ACTIVE HOST SECTOR? 00C4 216A01 LXI H,HSTACT ;HOST ACTIVE FLAG 00C7 7E MOV A,M 00C8 3601 MVI M,1 ;ALWAYS BECOMES 1 00CA B7 ORA A ;WAS IT ALREADY? 00CB CAF200 JZ FILHST ;FILL HOST IF NOT ; ; HOST BUFFER ACTIVE, SAME AS SEEK BUFFER? 00CE 3A6101 LDA SEKDSK 00D1 216501 LXI H,HSTDSK ;SAME DISK? 00D4 BE CMP M ;SEKDSK = HSTDSK? 00D5 C2EB00
Appendix G : Blocking and Deblocking Algorithms CP/M Operating System Manual 010B AF XRA A ;0 TO ACCUM 010C 326B01 STA HSTWRT ;NO PENDING WRITE ; MATCH: ;COPY DATA TO OR FROM BUFFER 010F 3A6401 LDA SEKSEC ;MASK BUFFER NUMBER 0112 E603 ANI SECMSK ;LEAST SIGNIF BITS 0114 6F MOV L,A ;READY TO SHIFT 0115 2600 MVI H,0 ;DOUBLE COUNT REPT 7 ;SHIFT LEFT 7 DAD H ENDM 0117+29 DAD H 0118+29 DAD H 0119+29 DAD H 011A+29 DAD H 011B+29 DAD H 011C+29 DAD H 011D+29 DAD H ; HL HAS RELATIVE HOST BUFFER ADDRESS 011E 117701 L
Appendix G : Blocking and Deblocking Algorithms CP/M Operating System Manual 0140 FE01 CPI WRDIR ;TO DIRECTORY? 0142 3A7101 LDA ERFLAG ;IN CASE OF ERRORS 0145 C0 RNZ ;NO FURTHER PROCESSING ; ; CLEAR HOST BUFFER FOR DIRECTORY WRITE 0146 B7 ORA A ;ERRORS? 0147 C0 RNZ ;SKIP IF SO 0148 AF XRA A ;0 TO ACCUM 0149 326B01 STA HSTWRT ;BUFFER WRITTEN 014C CD5F01 CALL WRITEHST 014F 3A7101 LDA ERFLAG 0152 C9 RET ; ;***************************************************** ;* * ;* UTILITY SUBROUTINE FOR 16-BIT COMPARE * ;
Appendix G : Blocking and Deblocking Algorithms CP/M Operating System Manual ; READHST: ;HSTDSK = HOST DISK #, HSTTRK = HOST TRACK #, ;HSTSEC = HOST SECT #. READ "HSTSIZ" BYTES ;INTO HSTBUF AND RETURN ERROR FLAG IN ERFLAG.
Appendix G : Blocking and Deblocking Algorithms CP/M Operating System Manual Appendix H Glossary address: Number representing the location of a byte in memory. Within CP/M there are two kinds of addresses: logical and physical. A physical address refers to an absolute and unique location within the computer's memory space. A logical address refers to the offset or displacement of a byte in relation to a base location.
Appendix H : Glossary CP/M Operating System Manual assembler: Program that translates assembly language into the binary machine code. Assembly language is simply a set of mnemonics used to designate the instruction set of the CPU. See ASM in Section 3 of this manual. back-up: Copy of a disk or file made for safekeeping, or the creation of the duplicate disk or file. Basic Disk Operating System: See BDOS. BDOS: Basic Disk Operating System.
Appendix H : Glossary CP/M Operating System Manual for the high-order bit. Bit values are often represented in hexadecimal notation by grouping the bits from the low-order bit in groups of four. Each group of four bits can have a value from 0 to 15 and thus can easily be represented by one hexadecimal digit. BLM: See block mask. block: Basic unit of disk space allocation. Each disk drive has a fixed block size (BLS) defined in its disk parameter block in the BIOS.
Appendix H : Glossary CP/M Operating System Manual BTREE: General purpose file access method that has become the standard organization for indexes in large data base systems. BTREE provides near optimum performance over the full range of file operations, such as insertion, deletion, search, and search next. buffer: Area of memory that temporarily stores data during the transfer of information. built-in commands: Commands that permanently reside in memory.
Appendix H : Glossary CP/M Operating System Manual command: CP/M command line. In general, a CP/M command line has three parts: the command keyword, command tail, and a carriage return. To execute a command, enter a CP/M command line directly after the CP/M prompt at the console and press the carriage return or enter key. command file: Executable program file of filetype COM. A command file is a machine language object module ready to be loaded and executed at the absolute address of 0100H.
Appendix H : Glossary CP/M Operating System Manual control character: Nonprinting character combination. CP/M interprets some control characters as simple commands such as line editing functions. To enter a control character, hold down the CONTROL key and strike the specified character key. Control Program for Microcomputers: See CP/M. CP/M: Control Program for Microcomputers.
Appendix H : Glossary CP/M Operating System Manual default buffer: Default 128-byte buffer maintained at 0080H in page zero. When the CCP loads a COM file, this buffer is initialized to the command tall; that is, any characters typed after the COM file name are loaded into the buffer. The first byte at 0080H contains the length of the command tall, while the command tail itself begins at 0081H. The command tail is terminated by a byte containing a binary zero value.
Appendix H : Glossary CP/M Operating System Manual removable cartridge disk, or fixed hard disk. Hard disk capacities range from five to several hundred megabytes of storage. diskdef macro library: Library of code that when used with MAC, the Digital Research macro assembler, creates disk definition tables such as the DPB and DPH automatically. disk drive: Peripheral device that reads and writes information on disk. CP/M assigns a letter to each drive under its control.
Appendix H : Glossary CP/M Operating System Manual DMA: Direct Memory Access. DMA is a method of transferring data from the disk into memory directly. In a CP/M system, the BDOS calls the BIOS entry point READ to read a sector from the disk into the currently selected DMA address. The DMA address must be the address of a 128-byte buffer in memory, either the default buffer at 0080H in page zero, or a user-assigned buffer in the TPA.
Appendix H : Glossary CP/M Operating System Manual CP/M 1.4 compatiblity should be aware of the implications of this difference. See CP/M 1.4 compatibility. extent mask (EXM): A byte parameter in the disk parameter block located at DPB + 3. The value of EXM is determined by the block size (BLS) and whether the maximum data block number (DSM) exceeds 255. There are EXM + 1 extents per directory FCB. FCB: See File Control Block.
Appendix H : Glossary CP/M Operating System Manual hard disk: Rigid, platter-like, magnetic disk sealed in a container. A hard disk stores more information than a floppy disk. hardware: Physical components of a computer. hexadecimal notation: Notation for base 16 values using the decimal digits and letters A, B, C, D, E, and F to represent the 16 digits. Hexadecimal notation is often used to refer to binary numbers.
Appendix H : Glossary CP/M Operating System Manual BIOS and interpreted by the BIOS I/O entry points CONST, CONIN, CONOUT, LIST, PUNCH, and READER. Depending on the setting of the IOBYTE, different I/O drivers can be selected by the BIOS. For example, setting LST:=TTY: might cause LIST output to be directed to a serial port, while setting LST:=LPT: causes LIST output to be directed to a parallel port. K: Abbreviation for kilobyte. See kilobyte. keyword: See command keyword.
Appendix H : Glossary CP/M Operating System Manual LST: Logical CP/M list device, usually a printer. The CP/M list device is an output-only device referenced through the LIST and LISTST entry points of the BIOS. The STAT command allows assignment of LST: to one of the physical devices: TTY:, CRT:, LPT:, or UL1:, provided these devices and the IOBYTE are implemented in the LIST and LISTST entry points of your CP/M BIOS module.
Appendix H : Glossary CP/M Operating System Manual environment between the computer and its peripheral devices. It enables user-written programs to execute safely. An operating system standardizes the use of computer resources for the programs running under it. option: One of many parameters that can be part of a command tall. Use options to specify additional conditions for a command's execution. output: Data that is sent to the console, disk, or printer.
Appendix H : Glossary CP/M Operating System Manual prompt: Any characters displayed on the video screen to help the user decide what the next appropriate action is. A system prompt is a special prompt displayed by the operating system. The alphabetic character indicates the default drive. Some applications programs have their own special prompts. See CP/M prompt. PUN: Logical CP/M punch device. The punch device is an output-only device accessed through the PUNCH entry point of the BIOS.
Appendix H : Glossary CP/M Operating System Manual restart (RST): One-byte call instruction usually used during interrupt sequences and for debugger break pointing. There are eight restart locations, RST 0 through RST 7, whose addresses are given by the product of 8 times the restart number. R/O: See Read-Only. ROM: Read-Only memory. This memory can be read but not written and so is suitable for code and preinitialized data areas only. RST: See restart. R/W: See Read-Write.
Appendix H : Glossary CP/M Operating System Manual per block is given by BLS/128. Physical sectors on the disk media are also numbered consecutively. If the physical sector size is also 128 bytes, a one-to-one relationship exists between logical and physical sectors. The logical-to-physical translation table (XLT) maps this relationship, and a skew factor is typically used in generating the table entries. For instance, if the skew factor is 6, XLT will be: Logical: 0 1 2 3 4 5 6 ......
Appendix H : Glossary CP/M Operating System Manual SYSGEN image: Memory image of the CP/M system created by SYSGEN when a destination drive is not specified. This is the same as the MOVCPM image that can be read by SYSGEN if a source drive is not specified. See MOVCPM image. system attribute (SYS): File attribute. You can give a file the system attribute by using the SYS option in the STAT command or by using the set file attributes function, BDOS Function 12.
Appendix H : Glossary CP/M Operating System Manual user number: Number assigned to files in the disk directory so that different users need only deal with their own files and have their own directories, even though they are all working from the same disk. In CP/M, files can be divided into 16 user groups. utility: Tool. Program that enables the user to perform certain operations, such as copying files, erasing files, and editing files.
Appendix H : Glossary CP/M Operating System Manual Appendix I CP/M Error Messages Messages come from several different sources. CP/M displays error messages when there are errors in calls to the Basic Disk Operating System (BDOS). CP/M also displays messages when there are errors in command lines. Each utility supplied with CP/M has its own set of messages. The following lists CP/M messages and utility messages. One might see messages other than those listed here if one is running an application program.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning N Not implemented: are trapped. 0 Overflow: P Phase error: assembly. R Register error: the value specified as a register is incompati- unimplemented features, such as macros, expression is too complex to evaluate. ble with the S Syntax error: U Undefined label: V Value error: label value changes on two passes through code. improperly formed expression. label used does not exist.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning Bdos Err On d: Bad Sector This message appears when CP/M finds no disk in the drive, when the disk is improperly formatted, when the drive latch is open, or when power to the drive is off. Check for one of these situations and try again. This could also indicate a hardware problem or a worn or improperly formatted disk.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table I-1. (continued) Message Meaning - The file specified in an R command cannot be found. > Buffer full. ED cannot put any more characters in the memory buffer, or the string specified in an F, N, or S command is too long. E Command aborted. A keystroke at the console aborted command execution. F Disk or directory full. This error is followed by either the disk or directory full message.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning CANNOT READ PIP. PIP cannot read the specified source. Reader cannot be implemented. CANNOT WRITE PIP. The destination specified in the PIP command is illegal. You probably specified an input device as a destination. Checksum error PIP. A HEX record checksum error was encountered. The HEX record that produced the error must be corrected, probably by recreating the HEX file.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning DESTINATION IS R/O, DELETE (Y/N)? PIP. The destination file specified in a PIP command already exists and it is Read-Only. If you type Y, the destination file is deleted before the file copy is done. Directory full ED. There is not enough directory space for the file being written to the destination disk.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning DISK WRITE ERROR--{filespec} DDT. A disk write operation cannot be successfully performed during a W command, probably due to a full disk. You should either erase some unnecessary files or get another disk with more space. PIP. A disk write operation cannot be successfully performed during a PIP command, probably due to a full disk.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message ERROR: Meaning DISK WRITE, LOAD ADDRESS hhhh LOAD. Destination disk is full. ERROR: INVERTED LOAD ADDRESS, LOAD ADDRESS hhhh LOAD. The address of a record was too far from the address of the previously-processed record. This is an internal limitation of LOAD, but it can be circumvented. Use DDT to read the HEX file into memory, then use a SAVE command to store the memory image file on disk.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning File exists, erase it ED. The destination filename already exists when you are placing the destination file on a different disk than the source. It should be erased or another disk selected to receive the output file. ** FILE IS READ/ONLY ** ED. The file specified in the command to invoke ED has the ReadOnly attribute.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning Insufficient memory DDT. There is not enough memory to load the file specified in an R or E command. Invalid Assignment STAT. You specified an invalid drive or file assignment, or misspelled a device name. This error message might be followed by a list of the valid file assignments that can follow a filename.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning INVALID DRIVE NAME (Use A, B, C, or D) SYSGEN. SYSGEN recognizes only drives A, 5, C, and D as valid destinations for system generation. Invalid File Indicator STAT. Appears if you do not specify RO, RW, DIR, or SYS. INVALID FORMAT PIP. The format of your PIP command is illegal. See the description of the PIP command. INVALID HEX DIGIT LOAD ADDRESS hhhh ERROR ADDRESS hhhh BYTES READ: hhhh LOAD.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning n? USER. You specified a number greater than fifteen for a user area number. For example, if you type USER 18, the screen displays 18?. NO DIRECTORY SPACE ASM. The disk directory is full. Erase some files to make room for PRN and HEX files. The directory can usually hold only 64 filenames. NO DIRECTORY SPACE--{filespec} PIP. There is not enough directory space for the output file.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning NO SOURCE FILE ON DISK SYSGEN. SYSGEN cannot find CP/M either in C P / M x x . C 0 M form or on the system tracks of the source disk. NO SOURCE FILE PRESENT ASM. The assembler cannot find the file you specified. Either you mistyped the file specification in your command line, or the filetype is not ASM. NO SPACE SAVE.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table I-1. (continued) Message Meaning OUTPUT FILE WRITE ERROR ASM. You specified a write-protected disk as the destination for the PRN and HEX files, or the disk has no space left. Correct the problem before assembling your program. Pa rameter error SUBMIT. Within the SUBMIT file of type sub, valid parameters are $0 through $9. PARAMETER ERROR, TYPE RETURN TO IGNORE SYSGEN.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning Requires CP/M 2.0 or new for operation PIP. This version of PIP requires the facilities of CP/M 2.0 or newer version. START NOT FOUND PIP. The string argument to an S parameter cannot be found in the source file. SOURCE FILE INCOMPLETE SYSGEN. SYSGEN cannot use your CP/M source file. SOURCE FILE NAME ERROR ASM. When you assemble a file, you cannot use the wildcard characters " and ? in the filename.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning ** TOO MANY' FILES ** STAT. There is not enough memory for STAT to sort the files specified, or more than 512 files were specified. UNEXPECTED END OF HEX FILE--{filespec} PIP. An end-of-file was encountered prior to a termination HEX record. The HEX file without a termination record should be corrected, probably by recreating the HEX file. Unrecognized Destination PIP.
Appendix I : CP/M Error Messages CP/M Operating System Manual Table 1-1. (continued) Message Meaning Your Input? If CP/M cannot find the command you specified, it returns the command name you entered followed by a question mark. Check that you have typed the command line correctly, or that the command you requested exists as a COM file on the default or specified disk.
Appendix I : CP/M Error Messages A CP/M Operating System Manual C Absolute line number, 2-5 Case translation, 1-6, 1-7, 1-31, 1-32 1-33, 2-7, 2-10, 2-20, Access mode, 1-19 2-21, 2-22, 3-7, 5-10, 5-11 afn (ambiguous file reference), 1-4, 1-7 CCP (Console Command Processor), Allocation vector, 5-27 1-2, 4-1, 5-1, 6-1 Ambiguous file reference (afn), 1-4, 1-7 CCP Stack, 5-6 ASM, 1-22, 3-1 Character pointer, 2-4 Assembler, 1-22, 3-1 cks parameter, 6-35 Assembler/disassembler module Close File function, 5-20
Index D Data allocation size, 6-31 Data block number, 6-32 DB statement, 3-15 DDT commands, 4-4, 6-9 DDT nucleus, 4-11 DDT prompt, 4-2 DDT sign-on message, 4-1 Decimal constant, 3-5 Default FCB, 4-7 Delete File function, 5-22 DESPOOL, 6-17 Device assignment, 1-16 DIR, 1-9 DIR attribute, 1-20 dir parameter, 6-35 Direct console 1/0 function, 5-14 Direct Memory Address, 5-27 Directory, 1-9 Directory code, 5-19, 5-20, 5-21, 5-22, 5-23, 5-24, 5-25 Disassembler, 4-4, 1 1 Disk attributes, 1-15 Disk drive name, 1-6
Index File reference, 1-4 File statistics, 1-15, 1-19 Filetvpe, 5-6 Find command, 2-11 fsc parameter, 6-35 G Get ADDR (Alloc) function, 5-27 Get ADDR (Disk Parms) function, 5-29 5-16 Get Console Status, 5- 17 Get 1/0 Byte function, 5-15 Get Read/Oiily Vector function, 5-28 GETSYS, 6-3, 6-11 H Hexadecimal constaiit, 3-5 HOME subroutine, 6-20, 22 CP/M Operating System Manual K Key fields, 5-34 Label field, 3-3 Labels, 3-3, 3-4, 3-16 Library read command, 2-16 Line-edit'ng control characters, 2-9, 4-2, Line
Index CP/M Operating System Manual N Negative bias, 6-7 O [o] parameter, 6-35 Octal constant, 3-5 ofs parameter, 6-35 On-line status, 5-19 Open File function, 5-19 Operand field, 3-4, 3-6 Operation field, 3-4, 3-16 Operators, 3-9, 3-16 ORG directive, 3-11 P Page zero, 6-26 Patching the CP/M system, 6-3 Peripheral devices, 6-17 Physical devices, 1-17, 6-17 Physical file size, 5-33 Physical to logical device assignment, 1-18, 6-19 PIP devices, 1-28 PIP parameters, 1-31 Print String function, 5-15 PRN file
Index SECTRAN, 6-2 SELDSK, 6-19, 6-22, 6-30 Select Disk function, 5-19 Sequential access, 5-8 Set DMA address function, 5-27 Set File Attributes function, 5-29 Set/Get User Code function, 5-30 Set 1/0 Bvte function, 5-15 Set Random Record function, 5-34 SET statement, 3-13 SETDMA, 6-23 SETSEC, 6-23 SETTRK, 6-22 Simple character 1/0, 6-17 Size in records, 1-19 skf parameter, 6-35, 6-37 Source files, 5-7 Stack pointer, 5-6 STAT, 1-15, 6-17,6-38 Stop console output, 1-13 String substitutions, 2-14 SUBMIT, 1-39