.op
.sp 15
.ce 100
.sh
CP/M
.sp
.sh
Operating System
.sp
.sh
Manual
.cs 5
.sp 10
Copyright (c) 1982
.sp
Digital Research
P.O. Box 579
160 Central Avenue
Pacific Grove, CA 93950
(408) 649-3896
TWX 910 360 5001
.sp 4
All Rights Reserved
.ce 0
.bp
.po 17
.ll 50
.ce
COPYRIGHT
.sp
Copyright (c) 1976, 1977, 1978, 1979, 1982, 1983, and 1984 by 
Digital Research Inc.  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 Inc., Post Office Box 579, 
Pacific Grove, California, 93950.
.sp
Thus, readers are granted permission to include the example 
programs, either in whole or in part, in their own programs.
.sp 2
.ce
DISCLAIMER
.sp
Digital Research Inc. makes no representations or warranties with
respect to the contents hereof and specifically disclaims
any implied warranties of merchantability or fitness for
any particular purpose.  Further, Digital Research Inc. reserves the
right to revise this publication and to make changes from
time to time in the content hereof without obligation of
Digital Research Inc. to notify any person of such revision or
changes.
.sp 2
.ce
TRADEMARKS
.sp
CP/M, CP/NET, and Digital Research and its logo are registered 
trademarks of Digital Research.  ASM, DESPOOL, DDT, LINK-80, MAC, 
MP/M, PL/I-80 and SID are trademarks of Digital Research.  IBM is 
a registered trademark of International Business Machines.  Intel 
is a registered trademark of Intel Corporation.  TI Silent 700 is 
a trademark of Texas Instruments Incorporated.  Zilog and Z80 are
registered trademarks of Zilog, Inc.
.mb 4
.fm 1
.sp 3
The \c
.ul
CP/M Operating System Manual \c
.qu
was prepared using the Digital Research TEX Text Formatter and printed
in the United States of America.
.sp 2
.ce 6
*********************************
*   First Edition:  1976        *
*  Second Edition:  July 1982   *
*   Third Edition:  March 1983  *
*  Fourth Edition:  March 1984  *
*********************************
.po 10
.ll 65
.in 0
.bp
.cs 5
.mt 5
.mb 6
.pl 66
.ll 65
.po 10
.hm 2
.fm 2
.he
.ft                                iii
.bp
.ce
.sh
Table of Contents
.sp 3
.nf
.sh
1  CP/M Features and Facilities
.sp
   1.1  Introduction  . . . . . . . . . . . . . . . . . . .   1-1
.sp
   1.2  Functional Description  . . . . . . . . . . . . . .   1-3
.sp
        1.2.1  General Command Structure  . . . . . . . . .   1-3
        1.2.2  File References  . . . . . . . . . . . . . .   1-3
.sp
   1.3  Switching Disks . . . . . . . . . . . . . . . . . .   1-5
   1.4  Built-in Commands . . . . . . . . . . . . . . . . .   1-6
.sp
        1.4.1  ERA Command  . . . . . . . . . . . . . . . .   1-6
        1.4.2  DIR Command  . . . . . . . . . . . . . . . .   1-7
        1.4.3  REN Command  . . . . . . . . . . . . . . . .   1-8
        1.4.4  SAVE Command . . . . . . . . . . . . . . . .   1-8
        1.4.5  TYPE Command . . . . . . . . . . . . . . . .   1-9
        1.4.6  USER Command . . . . . . . . . . . . . . . .   1-9
.sp
   1.5  Line Editing and Output Control . . . . . . . . . .  1-10
.sp
   1.6  Transient Commands  . . . . . . . . . . . . . . . .  1-11
.sp
        1.6.1  STAT Command . . . . . . . . . . . . . . . .  1-12
        1.6.2  ASM Command  . . . . . . . . . . . . . . . .  1-18
        1.6.3  LOAD Command . . . . . . . . . . . . . . . .  1-19
        1.6.4  PIP  . . . . . . . . . . . . . . . . . . . .  1-20
        1.6.5  ED Command . . . . . . . . . . . . . . . . .  1-29
        1.6.6  SYSGEN Command . . . . . . . . . . . . . . .  1-31
        1.6.7  SUBMIT Command . . . . . . . . . . . . . . .  1-33
        1.6.8  DUMP Command . . . . . . . . . . . . . . . .  1-35
        1.6.9  MOVCPM Command . . . . . . . . . . . . . . .  1-35
.sp
   1.7  BDOS Error Messages . . . . . . . . . . . . . . . .  1-37
.sp
   1.8  CP/M Operation on the Model 800 . . . . . . . . . .  1-38
.sp 2
.sh
2  The CP/M Editor
.sp
   2.1  Introduction to ED  . . . . . . . . . . . . . . . .   2-1
.sp
        2.1.1  ED Operation . . . . . . . . . . . . . . . .   2-1
        2.1.2  Text Transfer Functions  . . . . . . . . . .   2-3
        2.1.3  Memory Buffer Organization . . . . . . . . .   2-4
        2.1.4  Line Numbers and ED Start-up . . . . . . . .   2-5
        2.1.5  Memory Buffer Operation  . . . . . . . . . .   2-6
        2.1.6  Command Strings  . . . . . . . . . . . . . .   2-7
        2.1.7  Text Search and Alteration . . . . . . . . .  2-10
        2.1.8  Source Libraries . . . . . . . . . . . . . .  2-13
        2.1.9  Repetitive Command Execution . . . . . . . .  2-14
.bp
.ft                                iv
.ce
.sh
Table of Contents
.qs
.sp
.ce
.sh
(continued)
.qs
.sp 3
   2.2  ED Error Conditions . . . . . . . . . . . . . . . .  2-14
.sp
   2.3  Control Characters and Commands . . . . . . . . . .  2-16
.sp 2
.sh
3  CP/M Assembler
.qs
.sp
   3.1  Introduction  . . . . . . . . . . . . . . . . . . .   3-1
.sp
   3.2  Program Format  . . . . . . . . . . . . . . . . . .   3-3
.sp
   3.3  Forming the Operand . . . . . . . . . . . . . . . .   3-4
.sp
        3.3.1  Labels . . . . . . . . . . . . . . . . . . .   3-4
        3.3.2  Numeric Constants  . . . . . . . . . . . . .   3-5
        3.3.3  Reserved Words . . . . . . . . . . . . . . .   3-5
        3.3.4  String Constants . . . . . . . . . . . . . .   3-6
        3.3.5  Arithmetic and Logical Operators . . . . . .   3-7
        3.3.6  Precedence of Operators  . . . . . . . . . .   3-8
.sp
   3.4  Assembler Directives  . . . . . . . . . . . . . . .   3-9
.sp
        3.4.1  The ORG Directive  . . . . . . . . . . . . .  3-10
        3.4.2  The END Directive  . . . . . . . . . . . . .  3-10
        3.4.3  The EQU Directive  . . . . . . . . . . . . .  3-11
        3.4.4  The SET Directive  . . . . . . . . . . . . .  3-11
        3.4.5  The IF and ENDIF Directives  . . . . . . . .  3-12
        3.4.6  The DB Directive . . . . . . . . . . . . . .  3-13
        3.4.7  The DW Directive . . . . . . . . . . . . . .  3-14
        3.4.8  The DS Directive . . . . . . . . . . . . . .  3-14
.sp
   3.5  Operation Codes . . . . . . . . . . . . . . . . . .  3-15
.sp
        3.5.1  Jumps, Calls, and Returns  . . . . . . . . .  3-15
        3.5.2  Immediate Operand Instructions . . . . . . .  3-17
        3.5.3  Increment and Decrement Instructions . . . .  3-17
        3.5.4  Data Movement Instructions . . . . . . . . .  3-18
        3.5.5  Arithmetic Logic Unit Operations . . . . . .  3-19
        3.5.6  Control Instructions . . . . . . . . . . . .  3-21
.sp
   3.6  Error Messages  . . . . . . . . . . . . . . . . . .  3-21
.sp
   3.7  A Sample Session  . . . . . . . . . . . . . . . . .  3-23
.bp
.ft                                v
.ce
.sh
Table of Contents
.qs
.sp
.ce
.sh
(continued)
.qs
.sp 3
.sh
4  CP/M Dynamic Debugging Tool
.qs
.sp
   4.1  Introduction  . . . . . . . . . . . . . . . . . . .   4-1
.sp
   4.2  DDT Commands  . . . . . . . . . . . . . . . . . . .   4-3
.sp
        4.2.1  The A (Assembly) Command . . . . . . . . . .   4-3
        4.2.2  The D (Display) Command  . . . . . . . . . .   4-4
        4.2.3  The F (Fill) Command . . . . . . . . . . . .   4-5
        4.2.4  The G (Go) Command . . . . . . . . . . . . .   4-5
        4.2.5  The I (Input) Command  . . . . . . . . . . .   4-6
        4.2.6  The L (List) Command . . . . . . . . . . . .   4-6
        4.2.7  The M (Move) Command . . . . . . . . . . . .   4-7
        4.2.8  The R (Read) Command . . . . . . . . . . . .   4-7
        4.2.9  The S (Set) Command  . . . . . . . . . . . .   4-8
        4.2.1- The T (Trace) Command  . . . . . . . . . . .   4-8
        4.2.11 The U (Untrace) Command  . . . . . . . . . .   4-9
        4.2.12 The X (Examine) Command  . . . . . . . . . .   4-9
.sp
   4.3  Implementation Notes  . . . . . . . . . . . . . . .  4-10
.sp
   4.4  A Sample Program  . . . . . . . . . . . . . . . . .  4-11
.sp 2
.sh
5  CP/M 2 System Interface
.qs
.sp
   5.1  Introduction  . . . . . . . . . . . . . . . . . . .   5-1
.sp
   5.2  Operating System Call Conventions . . . . . . . . .   5-3
.sp
   5.3  A Sample File-to-File Copy Program  . . . . . . . .  5-35
.sp
   5.4  A Sample File Dump Utility  . . . . . . . . . . . .  5-38
.sp
   5.5  A Sample Random Access Program  . . . . . . . . . .  5-42
.sp
   5.6  System Function Summary . . . . . . . . . . . . . .  5-50
.sp 2
.sh
6  CP/M 2 Alteration
.qs
.sp
   6.1  Introduction  . . . . . . . . . . . . . . . . . . .   6-1
.sp
   6.2  First-level System Regeneration . . . . . . . . . .   6-2
.sp
   6.3  Second-level System Generation  . . . . . . . . . .   6-5
.sp
   6.4  Sample GETSYS and PUTSYS Programs . . . . . . . . .   6-9
.bp
.ft                                vi
.ce
.sh
Table of Contents
.qs
.sp
.ce
.sh
(continued)
.qs
.sp 3
   6.5  Disk Organization . . . . . . . . . . . . . . . . .  6-11
.sp
   6.6  The BIOS Entry Points . . . . . . . . . . . . . . .  6-13
.sp
   6.7  A Sample BIOS . . . . . . . . . . . . . . . . . . .  6-21
.sp
   6.8  A Sample Cold Start Loader  . . . . . . . . . . . .  6-21
.sp
   6.9  Reserved Locations in Page Zero . . . . . . . . . .  6-22
.sp
   6.10  Disk Parameter Tables  . . . . . . . . . . . . . .  6-23
.sp
   6.11  The DISKDEF Macro Library  . . . . . . . . . . . .  6-28
.sp
   6.12  Sector Blocking and Deblocking . . . . . . . . . .  6-32
.bp
.ft                                vii
.ce
.sh
Appendixes
.qs
.sp 3
.sh
A  \c
.qs
Basic Input/Output System (BIOS)  . . . . . . . . . . .   A-1
.sp 2
.sh
B  \c
.qs
A Skeletal CBIOS  . . . . . . . . . . . . . . . . . . .   B-1
.sp 2
.sh
C  \c
.qs
A Skeletal GETSYS/PUTSYS Program  . . . . . . . . . . .   C-1
.sp 2
.sh
D  \c
.qs
The Model 800 Cold Start Loader for CP/M 2  . . . . . .   D-1
.sp 2
.sh
E  \c
.qs
A Skeletal Cold Start Loader  . . . . . . . . . . . . .   E-1
.sp 2
.sh
F  \c
.qs
CP/M Disk Definition Library  . . . . . . . . . . . . .   F-1
.sp 2
.sh
G  \c
.qs
Blocking and Deblocking Algorithms  . . . . . . . . . .   G-1
.sp 2
.sh
H  \c
.qs
Glossary  . . . . . . . . . . . . . . . . . . . . . . .   H-1
.sp 2
.sh
I  \c
.qs
CP/M Error Messages . . . . . . . . . . . . . . . . . .   I-1
.bp
.ft                                viii
.ce
.sh
Tables, Figures, and Listings
.qs
.sp 3
.sh
Tables
.qs
.sp
     1-1.   Line-editing Control Characters . . . . . . . .  1-10
     1-2.   CP/M Transient Commands . . . . . . . . . . . .  1-11
     1-3.   Physical Devices  . . . . . . . . . . . . . . .  1-14
     1-4.   PIP Parameters  . . . . . . . . . . . . . . . .  1-24
.sp
     2-1.   ED Text Transfer Commands . . . . . . . . . . .   2-3
     2-2.   Editing Commands  . . . . . . . . . . . . . . .   2-6
     2-3.   Line-editing Controls . . . . . . . . . . . . .   2-7
     2-4.   Error Message Symbols . . . . . . . . . . . . .  2-13
     2-5.   ED Control Characters . . . . . . . . . . . . .  2-14
     2-6.   ED Commands . . . . . . . . . . . . . . . . . .  2-15
.sp
     3-1.   Reserved Characters . . . . . . . . . . . . . .   3-6
     3-2.   Arithmetic and Logical Operators  . . . . . . .   3-7
     3-3.   Assembler Directives  . . . . . . . . . . . . .   3-9
     3-4.   Jumps, Calls, and Returns . . . . . . . . . . .  3-15
     3-5.   Immediate Operand Instructions  . . . . . . . .  3-16
     3-6.   Increment and Decrement Instructions  . . . . .  3-17
     3-7.   Data Movement Instructions  . . . . . . . . . .  3-17
     3-8.   Arithmetic Logic Unit Operations  . . . . . . .  3-18
     3-9.   Error Codes . . . . . . . . . . . . . . . . . .  3-20
     3-10.  Error Messages  . . . . . . . . . . . . . . . .  3-21
.sp
     4-1.   Line-editing Controls . . . . . . . . . . . . .   4-2
     4-2.   DDT Commands  . . . . . . . . . . . . . . . . .   4-2
     4-3.   CPU Registers . . . . . . . . . . . . . . . . .   4-9
.sp
     5-1.   CP/M Filetypes  . . . . . . . . . . . . . . . .   5-6
     5-2.   File Control Block Fields . . . . . . . . . . .   5-7
     5-3.   Edit Control Characters . . . . . . . . . . . .  5-20
.sp
     6-1.   Standard Memory Size Values . . . . . . . . . .   6-2
     6-2.   Common Values for CP/M Systems  . . . . . . . .   6-7
     6-3.   CP/M Disk Sector Allocation . . . . . . . . . .  6-11
     6-4.   IOBYTE Field Values . . . . . . . . . . . . . .  6-15
     6-5.   BIOS Entry Points . . . . . . . . . . . . . . .  6-16
     6-6.   Reserved Locations in Page Zero . . . . . . . .  6-21
     6-7.   Disk Parameter Headers  . . . . . . . . . . . .  6-23
     6-8.   BSH and BLM Values  . . . . . . . . . . . . . .  6-25
     6-9.   EXM Values  . . . . . . . . . . . . . . . . . .  6-25
     6-10.  BLS Tabluation  . . . . . . . . . . . . . . . .  6-26
.sp
     I-1.   CP/M Error Messages . . . . . . . . . . . . . .   I-1
.sp 2
.sh
Figures
.qs
.sp
     2-1.   Overall ED Operation  . . . . . . . . . . . . .   2-2
     2-2.   Memory Buffer Organization  . . . . . . . . . .   2-2
.bp
.ft                                ix
.ce
.sh
Tables, Figures, and Listings
.qs
.sp
.ce
.sh
(continued)
.qs
.sp 3
.sh
Figures
.qs
.sp
     2-3.   Logical Organization of Memory Buffer . . . . .   2-4
.sp
     5-1.   CP/M Memory Organization  . . . . . . . . . . .   5-1
     5-2.   File Control Block Format . . . . . . . . . . .   5-7
.sp
     6-1.   IOBYTE Fields . . . . . . . . . . . . . . . . .  6-15
     6-2.   Disk Parameter Header Format  . . . . . . . . .  6-22
     6-3.   Disk Parameter Header Table . . . . . . . . . .  6-23
     6-4.   Disk Parameter Block Format . . . . . . . . . .  6-24
     6-5.   AL0 and AL1 . . . . . . . . . . . . . . . . . .  6-25
.sp 2
.sh
Listings
.qs
.sp
     6-1.   GETSYS Program  . . . . . . . . . . . . . . . .   6-9
     6-2.   BIOS Entry Points . . . . . . . . . . . . . . .  6-13
.nx onea
