-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCPM_BIOS.txt
339 lines (207 loc) · 10.3 KB
/
CPM_BIOS.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
CP/M pages
Home <../index.html> -> CP/M <index.html> -> BIOS
CP/M Basic Input/Output System
The BIOS is the machine-dependent part of CP/M. In theory, all you need
to do is change the BIOS and CP/M will work on a different machine. The
same used to be true of MSDOS...
The BIOS begins with the following jumps to service routines:
JMP BOOT <#boot> ;-3: Cold start routine
JMP WBOOT <#wboot> ; 0: Warm boot - reload command processor
JMP CONST <#const> ; 3: Console status
JMP CONIN <#const> ; 6: Console input
JMP CONOUT <#conout> ; 9: Console output
JMP LIST <#list> ;12: Printer output
JMP PUNCH <#punch> ;15: Paper tape punch output
JMP READER <#reader> ;18: Paper tape reader input
JMP HOME <#home> ;21: Move disc head to track 0
JMP SELDSK <#seldsk> ;24: Select disc drive
JMP SETTRK <#settrk> ;27: Set track number
JMP SETSEC <#setsec> ;30: Set sector number
JMP SETDMA <#setdma> ;33: Set DMA address
JMP READ <#read> ;36: Read a sector
JMP WRITE <#write> ;39: Write a sector
In CP/M 2 and later, the following extra jumps appear:
JMP LISTST <#listst> ;42: Status of list device
JMP SECTRAN <#sectran> ;45: Sector translation for skewing
In CP/M 3, a further set of jumps is present:
JMP CONOST <#conost> ;48: Status of console output
JMP AUXIST <#auxist> ;51: Status of auxiliary input
JMP AUXOST <#auxost> ;54: Status of auxiliary output
JMP DEVTBL <#devtbl> ;57: Address of devices table
JMP DEVINI <#devini> ;60: Initialise a device
JMP DRVTBL <#drvtbl> ;63: Address of discs table
JMP MULTIO <#multio> ;66: Read/write multiple sectors
JMP FLUSH <#flush> ;69: Flush host buffers
JMP MOVE <#move> ;72: Move a block of memory
JMP TIME <#time> ;75: Real time clock
JMP SELMEM <#selmem> ;78: Select memory bank
JMP SETBNK <#setbnk> ;81: Select bank for DMA operation
JMP XMOVE <#xmove> ;84: Preload banks for MOVE
JMP USERF <#userf> ;87: System-depedent functions
JMP RESERV1 <#reserv> ;90: Reserved
JMP RESERV2 <#reserv> ;93: Reserved
BOOT (function 0)
This function is completely implementation-dependent and should never be
called from user code.
WBOOT (function 1)
Reloads the command processor and (on some systems) the BDOS as well.
How it does this is implementation-dependent; it may use the reserved
tracks of a floppy disc or extra memory.
CONST (function 2)
Returns its status in A; 0 if no character is ready, 0FFh if one is.
CONIN (function 3)
Wait until the keyboard is ready to provide a character, and return it
in A.
CONOUT (function 4)
Write the character in C to the screen.
LIST (function 5)
Write the character in C to the printer. If the printer isn't ready,
wait until it is.
PUNCH / AUXOUT (function 6)
Write the character in C to the "paper tape punch" - or whatever the
current auxiliary device is. If the device isn't ready, wait until it is.
This function is called PUNCH in CP/M 2.x, AUXOUT in CP/M 3.
READER (function 7)
Read a character from the "paper tape reader" - or whatever the current
auxiliary device is. If the device isn't ready, wait until it is. The
character will be returned in A. If this device isn't implemented,
return character 26 (^Z).
This function is called READER in CP/M 2.x, AUXIN in CP/M 3.
HOME (function 8)
Move the current drive to track 0.
SELDSK (function 9)
Select the disc drive in register C (0=A:, 1=B: ...). Called with E=0 or
0FFFFh.
If bit 0 of E is 0, then the disc is logged in as if new; if the format
has to be determined from the boot sector, for example, this will be done.
If bit 0 if E is 1, then the disc has been logged in before. The disc is
not accessed; the DPH <dph.html> address (or zero) is returned immediately.
*SELDSK* returns the address of a Disc Parameter Header <dph.html> in
HL. The exact format of a DPH varies between CP/M versions; note that
under CP/M 3, the DPH is in memory bank 0 and probably not visible to
programs. If the disc could not be selected it returns HL=0.
SETTRK (function 10)
Set the track in BC - 0 based.
SETSEC (function 11)
Set the sector in BC. Under CP/M 1 and 2 a sector is 128 bytes. Under
CP/M 3 the sector size is given in the Disk Parameter Block.
There has been discussion in comp.os.cpm <news:comp.os.cpm> about
whether the parameter to this function is a byte or a word. The
conclusion (based on examining the BDOS source) was that it is a word.
SETDMA (function 12)
The next disc operation will read its data from (or write its data to)
the address given in BC.
READ (function 13)
Read the currently set track and sector at the current DMA address.
Returns A=0 for OK, 1 for unrecoverable error, 0FFh if media changed.
WRITE (function 14)
Write the currently set track and sector. C contains a deblocking code:
C=0 - Write can be deferred
C=1 - Write must be immediate
C=2 - Write can be deferred, no pre-read is necessary.
Returns A=0 for OK, 1 for unrecoverable error, 2 if disc is readonly,
0FFh if media changed.
LISTST (function 15)
Return status of current printer device.
Returns A=0 (not ready) or A=0FFh (ready).
SECTRAN (function 16)
Translate sector numbers to take account of skewing.
On entry, BC=logical sector number (zero based) and DE=address of
translation table. On exit, HL contains physical sector number. On a
system with hardware skewing, this would normally ignore DE and return
either BC or BC+1.
CONOST (function 17)
Return status of current screen output device.
Returns A=0 (not ready) or A=0FFh (ready).
AUXIST (function 18)
Return status of current auxiliary input device.
Returns A=0 (not ready) or A=0FFh (ready).
AUXOST (function 19)
Return status of current auxiliary output device.
Returns A=0 (not ready) or A=0FFh (ready).
DEVTBL (function 20)
Return in HL the address of the devices table, or 0 if the devices table
isn't implemented.
The devices table will be visible to programs without the need for bank
switching, ie. it will be in common memory.
The device table contains one entry for each character device. Each
entry is formed:
DEFB 'NAME ' ;Name, 6 bytes. If the first byte is zero,
;this is the end of the table.
DEFB mode ;Bitmapped value:
;Bit 0 set => can input from this device
;Bit 1 set => can output to this device
;Bit 2 set => can change the baud rate
;Bit 3 set => supports XON/XOFF
;Bit 4 set => is using XON/XOFF
;Bits 5,6,7 set to 0.
; Amstrad extension: If bit 7 is set, output
;to the device does not time out.
DEFB baudrate ;Coded speed, 1-15 or 0 if speed can't be
;changed.
;Rates are 50,75,110,134.5,150,300,600,1200,
; 1800,2400,3600,4800,7200,9600,19200.
The maximum number of devices allowed in CP/M Plus is unclear. The
documentation variously says there can be 12 or 13, while the DEVICE.COM
source code suggests 15.
DEVINI (function 21)
Reinitialise character device number C - called when the device's
settings (baud rate, mode etc.) are changed.
DRVTBL (function 22)
Return in HL the address of the drive table, or 0 (or 0FFFFh, or 0FFFEh)
if the drive table isn't implemented. The drive table contains 16
pointers to the Disc Parameter Headers of the 16 disc drives A-P; if a
pointer is 0 it means that the corresponding drive does not exist.
The drive table is usually (but not always) in common memory (ie
accessible by user programs).
MULTIO (function 23)
Notify the BIOS that the BDOS is intending to transfer a number of
consecutive disc sectors with READ <#read> or WRITE <#write>. Entered
with C = number of calls that will be made; up to 16k of data will be
transferred.
The idea is that after the MULTIO call, the BIOS can choose to transfer
all the data in the first READ/WRITE operation, and then not to do
anything on the subsequent (n-1) operations.
FLUSH (function 24)
Write any pending data to disc.
Returns A=0 if successful, 1 for physical disc error, 2 for drive R/O.
This function is only useful when the BIOS is doing the deblocking - ie,
the physical sector size is not the size that the BIOS reports to the BDOS.
MOVE (function 25)
Move BC bytes of memory, from the address in DE to the address in HL
(the other way round from the Z80's LDIR instruction). Should return HL
and DE pointing to the first addresses not copied. If XMOVE <#xmove> is
used before this function, data are moved between two memory banks.
TIME (function 26)
Get the current date and time into the SCB (at BOOT-0Ch). HL and DE must
be preserved. If C=0FFh, then set the time from the SCB instead.
The format of the 5-byte buffer is:
DW day ;Day 1 is 1 Jan 1978
DB hour ;packed BCD
DB minute ;packed BCD
DB second ;packed BCD
SELMEM (function 27)
Set the current bank to the number in A. Bank 1 is the bank in which
user programs run (the TPA); Bank 0 and any other banks are used by CP/M
for disc buffers or as a RAMdisc.
According to the DRI documentation, this function must preserve all
registers except A.
SETBNK (function 28)
Set the bank to be used for the next read/write sector operation. The
bank number is passed in A. Note that the BDOS will call SETBNK *after*
calling SETDMA; some BIOSes insist on this order, so it's safest if your
programs do the same.
XMOVE (function 29)
After *XMOVE*, the next call to MOVE <#move> will move data between
different memory banks. Call *XMOVE* with C=source bank and
B=destination bank. According to the CP/M Plus System Guide, the BDOS
will only ever use this function to move 128 or fewer bytes in one go;
some BIOSes may not support bigger moves between banks.
USERF (function 30)
This function is reserved for the author of the BIOS to add any extra
features. On Amstrad computers, for example, this call accesses the
extended BIOS functions <xbios.html>.
RESERV1 and RESERV2 (functions 31, 32)
These calls are reserved and contain |JMP 0| instructions.
------------------------------------------------------------------------
Return to archive listing <index.html#archive>