DOS 2.10 Technical Reference Sep83
DOS 2.10 Technical Reference Sep83
Personal Computer
Computer Language
Series
Disk
Operating
System
Technical Reference
by Microsoft Corp.
Preface
iii
iv
Contents
1-1
1-3
1-4
1-5
1-6
1-6
1-7
1-8
3-1
3-3
3-4
3-4
3-6
3-9
3-10
3-11
3-11
3-12
3-13
3-16
3-21
3-26
3-27
vi
7-1
8-1
8-3
8-4
8-6
8-8
9-1
X-I
vii
viii
Contents
DOS Structure ..............................
DOS Initialization ...........................
The Command Processor .....................
Available DOS Functions ....................
File Management Notes ......................
The Disk Transfer Area (DT A) ...............
Error Trapping ..............................
1-3
1-4
1-5
1-6
1-6
1-7
1-8
1-1
1-2
DOS Structure
DOS consists of the following four components:
1.
2.
3.
4.
1-3
DOS Initialization
When the system is started (either System Reset or
power ON with the DOS diskette in drive A), the boot
record is read into memory and given control. It checks
the directory to assure that the first two files listed are
IBMBIO.COM and IBMDOS.COM, in that order. (An
error message is issued if not.) These two files are then
read into memory. (IBMBIO.COM must be the first file
in the directory, and its sectors must be contiguous.)
The initialization code in IBMBIO.COM determines
equipment status, resets the disk system, initializes the
attached devices, causes device drivers to be loaded,
and sets the low-numbered interrupt vectors. It then
relocates IBMDOS.COM downward and calls the first
byte of DOS.
As in IBMBIO.COM, offset 0 in DOS contains ajump
to its initialization code, which will later be overlaid by
a data area and the command processor. DOS
initializes its internal working tables, initializes interrupt
vectors for interrupts hex 20 through hex 27 and builds
a Program Segment Prefix (see Chapter 6) for
COMMAND. COM at the lowest available segment,
then returns to IBMBIO. COM.
The last remaining task of initialization is for
IBMBIO.COM to load COMMAND. COM at the
location set up by DOS initialization. IBMBIO.COM
then passes control to the first byte of COMMAND.
1-4
1-5
Error Trapping
DOS provides a method by which a program can
receive control whenever a disk or device read/write
error occurs, or when a bad memory image of the file
allocation table is detected. When these events occur,
DOS executes an INT hex 24 to pass control to the
error handler. The default error handler resides in
COMMAND. COM, but any program can establish its
own by setting the INT hex 24 vector to point to the
new error handler. DOS provides error information via
the registers and provides Abort, Retry, or Ignore
support via return codes. (Refer to Chapter 5, "DOS
Interrupts and Function Calls".)
1-8
Contents
Introduction
2-3
2-4
2-4
2-4
2-5
2-5
2-5
2-6
2-6
2-6
2-7
2-7
Erasing ..................................
Erase in Display .......................
Erase in Line ..........................
2-8
2-8
2-8
2-1
2-2
Introduction
DEVICE=ANSI.SYS
3.
4.
2-3
Cursor Control
Cursor Position
CUP
Function
ESC [#;#H
Cursor Up
CUD
Function
ESC [#A
2-4
Cursor Down
CUD
Function
ESC [#8
Cursor Forward
CUF
Function
ESC [#C
Cursor Backward
CUB
Function
ESC [#0
2-5
Function
ESC [#;#1
Function
ESC [6n
Function
ESC [#;#R
2-6
Function
ESC [s
Function
ESC [u
2-7
Erasing
Erase in Display
ED
Function
ESC [2J
Erase in Line
EL
Function
ESC [k
2-8
Mode of Operation
Function
Parameter
0
1
4
5
7
8
30
31
32
33
34
35
36
37
40
41
42
43
44
45
46
47
Meaning
All attributes Off (normal
white on black)
Bold On (high intensity)
Underscore On (IBM
Monochrome Display only)
Blink On
Reverse video On
Cancelled On (invisible)
Black foreground
Red foreground
Green foreground
Yellow foreground
Blue foreground
Magenta foreground
Cyan foreground
White foreground
Black background
Red background
Green background
Yellow background
Blue background
Magenta background
Cyan background
White background
2-9
Set Mode
SM
Function
Reset Mode
RM
Function
ESC [=#1
or ESC [=1
or ESC [=01
or ESC [?71
2-10
Function
or ESC ["string";p
or ESC
2.
[65;81
A becomes Q
[97; 113p a becomes q
[81 P;65p Q becomes A
[113;97p q becomes a
2-11
3.
CSEG
ORG
LABEL
ORG
ENTPT: JMP
STRINq DB
5DH
FAR
RET FAR
i INT 11H
lODH
SHORT START
17,'[Di&8i"SDIR B:"i13p' iREDEFINE F1D KEY
STRSIZ EQU
HANDLE EQU
S-STRING
DOS
PROC
MOV
MOV
i <th is is done
START
CSEG
2-12
NOV
MOV
MOV
MOV
CAll
RET
ENDP
ENDS
END
; OFFSET
; SEGMENT (TO BE FILLED)
NEAR
AX,CS
;FIND WHERE THIS CODE IS
DOSSEG,AX
;SET VECTOR ACCORDINGLY
so this code becomes self-relocatable, suitable for . com file)
BX,HANDLE
CX,STRSIZ
DX,OFFSET STRING
AH,4DH
DOSVECTOR
ENTPT
Contents
Introduction
3-3
3-4
3-4
3-5
3-5
3-6
3-6
3-7
3-8
3-8
3-9
3-11
3-11
3-12
3-13
3-16
3-17
3-18
3-18
3-21
3-22
3-24
3-24
3-25
3-2
Introduction
3-3
Types of Devices
There are two basic types of devices:
3-4
Character devices
Block devices
Character Devices
These are devices that are designed to do character I/O
in a serial manner like CON, AUX, and PRN. These
devices have names like CON, AUX, CLOCK$, and
you can open channels (handles or FCBs) to do input
and output to them.
Note: Because character devices have only one
name, they can support only one device.
Block Devices
These devices are the "fixed disk or diskette drives" on
the system, they can do random I/O in pieces called
blocks (usually the physical sector size of the disk).
These devices are not named as the character devices
are, and cannot be opened directly. Instead they are
mapped via the drive letters (A, B, C, etc.). Block
devices can have units within them. In this way, a single
block driver can be responsible for one or more disk or
diskette drives. For example, block device driver
ALPHA can be responsible for drives A, B, C and D.
This means that ALPHA has four units defined and
therefore takes up four drive letters. The way the drive
units and drive letters correspond is determined by the
position of the driver in the chain of all drivers. For
example, if device driver ALPHA is the first block
driver in the device chain, and it has defined four units,
then those units will be A, B, C and D. If BETA is the
second block driver, and it defines three units, then
those units will be E, F and G. DOS Version 2.10 is
not limited to 16 block device units as previous versions
were. The new limit is 63, but drives are assigned
alphabetically through the collating sequence, so after
drive Z, the drive "characters" get a little strange (like
<, \, .
3-5
Device Header
A device header is required at the beginning of a device
driver. Here is what the Device Header looks like:
Description
Definition
DWORD
Attribute
WORD
WORD
WORD
N arne/unit field
8 BYTES
3-6
Attribute Field
The next field in the header describes to the system the
attributes of the device. They are as follows:
bit 15 = 1 if character device
o if block device
bit 14 = 1 if IOCTL is supported
o if it is not
bit 13 = 1 if non IBM format (block only)
o if IBM format
bit 3 = 1 if current clock device
o if it is not
bit 2 = 1 if current NUL device
o if it is not
bit 1 = 1 if current standard output device
o if it is not
bit 0 = 1 if current standard input device
o if it is not
All other bits must be off.
The most important bit is bit 15, which tells the system
that it is a block or a character device. With the
exception of bits 13 and 14, the rest are for giving
character devices special treatment and mean nothing
on a block device. These special treatment bits allow
you to tell DOS that your new device driver is the new
standard input device and standard output device (the
CON device). This can be done by setting bits 0 and 1
to 1. Similarly, a new CLOCK$ device could be
installed by setting that attribute bit.
Although there is a NUL device attribute bit, the NUL
device cannot be reassigned. This is an attribute that
exists for DO S so it can tell if the NUL device is being
used. The non IBM format bit applies only to block
devices and affects the operation of the Get BPB (BIOS
Parameter Block) device call (covered later in this
chapter). The other bit of interest is the IOCTL bit.
This is used for both block and character devices, and
tells DOS whether the device is able to handle control
strings (through the IOCTL system call).
3-7
Name Field
This is an 8-byte field that contains the name of a
character device, or the number of units of a block
device. If it is a block device, the number of units can
be put in the first byte. This is optional, because DOS
will fill in this location with the value returned by the
driver's INIT code. (Refer to "Installation of Device
Drivers" in this chapter.)
3-8
3-9
3-10
Request Header
Unit Code
The unit code field identifies which unit in your device
driver the request is for. For example, if your device
driver has 3 units defined, then the possible values of
the unit code field would be 0, I, and 2.
3-11
Command Code
The command code field in the Request Header can
have the following values:
Code
Function
INIT
INPUT (read)
OUTPUT (write)
10
11
12
3-12
Media Changed
Not Sure
Status Word
The status word in the Request Header.
E
R
B D
RESERVED
U
S
0
N
3-13
3-14
3-15
3-16
INIT
Command code=O
ES:BX
13-BYTE Request Header
BYTE number of units
(not set by character devices)
DWORD Ending Address
DWORD Pointer to BPB array
(not set by character devices)
The driver must do the following:
3-17
MEDIA CHECK
Command code= 1
ES:BX
13-BYTE Request Header
BYTE Media Descriptor from DOS
BYTE return information
The driver must perform the following:
3-18
3-19
The three words at the end are optional. DOS does not
care about them because they are not part of the BPB.
They are intended to help the device driver understand
the media. Sectors per track may be redundant because
it can be calculated from the total size of the disk. The
number of heads is useful for supporting different
multi-head drives that have the same storage capacity
but a different number of surfaces. The number of
hidden sectors is useful for supporting drive partitioning
schemes.
3-20
x x x
7 6 5 4 3 2
Bit
Meaning
1=2 sided
1=8 sector
1=removable
2
3-7
O=not 2 sided
O=not 8 sector
O=not removable
must be set to 1
5 1/4~' Diskettes:
hex
hex
hex
hex
FC
FD
FE
FF
1 sided
2 sided
1 sided
2 sided
9 sector
9 sector
8 sector
8 sector
Fixed Disks:
hex F8 (Fixed disk)
8" Diskettes:
Hex FE (IBM 3740 Format). Single sided,
single density, 128 bytes per sector, soft sectored,
4 sectors per allocation unit, 1 reserved sector,
2 FATs, 68 directory entries, 77*26 sectors.
3-21
INPUT or OUTPUT
Command codes=3,4,8,9, and 12
ES:BX
13-BYTE Request Header
BYTE Media descriptor byte
DWORD transfer address (buffer address)
WORD byte/sector Count
WORD starting sector number
(no meaning on character devices)
3-22
3-23
ES:BX
13-BYTE Request Header
BYTE read from device
The driver must perform the following:
STATUS
Command codes =6 and 10
ES:BX
3-24
FLUSH
Command codes =7 and 11
ES:BX
13-BYTE Request Header
This call tells the driver to flush (terminate) all
pending requests that it has knowledge of. Its primary
use is to flush the input queue on character devices.
The driver must set status word in the Request
Header upon return.
3-25
3-26
3
4
5
6
7
8
9
10
0000
,; ******************************************************
* IS AN INSTALLABLE
PROLOG
**
DEVICE DRIVER FOR AN
;,** INTHISSTORAGE
DISKEm I VIRTUALI WITH 180K CAPACITY. *
, ******************************************************
CSEG
SEGMENT PARA PUBLIC 'CODE'
MACROIS)
11
12
13
14
15
16
17
18
hATUS
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
0000
0000
0001
0002
0003
0005
34
37
38
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(STATE>, (BUSY>
ES. WORD PTR SRH_STAJLD[BXJ, 0200H
(ERR} , (ERROR)
ES: WORD PTR SRH_STAJLD[BXJ ,1000H
mC}
EQUATES
36
42
STATE,ERR,RC
(STATE>, (DONE}
ES. WORD PTR SRH_STAJLD[BXJ, 0100H
: READ/WRITE
35
39
40
41
MACRO
IFIDN
OR
ENOIF
IFIDN
OR
END IF
IFIDN
OR
ENOIF
IFNB
OR
ENDIF
ENDH
=
=
=
=
=
=
=
=
0000
0001
OOOE
0004
0012
0002
0014
0002
~RH
SRH LEN
SRH:LENJLD
SRH UCD FLO
SRH:CCD:FLD
SRH_STAJLD
SRH_RESJLD
~D
HD LEN
DTA
DTA LEN
COUNT
COUNT_LEN
SSN
SSN_LEN
EQU
EQU
EQU
EQU
EQU
EQU
EQU
13
SRH
SRHt1
SRH+2
SRH+3
SRH+5
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
SRHtSRH_LEN
1
MDfHD_LEN
4
DTAtDTA _LEN
2
COUNT tCOUNT _LEN
2
HDfHD_LEN
DTMDTA_LEN
4
; POINTER TO BPB
..
.... LENGTH
LENGTH
; HEDIA CHECK
= OOOE
~UYTE
EQU
; BUILD BPB
= 0012
= 0004
~PBA PTR
EQU
BPBA:PTR_LEN EQU
; INIT
3-27
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
3-28
~IT5
0000
0001
OOOE
0010
0004
0012
0014
UNITS LEN
BR ADiiR 0
BR-ADDR-l
BR - ADDR -LEN
BPB PTR-OFF
BPB)T(SEG
0000
~OSK
0000
= 0000
BEGIN'
START
0000 FF FF FF FF
0004 2000
0006 00E1 R
0008 OOEC R
OOOA 01
07 (
OOOB
~EXT
EQU
EQU
EQU
EQU
EQU
EQU
EQU
PROC
ASSUME
DEV
ATTRIBUTE
STRATEGY
INTERRUPT
OEV_NAME
SRHtSRH LEN
UNITStUNITS LEN
BR ADDR 0+24 BR AOOR O+8R AOOR LEN
BPS_PTR)FF+2
FAR
CS: CSEG, ES: CSEG ,DS: CSEG
EQU
$
SPECIAL
DEVICE
OD
-1
OW
2000H
OW
DEV STRATEGY
OW
DEV-INT
DB
lDB
7 DUP!?)
HEADER
; POINTER TO NEXT DEVICE
; BLOCK DEVICE I NON-IBM FORMAT!
;POINTER TO DEVICE STRATEGY
; POINTER TO DEVICE INTERRUPT HANDLER
;NUMBER OF BLOCK DEVICES
; 7 BYTES OF FILLER
7?
0012
0014
7771
OFF
OW
RH-SEG
OW
?
; BIOS PARAMETER BLOCK
BPB
EQU
$
DW
512
DB
1
OW
1
DB
2
OW
64
ow
360
DB
OFCH
OW
2
????
= 0016
0016 0200
0018 01
0019 0001
0018 02
OOlC 0040
DOlE 0168
0020 Fe
0021 0002
0023
~PB PTR OW
BPB
; cURRENT VIRTUAL DISK INFORMATION
TOTAL
OW
?
VERIFY
DB
0
START SEC
OW
0
VDISK-PTR
ow
0
USER iiTA
00
7
BOOT - REC
EQU
$
DB
3 DUPIO)
0016 R
0025 717?
0027 00
0028 0000
002A 0000
002C 77?????7
= 0030
03 (
0030
00
0033
003B
0030
003E
49 42 40 20 20 32
2E 30
0200
01
0001
DB
'IBM 2.0'
; VENDOR IDENTIFICATION
ow
512
1
1
DB
OW
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
0040
0041
0043
0045
0046
02
0040
0168
Fe
0002
ow
ow
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
360
OFCH
08
ow
;2 FATS
,NUMBER OF
;360 TOTAL
; TELLS DOS
;NUMBER OF
DIRECTORY ENTRIES
SECTORS IN IMAGE
THIS IS A SINGLE SIDED 9 SECTOR DISK
SECTORS IN FAT
FUNCTION TABLE
0048
0048
OOLlA
004C
004E
0050
0052
0054
0056
0058
005A
005C
005E
0060
0105
0188
01CC
0212
0212
0212
0212
0212
0241
0280
0212
0212
0212
~UNTAB
R
R
R
R
R
R
R
R
R
R
R
R
R
0062
0062
0066
006A
006E
0072
0076
0078
007C
0070
26: 8B
2E: A3
26 8B
2E. A3
26: 8B
32 E4
2E: A3
C3
LA8EL
ow
OW
ow
OW
ow
ow
ow
OW
ow
OW
ow
OW
ow
135
186
137
138
2
64
DB
47 OE
002C R
47 10
002E R
47 12
0025 R
0070
0070 2E Ai 0028 R
0081 B9 0020
0084 F7 E1
0086 2E: 8B 16 002A R
008B 03 00
0080 BE OA
OOBF 33 F6
0091 2E. Al 0025 R
0095 B9 0200
0098 F7 E1
009A OB CO
009C 75 03
009E sa FFFF
OOAl
OOAl 91
00A2 C3
00A3
BYTE
INIT
MEDIA CHECK
BUILO-BP8
!DCTL -IN
INPUTNO INPUT
IN-STAT
IN-FLUSH
OUTPUT
OUT VERIFY
OUT-STAT
OUT)LUSH
IOCTL_OUT
:LOCAL
PROCEDURES
iN SAVE PROC
MOV
MOV
MOV
MOV
MOV
XOR
MOV
RET
IN_SAVE ENOP
NEAR
~C
; INITIALIZATION
; MEDIA CHECK IBLOCK ONLYl
;BUILO BPB
"
"
,IOCTL INPUT
,INPUT I READ)
;NON DESTRUCTIVE INPUT NO WAlT ICHAR ONLY)
; INP[jr STATUS
U
U
; INPUT FLUSH
,OUTPUT IWRITE)
,OUTPUT (WRITE) WITH VERIFY
;OUTPUT STATUS
,OUTPUT FLUSH
,IOCTL OUTPUT
3-29
168
169
170
171
172
173
174
175
176
177
178
179
180
181
lB2
183
184
185
186
lB7
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
00A3
00A3 EB 0070 R
00A6 2E: BE 06 002E R
OOAB 2E: BB 3E 002C R
ooca
00C4
00C5
00C7
ooce
8B
03
73
B8
2B
8B
C7
Cl
07
FFFF
C7
CB
F31 A4
C3
EB 0070 R
lE
07
88 FE
2E: BE lE 002E R
2E: 8B 36 002C R
MOV
AX,OI
AX,CX
ADD
READ COPY
JNC
HOV
AX,OFFFFH
SUB
AX,OI
HOV
CX,AX
READ_COPY:
MOVSB
REP
RET
SECTOR_READ ENOP
~ECTOR_WRlTE
CALL
PUSH
POP
MOV
MeV
MOV
PRDC NEAR
CALC_AOOR
05
ES
DI,SI
05 ,CS :USER_OTA+2
SI,CS :USER_OTA
3-30
88
03
73
B8
28
8B
C6
Cl
07
FFFF
C6
CB
F31 A4
C3
MeV
ADD
JNC
HOV
SUB
MeU
WRITE_COPY:
REP
MOUSB
AX,SI
AX,CX
WRITE COPY
AX,OFFFFH
AX,SI
ex ,AX
RET
SECTOR_WRITE ENOP
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
PAGE
DEVICE
OOEl
OOEl
00E6
OOEB
2E. Be 06 0014 R
2E: 89 lE 0012 R
CB
CS:RftSEG,ES
CS RH_ OFF, BX
;DEVICE
INTERRUPT
FC
lE
06
50
53
51
52
57
56
DEV INT:
, PRESERVE MACHINE STATE ON ENTRY
CLD
PUSH
OS
PUSH
ES
PUSH
AX
PUSH
BX
PUSH
CX
PUSH
OX
PUSH
01
PUSH
SI
OOEC
OOEC
OOED
OOEE
OOEF
OOFO
OOFl
00F2
00F3
00F4
STRATEGY
bEV STRATEGY:
MOV
MOV
RET
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
00F5 26. 8A 47 02
00F9 DO CO
OOFB 80 3E 0048 R
OOFF 32 E4
0101 03 F8
0103 FF 25
LEA
XOR
ADD
JMP
MOV
AL ,ES: [BXJ+2
AL,l
DI,FUNTAB
AH,AH
OI,AX
IoIORD PTR[DIJ
PUSH
POP
LEA
MOV
ROR
ADD
MOV
MOV
ADO
MOV
MOV
MOV
LEA
MOV
MOV
MOV
XOR
LEA
MOV
MOVSB
CS
OX
; CURRENT CS TO OX
AX,CS'VOISK
;GET ADDRESS OF VIRTUAL DISK
CL,4
AX,CL
;OIVIDE BY 16 (PARAGRAPH FORM)
OX ,AX
,ADO TO CURRENT CS VALUE
CS.VDISK_PTR,OX
;SAVE AS STARTING SEGMENT OF VIRTUAL DISK
AX,2000H
; ADO 2DOOH PARAGRAPHS TO STARTING
OX ,AX
;
SEGMENT OF VIRTUAL DISK
ES WORD PTR BR_AOOR_OEBXJ,O
ES:BR_AODR_HBXJ,DX
,MAKE THAT THE BREAK ADDRESS
ES:BYTE PTR UNITS[BXJ,l ;NUMBER OF DISKETTE UNITS
OX,BPB_PTR
;GET ADDRESS OF BPB POINTER ARRAY
ES:BPB_PTR_OFFCBXJ ,OX ,SAVE OFFSET IN DATA PACKET
ES:BPB_PTR_SEGrBXJ,CS ;SAVE SEGMENT IN DATA PACKET
ES,CS:VOISK_PTR
;GET STARTING SECTOR OF VIRTUAL DISK
01,01
;ZERO OUT 01 (BOOT RECORD)
SI, BOOT _REC
;ADDRESS OF BOOT RECORD
CX,24
: COPY 24 BYTES OF BOOT RECORD
RDL
INIT
0105
0105
0106
0107
OlOC
010E
0110
0112
0117
011A
011C
0122
0126
012B
012F
0133
0137
013C
013E
0142
0145
OE
5A
2E: 80 06 OCAO R
Bl 04
03 C8
03 00
2E' 89 16 OOCA R
B8 2000
03 00
26: C7 47 OE 0000
26: 89 57 10
26: C6 47 00 01
80 16 0023 R
26. 89 57 12
26: 8C 4F 14
2E: 8E 06 OOCA R
33 FF
80 36 0030 R
B9 0018
F31 A4
iNn:
REP
3-31
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
3-32
R 0001
R 0002
REP
R 0003
R 0002
MOV
MOV
CALL
PUSH
POP
MOV
XOR
STOSB
MOV
MOV
MOV
PUSH
PUSH
MOV
MOV
CALL
PUSH
POP
HOV
REP
R 0005
R 0004
REP
R
R
POP
POP
MOVS8
MOV
MeV
CALL
XOR
PUSH
POP
XOR
STDSB
MOV
MOV
STATUS
OR
OR
JHP
; MEDIA CHECK
;MEDIA CHECK (BLOCK ONLY)
kOlA_CHECK:
0188
MeV
STATUS
OR
OR
JMP
06
53
2E: C7 06 0028 R 0000
~ILD_BPB:
PUSH
PUSH
MOV
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
33B
339
340
341
342
343
344
0105
010C
010F
OlEO
01El
01E5
01E8
01EB
OlEO
01EE
01EF
01F3
01F7
01FB
01FF
0203
0209
020F
26: 81 4F 03 0100
26: Bl 4F 03 0000
EB 77 90
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
LEA
5B
07
ADD
MOV
MOVSB
POP
POP
80 16 0016 R
LEA
26:
26:
26:
26:
MOV
MOV
MOV
HOV
STATUS
OR
OR
JMP
F31 A4
B9
8C
89
8C
REP
57
4F
57
4F
12
14
OE
10
iOCTL IN:
IOCTL-OUT:
NO INPuT:
IN-STAT:
IN-FLUSH:
oui' STAT:
OUT:FLUSH.
0212
0212
0215
0219
0210
0221
0225
022B
0220
INPUT:
E8 0062 R
26: 8B 47 14
2E: A3 0028 R
26. BB 47 12
2E: A3 0025 R
E8 00A3 R
2E: BB lE 0012 R
2E. BE 06 0014 R
0232
0238
023E
26: 81 4F 03 0100
26: Bl 4F 03 0000
EB 48 90
345
346
347
348
MOV
CAlL
PUSH
POP
: DISK READ
CALL
HOV
HOV
HOV
HOV
CALL
MOV
HOV
STATUS
OR
OR
JHP
IN SAVE
; CALL THE INITIAL SAVE ROUTINE
AX:ES : WORD PTR SSNCBXJ SET STARTING SECTOR NUMBER
CS: START _SEC, AX
; SAVE STARTING SECTOR NUMBER
AX, ES: WORD PTR COUNTCBXJ
CS : TOTAL. AX
; SAVE TOTAL SECTORS TO TRANSFER
SECTOR READ
;REAO IN THAT MANY SECTORS
BX, CS RH_OFF
RESTORE ES: BX AS REQUEST HEADER POINTER
ES ,CS: RH_SEG
DONE ,NDERROR ,0
;SET STATUS WORD (DONE, NOERROR)
ES:WORO PTR SRH_STA_FLOCBXJ,0100H
ES:WORD PTR SRH_STA_FLDCBXJ,O
EXIT
; DISK WRITE
0241
0241
0244
0248
024C
0250
0254
6urPUT:
E8 0062 R
26 8B 47 14
2E A3 0028 R
26 8B 47 12
2E A3 0025 R
E8 OOCO R
CAlL
HOV
MOV
HOV
HOV
CAlL
;OUTPUT (WRITE)
IN SAVE
Al(ES.WORD PTR SSNCBXJ ;GET STARTING SECTOR NUMBER
CS:START_SEC,AX
; SET
"
"
AX,ES:WORD PTR COUNTCBXJ
CS:TOTAL,AX
;SAVE TOTAL SECTORS TO WRITE
SECTOR_WRITE
; WRITE OUT THOSE SECTORS
3-33
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
3-34
0257 2E: 8B
025C 2E. BE
0261 2E 80
0267 74 08
0269 2E: C6
026F EB Al
0271
0271
0277
0270
02BO
0280
0286
lE 0012 R
06 0014 R
3E 0027 R 00
06 0027 R 00
26: 81 4F 03 0100
26: 81 4F 03 0000
EB 09 90
2E' C6 06 0027 R 01
EB 89
MOV
MOV
CMP
JZ
MOV
JMP
NO_VERIFY:
STATUS
OR
OR
JMP
OUT_VERIFY.
MOV
JMP
8X,CS:llH_OFF
ES,CS:llH_SEG
CS: BYTE PTIl VERIFY, 0
NO VERIFY
CS:BYTE PTR VERIFY ,0
INPUT
DONE, NOERROR , 0
; SET DONE, NO ERROR IN STATUS WORD
ES.WORD PTR SllH_STAJLD[BXJ ,0100H
ES:WORD PTII SllH_STAJLD[BXJ,O
EXIT
;OUTPUT (WRITE) WITH VERIFY
; SET THE VERIFY FLAG
CS . BYTE PTR VERIFY ,1
; BRANCH TO OUTPUT ROUTINE
OUTPUT
; COMMON EXIT
0288
0288
0289
028A
028B
028C
0280
02BE
028F
0290
0291
02A0
= 02A0
02A0
02A0
5E
5F
5A
59
5B
58
07
IF
cll
~IT:
POP
POP
POP
POP
POP
POP
POP
POP
SI
01
OX
CX
8X
AX
ES
OS
RET
EO P:
; -MACRO TO ALIGN THE VIRTUAL DISK ON A PARAGRAPH BOUNDARY
If (S-START! MOD 16
(S-STAIlT!+16-( (S-START) MOD 16)
ORG
endlf
VOISK
EQU
ENOP
VOSK
ENDS
CSEG
BEGIN
END
Contents
DOS Disk Directory ................... 4-4
DOS File Allocation Table .............. 4-8
How to Use the File Allocation Table ..... 4-10
41
4-2
4-3
#
Sides
Sectors/
Track
FAT size
Sectors
Dir
Sectors
Dir
Entries
Sectors/
Cluster
1
2
1
2
8
8
9
9
1
1
2
2
4
7
4
7
64
112
64
112
1
2
1
2
DO S Disk Directory
FO RMAT initially builds the root directory for all
disks. Its location (logical sector number) and the
maximum number of entries are available through the
device driver interfaces.
Since directories other than the root directory are
actually files, there is no limit to the number of entries
they may contain. Subdirectories can be read as data
files, using an extended FCB with the appropriate
attribute byte.
4-4
hex E5
hex 2E
Filename extension.
11
02
04
4-5
08
10
20
Reserved.
22-23
<
hh
> < mm > < xx >
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
where:
is the binary number of hours (0-23)
mm is the ~inary number of minutes (0-59)
xx is the binary number of two-second
increments
hh
24-25
<
25
> <
24
>
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Y Y Y Y Y Y ymmmmddddd
where:
mm is 1-12
dd is 1-31
yy is 0-119 (1980-2099)
28-31
4-7
Meaning
FF
FE
FD
FC
F8
Fixed disk
4-8
000
FFS-FFF
xxx
4-9
2.
3.
4.
5.
4-10
1.
2.
3.
Contents
Interrupts ............................. 5-3
Function Calls ........................ 5-13
Error Return Table ................ 5-14
Invoking DOS Functions ................ 5-16
5-1
5-2
Interrupts
Note: We recommend that a program wishing to
examine or set the contents of any interrupt vector
use the DOS function calls (hex 35 and hex 25)
provided for those purposes, and avoid referencing
the interrupt vector locations directly.
DOS reserves interrupt types hex 20 to hex 3 F for its
use. This means absolute memory locations hex 80 to
hex FF are reserved by DOS. The defined interrupts
are as follows with all values in hexadecimal.
20
5-3
5-4
21
22
23
5-5
o
1
2
3
4
5
6
7
8
9
A
B
C
Description
Attempt to write on
write-protected diskette
Unknown unit
Drive not ready
Unknown command
Data error (CRC)
Bad request structure length
Seek error
Unknown media type
Sector not found
Printer out of paper
Write fault
Read fault
General failure
AX
BX
CX
DX
SI
DI
BP
DS
ES
5-6
(AL)=O
=
=2
Disk Errors
If it is a hard error on disk (AH bit 7=0), register AL
contains the failing drive number (0 = drive A, etc.);
AH bits 0-2 indicate the affected disk area and whether
it was a read or write operation, as follows:
Bit 0=0 if read operation,
1 if write operation.
Bits 2-1 (affected disk area)
o0
o1
5-7
Other Errors
If AH bit 7 = 1, then the error occurred on a character
device, or was the result of a bad memory image of the
FAT. The device header passed in BP:SI can be
examined to determine which case exists. If the
attribute byte high order bit indicates a block device,
then the error was a bad FAT. Otherwise, the error is
on a character device.
5-8
1.
2.
3.
4.
5.
6.
7.
5-9
25
5-10
80
40
20
10
08
04
03
hex 02
hex 00
26
27
5-11
Notes:
5-12
1.
2.
3.
4.
28
29-2E
2F
30-3F
Function Calls
DOS provides a wide variety of function calls for
character device I/O, file management, memory
management, date and time functions, execution of
other programs, and others. They are grouped as
follows (call numbers are in hexadecimal):
0-12
12-24
25-26
27-29
2A-2E
2F-38
39-3B
Directory group
3C-46
47
Directory group
48-4B
4C-4F
54-57
5-13
5-14
5
6
7
8
9
10
11
12
13
15
16
17
18
0001
0002
0003
0004
5-15
5-16
1.
2.
3.
5-17
5-18
1.
2.
3.
5-19
5-20
5-21
11
FCB.
Notes:
If an extended FCB is used, the following
search pattern is used:
1.
5-22
2.
13
5-23
14
15
16
5-24
17
18
19
5-25
5-26
1F
20
21
22
23
24
25
26
5-27
27
28
29
bit:
< ignored>
7 6 5 4
3 2
1 0
5-28
5-29
5-30
31
32
33
34
35
5-31
36
37
38
i WORD Date/tim;iormat- -1
1---------------1
; BYTE ASCIIZ string
I currency symbol
I followed by byte of zeros
I
I
r-------------I
I thousands separator
I
I
'-------------'-1
; BYTE ASCIIZ string decimal
I separator
I followed by byte of zeros
I
I
1---------------1
I . 24 bytes
I
I ___________
Reserved
L
.JI
5-32
h:m:s mldly
1 = Europe standard
h:m:s dimly
39
Japan standard
h:m:s d:m:y
5-33
5-34
5-35
5-36
40
41
42
5-37
44
5-38
o
R
E
S
Reserved
5-39
If ISDEV = 0
EOF = 0 if channel has been written.
Bits 0-5 are the block device
number for the channel
(0 = A, 1 = B, ... ).
Bits 15, 8-13, 4 are reserved and should not be
altered.
Note:
5-40
46
47
48
49
5-41
o=
5-42
AL = 0 Load/execute program
WORD segment address of environment string
to be passed
DWORD pointer to command line to be placed
at PSP+ 80h
DWORD points to default FCB to be passed at
PSP+ 5Ch
DWORD pointer to default FCB to be passed
at PSP+ 6Ch
AL = 3 Load overlay
WORD segment address where file will be
loaded
WORD relocation factor to be applied to the
image
5-43
parameter=value
For example, the string VERIFY=ON could be
passed. A zero value of the environment address
will cause the newly created process to inherit the
parent's environment unchanged. The segment
address of the environment is placed at offset hex
2C of the Program Segment Prefix for the program
being invoked. Error returns are 1, 2, 5, 8, 10, and
11 (refer to the error return table).
Notes:
1.
5-44
2.
5-45
- attribute found
5-46
51
52
53
54
55
56
5-47
57
5-48
Contents
DOS Memory Map ........................ 6-3
DOS Program Segment .................... 6-5
Program Segment Prefix ................... 6-9
File Control Block. . . . . . . . . . . . . . . . . . . . . . . .. 6-11
Standard File Control Block ............. 6-12
Extended File Control Block ............ 6-15
6-1
6-2
0040:0000
RO M communication area
0050:0000
XXXX:OOOO
XXXX:OOOO
XXXX:OOOO
XXXX:OOOO
XXXX:OOOO
XXXX:OOOO
6-3
Notes:
1.
2.
Used by BASIC
0050:0004
6-4
3.
6-5
NAME=parameter
Each string is terminated by a byte of zeros, and
the entire set of strings is terminated by another
byte of zeros. The environment built by the
command processor (and passed to all programs it
invokes) will contain a COMSPEC= string at a
minimum (the parameter on COMSPEC is the
path used by DO S to locate the command
processor on disk). The last PATH and PROMPT
commands issued will also be in the environment,
along with any environment strings entered
through the SET command (see Chapter 2 of the
DOS Reference manual).
6-6
6-7
6-8
Long call to
Top of
Reserved
DOS function disINT hex 20
memory
1
patcher (5 bytes)2
8
CTRL-BREAK
Terminate address
exit address
(lP,CS)
(lP)
10
ICTRL-BREAK
CRITICAL ERROR
exit address
exit address
(CS)
(lP, CS)
::::~
I'
Used by DOS
~~
2C
Note 3
6C
80
~
~--------------------------------~
Unformatted parameter area
(default disk transfer area)
= " ' , T~
100~-------------------------------
6-9
6-10
I.
2.
3.
4.
_.
-7'--T-----------I
hex FF
Zeros
- - - , FCB
Attribute I extension
O~i--------~------~--------------------------------------~------~
Drive
8rl--------~------------------------r---------------~--------------~
Filename extension
Current block
24
32
Current
record
Random record
number (low part)
Random record
number (high part)
(Offsets are in decimal)
C!'
S)(~OUI
""'t
t:C
o(')
16
Record size
o
::s
f""'t-
Standard
FCB
n>
(j
Function
0 - default drive
I - drive A
2 - drive B
etc.
After open:
I - drive A
2 - drive B
etc.
6-12
1-8
9-11
12-13
14-15
16-19
20-21
<
21
> <
20
>
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Y Y Y Y Y Y ymmmmddddd
where:
mm is 1-12
dd is 1-31
yy is 0-119 (1980-2099)
22-31
32
33-36
6-13
Notes:
6-14
1.
2.
3.
Byte
Function
FCB-7
FCB-6 to FCB-2
Reserved.
FCB-I
6-15
6-16
7-1
7-2
2.
3.
7-3
7-4
Contents
Fixed Disk Architecture ................
System Initialization ...................
Boot Record/Partition Table .............
Technical Information ..................
8-3
8-4
8-6
8-8
8-1
8-2
8-3
System Initialization
The System initialization (or system boot) sequence is
as follows:
8-4
1.
2.
3.
4.
5.
6.
8-5
8-6
1.
2.
Head
Sector
Cylinder
boot ind
CYL
syst ind
CYL
Low word
High word
Low word
High word
boot ind
CYL
syst ind
CYL
Low word
High word
Low word
High word
boot ind
CYL
syst ind
CYL
Low word
High word
Low word
High word
boot ind
CYL
syst ind
CYL
Low word
High word
Low word
High word
1FE Signature
hex 55
hex AA
8-7
Technical Information
When shipped by IBM, the 10-megabyte fixed disks are
formatted with 512-byte sectors at an interleave factor
of 6 (17 sectors per track, 4 heads per cylinder). They
contain no data or boot records.
The boot indicator byte must contain 0 for a
non-bootable partition, or hex 80 for a bootable
partition. Only one partition can be marked bootable.
The "syst ind" field contains an indicator of the
operating system that "owns" the partition. Each
operating system can "own" only one partition.
The system indicators are:
hex 00 - unknown (unspecified)
hex 01 - DOS
The I-byte fields labelled "CYL" contain the low-order
8 bits of the cylinder number-the high order 2 bits are
in the high order 2 bits of the "S" (sector) field. This
corresponds with ROM BIOS Interrupt hex 13 (disk
I/O) requirements, to allow for a 10-bit cylinder
number.
The fields are ordered in such a manner that only
2 MOV instructions are required to properly set up the
DX and CX registers for a ROM BIOS call to load the
appropriate boot record (fixed disk booting is only
possible from the first fixed disk on a system, whose
BIOS drive number (hex 80) corresponds to the boot
indicator byte.)
All partitions are allocated in cylinder multiples and
begin on sector 1, head O. EXCEPTION: the partition
which is allocated at the beginning of the disk starts at
sector 2, to account for the disk's master boot record.
8-8
8-9
8-10
1.
2.
3.
9-1
9-2
Hex Offset
Contents
00-01
02-03
04-05
06-07
08-09
OA-OB
9-3
Hex Offset
Contents
oc-on
OE-OF
10-11
12-13
14-15
16-17
18-19
lA-IB
9-4
2.
3.
4.
5.
9-5
96
6.
7.
10-1
10-2
10-4
Index
Special Characters
application, executing
commands within your 7-3
/S option 4-7
Auxiliary Asynchronous
Communications
Adapter 5-18
auxiliary input 5-18
auxiliary output 5-18
available functions, DOS 1-6
AX register 5-6, 5-16
A
absolute disk read 5-10
absolute disk write 5-11
access, random 1-6
address terminate
interrupt 5-4
AH register 5-11
allocating disk space 1-6
allocating space 1-6
allocating diskette
space 4-8
allocation table
information 5-25
allocation, diskette 4-3
allocation 4-3, 4-4
disk allocation 4-3
architecture, 8088 1-3
structure 1-3
ASCII codes, extended 5-17
ASCIIZ string 5-15
Asynchronous
Communications
Adapter 5-18
attribute byte 6-15
attribute field 3-6
attribute, file 4-5
AUTOEXEC file 1-5
B
batch file processor 1-5
BIOS 5-10
BIOS interface module 1-3
BIOS Parameter Block 3-15
block devices 3-5
block number, current 6-12
block read, random 5-26, 5-28
block write, random 5-26,
5-28
size 5-25
blocking/deblocking, data 1-3
BP register 5-6
BPB, what is 3-16
buffered standard input 5-19
buffers, file 5-3
built-in functions 1-3
BX register 5-6
byte, attribute 6-15
byte, flag 6-15
X-I
c
calls, function 5-13
chaining file sectors 1-6
character devices 3-5
check keyboard status 5-20
checksum methodology 1-5
CL register 5-16
close file 5-21
cluster number, relative 4-7
cluster, calculate 4-10
cluster, locate next 4-9, 4-10
cluster, starting 4-7
clusters 1-6, 4-3
directory 4-5
diskette directory 4-4
codes, error 5-6
COM filename extension 1-5
.COM 1-5
.EXE 1-5
COM programs 6-8
command processor 1-4
command processor, resident
portion of 1-4
COMMAND.COM 1-4,4-7,
6-3
Communications Adapter,
Auxiliary Asynchronous
5-18
console I/O, direct 5-19
control blocks 6-15
control screen cursor 2-3
create file 5-24
creating a device driver 3-8
critical error handler
vector 5-5
CS register 5-3, 5-7, 6-8
CTRL-BREAK exit
address 1-5,5-4
CTRL-BREAK handler 1-5
current block number 6-12
X-2
D
data blocking/deblocking 1-3
date file created or
updated 6-12
deblocking/blocking, data 1-3
Initialization 1-4
delete file 5-23
device driver, creating 3-9
device drivers 3-3
device drivers,
installation 3-10
device field, next 3-6
device header 3-6
devices, types of 3-4
DI register 5-6
direct console I/O 5-19
disk
current 5-25
reset 5-20
select 5-20
disk error handling 1-5
disk errors 5-7
disk read, absolute 5-10
disk transfer address 6-7
disk transfer address, set 5-25
Disk Transfer Area (DIA) 1-7
disk write, absolute 5-11
display output 5-18
DOS environment 6-6
DS register 5-6, 6-8
DT A (Disk Transfer
Area) 1-7
DX register 5-6
E
end-of-file mark 4-9
entries, search for 5-22
environment, DOS 6-6
error codes 5-6
error handling
critical 1-5
disk 1-5
error return table 5-14
error trapping 1-8
ES register 5-6, 6-8
EXE file structure 9-2
EXE filename extension 1-5,
6-3
high 1-5
EXE files, load 9-2
EXE programs 6-8
executing commands within an
application 7-2
extended ASCII codes 5-17
extended file control
block 6-15
external commands 1-6
F
FA T (see File Allocation
Table)
allocating space 4-8
FCB 6-12
FCB (see File Control Block)
field name 3-8
field, attribute 3-7
File Allocation Table
(FAT) 1-4,1-6,4-8
file allocation table, how to use
4-10
G
get
date 5-30
time 5-30
H
header 9-3
hidden files 4-5, 5-24, 6-13
attribute 4-6
high memory 1-5
available functions 1-6
high/low loader switch 9-5
X-3
I
IBMBIO.COM 1-3, 1-4, 4-7
IBMDOS.COM 1-3,4-7
initialization, DOS 1-3
input, auxiliary 5-18
installation of device
drivers 3-10
instruction set, 8088 1-2
INT hex 24 1-8
INT 21 1-6
random 1-6
sectors 1-6
sequential 1-6
interface module, BIOS 1-3
internal command
processors 1-5
interrupt hex 20 5-3
interrupt hex 22 1-5, 5-4
interrupt hex 23 1-5, 5-4
interrupt hex 24 5-5
interrupt hex 25 5-10
interrupt hex 26 5-11
interrupt hex 27 5-11
interrupt mechanism,
8088 1-2
interrupt routines 3-8
interrupt vectors 1-4
interrupt, set 5-27
interrupts 5-3
IP register 5-7, 6-8
IRET 5-5
K
keyboard input 5-17
buffered 5-19
keyboard status, check 5-20
keys, reassigning 2-3
L
linefeed 5-5
loading .EXE files 9-2
locate next cluster 4-9, 4-10
logical record size 6-12
logical sector numbers 5-10
M
mapping file sectors 1-6
memory management 10-1
memory map 6-3
MOV instruction 4-10
N
name field 3-8
next device field 3-6
o
open file 5-21
output, auxiliary 5-18
output, display 5-18
X-4
routines
memory management 1-6
ROM BIOS 5-19
parameters, function call 3-16
routines,
strategy/interrupt 3-8
parse filename 5-28
pointer to next device 3-9
print string 5-19
printer output 5-18
program segment
screen cursor control 2-3
create new 5-27
search for entries 5-22
DOS 6-5
sector
numbers, logical 5-10
Program Segment Prefix 1-4,
sectors,
file 1-6
1-7, 6-8, 6-9
segment
address 6-6
program terminate 5-1 7
segment, create new
program 5-27
segment, start 9-5
R
select disk 5-20
separators, filename 5-28
random access 1-6
sequential read 5-24
random block read 1-6, 5-28
sequential write 5-24
random block write 1-6, 5-28
set
random read 5-26
date 5-30
random record field, set 5-24
interrupt 5-27
random write 5-26
random record field 5-27
Read-Only Memory
time 5-30
(ROM) 1-3
verify switch 5-30
read, random 5-26
set disk transfer address 5-25
read, random block 5-28
SI register 5-6
read, sequential 5-24
single-drive system 5-20
reassign keys 2-2
size, file 6-13
record number, relative 6-13
SP register 6-8
record size, logical 6-11
space allocation 1-6, 4-3
relative record number 6-13
SS register 6-8
relocation 9-5
stack, user 5-6
rename file 5-25
start segment 9-5
reset, disk 5-20
starting cluster 4-7
reset, system 1-4
strategy routines 3-8
resident portion of command
structure, DOS 1-3
processor 1-5
switch, high/low loader 9-5
ROM (Read-Only
System Initialization 8-4
Memory) 1-3
system prompt 1-5
ROM BIOS routine 5-20
x-s
T
technical information,
DOS 1-3
terminate address
interrupt 5-4
terminate program 5-1 7
terminate program
interrupt 5-4
terminators, filename 5-28
transfer address, disk 6-7
transient portion of command
processor 1-5
u
user stack 5-6
v
verify switch 5-30
w
work areas 6-3
wrap around 3-23
write, random 5-25
write, random block 5-28
write, sequential 5-24
X-6
1502346
111111
ND PDSTAGE
NECESSARY
IF MAILED
IN THE
UNITED STATES
9J94 Pia.:!
9d e l
-- --=--=
===
- --=~="!'=
==.=~
1502346
111111
NO POSTAGE
NECESSARY
IF MAILED
IN THE
UNITED STATES
aJa4 PIO.::!
ade!
1502346
111111
NO POSTAGE
NECESSARY
IF MAILED
IN THE
UNITED STATES
aJall PIO:l
adel
-----:-:.-:=:
-=-'-
----
1502346
111111
NO POSTAGE
NECESSARY
IF MAILED
IN THE
UNITED STATES
9J94 Pia.:!
adel
----
~: :i~~
1502346
111111
NO POSTAGE
NECESSARY
IF MAILED
IN THE
UNITED STATES
aJa4 Pia:!
adel