DIGITALRESEARCH TMCP/MOperating SystemManualCP/M Features and Facilities The CP/M Editor
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 CC
3.5.6 Control InstructionsThe four remaining instructions, categorized as control instructions, are the following: -HLT halts the 8080 processor
Table 3-9. (continued) Error Code Meaning R Register error: the value specified as a register is not compatible with the operatio
3.7 A Sample SessionThe following sample session shows interaction with the assembler and debugger in thedevelopment of a simple assembly-language pro
0110 214601 LXI H,SW ;CHECK FOR ZERO SWITCHES0113 7EB7C2000001 MOV A,M! OR A! JNZ SORT ; END OF SORT IF SW=0 ;0118 FF
:10010000214601360121470136007EFE09D2190140:100110002146017EB7C20001FF5F16002148011988:10012000194E79234623965778239EDA3F01B2CAA7:100130003F0156702B5E
010D JC 119 Change to jump on carry0110-xpP=010B 100 Reset program counter back to beginning of program-T10
0118 RST 07 List more0119 MOV E,A011A MVI D,00011C LXI H,0148 Abort list with rubout-G,11B Start
010D JC 1190110-L100 List starting section of program0100 LXI H,01460103 MVI M,010105 LXI H,01470108 MVI M,00-Abort list with
a>ED SORT.ASM Make changes to original program (the caret,^, indicates a control charac
A>DDT SORT.HEX Test program changes16K DDT VER 1.0NEXT PC015C 0000-G100*0118-D148 Data sorted0148 05 00 07 00 14 00 1
Most of the commands reference a particular file or group of files. The form of a file reference isspecified in Section 1.2.2.1.2.2 File ReferencesA f
Section 4CP/M Dynamic Debugging Tool4.1 IntroductionThe DDT program allows dynamic interactive testing and debugging of programs generated inthe CP/M
Following the sign-on message, DDT prompts you with the hyphen character, -, and waits forinput commands from the console. You can type any of severa
Table 4-2. (continued) Command Character Result A enters assembly-language mnemonics with operands. S substitutes mem
4.2 DDT CommandsThe individual commands are detailed below. In each case, the operator must wait for the hyphenprompt character before entering the co
4.2.2 The D (Display) CommandThe D command allows you to view the contents of memory in hexadecimal and ASCII formats.The D command takes the forms:DD
4.2.4 The G (Go) CommandA program is executed using the G command, with up to two optional breakpoint addresses. TheG command takes the forms:GGsGs,bG
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 fr
4.2.7 The M (Move) CommandThe M command allows block movement of program or data areas from one location to anotherin memory. The M command takes the
Whenever the R command is issued, DDT responds with either the error indicator ? (file cannotbe opened, or a checksum error occurred in a HEX file) or
The second form of the T command is similar to the first, except that execution is traced for nsteps (n is a hexadecimal value) before a program break
matches the following unambiguous filenamesXYZ.COMandX3Z.CAMThe wildcard character can also be used in an ambiguous file reference. The * character re
Table 4-3. CPU Registers Register Meaning Value C Carry flag (0/1) Z Zero flag
In particular, the BDOS address at location 6H (address field of the JMP instruction at location5H) is modified by DDT to address the base location of
MOV A, C ;GET LARGEST VALUESTA LARGEJMP 0 ;REBOOT;; TEST DATAVECT; DB 2,0,4,3,5,6,1,5LEN EQU 4-VECT ;LENGTHLARGE; DS 1 ;LARGEST VALUE ON EXITEND^-Z*BO
A>ASM, SCANCP/M ASSEMBLER - VER 1.00122002H USE FACTOREND OF ASSEMBLY Assembly complete; look at program listingA>TYPE SCAN PRNCode address
A>DDT SCAN. HEX Start debugger using hex format machine codeDDT VER 1.0NEXT PC Next instruction0121 0000 to execute at-X PC = 0|COZOMOEOIO A=00
0113 STA 01210116 JMP 00000119 STAX B A little more machine011A NOP code. Note that pro-011B INR B ram ends at location011C IN
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-TTrace again (Register C is cleared)COZOMEO
CPU state at end of U5COZOMOE1I1 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 br
Trace 10 (hexadecimal) stepsC0Z1M0E1I1 A-00 B-0800 D=0000 H=0121 S=0100 P=0100 MVI B,08C0Z1M0E1I1 A-00 B-0000 D=0000 H=0121 S=0100 P=0102 MVI C,00C0Z1
-L100 List some code0100 MVI B,080102 MVI C,000104 LXI H,01190107 MOV A,M0108 SUB C0109 JC 010D Previous patch is present in X.COM010C MOV C,A010
Similarly, the commandA>DIR X?Y.C?Mcauses a search for all unambiguous filenames on the disk that satisfy this ambiguous reference.The following fi
*0108-X / Next data itemC1ZOMOE1I1 A=04 B=0602 D=0000 H=011B S=0100 P=0108 SUB C-TSingle step for a few cyclesC1ZOMOE1I1 A=04 B=0602 D=0000 H=011B
-L1000111 MVI B,080102 MVI C,000104 LXI H,01190107 MOV A,M0108 SUB C0109 JC 010D010C MOV C,A010D INX H010E JNZ 01070112 MOV A,C-L0113 STA 01210116 RST
/ Base address of data setC0Z1M0E1I1 A-03 B-0800 D=0000 H=0119 S=0100 P=0107 MOV A,M*0108-T / First data item brought to AC0Z1M0E1I1 A-02 B-0800 D=0
0111 MVI B,080102 MVI C,000104 LXI H,01190107 MOV A,M0108 SUB C <-- This should have been a CMP so that register A0109 JC 010D would not be dest
*0116-XCC1-XC1Z1M0E1I1 A=06 B=0006 D=0000 H=0121 S=0100 P=0116 RST 07-S121 Look at "large" - it appears to be correct.0121 060122 000123 22-
A>DDT SCAN.HEXDDT VER 1.0NEXT PC0121 0000-L116-116 JMP 0000 Check to ensure end is still at 116H0119 STAX B011A NOP011B INR B-(rubout)-G100,116 Go
5.1 IntroductionThis chapter describes CP/M (release 2) system organization including the structure of memoryand system entry points. This section pro
+---------------------------------+ High | | Memory | FDOS (BDOS + BIOS) | FBASE: |
Transient programs are loaded into the TPA and executed as follows. The operatorcommunicates with the CCP by typing command lines following each promp
5.2 Operating System Call ConventionsThis section provides detailed information for performing direct operating system calls from userprograms. Many o
1.3 Switching DisksThe operator can switch the currently logged disk by typing the disk drive name, A through P,followed by a colon when the CCP is wa
0 System Reset 19 Delete File 1 Console Input 20 Read Sequential 2 Console Output 21 Write S
Upon entry to a transient program, the CCP leaves the stack pointer set to an eight-level stackarea with the CCP return address pushed onto the stack,
Table 5-1. CP/M Filetypes Filetype Meaning ASM Assembler Source PRN Printer Listing HEX Hex Machine Code
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 meg
The following table lists and describes each of the fields in the File Control Block figure. Table 5-2. File Control Block Fields Fi
Each file being accessed through CP/M must have a corresponding FCB, which provides thename and allocation information for all subsequent file operati
As an added convenience, the default buffer area at location BOOT+0080H is initialized to thecommand line tail typed by the operator following the pro
FUNCTION 1: CONSOLE INPUTEntry Parameters:RegisterC: 01HReturned Value:Register A: ASCII CharacterThe Console Input function reads the next console ch
FUNCTION 3: READER INPUTEntry Parameters:Register C: 03HReturned Value:Register A: ASCII CharacterThe Reader Input function reads the next character f
FUNCTION 5: LIST OUTPUTEntry Parameters:Register C: 05HRegister E: ASCII CharacterThe List Output function sends the ASCII character in register E to
1.4.1 ERA CommandSyntax:ERA afnThe ERA (erase) command removes files from the currently logged-in disk, for example, the diskname currently prompted b
FUNCTION 7: GET 1/0 BYTEEntry Parameters:Register C: 07HReturned Value:Register A: 1/0 Byte ValueThe Get I/O Byte function returns the current value o
Entry Parameters:Register C: OAHRegisters DE: Buffer AddressReturned Value:Console Characters in BufferThe Read Buffer function reads a line of edited
Table 5-3. (continued) Character Edit Control Function CTRL-M (return) terminates input line CTRL-R retypes the curre
FUNCTION 12: RETURN VERSION NUMBEREntry Parameters:Register C: 0CHReturned Value: Version NumberRegisters HL:Function 12 provides information that all
FUNCTION 14: SELECT DISKEntry Parameters:Register C: 0EHRegister E: Selected DiskThe Select Disk function designates the disk drive named in register
If a directory element is matched, the relevant directory information is copied into bytes d0through dn of FCB, thus allowing access to the files thro
FUNCTION 17: SEARCH FOR FIRSTEntry Parameters:RegisterC: 11HRegisters DE: FCB AddressReturned Value:Register A: Directory CodeSearch First scans th
FUNCTION 18: SEARCH FOR NEXTEntry Parameters:Register C: 12HReturned Value:Register A: Directory CodeThe Search Next function is similar to the Search
FUNCTION 20: READ SEQUENTIALEntry Parameters:Register C: 14HRegisters DE: FCB AddressReturned Value:Register A: Directory CodeGiven that the FCB addre
FUNCTION21: WRITE SEQUENTIALEntry Parameters:Register C: 15HRegisters DE: FCB AddressReturned Value:Register A: Directory CodeGiven that the FCB addr
1.4.2 DIR CommandSyntax:DIR afnThe DIR (directory) command causes the names of all files that satisfy the ambiguous filenameafn to be listed at the co
FUNCTION 22: MAKE FILEEntry Parameters:Register C: 16HRegisters DE: FCB AddressReturned Value:Register A: Directory CodeThe Make File operation is sim
FUNCTION 24: RETURN LOG-IN VECTOREntry Parameters:Register C: 18HReturned Value:Registers HL: Log-in VectorThe log-in vector value returned by CP/M is
FUNCTION 26: SET DMA ADDRESSEntry Parameters:Register C: 1AHRegisters DE: DMA AddressDMA is an acronym for Direct Memory Address, which is often used
FUNCTION 28: WRITE PROTECT DISKEntry Parameters:Register C: I CHThe Write Protect Disk function provides temporary write protection for the currently
FUNCTION 30: SET FILE ATTRIBUTESEntry Parameters:Register C: 1EHRegisters DE: FCB AddressReturned Value:Register A: Directory CodeThe Set File Attribu
FUNCTION 32: SET/GET USER CODEEntry Parameters:Register C: 20HRegister E: OFFH (get) orUser Code (set)Returned Value:Register A: Current Code or(no va
Thus, the r0, r1 byte pair is treated as a double-byte, or word value, that contains the record toread. This value ranges from 0 to 65535, providing a
FUNCTION 34: WRITE RANDOMEntry Parameters:Register C: 22HRegisters DE: FCB AddressReturned Value:Register A: Return CodeThe Write Random operation is
FUNCTION 35: COMPUTE FILE SIZEEntry Parameters:Register C: 23HRegisters DE: FCB AddressReturned Value:Random Record Field SetWhen computing the size o
FUNCTION 36: SET RANDOM RECORDEntry Parameters:Register C: 24HRegisters DE: FCB AddressReturned Value:Random Record Field SetThe Set Random Record fun
1.4.3 REN CommandSyntax:REN ufn1=ufn2The REN (rename) command allows you to change the names of files on disk. The file satisfyingufn2 is changed to u
FUNCTION 37: RESET DRIVEEntry Parameters:Register C: 25HRegisters DE: Drive VectorReturned Value:Register A: 00HThe Reset Drive function allows resett
5.3 A Sample File-to-File Copy ProgramThe following program provides a relatively simple example of file operations. The programsource file is create
0016 = makef equ 22; make file func# ; 0100 org tpa ; beginning of tpa 0100 311902 lxi sp,sta
0137 115C00 copy: lxi d,sfcb ; source 013A CD7801 call read ; read next record 013D B7 ora a
0178 0E14 read: mvi c,readf 017A C30500 jmp bdos ; 017D 0E15 write: mvi c,writef 017F C30500 jmp
5.4 A Sample File Dump UtilityThe following file dump program is slightly more complex than the simple copy program givenin the previous section. The
007C = FCBCR EQU FCB+32 ;CURRENT (NEXT) RECORD ;NUMBER (0 TO 127) 007D = FCBLN EQU FCB+33 ;FCB LENGTH ;
012D E60F ANI 0FH ;CHECK LOW 4 BITS 012F C24401 JNZ NONUM ; PRINT LINE NUMBER 0132 CD7201 CALL CRLF ;
015E CD0500 CALL BDOS 0161 C1D1E1 POP B! POP D! POP H; ENVIRONMENT RESTORED 0164 C9 RET ; PCHAR: ;PRINT
0197 F1 POP PSW 0198 CD7D01 CALL PNIB 019B C9 RET ; ERR: ;PRINT ERROR MESSAGE ; D,E
1.4.4 SAVE CommandSyntax:SAVE n ufnThe SAVE command places n pages (256-byte blocks) onto disk from the TPA and names thisfile ufn. In the CP/M distri
SETUP: ;SET UP FILE ; OPEN THE FILE FOR INPUT 01C1 AF XRA A ;ZERO TO ACCUM 01C2 327C00 STA FCBCR ;CLEAR CUR
5.5 A Sample Random Access ProgramThis section concludes with an extensive example of random access operation. The programlisted below performs the s
Sample Random Access Program for CP/M 2.0 0100 org 100h ; base of tpa ; 0000 = reboot equ
010D 111502 lxi d,badver 0110 CDD501 call print 0113 C30000 jmp reboot ;
014F 3C inr a ; err 255 becomes 0 0150 CAB401 jz error ; error message, retry 0153 C30000
; ; end of write command, process read ; notw: ; not a write c
getchr: ; read next console character to a 01BD 0E01 mvi c,coninp 01BF CD0500 call
01F4 1A readc: dax d ; next command character 01F5 13 inx d ; to next command position 01F6 B7
0254 6572726F72errmsg: db 'error, try again.$' 0266 6E65787420prompt: db 'next command? $' ;
Instead of reading a number, the QUERY program reads an alphanumeric string that is aparticular key to find in the N A M E S . D A T data base. Becau
The TYPE command expands tabs, CTRL-I characters, assuming tab positions are set at everyeighth column. The ufn can also reference a drive name.TYPE B
Function Function Input OutputNumber Name8 8 Set I/O Byte E = I/O byte none9 9 Print String DE = Buffer Address none10 A Read Console String DE = Buff
Function Function Input OutputNumber Name34 22 Write Random DE = FCB address A = error Code35 23 Compute File SIze DE = FCB address r0, r1, r236 24 Se
Section 6CP/M 2 Alteration6.1 IntroductionThe standard CP/M system assumes operation on an Intel MDS-800 microcomputer developmentsystem, but is desig
File expansion is achieved by providing up to 512 logical file extents, where each logical extentcontains 16K bytes of data. CP/M 2 is structured, ho
6.2 First-level System RegenerationThe procedure to patch the CP/M system is given below. Address references in each step areshown with H denoting the
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 byt
11. Upon completion of step 10, CP/M has prompted the console for a command input. To test the disk write operation, typeSAVE 1 X.COMAll commands mus
18. Load and test the debugger by typingDDTSee Section 4 for operating procedures. 19. Before making further CBIOS modifications, practice using the
To get the memory image of CP/M into the TPA configured for the desired memorv size, typethe command:MOVCPM xx*where xx is the memory size in decimal
3400H + n = 980H, or n = 980H - 3400HAssuming two's complement arithmetic, n = D580H, which can be checked by 3400H+D580H = 10980H = 0980H (ignor
COPYRIGHTCopyright C 1976, 1977, 1978, 1979, 1982, and 1983 by Digital Research. All rights reserved.No part of this publication may be reproduced, t
CTRL-I Terminates current input (line-feed). CTRL-M Terminates current input (carriage return). CTRL-P Copies all subsequent console outp
If you want to locate the address x within the memory image loaded under DDT in a 20Ksystei-n, first typeHx,n Hexadecimal sum and
Examine the CBOOT withL900You are now ready to replace the CBIOS by examining the area at 1F80H, where the originalversion of the CBIOS resides, and t
The following program provides a framework for the GETSYS and PUTSYS programsreferenced in Sections 6.1 and 6.2. To read and write the specific sector
RDSEC: ; READ NEXT SECTOR CALL RDSEC ; USER SUPPLIED SUBROUTINE LXI D,128 ; MOVE LOAD ADDRESS TO NEX
The sector allocation for the standard distribution version of CP/M is given here for referencepurposes. The first sector contains an optional softwar
Table 6-3. CP/M Disk Sector Allocation Track Sector Page # Memory Address CP/M Module name 00 01 (boot address) Cold Start L
The entry points into the BIOS from the cold start loader and BDOS are detailed below. Entry tothe BIOS is through a jump vector located at 4A00H + b,
4A09H+b JMP CONIN ;READ CONSOLE CHARACTER IN4A0CH+b JMP CONOUT ;WRITE CONSOLE CHARACTER OUT4A0FH+b JMP LIST ;WRITE LISTING C
All simple character I/O operations are assumed to be performed in ASCII, upper- andlower-case, with high-order (parity bit) set to zero. An end-of-fi
The definition of the IOBYTE function corresponds to the Intel standard as follows: a singlelocation in memory, currently location 0003H, is maintaine
1.6 Transient CommandsTransient commands are loaded from the currently logged disk and executed in the TPA. Thetransient commands for execution under
Table 6-4. (continued) Value Meaning PUNCH field (bits 4,5) 0 PUNCH is the teletype device (TTY:) 1 PUNC
The READ and WRITE routines should perform several retries (10 is standard) before reportingthe error condition to the BDOS. If the error condition i
Table 6-5. (continued) Entry Point Function location 5,6,7 Set to JMP BDOS, which is the primary entry point to CP/M
Table 6-5. (continued) Entry Point Function HOME The disk head of the currently selected disk (initially disk A) is moved to the
Table 6-5. (continued) Entry Point Function SETSEC Register BC contains the sector number, 1 through 26, for subsequent disk acc
Table 6-5. (continued) Entry Point Function WRITE Data is written from the currently selected DMA address to the currently selec
6.7 A Sample BIOSThe program shown in Appendix B can serve as a basis for your first BIOS. The simplestfunctions are assumed in this BIOS, so that you
6.9 Reserved Locations in Page ZeroMain memory page zero, between locations 0H and 0FFH, contains several segments of code anddata that are used durin
Table 6-6. (continued) Locations Contents 0040H-004FH A 16-byte area reserved for scratch by CBIOS, but is not used for any purp
6.10 Disk Parameter TablesTables are included in the BIOS that describe the particular characteristics of the disk subsystemused with CP/M. These tabl
Transient commands are specified in the same manner as built-in commands, and additionalcommands are easily defined by the user. For convenience, the
Table 6-7. (continued) Disk Parameter Header Meaning DPB Address of a disk parameter block for this drive. Drives withide
A responsibility of the SELDSK subroutine is to return the base address of the DPH for theselected drive. The following sequence of operations returns
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
Table 6-9. EXM Values EXM values BLS DSM<256 DSM>255 1,024 0
Position 00 corresponds to the high-order bit of the byte labeled AL0 and 15 corresponds to thelow-order bit of the byte labeled AL1. Each bit positio
The size of the area addressed by CSV is CKS bytes, which is sufficient to hold the directorycheck information for this particular drive. If CKS = (DR
The remaining portion of the BIOS is defined following the DISKDEF macros, with the ENDEFmacro call immediately preceding the END statement. The ENDEF
The cks parameter determines the number of directory items to check on each directory scan andis used internally to detect changed disks during system
The DISKS macro generates n DPHS, starting at the DPH table address DPBASE generated bythe macro. Each disk header block contains sixteen bytes, as de
Following the ENDEF macro call, a number of uninitialized data areas are defined. These dataareas need not be a part of the BIOS that is loaded upon c
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, wit
Three examples of DISKDEF macro invocations are shown below with corresponding STATparameter values. The last example produces a full 8-megabyte syste
Appendix G lists the blocking and deblocking algorithms in skeletal form; this file is included onyour CP/M disk. Generally, the algorithms map all C
; MDS-800 I/O DRIVERS FOR CP/M 2.2 ; (FOUR DRIVE SINGLE DENSITY VERSION) ; ; VERSION 2.2
; REG-A = FF IF CHARACTER READY ; CONIN CONSOLE CHARACTER IN (RESULT IN REG-A) ; CONOUT CONSOLE CHARACTE
DISKS4 ;FOUR DISKS 1633+= DPBASE EQU $ ;BASE OF DISK PARAMETER BLOCKS 1633+82160000 DPE0: DW XLT0,0000H ;TRANSLATE TABLE 163
1690+08 DB 8 1691+0E DB 14 1692+14 DB 20 1693+1A DB 26 1694+06 DB 6 1695+0C DB 12 1696+12 DB
;(MONITOR) ; ; MDS MONITOR EQUATES F800 = MON80 EQU 0F800H ;MDS MONITOR FF0F = RMON80 EQU 0FF0FH ;RESTAR
16B6 219C16 LXI H,SIGNON 16B9 CDD317 CALL PRMSG ;PRINT MESSAGE 16BC AF XRA A ;CLEAR ACCUMULATOR 16BD 320400 STA CDISK ;SET INITIA
; 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
; PREVIOUSLY SELECTED DISK WAS B, SEND PARAMETER TO CPM 1741 3A0400 LDA CDISK ;LAST LOGGED DISK NUMBER 1744 4F MOV C,A ;SE
The actual devices attached to any particular computer system are driven by subroutines in theBIOS portion of CP/M. Thus, the logical RDR: device, for
; PUNCH: ;PUNCH DEVICE OUT ; (EXACTLY THE SAME AS MDS CALL) 1772 C30CF8 JMP PO ;
; SETTRK: ;SET TRACK ADDRESS GIVEN BY C 17A7 216A18 LXI H,IOT 17AA 71 MOV M,C 17AB C9 RET
17D5 C8 RZ ; MORE TO PRINT 17D6 E5 PUSH H 17D7 4F MOV C,A 17D8 CD6A17 CALL CONOUT 17DB E1 POP H 17D
180E D38A OUT IHIGH+10H ; 1810 CD5918 WAIT0: CALL INSTAT ;WAIT FOR COMPLETION 1813 E604 ANI IORDY ;READY? 1815 CA1018
; (ACCUMULATOR BITS ARE NUMBERED 7 6 5 4 3 2 1 0) ; ; IT MAY BE USEFUL TO FILTER OUT THE VARIOUS CONDITI
IOPB: ;IO PARAMETER BLOCK 1867 80 DB 80H ;NORMAL I/O OPERATION 1868 04 IOF: DB READF ;IO FUNCTION, INITIAL READ 1869 01
; 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
; disk parameter header for disk 01dw trans, 0000hdw 0000h, 0000hdw dirbf, dpblkdw chk01, all01; disk parameter header for disk 02dw trans, 0000hdw 00
;wboot: ;simplest case is to read the disk until all sectors loadedlxi sp, 80h ;use space below buffer for stackmvi c, 0 ;select disk 0call seldskcall
inr c ;track=track+1;; save register state, and change trackspush bpush dpush hcall settrk ;track address set from register cpop hpop dpop bjmp load1
It is emphasized that the physical device names might not actually correspond to devices that thenames imply. That is, you can implement the PTP: devi
;conout: ;console character output from register cmov a, c ;get to accumulatords 10h ;space for output routineret;list: ;list character from register
mov l, a ;l=disk number 0, 1, 2, 3mvi h, 0 ;high order zerodad h ;*2dad h ;*4dad h ;*8dad h ;*16 (size of each header)lxi d, dpbasedad 0 ;hl=,dpbase (
write: ;perform a write operationds 10h ;set up write command;waitio: ;enter here from read and write to perform the actual i/o; operation. return a 0
; COMBINED GETSYS AND PUTSYS PROGRAMS FROM ; SEC 6.4 ; ; START THE PROGRAMS AT THE BASE O
;ARRIVE HERE AT END OF LOAD, HALT FOR LACK OF ANYTHING ;BETTER 011F FB EI 0120
READ$SEC: ;READ THE NEXT SECTOR ;TRACK IN <B>, ;SECTOR IN <
title 'mds cold start loader at 3000h';; mds-800 cold start loader for cp/m 2.0;; version 2.0 august, 1979;false equ 0true equ not falsete
;rstart:lxi sp,stack; ;in case of call to mon80; clear disk statusin rtypein rbyte; check if boot switch is offcoldstart:in bswani 02h ;switch on?jnz
rar ;restoreani 11110b ;overrun/addr err/seek/crc/xxxx;if testingcnz rmon80 ;go to monitorendifif not testingjnz rstart ;retry the loadendif;;lxi d,io
;THIS IS A SAMPLE COLD START LOADER, WHICH, WHEN ;MODIFIED ;RESIDES ON TRACK 00, SECTOR 01 (THE FIRST S
The current logical-to-physical device assignment is changed by typing a STAT command of theform:STAT ld1=pd1,ld2=pd2,...,ldn=pdnwhere ld1 through ldn
;ADDRESS LSECT: ;LOAD THE NEXT SECTOR ; INSERT INLINE CODE AT THIS POINT TO
007A 0E01 MVI C,1 ;SECTOR = 1 007C 04 INR B ;TRACK = TRACK + 1 007D C30800 JMP LSECT ;FOR ANOTHER GROUP 0080
; 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
; 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
ddw macro data,comment;; define a dw statementdw data commentendm;gcd macro m,n;; greatest common divisor of m,n;; produces value gcdn as result;; (us
exitmendif;; otherwise, high order 1 not found yetblkshf set blkshf+1blkmsk set (blkmsk shl 1) or 1blkval set blkval/2endm;; generate the extent mask
ddb %blkshf,<;block shift>ddb %blkmsk,<;block mask>ddb %extmsk,<;extnt mask>ddw %(dks)-1,<;disk size-1>ddw %(dir)-1,<;direc
endm;defds macro lab,spacelab: ds spaceendm;lds macro lb,dn,valdefds lb&dn,%val&dnendm;endef macro;; generate the necessary ram data areasbegd
;***************************************************** ;* *
; ;***************************************************** ;*
The Ext field counts the number of physical extents allocated to the file. The Ext countcorresponds to the number of directory entries given to the fi
; SETTRK: ;SET TRACK GIVEN BY REGISTERS BC 0023 60 MOV H,B 0024 69 MOV L,C 0025 226201
;* * ;* THE WRITE ENTRY POINT TAKES THE PLACE OF *
0090 217001 LXI H,UNASEC 0093 BE CMP M ;SEKSEC = UNASEC? 0094 C2AE00 JNZ ALLOC ;SKIP IF NOT ; ; MATCH,
00BF+B7 ORA A ;CARRY = 0 00C0+1F RAR ;SHIFT RIGHT 00C1 326901 STA SEKHST ;HOST SECTOR TO SEEK ; ; A
010B AF XRA A ;0 TO ACCUM 010C 326B01 STA HSTWRT ;NO PENDING WRITE ; MATCH: ;COPY DATA TO OR
0140 FE01 CPI WRDIR ;TO DIRECTORY? 0142 3A7101 LDA ERFLAG ;IN CASE OF ERRORS 0145 C0 RNZ ;NO FURTHER PROCESSING ;
; READHST: ;HSTDSK = HOST DISK #, HSTTRK = HOST TRACK #, ;HSTSEC = HOST SECT #. READ &q
Appendix HGlossaryaddress: Number representing the location of a byte in memory. Within CP/M there are twokinds of addresses: logical and physical. A
assembler: Program that translates assembly language into the binary machine code. Assemblylanguage is simply a set of mnemonics used to designate the
for the high-order bit. Bit values are often represented in hexadecimal notation by grouping thebits from the low-order bit in groups of four. Each g
When a file is marked R/O, subsequent attempts to erase orwrite into the file produce the following BDOS message at yourscreen:BDOS Err on d: File R/O
BTREE: General purpose file access method that has become the standard organization forindexes in large data base systems. BTREE provides near optimu
command: CP/M command line. In general, a CP/M command line has three parts: thecommand keyword, command tail, and a carriage return. To execute a com
control character: Nonprinting character combination. CP/M interprets some control charactersas simple commands such as line editing functions. To ent
default buffer: Default 128-byte buffer maintained at 0080H in page zero. When the CCP loadsa COM file, this buffer is initialized to the command tall
removable cartridge disk, or fixed hard disk. Hard disk capacities range from five to severalhundred megabytes of storage.diskdef macro library: Libr
DMA: Direct Memory Access. DMA is a method of transferring data from the disk into memorydirectly. In a CP/M system, the BDOS calls the BIOS entry poi
CP/M 1.4 compatiblity should be aware of the implications of this difference. See CP/M 1.4compatibility.extent mask (EXM): A byte parameter in the dis
hard disk: Rigid, platter-like, magnetic disk sealed in a container. A hard disk stores moreinformation than a floppy disk.hardware: Physical componen
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
LST: Logical CP/M list device, usually a printer. The CP/M list device is an output-only devicereferenced through the LIST and LISTST entry points of
For logical drives that share the same physical disk, the number of reserved tracks can be quitelarge because this mechanism is used to skip lower-num
environment between the computer and its peripheral devices. It enables user-written programs toexecute safely. An operating system standardizes the
prompt: Any characters displayed on the video screen to help the user decide what the nextappropriate action is. A system prompt is a special prompt d
restart (RST): One-byte call instruction usually used during interrupt sequences and fordebugger break pointing. There are eight restart locations, RS
per block is given by BLS/128. Physical sectors on the disk media are also numberedconsecutively. If the physical sector size is also 128 bytes, a one
SYSGEN image: Memory image of the CP/M system created by SYSGEN when a destinationdrive is not specified. This is the same as the MOVCPM image that ca
user number: Number assigned to files in the disk directory so that different users need onlydeal with their own files and have their own directories,
Appendix ICP/M Error MessagesMessages come from several different sources. CP/M displays error messages when there areerrors in calls to the Basic Di
Table 1-1. (continued)Message MeaningN Not implemented: unimplemented features, such as macros,are trapped.0 Overflow: expression is too complex to ev
Table 1-1. (continued)Message MeaningBdos Err On d: Bad SectorThis message appears when CP/M finds no disk in the drive, when the disk isimpro
Table I-1. (continued)Message Meaning- The file specified in an R command cannot be found.> Buffer full. ED cannot put any more characters
Table of Contents1 CP/M Features and Facilities1.1 Introduction 1-11.2 Functional . . Description ...
The assembler produces a file:X.PRNwhere X is the primary name specified in the ASM command. The PRN file contains a listing ofthe source program
Table 1-1. (continued)Message MeaningCANNOT READPIP. PIP cannot read the specified source. Reader cannot be implemented.CANNOT WRITEPIP. The
Table 1-1. (continued)Message MeaningDESTINATION IS R/O, DELETE (Y/N)?PIP. The destination file specified in a PIP command already exists and
Table 1-1. (continued)Message MeaningDISK WRITE ERROR--{filespec}DDT. A disk write operation cannot be successfully performed during a Wcomma
Table 1-1. (continued)Message MeaningERROR: DISK WRITE, LOAD ADDRESS hhhhLOAD. Destination disk is full.ERROR: INVERTED LOAD ADDRESS, LOAD AD
Table 1-1. (continued)Message MeaningFile exists, erase itED. The destination filename already exists when you are placing the destinationfi
Table 1-1. (continued)Message MeaningInsufficient memoryDDT. There is not enough memory to load the file specified in an R or Ecommand.Invalid Assign
Table 1-1. (continued)Message MeaningINVALID DRIVE NAME (Use A, B, C, or D)SYSGEN. SYSGEN recognizes only drives A, 5, C, and D as valid destinations
Table 1-1. (continued)Message Meaningn ? USER. You specified a number greater than fifteen for a user area number. Forexample, if you type USER 18
Table 1-1. (continued)Message MeaningNO SOURCE FILE ON DISKSYSGEN. SYSGEN cannot find CP/M either in C P / M x x . C 0 M form or onthe system tracks
Table I-1. (continued)Message MeaningOUTPUT FILE WRITE ERRORASM. You specified a write-protected disk as the destination for the PRN andHEX f
1.6.3 LOAD CommandSyntax:LOAD ufnThe LOAD command reads the file ufn, which is assumed to contain HEX format machine code,and produces a memory image
Table 1-1. (continued)Message MeaningRequires CP/M 2.0 or new for operationPIP. This version of PIP requires the facilities of CP/M 2.0 or ne
Table 1-1. (continued)Message Meaning** TOO MANY' FILES **STAT. There is not enough memory for STAT to sort the files specified, or more
Table 1-1. (continued)Message MeaningYour Input?If CP/M cannot find the command you specified, it returns the command nameyou entered followed by
ACAbsolute 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-11afn (ambiguous f
D Drive characteristics, 1-21Drive select code, 5-9Data allocation size, 6-31 Drive specification, 1-7Data block number, 6-32 DS statement, 3-16DB sta
File reference, 1-4 KFile statistics, 1-15, 1-19Filetvpe, 5-6 Key fields, 5-34Find command, 2-11fsc parameter, 6-35G Label field, 3-3Labels, 3-3, 3-4,
NNegative bias, 6-7 Radix indicators, 3-5Random access, 5-31, 5-32, 5-46Random record number, 5-32O READ, 6-23Read Console Buffer function, 5-16[o] pa
SECTRAN, 6-2 Translate table, 6-37SELDSK, 6-19, 6-22, 6-30 Translation vectors, 6-30Select Disk function, 5-19 TYPE, 1-11Sequential access, 5-8 Set
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 10
When multiple files are given in the command line (for example, n>1), the individual files areassumed to contain ASCII characters, with an assumed
For convenience, PIP allows abbreviated commands for transferring files between disk drives.The abbreviated PIP forms arePIP d:=afnPIP d1:=d2:afnPIP u
PIP allows reference to physical and logical devices that are attached to the CP/M svstem. Thedevice names are the same as given under the STAT comman
-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 cha
The following are valid PIP commands:PIP LST:=X.PRNCopies X.PRN to the LST device and terminates the PIP program.PIPStarts PIP for a sequence of comma
Table 1-4. PIP ParametersParameter Meaning B Blocks mode transfer. Data are buffered by PIP until an ASCII x-off
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.
Table of Contents (continued)2.1.7 Text Search and Alteration ... 2-112.1.8 Source Libraries ... 2-152.1.9 Repetitive Command E
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 dr
The file transfer is skipped, and PIP continues with the next operation in sequence. To avoid theprompt and response in the case of R/O file overwrite
1.6.5 ED Command Syntax:ED ufnThe ED program is the CP/M system context editor that allows creation and alteration of ASCIIfiles in the CP/M environme
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
Similar to other transient commands, editing can take place on a drive different from thecurrently logged disk by preceding the source filename by a d
FUNCTION COMPLETESystem is copied to memory. SYSGEN then prompts with the following:DESTINATION DRIVE NAME(OR RETURN TO REBOOT)If a disk is being init
1.6.7 SUBMIT CommandSyntax:SUBMIT ufn parm#l ... parm#nThe SUBMIT command allows CP/M commands to be batched for automatic processing. Theufn given in
The last command in a SUB file can initiate another SUB file, allowing chained batchcommands.Suppose the file ASMBL.SUB exists on disk and contains th
An additional utility program called XSUB extends the power of the SUBMIT facility to includeline input to programs as well as the CCP. The XSUB comma
1.6.9 MOVCPM CommandSyntax:MOVCPMThe MOVCPM program allows you to reconfigure the CP/M system for any particular memorysize. Two optional parameters c
Table of Contents (continued)4 CP/M Dynamic Debugging Tool4.1 Introduction 4-14.2 DDT Commands 4-44.2.1 T
For example, the command,MOVCPM * *constructs a new version of the CP/M system and leaves it in memory, ready for a SYSGENoperation. The messageREADY
You can then go through the reboot process with the old or new disk. Instead of performing theSYSGEN operation, you can type a command of the form:SAV
The BAD SECTOR message indicates that the disk controller electronics has detected an errorcondition in reading or writing the disk. This condition is
1.8 Operation of CP/M on the MDSThis section gives operating procedures for using CP/M on the Intel MDS microcomputerdevelopment system. Basic knowled
You should use IBM-compatible disks rather than disks that have previously been used with anyISIS version. In particular, the ISIS FORMAT operation pr
Section 2The CP/M Editor2.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
Figure 2-1. Overall ED OperationThe memory buffer is logically between the source file and working file, as shown in Figure 2-2.2-2
Figure 2-2. Memory Buffer Organization2.1.2 Text Transfer FunctionsGiven that n is an integer value in the range 0 through 65535, several single-lett
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 h
The memory buffer appears logically as shown in Figure 2-3, where the dashes representcharacters of the source line of indefinite length, terminated b
Table of Contents (continued)6.9 Reserved Locations in Page Zero ...6-266.10 Disk Parameter Tables ...
You can reference an absolute line number by preceding any command by a number followed bya colon, in the same format as the line number display. In t
2.1.5 Memory Buffer OperationWhen ED begins, the memory buffer is empty. You can either append lines from the source filewith the A command, or enter
Table 2-2. Editing Commands Command Action +-B Move CP to beginning of memory buffer if + and to bottom if +-nC Mo
Table 2-3. Line-editing Controls Command Result CTRL-C Reboots the CP/M system when typed at the start of a line.
Suppose the memory buffer contains the characters shown in the previous section, with the CPfollowing the last character of the buffer. In the followi
-2L#T<cr> Move up two lines and type 65535 lines ahead of CP NOW IS THE. The result in the memory buffer isNOW IS THE<cr><lf>^T
The following commands illustrate the use of the F command: Command String Effect B#T<cr> Move to the beginning and type the entire
Command String Effect BITHIS IS ^Z<cr> Insert THIS IS at the beginning of the text. The result in the memory buffer isTHIS IS
ED also provides a single command that combines the F and I commands to perform simplestring substitutions. The command takes the following form:nSs1^
A final line editing function, called the Juxtaposition comniand, takes the formnJs1^Zs2^Zs3<cr>ornJs1^Zs2^Zs3^Zwith the following action applie
Table of Contents (continued)3-7 Data Movement Instructions ...3-211-1 Arithmetic Logic Unit Operations ...
where filename is the primary filename of a source file on the disk with an assumed filetype ofLIB. ED reads the specified file, and places the charac
2.1.9 Repetitive Command ExecutionThe macro command M allows you to group ED commands together for repeated evaluation. TheM command takes the followi
2.2 ED Error ConditionsOn error conditions, ED prints the message BREAK X AT C where X is one of the errorindicators shown in Table 2-4.
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 fil
Table 2-6 summarizes the commands used in ED. Table 2-6. ED Commands Command Function nA Append lines +-B Begi
Command Function nS Substitute strings +-nT Type lines U Translate lower- to upper-case if U, no translation if -U V Verif
The commands I, J, M, N, R, and S should be typed as i, j, m, n, r, and s if both upper- andlower-case characters are used in the operation, otherwise
Section 3CP/M Assembler3.1 IntroductionThe CP/M assembler reads assembly-language source files from the disk and produces 8080machine language in Inte
The form ASM filename parms is used to redirect input and output files from their defaults. Inthis case, the parms portion of the command is a three-l
The commandASM X.ABXindicates that the source file is to be taken from disk A, the hex file is to be placed on disk B, andthe listing file is to be se
Section 1CP/M Features and Facilities1.1 IntroductionCP/M is a monitor control program for microcomputer system development that uses floppydisks or W
x xy long$name x: yxl: longer$naned$data: X1Y2 X1x2 x234$5678$9012$3456:The operation field contains either a
3.3.1 LabelsA label is an identifier that occurs on a particular statement. In general, the label is given a valuedetermined by the type of statement
Similar to identifiers, embedded $ signs are allowed within constants to improve theirreadability. Finally, the radix indicator is translated to upper
3.3.4 String ConstantsString constants represent sequences of ASCII characters and are represented by enclosing thecharacters within apostrophe symbol
Table 3-2. Arithmetic and Logical Operators (continued) a * b unsigned magnitude multiplication of a and b a / bunsigned magnitude division of
3.3.6 Precedence of OperatorsAs a convenience to the programmer, ASM assumes that operators have a relative precedence ofapplication that allows the p
An unparenthesized expression is well-formed only if the expression that results from insertingthe assumed parentheses is well-formed.3.4 Assembler Di
3.4.1 The ORG DirectiveThe ORG statement takes the form:label ORG expressionwhere label is an optional program identifier and expression is a 16-bit e
3.4.3 The EQU DirectiveThe EQU (equate) statement is used to set up synonyms for particular numeric values. The EQUstatement takes the form:label EQU
3.4.4 The SET DirectiveThe SET statement is similar to the EQU, taking the form:label SET expressionexcept that the label can occur on other SET state
CP/M also supports ED, a powerful context editor, ASM, an Intel-compatible assembler, andDDT, debugger subsystems. Optional software includes a power
When encountering the IF statement, the assembler evaluates the expression following the IF. Alloperands in the expression must be defined ahead of th
3.4.6 The DB DirectiveThe DB directive allows the programmer to define initialized storage areas in singleprecisionbyte format. The DB statement takes
3.4.8 The DS DirectiveThe DS statement is used to reserve an area of uninitialized memory, and takes the form:label DS expressionwhere the label is op
3.5.1 Jumps, Calls, and ReturnsThe Jump, Call, and Return instructions allow several different forms that test the condition flagsset in the 8080 micr
Table 3-4. Jumps, Calls, and Returns (continued) Bit Form Value Example Meaning CPE e16 CPE $4 Call subroutine if par
3.5.2 Immediate Operand InstructionsSeveral instructions are available that load single- or double-precision registers orsingle-precision memory cells
3.5.3 Increment and Decrement InstructionsThe 8080 provides instructions for incrementing or decrementing single- and double precisionregisters. The i
3.5.4 Data Movement InstructionsInstructions that move data from memory to the CPU and from CPU to memory are given in thefollowing table.Table 3-7.
Table 3-7. (continued) Form with Bit Value Example Meaning IN e8 IN 0 Load register A with data from port e8. O
Table 3-8. (continued) Form with Bit Value Example Meaning ANA e3 ANA 1+1 Logical and reg with A, e3 as above. XRA e
Komentáře k této Příručce