Professional Documents
Culture Documents
8411-310-02 MSDOS 3.10 Programmers Reference Manual 1984
8411-310-02 MSDOS 3.10 Programmers Reference Manual 1984
Microsoft Corporation
Information in this document is subject to change without
notice and does not represent a commitment on the part of
Microsoft Corporation. The software described in this
document is furnished under a license agreement or
nondisclosure agreement. The software may be used or copied
only in accordance with the terms of the agreement. It is
against the law to copy the Programmer's Reference Manual on
magnetic tape, disk, or any other medium for any purpose
other than the purchaser's pers9nal use.
Microsoft Corporation
Microsoft Building
10700 Northup Way
Bellevue, WA 98004
Disk drive(s)
One disk drive if and only if output is sent to the
same physical disk from which the input was taken.
None of the programs allows time to swap disks
during operation on a one-drive configuration.
Therefore, two disk drives is a more practical
cxmfiguration.
1.1 INTRODUCTION
1.5.1 Handles
File Sharing
Table 1.9 describes the file attributes and how they are
represented in the attribute byte of the directory entry
(offset OBH). The attributes can be inspected or changed
with Function 43H (Get/Set File Attributes) .
Code Description
OOH Normal. Can be read or written without restriction.
lOH Subdirectory.
Most of the system calls that have been superseded deal with
files. Table 1.12 lists these old calls and the function
requests that have superseded them.
The program Segment Prefix (PSP) includes room for two FCBs
at offsets 5CH and 6CH. See Chapter 4 for a description of
the PSP and how these FCBs are used. Table 1.13 describes
the fields of the FCB.
SYSTEM CALLS Page 1-17
Offset
Hex Dec Bytes Name
Date of Last Write (offset 14H): The date the file was
created -or- last updated.----The year, month, and day are
mapped into two bytes as follows:
Offset 15H Offset 14H
lylylylylylylylMI IMIMIMIDIDIDIDIDI
15 9 854 a
Time of Last Write (offset l6H): The time the file was
created or last updated. The hour, minutes, and seconds are
mapped into two bytes as follows:
Note
Extended FCB
MS-DOS reserves Interrupts 20H through 3FH for its own use.
The table of interrupt handler addresses (vector table) is
maintained in locations 80H-FCH. Most of the interrupts
have been superseded by function requests. Descriptions of
three MS-DOS interrupt handlers (Program Terminate,
Control-C, and Critical Error) are included in case you must
write your own routines to handle these interrupts.
TO issue an interrupt, move any required data into the
registers and issue the interrupt.
SYSTEM CALLS Page 1-20
31 General failure
32 Sharing violation
33 Lock violation
34 Wrong disk
35 FCB unavailable
36-49 RESERVED
50 Network request not supported
51 Remote computer not listening
52 Duplicate name on network
53 Network name not found
54 Network busy
55 Network device no longer exists
56 Net BIOS command limit exceeded
57 Network adapter hardware error
58 Incorrect response from network
59 Unexpected network error
60 Incompatible remote adapt
61 Print queue full
62 Queue not full
63 Not enough space for print file
64 Network name was deleted
65 Access denied
66 Network device type incorrect
67 Network name not found
68 Network name limit exceeded
69 Net BIOS session limit exceeded
70 Temporarily paused
71 Network request not accepted
72 Print or disk redirection is paused
73-79 RESERVED
80 File exists
81 RESERVED
82 Cannot make
83 Interrupt 24 failure
84 Out of structures
85 Already assigned
86 Invalid password
87 Invalid parameter
88 Net write fault
JC <error>
where <error> represents the label of an error-handling
routine that gets the specific error condition by checking
the value in AX and takes appropriate action.
Some of the older system calls return a value in a register
that specifies whether the operation was successful. To
handle such errors, check the error code and take the
appropriate action.
SYSTEM CALLS Page 1-23
cx: CH CL
ox: DM DL
Return
~
BP
S,
DI
I
FLAGSH 'I F~Sl I
~ SS
ES
segment
assume cS:COq.~ids : code ,eS: nothing.; ss: nothing
org IOOH
start: jmp begin
filename db ftb:\te.~tfile.asc" ,0
buffer db 129PllP (1)
handle dw ?
Interrupt Description
Description Interrupt
Absolute Disk Read 25H
Absolute Disk Write 26H
Control-C Handler Address 23H
Critical Error Handler Address 24H
Function Request 21H
Program Terminate 20H
RESERVED 28H-3FH
Terminate Process Exit Address 22H
Terminate But Stay Resident 27H
SYSTEM CALLS Page 1-27
Function Description
Function Description
1.10 INTERRUPTS
~
p
BP Return
51 None
01
I FLAGS" Ii FLAGS, I
~
~
55
ES
Note
Example
The following program displays a message and returns to
MS-DOS. It uses only the opening portion of the sample
program skeleton shown in Figure 1.2:
message db "displayed by INT20H example". ODH, OAH, "$"
~
As specified in individual function
BP
SI
Return
01
As specified in individual function
~ SS
ES
Example
User Stack
The user stack is in effect, and contains the following
(starting with the top of the stack):
Bits
2-1 Location of error
00 MS-DOS area
01 File Allocation Table
10 Directory
11 Data area
Bits 3-5 of AH specify valid responses to the error prompt:
~
p
BP
CX
SI
Number of sectors
01
DX
Beginning relative sector
Return
~
AL
Error code if CF=l
FlagsL
a==J CF 0 if successful
1 if not successful
Warning
Note
The system pushes the flags at the time of the call; they
are still there upon return. Be sure to pop the stack upon
return to prevent uncontrolled growth.
Macro Definition:
abs disk read macro disk,buffer,num sectors,first sector
- - mov al,disk - -
mov bx,offset buffer
mov cx,num sectors
mov dx,first sector
int 25H -
popf
endm
Example
~
p
BP
ex
Number of sectors
SI
DX
DI
Beginning relative sector
I FLAGS" '[ ~. ]
Return
~
: AL
Error code if CF '= 1
SS FLAGSL
ES CF = 0 if successful
1 if not successful
warning
Note
The system pushes the flags at the time of the calli they
are still there upon return. Be sure to pop the stack upon
return to prevent uncontrolled growth.
If the disk operation was successful, the Carry Flag (CF) is
O. If the disk operation was not successful, CF is 1 and AL
contains the MS-DOS error code (see Interrupt 24H for the
codes and their meanings).
Macro Definition:
abs disk write macro disk,buffer,num sectors,first sector
mov al,disk - -
mov bx,offset buffer
mov cx,num sectors
mov dx,first sector
int 26H -
popf
endm
Example
The following program copies the contents of a single-sided
disk in drive A to the disk in drive B, verifying each
write. It uses a buffer of 32K bytes.
off equ 0
on equ 1
,
prompt db "Source in A, target in B",ODH,OAH
db "Any key to start. $"
first dw 0
buffer db 60 dup (512 dup (?» ; 60 sectors
~
BP
Return
SI
None
01
I FLAGSH If FLAGSL I
~ SS
ES
Example
~
p
BP
SI
Return
01
None
~
:
ss
ES
Warning
Example
The following program displays a message and returns to
MS-DOS. It uses only the opening portion of the sample
program skeleton shown in Figure 1.2.
~
p
AL
BP Character typed
SI
01
I FLAGS" If FLAGSL I
~
s
os
SS
ES
Example
The following program displays and prints characters as they
are typed. If Return is pressed, the program sends a Line
Feed-Carriage Return sequence to both the display and the
printer.
~
p
BP
Return
SI
None
01
§
s
os
SS
ES
Example
The following program converts lowercase characters to
uppercase before displaying them.
ox: OH OL
Return
~
p
AL
BP
Character from auxiliary device
SI
01
I FLAGSH II FlAGSL I
~
~
SS
ES
Example
~
p
BP
Return
SI
None
DI
~
s
os
SS
ES
Examp1e
The following program gets a series of strings of up to 80
bytes from the keyboard, sending each to the auxiliary
device. It stops when a null string (CR only) is typed.
~
BP
Return
SI
None
01
~
os
SS
ES
Example
line- num db 0
begin: mov cx,60 :print 60 lines
start line: mov bl,33 :first printable ASCII
- :character (1 )
add bl,line- num :to offset one character
push cx :save number-of-lines counter
mov cx,80 : loop counter for line
print_ it: print- char bl :THIS FUNCTION
inc bl :move to next ASCII character
cmp bl,126 :last printable ASCII
;character (-)
jl no reset :not there yet
SYSTEM CALLS Function 05H Page 1-54
~
BP
Return
SI
AL
01
If DL = FFH before call,
then zero flag not set means AL
has character from standard input.
Zero flag set means there was not
~
a character to get, and AL = 0
os
SS
ES
Value in DL Action
Example
OX: OH OL
Return
~
BP
AL
SI
Character from keyboard
DI
~
s
os
SS
ES
Examp1e
password db 8 dup(?)
prompt db "Password: $" isee Function 09H for
iexplanation of $
begin: display prompt isee Function 09H
nov cx,8 imaximum length of password
xor bx,bx iSO BL can be used as index
get_pass: dir console input iTHIS FUNCTION
cmp al,ODH- iwas it a CR?
je return iyes, all done
rnov password[bx},al ino, put character in string
inc bx ibump index
loop get_pass ig et another character
SYSTEM CALLS Function 08H Page 1-58
ox: DH OL
Return
~
p
AL
BP
Character from keyboard
SI
01
~
s
os
SS
ES
Example
password db 8 dup(?)
prompt db "Password: $" ;see Function 09H
;for explanation of $
begin: display prompt ;see Function 09H
mov cx,8 ;maximum length of password
xor bx,bx ;BL can be an index
read kbd ;THIS FUNCTION
cmp aI, ODH ;was it a CR?
je return ;yes, all done
mov password [bx] ,al ;no, put char. in string
inc bx ;bump index
loop get_pass ;get another character
SYSTEM CALLS Function 09H Page 1-59
~
p
BP
Return
SI
None
01
I II I
~ .
FLAGS" FLAGSL
§ SS
ES
Example
The following program displays the hexadecimal code of the
key that is typed.
table db "0123456789ABCDEF"
result db " - OOH",ODH,OAH,"$" ;see text for
;explanation of $
begin: read kbd and echo ;see Function OlH
xor - ah,ah ;clear upper byte
convert ax,16,result[3] ;see end of chapter
display result ;THIS FUNCTION
jmp begin ;do it again
SYSTEM CALLS Function OAR Page 1-60
~
p
BP
Return
SI
None
01
I FLAGS" Ii FLAGSl I
~
...•.. ;
SS
....
ES
Byte Contents
1 Maximum number of characters in buffer, including
the carriage return (you must set this value) .
ox: OH OL
Return
~
p
AL
BP
FFH = characters in type-ahead
SI
buffer
01
o = no characters in type-ahead
buffer
~
s
os
SS
ES
time db "OO:OO:OO.OO",ODH,OAH,"$"
~
p
BP
is called.
SI
Any other value = no
01
further processing.
~
s o= Type-ahead buffer was
OS flushed; no other
SS processing performed.
ES
Example
ox: OH OL
Return
~
None
BP
SI
01
~
s
os
5S
ES
Example
~
BP
SI
Return
01
AL
Number of logical drives
I FLAGSH Ii FLAGSL I
~
os
SS
ES
Note
Example
~
BP
Return
SI
AL
01
o = Directory entry found
I
FLAGSH II FLAGSL I FFH = No directory entry found
~ SS
ES
Example
fcb db 2, "TEXTFILEASC"
db 26 dup (?)
buffer db 128 dup (?)
~
BP Return
51 AL
01
o = Directory entry found
FFH = No directory entry found
§ 55
E5
Example
~
p
BP
Return
SI
AL
01
o = Directory entry found
FFH = No directory entry found
~
s
. . . . . . . . . . ... >
I:.~
SS
ES
If the search FCB was normal, the first byte at the Disk
Transfer Address is set to the drive number used (l=A, 2=B,
etc.) and the next 32 bytes contain the directory entry.
If the search FCB was extended, the first byte at the Disk
Transfer Address is set to FFH, the next 5 bytes are set to
OOH, and the following byte is set to the value of the
attribute byte in the search FCB. The remaining 33 bytes
are the same as the result of the normal FCB (drive number
and 32 bytes of directory entry) •
~
BP
Return
SI
AL
01
o = Directory entry found
FFH = No directory entry found
I
FLAGSH If FLAGSL I
~ SS
ES
Example
~
p
BP Return
51 AL
01 o = Directory entry found
FFH = No directory entry found
~
.'i.;'." . . . . '.
55
ES
Example
year dw 1982
nonth db 12
day db 31
files db
message
feb
db
db
°
"NO FILES DELETED.",ODH,OAH,"$"
2,"???????????"
db 26 dup (? )
buffer db 128 dup (?)
~
p
BP Return
SI AL
01 OOH Read completed successfully
OlH EOF
I I 02H DTA too small
...; . . .,.',
FLAGSH Ii FLAGSL
03H EOF, partial record
§ ss
ES
The length of the record is taken from the Record Size field
(offset OEH) of the FCB.
Code Meaning
Example
The following program displays the file named TEXTFILE.ASC
that is on the disk in drive Bi its function is similar to
the MS-DOS Type command. If a partial record is in the
buffer at end of file, the routine that displays the partial
record displays characters until it encounters an
end-of-file mark (ASCII lAH, or Control-Z).
fcb db 2, "TEXTFILEASC"
db 26 dup (?)
buffer db 128 dup (?) ,"$"
begin: set dta buffer isee Function lAH
open fcb isee Function OFH
read seq fcb iTHIS FUNCTION
cmp - al,02H iDTA too small?
je all done ;yes
cmp al,OOH ;end-of-file?
jg check more iyes
display buffer ;see Function 09H
jmp read line iget another record
cmp al,03H ;partial record in buffer?
jne all done ino, go home
xor si,si iset index to 0
find eof: cmp buffer [si] ,26 ;is character EOF?
Je all done iyes, no more to display
display char buffer [si] isee Function 02H
inc sT ibump index
jmp find eof icheck next character
all done: close fcb isee Function lOH
SYSTEM CALLS Function ISH Page 1-79
AX: AM At Call
BX: BH BL AH = ISH
cx: CH CL
DS:DX
ox: DH 01.
Pointer to opened FCB
~
BP Return
SI AL
01 OOH Write completed successfully
OlH Disk full
02H DTA too small
~
DS
SS
ES
The record size is taken from the value of the Record Size
field (offset OEH) of the FCB. If the Record Size is less
than a sector, the data at the Disk Transfer Address is
written to an MS-DOS buffer; MS-DOS writes the buffer to
disk when it contains a full sector of data, or the file is
closed, or a Reset Disk system call (Function ODH) is
issued.
AL returns a code that describes the processing:
Code Meaning
AX: Call
BX: BH BL AlI = 16H
ex: CH Cl OO:DX
ox: DH DL ' Pointer to unopened FCB
~
p
BP
Return
Sl
AL
01 OOH Empty directory found
FFH = Noempty directory
available
~
": ss
ES
Example
AX: AM AL Call
ex: BH Bl AH = 17H
cx: CH Cl DS:DX
ox: OH DL Pointer to modified FCB
~
BP Return
SI AL
01 OOH = Directory entry found
FFH = No directory entry
found or destination already
exists
~
-os
SS
ES
Example
~
AL
BP
Currently selected drive
51
(0 = A, 1 = B, etc.)
01
etc.) •
m 5
05
55
E5
Example
The following program displays the currently selected
(default) drive in a 2-drive system.
AX: 4M AL Call
BX: BH BL AH = lAH
CX: CH CL DS:DX
OX: f DI'I ~ Disk Transfer Address
~
p
BP Return
SI None
01
I I,FLAGS" FLAGS, I
§
Function lAH sets the Disk Transfer Address. DX must
contain the offset (from the segment address in DS) of the
Disk Transfer Address. Disk transfers cannot wrap around
from the end of the segment to the beginning, nor can they
overflow into another segment.
If you do not set the Disk Transfer Address, MS-DOS defaults
to offset 80H in the Program Segment Prefix. You can check
the current Disk Transfer Address with Function 2FH (Get
Data Transfer Address).
Example
AX: Call
ex: AH = lBH
ex:
ox:
Return
~
p AL
BP Sectors per cluster
SI ex
01 Bytes per sector
DX
Clusters per drive
OO:BX
.i; ....
~
Pointer to FAT 1D byte
ss
ES
Example
stdout equ 1
AX: Call
BX: AH lCH
ex: DL
OX: Drive (O=default, l=A, etc.)
~
p
Return
BP
AL
51
OFFH if drive number is invalid,
01 otherwise sectors per cluster
ex
Bytes per sector
DX
Clusters per drive
DS:BX
Pointer to FAT ID byte
Example
~
p
BP Return
SI AL
01 o Read completed successfully
1 End of file, record empty
2 DTA too small
3 End of file, partial record
~
.:' ......•.
ss
ES
Code Meaning
Example
AX: Call
BX: BH BL AH = 22H
ex: CH CL OO:DX
ox: .. .,~ Pointer to opened FCB
~
p
BP Return
SI AL
01 OOH Write completed successfully
OIH Disk full
I FLAGS" 'j FLAGS, I 02H DTA too small
~
s
...............::< ..............
ES
Code Meaning
Example
mov
icode to record
fcb[relative record] ,al
*
- iset relative record
display crlf isee Function 09H
read ran fcb iTHIS FUNCTION
display buffer isee Function 09H
display crlf isee Function 09H
display prompt2 isee Function 09H
get string 27,reply isee Function OAH
display crlf ;see Function 09H
cmp reply[l],O ;was anything typed
ibesides CR?
je ino
iget another char.
xor bx,bx ito load a byte
mov bl, reply [1] iuse reply length as
icounter
SYSTEM CALLS Function 22H Page 1-96
AX: Call
BX: BH BL AH = 23H
CX: CH CL DS:DX
OX: DK QL. Pointer to unopened FCB
~
p
BP Return
51 AL
01 OOH Directory entry found
FFH No directory entry found
~
5
OS . . . . .
5S
ES
You must set the Record Size field of the FCB to the correct
value before calling this function. If the Record Size
field is not an even divisor of the File Size field, the
value set in the Relative Record field is rounded up,
yielding a value larger than the actual number of records.
Example
~
p
BP Return
51 None
01
I FLAGS" II FLAGSl I
~.
CS .
us
55
ES
Example
The following program copies a file using the Random Block
Read and Random Block Write system calls. It speeds the
copy by setting the record length equal to the file size and
the record count to 1, and using a buffer of 32K bytes. It
positions the file pointer by setting the Current Record
field (offset 20H) to 1 and using Set Relative Record to
make the Relative Record field (offset 21H) point to the
same record as the combination of the Current Block field
(offset OCH) and Current Record field (offset 20H).
SYSTEM CALLS Function 24H Page 1-100
~
Pointer to interrupt-handling
BP routine
SI
01
Return
None
~
:
ss
ES
Macro Definition:
Example
~
p
BP Return
81 None
DI
~
s
os
SS
ES
Example
~
p
Number of blocks to read
BP
SI
01 Return
AL
I FLAGS" 'I FLAGSL I o
1
Read completed successfully
End of file, empty record
2 DTA too small
~
.:. 3 End of file, partial record
ss CX
ES
Number of blocks read
Oode Meaning
Macro Definition:
= ~ ~ Call
~ ~ ~ AH = 28H
~ DS:DX
~
Pointer to opened FeB
CX
Number of blocks to write
(0 = set File Size field)
Return
AL
OOH Write completed successfully
OlH Disk full
~
....... ~
c. s........•...•.........•.. 02H End of segment
~
CX
~
Number of blocks written
Code Meaning
Macro Definition:
Example
a
~
a
=
- ~
~
•
~
~
~
Call
AH = 29H
AL
Controls parsing (see text)
DS:S1
~
Pointer to string to parse
~
ES:D1
•
. • . . . . . • . • . • . . • • • • •s.:
....p
...•••..
: :•.••...••• :...••.•..•..•••••:...••.:•. :.•:.••.•••..•
~
: :.••••..•.••.•
:: :••.•••••.::•••.::•.::•.
Pointer to buffer for unopened FCB
Return
AL
OOH No wildcard characters
. . .:. . . . . .:
OlH Wildcard characters used
§ 9
~
FFH
DS:S1
Drive letter invalid
Pointer to first byte past
string that was parsed
ES:D1
Pointer to unopened FCB
Example
The following program verifies the existence of the file
named in reply to the prompt.
~
p CX
BP Year (1980-2099)
SI DH
01 Month (1-12)
DL
Day (1-31)
I FLAGS" Ii FLAGS, I AL
Day of week (O=Sun., 6=Sat.)
~
~
SS
ES
Example
month db 31,28,31,30,31,30,31,31,30,31,30,31
,
begin: get_date iTHIS FUNCTION
inc dl iincrement day
xor bx,bx iSO BL can be used as index
mov bl,dh imove month to index register
dec bx imonth table starts with 0
cmp dl,month[bx] ipast end of month?
jle month ok ino, set the new date
mov dl,l iyes, set day to 1
inc dh iand increment month
cmp dh,12 ipast end of year?
jle month ok ino, set the new date
mov dh,l iyes, set the month to 1
inc cx iincrement year
month ok: set_date cx,dh,dl isee Function 2AH
SYSTEM CALLS Function 2BH Page 1-114
~
p Month (1-12)
BP DL
SI Day (1-31)
DI
Return
AL
OOH
~
s Date was valid
os FFH Date was invalid
SS
ES
ex Year (1980-2099)
DH Month (l=January, 2=February, etc.)
DL Day (1-31)
If the date is valid, the date is set and AL returns O. If
the date is not valid, the function is canceled and AL
returns FFH.
Macro Definition: set date macro year,month,day
mov cx,year
mov dh,month
mov dl,day
mov ah,2BH
int 21H
endm
SYSTEM CALLS Function 2BH Page 1-115
Example
month db 31,28,31,30,31,30,31,31,30,31,30,31
,
begin: get date isee Function 2AH
inc- dl iincrement day
xor bx,bx iSO BL can be used as index
mov bl,dh imove month to index register
dec bx imonth table starts with 0
cmp dl,month[bx] ipast end of month?
jle month ok ino, set the new date
mov dl,l ;yes, set day to 1
inc dh iand increment month
cmp dh,12 ;past end of year?
jle month ok ino, set the new date
mov dh,l iyes, set the month to 1
inc cx iincrement year
month ok: set date cx,dh,dl ;THIS FUNCTION
SYSTEM CALLS Function 2CH Page 1-116
AX: ~ AL Call
BX: BH BL AH = 2CH
ex: (lH .•. Cl
ox: ·.lItf . . . 01.
Return
~
CH
BP Hour (0-23)
51 CL
01 Minutes (0-59 )
DH
Seconds (0 - 59)
IlL
Hundredths (0-99)
~
os
55
E5
Example
time db "OO:OO:OO.OO",ODH,"$"
,
begin: get time iTHIS FUNCTION
~te to dec ch,time isee end of chapter
~te-to-dec cl,time[3] isee end of chapter
~te-to-dec dh,time[6] isee end of chapter
~te-to-dec dl,time[9] isee end of chapter
display-time isee Function 09H
check kbd status isee Function OBH
crop - al, OFFH ihas a key been pressed?
je return iyes, terminate
jmp begin ino, display time
SYSTEM CALLS Function 2DH page 1-118
AX: Call
BX: AH = 2DH
ex: CH
OX:
Hour (0-23)
CL
~
p Minutes (0-59)
BP DR
SI Seconds (0-59)
DI DL
Hundredths (0-99)
I FLAGS" II FLAGSL I
Return
~
s
OS AL
SS OOH Time was valid
ES
FFH Time was invalid
CH Hour (0-23)
CL Minutes (0-59)
DH Seconds (0-59)
DL Hundredths of a second (0-99)
EXaDlple
The following program sets the system clock to °
and
continuously displays the time. When a character is typed,
the display freezesi
clock is reset to ° when another character is typed,
and the display starts again.
the
time db "OO:OO:OO.OO",ODH,OAH,"$"
~
p
BP
81 Return
01 None
SS
ES
Example
The following program copies the contents of a single-sided
disk in drive A to the disk in drive B, verifying each
write. It uses a buffer of 32K bytes.
on equ 1
off equ 0
AX: Call
BX: AH = 2FH
CX:
OX: OH OL Return
ES:BX
~
p Pointer to Disk Transfer Address
BP
51
01
I I
,.",,. '. ',
'f
w
FLAGS" FLAGSL
OS
55
5........,.,.....".....•.......
,
··i' •. ,:J:!S,
c....
,
Example
AX: Call
BX: AH = 30H
ex:
ox: Return
AL
~
p Major version number
BP AH
51 Minor version number
01 BH
OEM serial number
BL:CX
24-bit user (serial) number
~
5
05
55
E5
Example
AX: Call
BX: AH = 3lH
ex: AL
ox: Return code
DX
~
p
Memory size, in paragraphs
BP
SI Return
01 None
I FLAGS" Ii FLAGS, I
~
s
OS
SS
ES
~
p
DL (if AL=l)
BP
0 Off
SI 1 = On
01
Return
I FLAGS" r FLAGSl I DL (if AL=O)
o Off
1 = On
~
s
OS AL
SS FFH error (AL was neither 0 nor 1
ES
when call was made)
Note
Example
AX: Call
BX: AH 35H
ex: AL
ox: DH OL Interrupt number
§
p
Return
BP ES:BX
SI Pointer to interrupt routine
01
~
os
es
..
SS
...
ES
Example
AX: Call
ax: AH 36H
ex: DL
ox: Drive (O=default, l=A, etc.)
~
p Return
BP AX
SI OFFFFH if drive number is invalid;
01 otherwise sectors per cluster
BX
Available clusters
CX
Bytes per sector
~
s
os DX
SS Clusters per drive
ES
Example
AX: Call
BX: AH 38H
ex: AL
ox: o Current country
1 to OFEH Country code
~
p OFFH BX contains Country code
BP BX (if AL=OFFH)
51 Country code 255 or higher
01 DS:DX
Pointer to 32-byte memory area
Return
~
j';~.;
Carry set:
AX
55 2 = Invalid country code
E5 Carry not set:
BX
Country code
Offset
Hex Decimal Field Name Length in bytes
Code Meaning
AX: Call
BX: AH 38H
ex: DX -1 (OFFFFH)
ox: AL
Country code less than 255, or
~
p
OFFH if the country code is in BX
BP
BX (if AL=OFFH)
SI Country code 255 or higher
01
Return
Carry set:
AX
2 = Invalid country code
~
s
os Carry not set:
SS No error
ES
Code Meaning
Example
uk equ 44
,
begin: set_country uk iTHIS FUNCTION
jc error iroutine not shown
SYSTEM CALLS Function 39H page 1-137
~
p Return
BP Carry set:
SI AX
DI 3 = Path not found
5 = Access denied
I I Carry not set:
.§. . .
FLAGS" Ii FLAGSc
No error
c....s........
,0$ .
ss
ES
Code Meaning
Example
AX:
Call
BX:
AH = 3AH
ex:
DS:DX
ox:
Pointer to pathname
~
p Return
BP Carry set:
SI AX
01 3 Path not found
5 Access denied
16 Current directory
Carry not set:
es No error
. ....................................
0$:
····················
SS
ES
m ·
Example
The following program adds a subdirectory named NEWDIR to
the root directory on the disk in drive B, changes the
current directory to NEWDIR, changes the current directory
back to the original directory, then deletes NEWDIR. It
displays the current directory after each step to confirm
the changes.
~
p
Return
BP Carry set:
SI AX
01 3 = Path not found
Carry not set:
No error
~
~........
SS
ES
Code Meaning
Example
The following program adds a subdirectory named NEW DIR to
the root directory on the disk in drive B, changes the
current directory to NEW DIR, changes the current directory
back to the original directory, then deletes NEW DIR. It
displays the current directory after each step to- confirm
the changes.
SYSTEM CALLS Function 3BH page 1-142
~
p File attribute
BP
SI Return
01 Carry set:
AX
3 Path not found
4 Too many open files
: 5 Access denied
~
. ... Carry not set:
SS AX
ES
Handle
Example
AX: Call
''
BX: BH BL Ali 3DH
CX: CH CL
AL
OX:
Access code (see text)
DS:DX
~
p Pointer to pathname
BP
SI Return
01 Carry set:
AX
I FLAGS" Ir",~,J 1
2
Invalid function code
File not found
3 Path not found
~
".' PI
..'.". .".'."." . ".'. . '. "'.."" ..'.'.,.,.', '.., ,.,',',.,',.' . ,.','.,.',.',. .'.,..C,'.','.'.S. . . .,. .'"."..,.',. ,... ,'"..., ".,.,'.,.'.',.','...,.,.,.',.,. .,'.,•,.'.'. .". .'...', ,',..' ',.'.',.',., 4
5
Too many open files
Access denied
SS
ES
12 Invalid access
carry not set:
No error
Bit
1_71_61_51_41_3 1_2 1_1 1_° 1
~----,,-\
1
I
Access code
I~) Sharing mode
) Inherit bit
SYSTEM CALLS Function 3DH Page 1-146
Inherit Bit
The high-order bit (bit 7) specifies whether the file is
inherited by a child process created with Function 4BH (Load
and Execute Program). If the bit is 0, the file is
inherited; if the bit is 1, the file is not inherited.
Sharing Mode
Access Code
Access
Bits 0-3 Allowed Description
Code Meaning
1 File sharing must be loaded to specify a sharing
node (bits 4-6 of AL).
Example
The following program prints the file named TEXTFILE.ASC on
the disk in drive B.
file db "b:textfile.asc",O
buffer db ?
handle dw ?
,
begin: open handle file,O iTHIS FUNCTION
nov -handle,ax ;Save handle
read char: read handle handle,buffer,l ;Read 1 character
jc -error read ;Routine not shown
anp ax,O ;End of file?
je return ;Yes, go home
print char buffer ;See Function OSH
jmp read_char ;Read another
SYSTEM CALLS Function 3EH Page 1-149
§ BP
SI
01
Return
Carry set:
AX
6 = Invalid handle
Carry not set:
I FLAGSH I, FlAGSt I No error
§ os
SS
ES
Code Meaning
Example
AX: Call
BX: AH 3FH
ex: BX
ox: Handle
CX
~
p Bytes to read
BP DS:DX
SI Pointer to buffer
01
Return
Carry set:
I FLAGS" '[:FLAGS.) AX
5 = Access denied
~
s
OS 6 = Invalid handle
SS
Carry not set:
ES
AX
Bytes read
Code Meaning
5 Handle is not open for reading.
Example
filename db "b:\textfile.asc",O
buffer db 129 dup (?)
handle dw ?
AX: Call
BX: AH 40H
ex: BX
ox: Handle
CX
~
f Bytes to write
Bf DS:DX
51 Pointer to buffer
DI
Return
I FLAGS" It ~t J Carry set:
AX
5 = Access denied
~
s
DS 6 = Invalid handle
5S
Carry not set:
ES
AX
Bytes written
Code Meaning
5 Handle is not open for writing.
~
p Return
BP Carry set:
SI AX
01 2 = File not found
5 = Access denied
Carry not set:
§.: . . .:..
No error
ss
ES
Example
year db 1981
month db 12
day db 31
files db ?
ten db OAH
message db "NO FILES DELETED.",ODH,OAH,"$"
path db "b:*.*", 0
buffer db 43 dup (?)
,
begin: set dta buffer ;See Function lAH
select disk "B" iSee Function OEH
find fIrst file path,O ;See Function 4EH
jc all done ;Go home if empty
compare: convert date- buffer ;See end of chapter
cmp cx,year iAfter 1981?
jg next ;Yes, don't delete
cmp dl,month ;After December?
jg next ;Yes, don't delete
cmp dh,day i31st or after?
jge next ;Yes, don't delete
delete entry buffer [lEH] ;THIS FUNCTION
jc error delete iRoutine not shown
inc files- iBump file counter
next: find next file iCheck directory
jnc - compare ;Go home if done
how_many: cmp files,O ;Was directory empty?
je all done ;Yes, go home
convert files,ten,message ;See end of chapter
all done: display message ;See Function 09H
select disk "A" ;See Function OEH
SYSTEM CALLS Function 42H Page 1-157
AX: Call
BX: AH 42H
ex: AL
ox: Method of moving
BX
~
p Handle
BP CX:DX
SI Distance in bytes (offset)
01
Return
I FLAGSH If FtAGSl J Carry set:
AX
1 = Invalid function
~
s
os 6 = Invalid handle
SS Carry not set:
ES
DX:AX
New read/write pointer location
Function 42H moves the read/write pointer of the file
associated with the specified handle. BX must contain the
handle. CX and DX must contain a 32-bit offset (CX contains
the most significant byte). AL must contain a code that
specifies how to move the pointer:
1 AL isn't 0, 1, or 2.
~
p
BP
ex (if AL=l)
Attributes to be set
SI
LS:DX
01
Pointer to pathname
~
e. s
0$
.
AX
1 Invalid function
SS 3 = Path not found
ES 5 = Access denied
carry not set:
ex
Attribute byte (if AL=O)
Code Meaning
1 AL isn't 0 or 1.
Example
The following program displays the attributes assigned to
the file named REPORT.ASM in the current directory on the
disk in drive B.
header db 15 dup (20h) ,"Read-",ODH,OAH
db "Filename Only Hidden
db "System Volume Sub-Dir Archive"
db ODH,OAH,ODH,OAH,"$"
path db "b:report.asm",3 dup (0) ,"$"
attribute dw ?
blanks db 9 dup (20h), "$"
;
begin: change_attr path,O,O ;THIS FUNCTION
jc error mode ;Routine not shown
mov attribute,cx ;Save attribute byte
display header ;See Function 09H
display path ;See Function 09H
mov cx,6 ;Check 6 bits (0-5)
mov bx,l ;Start with bit 0
chk bit: test attribute,bx ;Is the bit set?
jz no attr ;No
display char "X" ;See Function 02H
jmp short next bit ;Done with this bit
no attr: display char 20h ;See Function 02H
next bit: display-blanks ;See Function 09H
shl bx,l ;Move to next bit
loop chk bit ;Check it
SYSTEM CALLS Function 44H, Codes 0 and 1 Page 1-161
AX: Call
BX: AH 44H
ex: AL
ox: 0 Get device data
1 Set device data
~
p BX
BP Handle
SI DX
01 Device data (see text)
Return
Carry set:
AX
~
s
os 1 = Invalid function
SS 6 = Invalid handle
ES Carry not set:
DX
Device data
15 RESERVED.
14 1 Device can process control strings sent
with Function 44H, Codes 2 and 3 (IOCTL
Control). This bit can only be read; it
cannot be set.
13-8 RESERVED
6 0 End of file on input.
5 1 Don't check for control characters.
o Check for control characters.
4 1 RESERVED.
3 1 Clock device.
2 1 Null device.
1 1 Console output device.
o 1 Console input device.
15-8 RESERVED
6 0 The file has been written.
0-5 Drive number (O=A, l=B, etc.) •
Code Meaning
Example
The following program gets the device data for Standard
Output and sets the bit that specifies not to check for
control characters (bit 5), then clears the bit.
get equ 0
set equ 1
stdout equ 1
AX: Call
BX: AH 44H
ex: AL
ox: 2 Send control data
3 Receive control data
~
p BX
BP Handle
51 CX
01 Bytes to read or write
DS:DX
Pointer to buffer
Return
~
"'i)'~;i;}'/"
5S
Carry set:
AX
ES
1 = Invalid function
6 = Invalid handle
Carry not set:
AX
Bytes transferred
Code Meaning
Examp1e
AX: Call
BX: AH 44H
ex: AL
ox: 4 Send control data
5 Receive control data
~
p BL
BP Drive number (O=default, l=A, etc.)
SI CX
01 Bytes to read or write
DS:DX
Pointer to buffer
Return
~
}'iX!?!cii/.ir
SS
Carry set:
AX
ES
1 = Invalid function
5 = Invalid drive
Carry not set:
AX
Bytes transferred
Code Meaning
AX: Call
BX: AH 44H
ex: AL
ox: 6 Check input status
7 Check output status
~
p BX
BP Handle
SI
01 Return
Carry set:
I FLAGSH I~~I AX
1 Invalid function
~
s 5 Access denied
os 6 Invalid handle
SS 13 Invalid data
ES Carry not set:
AL
OOH Not ready
OFFH Ready
Code Meaning
1 AL is not 6 or 7.
5 Access denied.
13 Invalid data.
SYSTEM CALLS Function 44H, Codes 6 and 7 Page 1-168
stdout equ 1
message db "File is
ready db "ready."
at eof db "at EOF."
crTf db ODH,OAH
,
begin: write handle stdout,message,8 idisplay message
jc write error iroutine not shown
ioctl status 6 - iTHIS FUNCTION
jc ioctl error iroutine not shown
cmp al,O - icheck status code
jne not eof ifile is ready
wr i te handle stdout,at eof,7 isee Function 40H
jc write error iroutine not shown
jmp all done iclean up & go home
not eof: write handle stdout,ready,6 isee Function 40H
all=done: write-handle stdout,crlf,2 i see Function 40H I
jc write error iroutine not shown
SYSTEM CALLS Function 44H, Code 08H Page 1-169
AX: Call
BX: AH 44H
ex: AL 08H
ox: OH OL
BL
Drive number (O=default, l=A, etc.)
~
p
BP Return
SI Carry set:
01 AX
1 = Invalid function
15 = Invalid drive
Carry not set:
AX
~
s
os a Changeable
SS
1 Not changeable
ES
Code Meaning
Example
stdout equ 1
AX: Call
BX: BH AH 44H
cx: CH AL 09H
ox: BL
Drive number (O=default, l=A, etc.)
~
p
BP Return
51 Carry set:
DI AX
1 = Invalid function code
I FLAGS" Ir·~1 15 = Invalid drive number
Carry not set:
DX
~
o: Device attribute bits
55
ES
Code Meaning
Example
stdout equ 1
message db "Drive B: is
loc db "local."
rem db "remote."
crlf db ODH,OAH
,
begin: write handle stdout,message,12 ~display message
jc write error ~routine not shown
ioctl rblock 2 - ;THIS FUNCTION
jc ioctl error ~routine not shown
test dx,lOOOh ~bit 12 set?
jnz not loc ~yes, it's remote
wr i te handle stdout,loc,6 ~see Function 40H
jc write error ~routine not shown
jrnp done -
not loc: write handle stdout,rem,7 ;see Function 40H
jc write error ;routine not shown
done: write handle stdout,crlf,2 ;see Function 40H
jc write error ;routine not shown
SYSTEM CALLS Function 44H, Code OAH Page 1-173
AX: Call
BX: AH 44H
ex: AL OAH
ox: BX
Handle
~
p
BP
Return
SI Carry set:
01 AX
1 = Invalid function code
6 = Invalid handle
Carry not set:
~
s DX
os IOCTL bit field
SS
ES
Code Meaning
Example
message db "Handle 5 is
loc db "local."
rem db "remote."
crlf db ODH,OAH
,
begin: write handle stdout,message,12idisplay message
jc - write error iroutine not shown
ioctl rhandle 5 - iTHIS FUNCTION
jc - ioctl error iroutine not shown
test dx,lOOOh ibit 12 set?
jnz not loc iyes, it's remote
write handle stdout,loc,6 isee Function 40H
jc - write error iroutine not shown
jmp done -
oot loc: write handle stdout,rem,7 isee Function 40H
jc write error iroutine not shown
done: write handle stdout,crlf,2 isee Function 40H
jc write error iroutine not shown
SYSTEM CALLS Function 44H, Code OBH Page 1-175
A)(: Call
B)(: AH 44H
C)(: AL OBH
0)(:
BX
Number of retries
~
p CX
BP Wait time
SI
01 Return
Carry set:
AX
1 = Invalid function code
~
s carry not set:
os No error
SS
ES
Code Meaning
Example
~
Return
BP Carry set:
SI AX
01 4 = Too many open files
6 = Invalid handle
I FLAGSH II F~$L I Carry not set:
AX
New handle
~
os
SS
ES
MS-DOS returns the new handle in AX. The new handle refers
to the same file as the handle in BX, with the file pointer
at the same position.
Code Meaning
4 Too many open files (no handle available).
Example
~
p
BP
SI Return
01 Carry set:
AX
4 = Too many open files
I FLAGS" If FtA$Sll 6 = Invalid handle
car ry not set:
~
s
os
No error
5S
ES
Code Meaning
Example
EF1
EB
Drive number
Return
Carry set:
AX
I FLAGS" 'I FLAG~ I 15 = Invalid drive number
Carry not set:
~
CS No error
55
E5
Code Meaning
Example
disk db "b:\$"
buffer db 64 dup (?)
,
begin: get_dir 2,buffer ;THIS FUNCTION
jc error dir ;Routine not shown
display disk- ;See Function 09H
display_asciz buffer ;See end of chapter
SYSTEM CALLS Function 48H Page 1-183
~
p
Return
BP Carry set:
SI AX
DI 7 Memory control blocks damaged
8 Insufficient memory
I FLAGS" T~tl BX
Paragraphs of memory available
Carry not set:
~
s
OS AX
SS Segment address of allocated memory
ES
Code Meaning
Example
The following program opens the file named TEXTFILE.ASC,
calculates its size with Function 42H (Move File Pointer),
allocates a block of memory the size of the file, reads the
file into the allocated memory block, then frees the
allocated memory.
path db "textfile.asc",O
msgl db "File loaded into allocated memory block.",
ODH,OAH
msg2 db "Allocated memory now being freed
~eallocated).",ODH,OAH
handle dw ?
mem seg dw ?
fiie len dw ?
AX: AH Al Call
BX: BH BL AH = 49H
cx: CH CL ES
OX: OH OL Segment address of memory to be
freed
~
p
BP Return
SI Carry set:
01 AX
7 = Memory control blocks damaged
I FLAGS" IIFLAG~ I 9 = Incorrect segment
Carry not set:
No error
~
OS
SS
CS....... .
.. ES
Code Meaning
Example
Call
AX:
BX: .,.
/liH
. AH 4AH
CX: CH CL BX
OX: OH OL Paragraphs of memory
ES
~
p
Segment address of memory area
BP
51 Return
01 Carry set:
AX
7 Memory control blocks damaged
8 Insufficient memory
9 Incorrect segment
BX
Paragraphs of memory available
Carry not set:
No error
Function 4AH changes the size of a memory allocation block.
ES must contain the segment address of the memory block. BX
must contain the new size of the memory block, in paragraphs
(1 paragraph is 16 bytes).
Code Meaning
Macro Definition:
Examp1e
AX:
Call
BX: AH = 4BH
ex: AL = OOH
ox:
DS:DX
Pointer to pathname
~
p ES:BX
BP Pointer to parameter block
SI
01 Return
Carry set:
I r¥LAGs~1
FLAGS"
AX
1 Invalid function
2 File not found
~ es 8 Insufficient memory
ss .....•. 10 Bad environment
ES
11 Bad format
Carry not set:
No error
Offset Length
(Hex) (Bytes) Description
Code Meaning
1 AL is not 0 or 3.
<length>/C <command><DDH>
<Length> is the length of the command line, counting the length
byte but not counting the ending carriage return (ODH).
<Command> is any valid MS-DOS command.
Macro Definition:
Example
~
ES:BX
BP
Pointer to parameter block
SI
,.p
......... , .... ,',.,.
, S.,
..
... ,.,., ".,...... ....
..,., ,."...... .....
"
,
....... Ol Return
carry set:
I FLAGS" II FLAGSL I AX
1Invalid function
File not found
~
~~i
2
• '. .• '.'.'. . . ,'. . •. . •. . . . •,.,...... .'. 8 Insufficient memory
ss 10 Bad environment
ES Carry not set:
No error
Offset Length
(Hex) (Bytes) Description
Code Meaning
Example
AX: AM Al
Call
BX: BH BL
AH 4CH
cx: CH CL
AL
ox: OH OL
Return code
~
Return
BP None
SI
01
I FLAGSH
IP
I FLAGSL
I
~
os
SS
ES
Example
The following program displays a message and returns to
MS-DOS with a return code of 8. It uses only the opening
portion of the sample program skeleton shown at the
beginning of this chapter.
message db "Displayed by FUNC_4CH example",ODH,OAH,"$"
,
begin: display message ~See Function 09H
end process 8 iTHIS FUNCTION
code ends
end code
SYSTEM CALLS Function 4DH Page 1-198
AX:
"
AI'! .4i, Call
BX: BH BL AH = 4DH
cx: CH CL
ox: OH OL Return
AX
~
p Return code
BP
51
01
~
5
05
55
ES
Code Meaning
0 Normal termination.
1 Terminated by Control-C.
Example
~
p
Attributes to match
BP
Sl Return
DI Carry set:
AX
2 = File not found
18 = No more files
Carry not set:
No error
Code Meaning
2 The specified path is invalid or doesn't exist.
ox: OH OL Return
Carry set:
~
AX
BP 18 = No more files
SI Carry not set:
01 No error
I 'i I
FLAGSH fLA4St
~ SS
ES
Code Meaning
Example
ox: OH OL
Return
AL
o
~
No verify after write
BP 1 Verify after write
SI
DI
I
FLAGSH Ii FLAGSL I
~
os
SS
ES
You can set the verify status with Function 2EH (Set/Reset
verify Flag) •
Example
~
5P
Pointer to second pathname
BP
51
...... . Return
m Carry set:
AX
2 File not found
5 = Access denied
17 = Not same device
.:
~
Carry not set:
. . . . . . . . . ..
55 No error
ES
Code Meaning
2 One of the paths is invalid or not open.
Example
AX: Call
BX: AH 57H
ex: AL Function code
ox: o Get date and time
1 = Set date and time
~
p BX
BP Handle
SI CX (if AL=l)
01 Time to be set
DX (if AL=l)
IFLAGS" li.;~.J Date to be set
Return
~
s
OS Carry set:
SS AX
ES 1 = Invalid function
6 = Invalid handle
Car ry not set:
CX (if AL=O)
Time file last written
DX (if AL=O)
Date file last written
Function 57H gets or sets the time and date a file was last
written. To get the time and date, AL must contain OJ the
time and date are returned in CX and DX. To set the time
and date, AL must contain l~ CX and DX must contain the
time and date. BX must contain the file handle. The time
and date are in the form described in "Fields of the FCB" in
Section 1. 8.1.
Code Meaning
1 AL is not 0 or 1.
Macro Definition:
Example
month db 31,28,31,30,31,30,31,31,30,31,30,31
path db "b:report.asm",O
handle dw ?
time db 2 dup (?)
date db 2 dup (?)
,
begin: open_handle path,O ;See Function 3DH
mov handle,ax ;Save handle
get set date time handle,O,time,date;THISFUNCT10N
jc - -error time ;Routine not shown
mov word ptr time,cx ;Save time
mov word ptr date,dx ;Save date
convert date date [-24] ;See end of chapter
inc -dh ;Increment day
xor bx,bx ;To use BL as index
mov bl,dl ;Get month
cmp dh,month[bx-l] ;Past last day?
jle month ok ;No, go home
mov dh,l - ;Yes, set day to 1
inc dl ;1ncrement month
cmp dl,12 ;1s it past December?
jle month ok ;No, go home
mov dl,l - ;Yes, set month to 1
inc cx ;Increment year
month ok: pack_date date ;See end of chapter
get set date time handle,1,time,dateiTH1SFUNCT10N
jc -error time Routine not shown
close handle -handle See Function 3EH
jc error close Routine not shown
SYSTEM CALLS Function 58H Page 1-208
AX: Call
BX: AH 58H
ex: AL
ox: o = Get strategy
1 = Set strategy
§
p
BX (AL=l)
BP o First fit
SI 1 Best fit
01 2 Last fit
Return
Carry set:
AX
§
s
os 1 = Invalid function code
SS
Carry not set:
ES
AX (AL=O)
o First fit
1 Best fit
2 Last fit
Function 58H gets or sets the strategy used by MS-DOS to
allocate memory when requested by a process. If AL contains
0, the strategy is returned in AX. If AL contains 1, BX
must contain the strategy. The three possible strategies
are:
Value Name Description
You can use this function request to control how MS-DOS uses
its memory resources.
Code Meaning
Examp1e
BH -- Error C1ass
Class Description
3 Authorization problem.
5 Hardware failure.
12 Other error.
BL -- Suggested Action
Action Description
CH -- Locus
Locus Description
1 Unknown.
2 Related to random access block devices, such as a
disk drive.
3 Related to Network.
Example
~
p Pointer to pathname followed by a
BP byte of 0 and 13 bytes of memory
SI
01 Return
Carry set:
AX
3 = Path not found
5 = Access denied
~
\ii ..... ; .. i • Carry not set:
AX
SS
ES
Handle
Code Meaning
5 Access denied.
SYSTEM CALLS Function 5AH Page 1-214
stdout equ 1
;
file db "TEXTFILE.ASC",O
path db "\WP\DOCS",O
temp db 13 dup (0)
open rnsg db " opened.",ODH,OAH
crl msg db " created.",ODH,OAH
rd_rnsg db " read into buffer.",ODH,OAH
wr msg db "Buffer written to "
cl-msg db "Files closed.",ODH,OAH
crTf db ODH,OAH
handlel dw ?
handle2 dw ?
buffer db 512 dup (1)
;
begin: open_handle file,O ;see Function 3DH
jc open error ;routine not shown
mov handlel,ax ;save handle
write_handle stdout,file,12 ;see Function 40H
jc write error ;routine not shown
write handle stdout,open msg,lO ;see Function 40H
jc - write error - ;routine not shown
create temp path~O ;THIS FUNCTION
jc - create error ;routine not shown
nov handle2,ax ;save handle
write handle stdout,path,8 ;see Function 40H
~ - write error ;routine not shown
display char ,,\,,- ;see Function 02H
write handle stdout,temp,12 ;see Function 40H
jc - write error ;routine not shown
write handle stdout,crl msg,ll ;See Function 40H
jc - write error - ;routine not shown
read handle handlel,buffer,512 ;see Function 3FH
jc - read error ;routine not shown
write handle stdout,file,12 ;see Function 40H
jc - write error ;routine not shown
write handle staout,rd msg,20 ;see Function 40H
jc - write error - ;routine not shown
write handle handle2,buffer,512 ;see Function 40H
jc - write error ;routine not shown
write handle staout,wr msg,18 ;see Function 40H
jc - write_error- ;routine not shown
SYSTEM CALLS Function 5AH Page 1-215
AX: Call
BX: AH 5BH
ex: CX
ox: Attribute
DS:DX
Pointer to pathname
Return
Carry set:
AX
3 Path not found
4 Too many open files
5 Access denied
80 File already exists
Carry not set:
AX
Handle
COde Meaning
5 Access denied.
Example
Call
AH 5CH
AL OOH
BX
Handle
CX:DX
Offset of region to be locked
SI:DI
Length of region to be locked
Return
Carry set:
AX
1 Invalid function code
6 Invalid handle
22 Lock violation
Carry not set:
No error
Code Meaning
Example
The following program opens a file named FINALRPT in Deny
None mode and locks two portions of it: the first 128 bytes
and bytes 1024 through 5119. After some (unspecified)
processing, it unlocks the same portions and closes the
file.
stdout equ 1
,
startl dd
Igthl
start2
dd
dd
°128
1023
Igth2 dd 4096
file db "FINALRPT",O
cp msg db " opened.",ODH,OAH
U-msg db "First 128 bytes locked.",ODH,OAH
12-msg db "Bytes 1024-5119 locked.",ODH,OAH
ul-msg db "First 128 bytes unlocked.",ODH,OAH
u2-msg db "Bytes 1024-5119 unlocked.",ODH,OAH
cl-msg db " closed.:,ODH,OAH
handle dw ?
,
begin: open_handle file,OlOOOOlOb isee Function 3DH
jc open error iroutine not shown
write handle stdout,file,8 isee Function 40H
jc - write error iroutine not shown
write handle stdout,op msg,lO isee Function 40H
jc - write error- iroutine not shown
mov handle,ax isave handle
lock handle,startl,lgthl iTHIS FUNCTION
jc lock error iroutine not shown
write handle stdout,ll msg,25 isee Function 40H
jc - write error- iroutine not shown
lock handle,start2,lgth2 iTHIS FUNCTION
jc lock error iroutine not shown
write handle stdout,12 msg,25 isee Function 40H
jc - write error- iroutine not shown
AX: Call
ex: AH 5CH
ex: AL OlH
ox: BX
Handle
~
CX:DX
Offset of area to be unlocked
SI:DI
Length of area to be unlocked
~
s AX
os 1 Invalid function code
SS 6 Invalid handle
ES 22 Lock violation
Carry not set:
No error
Code Meaning
Example
AX: Call
BX: AH = SEH
ex: AL = 0
ox: DS:DX
Pointer to 16-byte buffer
~
p
BP Return
SI Carry set:
01 AX
1 = Invalid function code
Carry not set:
CX
Identification number of local
~
.?t~ii
SS
computer
ES
Code Meaning
Example
The following program displays the name of a Microsoft
Networks workstation.
stdout equ 1
AX: Ca11
BX: AH SEH
ex: AL 02H
ox: BX
Assign list index
~,.",
ex
BP
Length of setup string
$ p..".".:.•."., ., "., ".:. ,':', .",".' .' ".':'.,'. "., '. ,.'"." .'•.":.':" ". '.•."'.
,." ..,..,.,.. ..
..
•.•. .. •.::.".".",., ",."..":'."'." "'.:.':.'."" .•. ".",:'.:'.'.",.,." S.",.",..
"" .• '." :."""
01
Pointer to setup string
DS:SI
Pointer to string
~
i'~: ss
Return
Carry set:
ES AX
1 = Invalid function code
Carry not set:
No error
Code Meaning
Example
AX: Call
BX: AH 5FH
CX: AL 02H
OX: BX
Assign list index
~".'
DS:SI
BP Pointer to buffer for local name
' •. ' ,., ·Sf
. • '., '." '," ,'., ,'., '., ',.•. • .,'. , .• .•.•.•.•p
ES:DI
."..'••'. .• .•'." ."'.•. • • •.• •.,'.•.,•. " .•. •. •.,• •.' .•.• •'. .,•,•'.,.'"•.S, .'•.• .,•.•'.'•,•.',.',. '., .,• •'.'.,.'•".,' " •.'.,'•,.' •'.•.',• .,• .,.,.''•".'.'•.,' •".• ".' .', .,'". '•,.'., .',.'
"' '. . •. 01 Pointer to buffer for remote name
Code Meaning
Example
str len dw ?
index dw ?
begin:
write_handle stdout,header,header len ;see Function 40H
jnc set index
jmp write error
set index:
mov index,O ;assign list index
SYSTEM CALLS Function 5FH, Code 02H Page 1-230
INCLUDE suffix.asm
SYSTEM CALLS Function 5FH, Code 03H Page 1-231
AX: Call
BX: AH 5FH
ex:
AL 03H
ox:
BL
3 Printer
~
4 Drive
CX
User value
DS:SI
Pointer to name of source device
IFLAGSH Ir·f~~<j ES:DI
Pointer to name of destination
device
tiS···"·"
5S""5
. ,. ', .•". .' ,. .' ,. .,':.,."., ".,•'.,".".'.,•'".':., :'. ". ':." ." .:'". :." :.':" .:', ." .:', ".: '". ",.' ",. .':, .:".:.".', :.
.•",...",."...,'.,.'."..'. ,.' :,'. ","':,•."' ." ".'...": ,."..":." ,.":,."...":' : "': .',...,,. ...":,"...":., .,' ..." "..,..". ".",:,.,...":"..:, ., :,.,,,:,.e
. .,'.,.:,"•.
Return
1:$.
Carry set:
AX
= '
1 Invalid function code
5 Access denied
3 Path not found
8 Insufficient memory
(Other errors particular to the
network may occur.)
Carry not set:
No error
<machine-name><pathname><OOH><password><OOH>
Cbde Meaning
Macro Definition:
redir macro device,value,source,destination
~v bl, device
~v cx, value
~v si, offset source
~v es, seg destination
~v di, offset destination
~v aI, 03H
~v ah, 5FH
int 2lH
endm
SYSTEM CALLS Function 5FH, Code 03H page 1-233
Example
IDeal dr i ve Netname
or printer on server Password
E: WORD none
F: COMM fred
PRN: PRINTER quick
printer equ 3
drive equ 4
,
local 1 db "e:",O
local-2 db "f:",O
local-3 db "prn", 0
remote 1 db "\harold\word",O,O
remote-2 db "\harold\comm",O,"fred",O
remote-3 db "\harold\printer",O,"quick",O
AX: call
BX: BH I Bl AH = SFH
cx: CH
I Cl AL = 04H
ox: OH I Ol DS:S1
Pointer to name of source device
Return
Carry set:
AX
1 = Invalid function code
15 = Redirection paused on server
(Other errors particular to the network
may occur.)
Carry not set:
No error
Code Meaning
1 Microsoft Networks must be running to use this
function request, or the ASCIZ string doesn't
name an existing source device.
~ Disk or printer redirection on the network
server is paused.
Example
local 1 db "e:",O
local-2 db "f:" ,0
local-3 db "prn",O
begin: cancel redir local 1 ~THIS FUNCTION
jc error ;routine not shown
cancel redir local 2 ~THIS FUNCTION
jc error ;routine not shown
cancel redir local_3 ;THIS FUNCTION
jc - error ;routine not shown
SYSTEM CALLS Function 62H page 1-236
~
p
Segment address of the Program
BP Segment
SI Prefix of the current process
01
I 'I
FLAGS" FLAGS, I
~
s
OS
SS
ES
Example
;*******************
; Interrupts
;*******************
; INTERRUPT 25H
PBS DISK READ macro disk,buffer,num_sectors,first_sector
- nov- al,disk
nov bx,offset buffer
mov cx,num sectors
mov dx,first sector
int 25H -
IOpf
endm
INTERRUPT 26H
ASS DISK WRITE macro disk,buffer,num_sectors,first_sector
- mov- al,disk
mov bx,offset buffer
mov cx,num sectors
mov dx,first sector
int 26H -
popf
endm
INTERRUPT 27H
STAY_RESIDENT macro last instruc
mov dx,offset last-instruc
inc dx
int 27H
endm
,
;*******************
; Function Requests
;*******************
, FUNCTION REQUEST OOH
TERMINATE PROGRAM macro
xor - ah,ah
int 21H
endm
FUNCTION REQUEST OlH
READ KBD AND ECHO macro
mov ah,OlH
int 21H
endm
FUNCTION REQUEST 02H
DISPLAY CHAR macro character
mov dl,character
mov ah,02H
int 21H
endm
FUNCTION REQUEST 03H
AUX INPUT macro
mov ah,03H
int 21H
endm
Page 1-238
i
i*******************
i General
i*******************
,
DISPLAY ASCIIZ macro ascllz_string
local search,found it
mov bx,offset asciiz_string
search:
cmp byte ptr [bx],O
je found it
inc bx
jmp short search
found it:
mov byte ptr [bx] ,"$"
display asciiz string
mov byte ptr [bx],O
display char ODH
display-char OAH
endm -
Page 1-251
start:
push ax
push bx
p..1sh dx
nov al,value
xor ah,ah
xor bx,bx
div base
nov bl,al
nov al,cs:table[bx]
nov destination,al
mov bl,ah
mov al,cs:table[bx]
mov destination[l] ,al
pop dx
IX>P bx
IX>P ax
endm
,
CONVERT TO BINARY macro string ,number ,value
local- ten,start,calc,mult,no mult
jmp start -
ten db 10
start:
mov value,O
xor cx,cx
mov cl,number
xor si,si
Page 1-252
calc:
xor ax,ax
rnov al,string[si]
sub al,48
cmp cx,2
jl no rnult
push ex
dec ex
mult:
mul cs:ten
loop mult
pop ex
no mult:
- add value,ax
inc si
loop calc
endm
,
OONVERT DATE macro dir entry
rnov dx,word ptr dir_entry[24]
IlDV cl,5
shr dl,cl
IlDV dh,dir entry[24]
and dh,lFH-
xor cx,cx
mov cl,dir entry[25]
shr cl,l -
add cx,1980
endrn
,
PACK DATE macro date
local set bit
sub cx,1980
push ex
mov date,dh
IroV cl,5
shl dl,cl
fOP ex
jnc set bit
or cl,80h
set bit:
or date ,dl
rol cl,l
IroV date[l],cl
endm
Chapter 2
MS-DOS Device Drivers
2.1 INTRODUCTION
Each driver in the chain has two entry points: the strategy
entry point and the interrupt entry point. MS-DOS does not
take advantage of the two entry points: it calls the
strategy routine, then immediately calls the interrupt
routine.
The dual entry points facilitate future multitasking
versions of MS-DOS. In multitasking environments, I/O must
be asynchronous~ to accomplish this, the strategy routine
will be called to (internally) queue a request and return
quickly. It is then the responsibility of the interrupt
routine to perform the I/O at interrupt time by getting
requests from the internal queue and processing them. When
a request is completed, it is flagged as "done" by the
interrupt routine. MS-DOS periodically scans the list of
requests looking for those that are flagged as done, and
MS-DOS DEVICE DRIVERS Page 2-2
Note
For device drivers, the file must not use the ORG 100H
(like .COM files). Because it does not use the Program
Segment prefix, the device driver is simply loaded;
therefore, the file must have an origin of zero (ORG 0
or no ORG statement).
Block devices are the "disk drives" on the system. They can
perform random I/O in structured pieces called blocks
(usually the physical sector size). These devices are not
named as the character devices are, and therefore cannot be
opened directly. Instead they have unit numbers and are
identified by driver letters such as A, B, and C.
A single block-device driver may be responsible for one or
more logically contiguous disk drives. For example, block
device driver ALPHA may be responsible for drives A, B, C,
and D. This means that it has four units defined (0-3), and
therefore, takes up four drive letters. The position of the
driver in the list of all drivers determines which units
correspond to which driver letters. If driver ALPHA is the
first block driver in the device list, and it defines 4
units (0-3), then they will be A, B, C, and D. If BETA is
the second block driver and defines three units (0-2), then
they will be E, F, and G, and so on. The theoretical limit
is 63, but it should be noted that the device installation
code will not allow the installation of a device if it would
result in a drive letter >'Z' (SAH). All block device
drivers present in the standard resident BIOS will be placed
ahead of installable block-device drivers in the list.
Note
Note
Because MS-DOS can install the driver anywhere in
memory, care must be taken when making far memory
references. You should not expect that your driver
will always be loaded in the same place every time.
MS-DOS DEVICE DRIVERS Page 2-5
WORD Attributes
Bit 15 = 1 if character device
= 0 if block device
Bit 14 = 1 if IOCTL supported
Bit 13 = 1 if output till busy
(character devices)
= 1 if NON FAT ID
(block devices)
Bit 12 = reserved (must be 0)
Bit 11 = 1 if support OPEN/CLOSE/RM
Bit 10-5 reserved (must be 0)
Bit 3 = 1 if intended current CLO<;K
device
Bit 2 = 1 if intended current NUL
device
Bit 1 = 1 if intended current sto
device
Bit 0 = 1 if intended current sti
device
WORD Pointer to device strategy
entry point
Note that the device entry points are words. They must be
offsets from the same segment number used to point to this
table. For example, if XXX:YYY points to the start of this
table, then XXX:strategy and XXX:interrupt are the entry
points.
Note
For example, assume that a user has a new device driver that
he wants to use as the standard input and output. In
addition to installing the driver, he must tell MS-DOS that
he wants his new driver to override the current standard
input and standard output (the CON device). This is
accomplished by setting the attributes to the desired
characteristics, so he would set bits 0 and 1 to 1 (note
that they are separate!). Similarly, a new CLOCK device
could be installed by setting that attribute. (Refer to
Section 2.10, "The CLOCK Device," in this chapter for more
information.) Although there is a NUL device attribute, the
NUL device cannot be reassigned. This attribute exists so
that MS-DOS can determine if the NUL device is being used.
The NON FAT ID bit for block devices affects the operation
of the BUILD BPB (BIOS Parameter Block) device call. The
NON FAT ID bit has a different meaning on character devices.
It indicates that the device implements the OUTPUT UNTIL
BUSY device call.
The IOCTL bit has meaning on character and block devices.
MS-DOS DEVICE DRIVERS Page 2-8
These two fields are the pointers to the entry points of the
strategy and interrupt routines. They are word values, so
they must be in the same segment as the device header.
8 BYTES Reserved
The command code field in the request header can have the
following values:
Command Function
Code
o INIT
1 MEDIA CHECK (Block devices only)
2 BUILD BPB "" "
3 IOCTL INPUT (Only called if device has IOCTL)
4 INPUT (read)
5 NON-DESTRUCTIVE INPUT NO WAIT (Char devs only)
6 INPUT STATUS
7 INPUT FLUSH
8 OUTPUT (Write)
9 OUTPUT (Write) with verify
10 OUTPUT STATUS
11 OUTPUT FLUSH
12 IOCTL OUTPUT (Only called if device has IOCTL)
13 DEVICE OPEN (Only called if OPEN/CLOSE/RM bit set)
14 DEVICE CLOSE (Only called if OPEN/CLOSE/RM bit set)
15 REMOVABLE MEDIA (Only called if OPEN/CLOSE/RM bit
set and device is block)
16 OUTPUT UNTIL BUSY (Only called if bit 13 is set on
character devices)
15 14 13 12 11 10 9 8 7 654 3 210
E B D
R RESERVED U 0 ERROR CODE (bi t 15 on)
R S N
Y E
Bit 8 is the done bit. When set, it means the operation has
completed. The driver sets it to 1 when it exits.
MS-DOS DEVICE DRIVERS Page 2-11
Bit 9 is the busy bit, which is set only by status calls and
the removable media call.
1. INIT
2. MEDIA CHECK
3. BUILD BPB
4. READ or WRITE or WRITE TIL BUSY or WRITE WITH
VERIFY or IOCTL Read or IOCTL Write
8. STATUS
9. FLUSH
the Request Header from the queue that the strategy routines
store them in. The command code in the request header tells
the driver which function to perform and what data follows
the request header.
Note
2.7.1 INIT
Command code = 0
INIT - ES:BX ->
deVice=tdeV\vt52oSYS /1
BPB address points here
Note
Command Code = 1
MEDIA CHECK - ES:BX ->
BYTE Returned
When such a disk access call to the DOS occurs (other than a
file read or write), the following sequence of events takes
place:
Note
Command code = 2
BUILD BPB - ES:BX ->
13-BYTE Request header
BYTE Media descriptor from BPB
For drivers that support this error, the BUILD BPB function
is a trigger that causes a new Volume ID to be read off the
disk. This action indicates that the disk has been legally
changed. A Volume ID is placed on a disk by the FORMAT
utility, and is simply an entry in the root directory of the
disk that has the Volume ID attribute. It is stored by the
driver as an ASCIZ string.
3 IOCTL READ
4 READ (block or character)
8 WRITE (block or character)
9 WRITE WITH VERIFY
12 IOCTL WRITE
16 OUTPUT TIL BUSY (char devs only)
When I/O completes, the device driver must set the status
word and report the number of sectors or bytes successfully
transferred. This should be done even if an error prevented
the transfer from being completed. Setting the error bit
and error code alone is not sufficient.
Command code = 5
NON DESTRUCTIVE READ NO WAIT - ES:BX ->
Command code = 15
2.7.8 STATUS
2.7.9 FLUSH
Important
.I
days SInce 1-1-80 minutes hours sec/lOO seconds
low bytelhi byte
FALSE EQU o
TRUE EQU NOT FALSE
o 6ms 3ms
MS-DOS DEVICE DRIVERS Page 2-30
1 6ms 6ms
2 10ms 10ms
3 20ms ISms
i
STPSPD EQU 1
NUMERR EQU ERROUT-ERRIN
CR EQU ODH
LF EQU OAH
CODE SEGMENT
ASSUME CS:CODE,DS:NOTHING,ES:NOTHING,SS:NOTHING
,------------------------------------------------------
DEVICE HEADER
,
DRVDEV LABEL WORD
DW -1,-1
DW 0000 iIBM format-compatible, Block
DW STRATEGY
DW DRV$IN
DRVMAX DB 4
STRATEGY
PTRSAV DD 0
MAIN ENTRY
MS-DOS DEVICE DRIVERS Page 2-31
PUSH CS
POP DS
ASSUME DS:CODE
,
-----------------------------------------------------------
EXIT - ALL ROUTINES RETURN THROUGH THIS PATH
,
ASSUME DS:NOTHING
MS-DOS DEVICE DRIVERS Page 2-32
CMDERRP:
POP AX iClean stack
CMDERR:
MOV AL,3 iUNKNOWN COMMAND ERROR
JMP SHORT ERR$EXIT
ERR$EXIT:
iAL has error code
MOV AH,10000001B iMARK ERROR RETURN
JMP SHORT ERRI
CURDRV DB -1
TRKTAB DB -1,-1,-1,-1
SECCNT DW 0
,
MEDIA$CHK: iAlways indicates Don't know
ASSUME DS:CODE
TEST AH,OOOOOI00B iTEST IF MEDIA REMOVABLE
MS-DOS DEVICE DRIVERS page 2-33
JZ MEDIA$EXT
XOR DI,DI iSAY I DON'T KNOW
MEDIA$EXT:
LDS BX, [PTRSAV]
MOV WORD PTR [BX] .TRANS,DI
JMP EXIT
BUILD$BPB:
ASSUME DS:CODE
MOV AH,BYTE PTR ES:[DI] iGET FAT ID BYTE
CALL BUILDBP iTRANSLATE
SETBPB: LDS BX, [PTRSAV]
MOV [BX] .MEDIA,AH
MOV [BX] .COUNT,DI
MOV [BX] .COUNT+2,CS
JMP EXIT
BUILDBP:
ASSUME DS:NOTHING
iAH is media byte on entry
iDI points to correct BPB on return
PUSH AX
PUSH CX
PUSH DX
PUSH BX
MOV CL,AH iSAVE MEDIA
AND CL,OF8H iNORMALIZE
CMP CL,OF8H iCOMPARE WITH GOOD MEDIA BYTE
JZ GOODID
MOV AH,OFEH iDEFAULT TO 8-SECTOR,
iSINGLE-SIDED
GOODID:
MOV AL,l iSET NUMBER OF FAT SECTORS
MOV BX,64*256+8 ;SET DIR ENTRIES AND SECTOR MAX
MOV CX,40*8 iSET SIZE OF DRIVE
MOV DX,Ol*256+l iSET HEAD LIMIT & SEC/ALL UNIT
MOV DI,OFFSET DRVBPB
TEST AH,OOOOOOlOB iTEST FOR 8 OR 9 SECTOR
JNZ HAS8 iNZ = HAS 8 SECTORS
INC AL iINC NUMBER OF FAT SECTORS
INC BL iINC SECTOR MAX
ADD CX,40 iINCREASE SIZE
HAS8: TEST AH,OOOOOOOlB iTEST FOR 1 OR 2 HEADS
JZ HASl iZ = 1 HEAD
ADD CX,CX iDOUBLE SIZE OF DISK
MOV BH,112 iINCREASE # OF DIREC. ENTRIES
INC DH iINC SEC/ALL UNIT
INC DL ;INC HEAD LIMIT
HAS1: MOV BYTE PTR [DI] .2,DH
MOV BYTE PTR [DI] .6,BH
MOV WORD PTR [DI].8,CX
MOV BYTE PTR [DI] .10,AH
MOV BYTE PTR [DI] .11,AL
MOV BYTE PTR [DI] .13,BL
MOV BYTE PTR [DI] .15,DL
MS-DOS DEVICE DRIVERS Page 2-34
POP BX
POP DX
POP CX
POP AX
RET
i----------------------------------------------------- -----
DISK I/O HANDLERS
,
;ENTRY:
AL DRIVE NUMBER (0-3)
AH MEDIA DESCRIPTOR
CX SECTOR COUNT
DX FIRST SECTOR
DS CS
ES:DI = TRANSFER ADDRESS
;EXIT:
IF SUCCESSFUL CARRY FLAG = 0
ELSE CF=l AND AL CONTAINS (MS-DOS) ERROR CODE,
CX # sectors NOT transferred
DRV$READ:
ASSUME DS:CODE
JCXZ DSKOK
CALL SETUP
JC DSK$IO
CALL DISKRD
JMP SHORT DSK$IO
DRV$WRIT:
ASSUME DS:CODE
JCXZ DSKOK
CALL SETUP
JC DSK$IO
CALL DISKWRT
ASSUME DS:NOTHING
DSK$IO: JNC DSKOK
JMP ERR$CNT
DSKOK: JMP EXIT
SETUP:
ASSUME DS:CODE
;Input same as above
iOn output
ES:DI = Trans addr
DS:BX Points to BPB
Carry set if error (AL is error code (MS-DOS»
else
[DRIVE] = Drive number (0-3)
[SECCNT] Sectors to transfer
[CURSEC] Sector number of start of I/O
[CURHD] Head number of start of I/O iSet
MS-DOS DEVICE DRIVERS Page 2-35
INRANGE:
MOV [DRIVE] ,AL
MOV [SECCNT] ,CX iSAVE SECTOR COUNT
XCHG AX,DX iSET UP LOGICAL SECTOR
iFOR DIVIDE
XOR DX,DX
DIV WORD PTR [01] .SECLIM iDIVIDE BY SEC PER TRACK
INC DL
MOV [CURSEC] ,DL iSAVE CURRENT SECTOR
MOV CX,WORD PTR [01] .HDLIM ;GET NUMBER OF HEADS
XOR DX,DX iDIVIDE TRACKS BY HEADS PER CYLINDER
DIV CX
MOV [CURHD] ,DL iSAVE CURRENT HEAD
MOV [CURTRK] ,AX i SAVE CURRENT TRACK
SEEK:
PUSH BX iXaddr
PUSH 01 iBPB pointer
CALL CHKNEW iUnload head if change drives
CALL DRIVESEL
MOV BL, [DRIVE]
XOR BH,BH iBX drive index
ADD BX,OFFSET TRKTAB iGet current track
MOV AX, [CURTRK]
MOV DL,AL iSave desired track
XCHG AL ,DS: [BX] iMake desired track current
OUT DISK+l,AL iTell Controller current track
CMP AL,DL iAt correct track?
JZ SEEKRET iDone if yes
MOV BH,2 iSeek retry count
CMP AL,-l iposition Known?
JNZ NOHOME iIf not home head
TRYSK:
CALL HOME
JC SEEKERR
NOHOME:
MOV AL,DL
OUT DISK+3,AL iDesired track
MOV AL,lCH+STPSPD iSeek
CALL DCOM
AND AL,98H iAccept not rdy, seek, & CRC errors
JZ SEEKRET
MS-DOS DEVICE DRIVERS Page 2-36
1---------------------------------------------
READ
DISKRD:
ASSUME DS:CODE
MOV CX, [SECCNT]
RDLP:
CALL PRESET
PUSH BX
MOV BL,lO ;Retry count
MOV DX,DISK+3 ;Data port
RDAGN:
MOV AL,80H ;Read command
CLI ;Disable for 1793
OUT DISK,AL ;Output read command
MOV BP,DI ;Save address for retry
JMP SHORT RLOOPENTRY
RLOOP:
STOSB
RLOOPENTRY:
IN AL,DISK+5 ;Wait for DRQ or INTRQ
SHR AL,l
IN AL,DX ;Read data
JNC RLOOP
STI ;Ints OK now
CALL GETSTAT
AND AL,9CH
JZ RDPOP ;Ok
MOV DI,BP ;Get back transfer
DEC BL
JNZ RDAGN
CMP AL,lOH iRecord not found?
MS-DOS DEVICE DRIVERS page 2-37
,----------------------------------------------
WRITE
DISKWRT:
ASSUME DS:CODE
MOV CX, [SECCNT]
MOV SI,DI
PUSH ES
POP DS
ASSUME DS:NOTHING
WRLP:
CALL PRESET
PUSH BX
MOV BL,lO iRetry count
MOV DX,DISK+3 iData port
WRAGN:
MOV AL,OAOH Write command
CLI Disable for 1793
OUT DISK,AL Output write command
MOV BP,SI Save address for retry
WRLOOP:
IN AL,DISK+S
SHR AL,l
LODSB ;Get data
OUT DX,AL ;Write data
JNC WRLOOP
STI ;Ints OK now
DEC SI
CALL GETSTAT
AND AL,OFCH
JZ WRPOP iOk
MOV SI,BP iGet back transfer
DEC BL
JNZ WRAGN
CALL GETERRCD
POP BX
RET
WRPOP:
MS-DOS DEVICE DRIVERS Page 2-38
POP BX
LOOP WRLP
CLC
RET
PRESET:
ASSUME DS:NOTHING
MOV AL,[CURSEC]
CMP AL,CS:[BX].SECLIM
JBE GOTSEC
MOV DH,[CURHD]
INC DH
CMP DH,CS: [BX] .HDLIM
JB SETHEAD Select new head
CALL STEP Go on to next track
XOR DH,DH Select head zero
SETHEAD:
MOV [CURHD] ,DH
CALL DRIVESEL
MOV AL,1 ;First sector
MOV [CURSEC] , AL ;Reset CURSEC
GOTSEC:
OUT DISK+2,AL ;Tell controller which sector
INC [CURSEC] ;We go on to next sector
RET
STEP:
ASSUME DS:NOTHING
MOV AL,58H+STPSPD ;Step in wi update, no verify
CALL DCOM
PUSH BX
MOV BL,[DRIVE]
XOR BH,BH ;BX drive index
ADD BX,OFFSET TRKTAB ;Get current track
INC BYTE PTR CS: [BX] ;Next track
POP BX
RET
HOME:
ASSUME DS:NOTHING
MOV BL,3
TRYHOM:
MOV AL,OCH+STPSPD ;Restore with verify
CALL DCOM
AND AL,98H
JZ RET3
JS HOMERR ;No retries if not ready
PUSH AX ;Save real error code
MOV AL,58H+STPSPD ;Step in wi update no verify
CALL DCOM
DEC BL
POP AX ;Get back real error code
JNZ TRYHOM
HOMERR:
MS-DOS DEVICE DRIVERS Page 2-39
STC
RET3: RET
CHKNEW:
ASSUME DS:NOTHING
MOV AL,[DRIVE] iGet disk drive number
MOV AH,AL
XCHG AL,[CURDRV] iMake new drive current.
eMP AL,AH iChanging drives?
JZ RETl iNo
i If changing drives, unload head so the head load delay
ione-shot will fire again. Do it by seeking to the same
itrack with the H bit reset.
IN AL,DISK+l jGet current track number
OUT DISK+3,AL jMake it the track to seek
MOV AL,lOH jSeek and unload head
DCOM:
ASSUME DS:NOTHING
OUT DISK,AL
PUSH AX
AAM ;Delay 10 microseconds
POP AX
GETSTAT:
IN AL,DISK+4
TEST AL,DONEBIT
JZ GETSTAT
IN AL,DISK
RET1: RET
DRIVESEL:
ASSUME DS:NOTHING
iSelect the drive based on current info
;Only AL altered
MOV AL, [DRIVE]
OR AL,SMALBIT + DDBIT ;5 1/4" IBM PC disks
CMP [CURHD] ,0
JZ GOTHEAD
OR AL,BACKBIT ;Select side 1
GOTHEAD:
OUT DISK+4,AL iSelect drive and side
RET
GETERRCD:
ASSUME DS:NOTHING
PUSH CX
PUSH ES
PUSH DI
PUSH CS
POP ES ;Make ES the local segment
MOV CS: [LSTERR] ,AL iTerminate list wi error code
MOV CX,NUMERR ;Number of error conditions
MOV DI,OFFSET ERRIN ;Point to error conditions
MS-DOS DEVICE DRIVERS Page 2-40
REPNE SCASB
MOV AL,NUMERR-l[DI] ;Get translation
STC ;Flag error condition
POP DI
POP ES
POP CX
RET ;and return
;*********************************************************
BPB FOR AN IBM FLOPPY DISK, VARIOUS PARAMETERS ARE
PATCHED BY BUILDBP TO REFLECT THE TYPE OF MEDIA
INSERTED
This is a nine sector single side BPB
DRVBPB:
DW 512 ;Physical sector size in bytes
DB 1 ;Sectors/allocation unit
DW 1 ;Reserved sectors for DOS
DB 2 ;# of allocation tables
DW 64 ;Nurnber directory entries
DW 9*40 ;Nurnber 512-byte sectors
DB 11111100B ;Media descriptor
DW 2 ;Nurnber of FAT sectors
DW 9 ;Sector limit
DW 1 ;Head limit
DRV$INIT:
;
; Determine number of physical drives by reading CONFIG.SYS
MS-DOS DEVICE DRIVERS Page 2-41
,
ASSUME OS:CODE
PUSH DS
LDS SI, [PTRSAV]
ASSUME DS:NOTHING
LOS SI,DWORD PTR [SI.COUNT] iDS:SI points to
iCONFIG.SYS
SCAN LOOP:
- CALL SCAN SWITCH
MOV AL,CL
OR AL,AL
JZ SCAN4
CMP AL,"s"
JZ SCAN4
WERROR: POP DS
ASSUME DS:CODE
MOV DX,OFFSET ERRMSG2
WERROR2: MOV AH,9
INT 21H
XOR AX,AX
PUSH AX iNo units
JMP SHORT ABORT
BADNDRV:
POP DS
MOV DX,OFFSET ERRMSGl
JMP WERROR2
SCAN4:
ASSUME DS:NOTHING
iBX is number of floppies
OR BX,BX
JZ BADNDRV ;User error
CMP BX,4
JA BADNDRV iUser error
POP DS
ASSUME DS:CODE
PUSH BX iSave unit count
ABORT: LOS BX,[PTRSAV]
ASSUME DS:NOTHING
POP AX
MOV BYTE PTR [BX].MEDIA,AL iUnit count
MOV [DRVMAX] ,AL
MOV WORD PTR [BX].TRANS,OFFSET DRV$INIT ;SET
i BREAK ADDRESS
MOV [BX].TRANS+2,CS
MOV WORD PTR [BX].COUNT,OFFSET INITAB
iSET POINTER TO BPB ARRAY
MOV [BX] .COUNT+2 ,CS
JMP EXIT
PUT SWITCH IN CL, VALUE IN BX
i
SCAN SWITCH:
MS-DOS DEVICE DRIVERS Page 2-42
XOR BX,BX
MOV CX,BX
LODSB
CMP AL,lO
JZ NUMRET
CMP AL,"-"
JZ GOT SWITCH
CMP AL,"/"
JNZ SCAN SWITCH
GOT SWITCH:
CMP BYTE PTR [SI+l],":"
JNZ TERROR
LODSB
OR AL,20H CONVERT TO LOWERCASE
MOV CL,AL GET SWITCH
LODSB SKIP ":"
ASSUME CS:CODE,DS:NOTHING,ES:NOTHING
,-----------------------------------------------------------
CON - CONSOLE DEVICE DRIVER
,
CONDEV: iHEADER FOR DEVICE "CON"
DW -1,-1
DW 1000000000010011B iCON IN AND CON OUT
DW STRATEGY
DW ENTRY
DB 'CON
;-----------------------------------------------------------
COMMAND JUMP TABLES
CONTBL:
DW CON$INIT
DW EXIT
DW EXIT
DW CMDERR
DW CON$READ
DW CON$RDND
DW EXIT
DW CON$FLSH
DW CON$WRIT
DW CON$WRIT
DW EXIT
DW EXIT
CMDTABL DB 'A'
MS-DOS DEVICE DRIVERS Page 2-44
DW CUU ;cursor up
DB 'B'
DW CUD ;cursor down
DB 'c'
DW CUF ;cursor forward
DB 'D'
DW CUB ;cursor back
DB 'H'
DW CUH ;cursor position
DB 'J'
DW ED ierase display
DB 'K'
DW EL ;erase line
DB 'Y'
DW CUP ;cursor position
DB 'j'
DW PSCP ;save cursor position
DB ' k'
DW PRCP ;restore cursor position
DB 'y'
DW RM ;reset mode
DB 'x'
DW SM ;set mode
DB 00
PAGE
,----------------------------------------------------
Device entry point
,
CMDLEN 0 ;LENGTH OF THIS COMMAND
UNIT 1 ;SUB UNIT SPECIFIER
CMD 2 ;COMMAND CODE
STATUS 3 ; STATUS
MEDIA 13 ;MEDIA DESCRIPTOR
TRANS 14 iTRANSFER ADDRESS
COUNT 18 iCOUNT OF BLOCKS OR CHARACTERS
START 20 iFIRST BLOCK TO TRANSFER
PTRSAV DD 0
STRATP PROC FAR
STRATEGY:
MOV WORD PTR CS: [PTRSAV] ,BX
MOV WORD PTR CS: [PTRSAV+2] ,ES
RET
STRATP ENDP
ENTRY:
PUSH SI
PUSH AX
PUSH CX
PUSH DX
MS-DOS DEVICE DRIVERS Page 2-45
PUSH DI
PUSH BP
PUSH DS
PUSH ES
PUSH BX
PUSH CS
POP DS
ASSUME DS:CODE
PAGE
;=====================================================
;=
i= SUBROUTINES SHARED BY MULTIPLE DEVICES
i=
;=====================================================
,------------------------------------------------------
CMDERR:
MOV AL,3 iUNKNOWN COMMAND ERROR
ERR$EXIT:
MOV AH,IOOOOOOIB iMARK ERROR RETURN
JMP SHORT ERRI
POP BX
POP ES
POP DS
POP BP
POP DI
POP DX
POP CX
POP AX
POP SI
RET iRESTORE REGS AND RETURN
EXITP ENDP
,------------------------------------------------
BREAK KEY HANDLING
,
BREAK:
MOV CS:ALTAH,3 iINDICATE BREAK KEY SET
INTRET: IRET
PAGE
int 10h
retS: ret
tryback:
cmp al,8
jnz outchr
cmp [col] ,0
jz retS
dec [col]
jmp short setit
outchr:
mov bx, [attrw]
mov cx,l
mov ah,9
int 10h
inc [col]
mov al, [col]
cmp al, [maxcol]
jbe setit
cmp [wrap] ,0
jz outchrl
dec [col]
ret
outchrl:
mov [col] ,0
If: inc [row]
cmp [row] ,24
jb setit
mov [row] ,23
call scroll
setit: mov dh,row
mov dl,col
xor bh,bh
mov ah,2
int lOh
ret
scroll: call getmod
cmp al,2
jz myscroll
cmp al,3
jz myscroll
mov al,IO
jmp toroID
myscroll:
mov bh, [attr]
mov bl, , ,
mov bp,80
mov ax, [base]
mov es,ax
mov ds,ax
xor di,di
mov si,160
MS-DOS DEVICE DRIVERS Page 2-48
mov cx,23*80
cld
cmp ax,Ob800h
jz colorcard
rep movsw
mov ax,bx
mov cx,bp
rep stosw
sret: push cs
pop ds
ret
colorcard:
mov dx,3dah
wait2: in al,dx
test al,8
jz wait2
mov al,25h
mov dx,3d8h
out dx,al jturn off video
rep movsw
mov ax,bx
mov cx,bp
rep stosw
mov al,29h
mov dx,3d8h
out dx,al jturn on video
jmp sret
PUSH DS
XOR BP,BP
MOV DS,BP iSelect segment 0
MOV DS:BYTE PTR 4lAH,lEH iReset KB queue head
ipointer
MOV DS:BYTE PTR 4lCH,lEH iReset tail pointer
POP DS
JMP EXVEC
j----------------------------------------------------------
CONSOLE WRITE ROUTINE
CON$WRIT:
MS-DOS DEVICE DRIVERS Page 2-50
JCXZ EXVEC
PUSH CX
MOV AH,3 iSET CURRENT CURSOR POSITION
XOR BX,BX
INT 16
MOV WORD PTR [COL] ,DX
POP CX
COUT: STI
PUSH DS
PUSH CS
POP DS
CALL OUTC
POP DS
IRET
OUTC: PUSH AX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH ES
PUSH BP
CALL VIDEO
POP BP
POP ES
POP DI
POP SI
POP DX
POP CX
POP AX
RET
1----------------------------------------------------------
OUTPUT SINGLE CHAR IN AL TO VIDEO DEVICE
i
VIDEO: MOV SI,OFFSET STATE
JMP [SI]
S2: PUSH AX
CALL GETMOD
POP AX
MOV BX,OFFSET CMDTABL-3
S7A: ADD BX,3
CMP BYTE PTR [BX] ,0
JZ SlA
CMP BYTE PTR [BX] ,AL
JNZ S7A
JMP WORD PTR [BX+l]
CON$INIT:
int Ilh
and al,OOllOOOOb
cmp al,OOllOOOOb
jnz iscolor
mov [base] ,0bOOOh ilook for bw card
iscolor:
cmp al,OOOlOOOOb ilook for 40 col mode
ja setbrk
mov [mode] ,0
mov [maxcol],39
setbrk:
XOR BX,BX
MOV DS,BX
MOV BX,BRKADR
MOV WORD PTR [BX],OFFSET BREAK
MOV WORD PTR [BX+2] ,CS
MOV BX,29H*4
MOV WORD PTR [BX] ,OFFSET COUT
MOV WORD PTR [BX+2] ,CS
MS-DOS DEVICE DRIVERS page 2-53
LDS BX,CS:[PTRSAV]
MOV WORD PTR [BX].TRANS,OFFSET CON$INIT
;SET BREAK ADDRESS
MOV [BX] .TRANS+2,CS
JMP EXIT
CODE ENDS
END
Chapter 3
MS-DOS Technical Information
OC-15 RESERVED.
Offset 18H
IMIM IM D D D D D
where:
Y is 0-119 (1980-2099)
M is 1-12
D is 1-31
Note
Note
(Offsets in Hex)
o
End of Reser- Long Offset add
INT 20H alloc. ved call Function
block (5 bytes) dispatcher
8
Segment addr. Terminate address Control-C exit
Function (IP, CS) address (IP)
dispatcher
10
Control-C Hard error exit address
exit (IP, CS)
address (CS)
Used by MS-DOS
5CH
100
Figure 4.1 Program Segment Prefix
MS-DOS CONTROL BLOCKS AND WORK AREAS Page 4-6
Important
Note
Offset Contents
6.1 INTRODUCTION
Data Records
LOGICAL ENUMERATED DATA RECORD
LOGICAL ITERATED DATA RECORD
FIXUP RECORD
*MODULE END RECORD
COMMENT RECORD
6.7 INDICES
"Index" fields occur throughout this document. An index is
an integer that selects some particular item from a
collection of such items. (List of examples: NAME INDEX,
SEGMENT INDEX, GROUP INDEX, EXTERNAL INDEX, TYPE INDEX.)
Note
Note
Pointer:
Base:
Offset:
Hibyte:
D
Lobyte:
D
Figure 6.1 LOCATION Types
Note
Note
Note
debug_record LINNUM
content def data record {FIXUPP}
thread def FIXUPP (containing only thread fields)
REC
TYP
xxH
RECORD
LENGTH
SAMPLE RECORD FORMAT
(SAMREC)
/ /f--.....,r---~
NAME NUMBER
II :EJ CRK
SUM
//1---+---1 "
-rpt
The BOXES
RECTYP
RECORD LENGTH
NAME
NUMBER
CHKSUM
BIT FIELDS
3
II 1 4
///
REC RECORD T CHK
TYP LENGTH MODULE SUM
BOH NAME
,/ '
T-MODULE NAME
r---~----------~--~/r----r----~
" /r-----t-------"
-rpt
NAME
, /, //
REC RECORD SEGMENT SEGMENT SEGMENT CRR
TYP LENGTH ATTR LENGTH NAME SUM
98H INDEX
, // //
SEG ATTR
---condi t ional-
A C
C LZ dx' dy'
Table 6.2 has no lines for C=O, C=l, C=3, C=4 and C=7. c=o
indicates that the relocatable LSEG may not be combined;
C=l and C=3 are undefined. C=4 and C=7 are treated like
C=2. Cl, C4, and C7 all have different meanings according
to the Intel standard.
The "pH field must always be zero. The "pH field is the
"Page resident" field in Intel-Land.
The FRAME NUMBER and OFFSET fields (present only for
absolute segments, A=O) specify the placement in MAS of the
absolute segment. The range of OFFSET is constrained to be
between 0 and 15 inclusive. If a value larger than 15 is
desired for OFFSET, then an adjustment of the FRAME NUMBER
should be done.
SEGMENT LENGTH
Note
Note
/1 /1/
REC RECORD GROUP GROUP CHK
TYP LENGTH NAME COMPONENT SUM
9AH INDEX DESCRIPTOR
/1/ II'
repeated-
r----..,---II
SI SEGMENT
INDEX
(FFH)
I 1/
REC RECORD NAME EIGHT CHK
TYP LENGTH (USUALLY LEAF SUM
8EH NULL) DESCRIPTOR
, I, 1/
repeated-
NAME
/ /1------.
E LEAF
N DESCRIPTOR
//1------1
-rpt-----'
~
to
128
o
129 to
64K-l
INTEL RELOCATABLE OBJECT MODULE FORMATS Page 6-27
o
132 to
l6M-l
-2G-l
136 to
2G-l
r---~------~-~,J/rL--~----,
//r--+--~/r---~------~-7,/,rL--~----~
~--------repeated--------~
PUBLIC BASE
~
/~----r-----I/
/r---~--~/r---r-------~
conditional
TARGET: EI{P)
FRAME: TARGET
TARGET: SI(L),d
FRAME: GI (G)
PUBLIC NAME
The PUBLIC NAME field gives the name of the object whose
location in MAS is made available to other modules. The
name must contain one or more characters.
PUBLIC OFFSET
TYPE INDEX
REC RECORD
'/~/,'
EXTERNAL
TYPE CHK
TYP LENGTH NAME INDEX SUM
8CH
~----~----------~--~// /,r---~----~
~------repeated--------~
EXTERNAL NAME
Note
TYPE INDEX
,I,
REC RECORD LIN E LINE LINE CHK
TYP LENGTH NUMB ER NUMBER NUMBER SUM
94H BAS E OFFSET
,
,I,
re p eated
~
R~UP
INDEX
SEG~~NT
INDEX
(ig/nOred)
I---""----fl
LINE NUMBER
~----~----------~--~// / /
SEGMENT INDEX
DAT
~/~ , //
REC RECORD SEGMENT ITERATED ITERATED CHK
TYP LENGTH INDEX DATA DATA SUM
A2H OFFSET BLOCK
//~ //~
~repeated-
SEGMENT INDEX
Note
REPEAT COUNT
BLOCK COUNT
CONTENT
Note
FIXUP RECORD
----CFIXUPP)
~----~----------~----~,'/,~'----~----~
~----~-----------+----~,'/,~'----~-----
-rpt-
THREAD
//
TRD INDEX
//
conditional
I I I
METHOD THRED
I I I
FIXUP
/ /1----,.....--1
I I I I J I o IR D I o IF F IS E IT
1 M S LOC D A T A R E C
I I I I I I I I I I I
10 b y te I hi b y te
Note
Note
Note
If the preceding DATA record is an LIDATA record, it is
possible for the value of DATA RECORD OFFSET to
designate a "location" within a REPEAT COUNT subfield
or a BLOCK COUNT subfield of the ITERATED DATA field.
Such a reference is an error. MS-LINK's action on such
a malformed record is undefined.
I
FRAME
I I
TARGT
I I I
See Note 1 See Note 2
Note
/
/
/~/_-I------I
+conditional+
MOD TYP
START ADDRS
J J J
I I I I I
+condltlonal+condltlonal+condltional+
COMMENT RECORD
(COMENT)
REC
TYP
aaH
RECORD
LENGTH
COMMENT
TYPE CO
~NT
J
I:EJCHK
SUM
COMMENT TYPE
COMMENT
CLASS
COMMENT
Notes:
1. Class value 129 is used to specify a library to add
to the Linker's library search list. The comment
field will contain the name of the library. Note
that unlike all other name specifications, the
library name is not prefixed with its length. Its
length is determined by the record length. The
"NODEFAULTLIBRARYSEARCH" switch causes the linker
to ignore all comment records whose class value is
129.
*6E RHEADR
*70 REGINT
*72 REDATA
*74 RIDATA
*76 OVLDEF
*78 ENDREC
*7A BLKDEF
*7C BLKEND
*7E DEBSYM
80 THEADR
*82 LHEADR
*84 PEDATA
*86 PIDATA
88 COMENT
8A MODEND
8C EXTDEF
8E TYPDEF
90 PUBDEF
*92 LOCSYM
94 LINNUM
96 LNAMES
98 SEGDEF
9A GRPDEF
9C FIXUPP
*9E (none)
AO LEDATA
A2 LIDATA
*A4 LIBHED
*A6 LIBNAM
*A8 LIBLOC
*AA LIBDIC
Note
If the objects produced from a.c, b.c, and c.c are linked
together, then the linker will allocate 1024 bytes for the
char array "foo".
A communal variable is defined in the object text by an
external definition record (EXTDEF) and the type definition
record (TYPDEF) to which it refers.
The TYPDEF for a communal variable has the following format:
, 11-'------.
REC RECORD EI GHT CHK
TYP LENGTH 0 LE AF SUM
8EH DESCR IPTOR
, 1,1-'---'----.....
ITJ;/g
E
N
LEAF
DESC~IPTOR
NEAR
62H
VAR
TYP LEN~Tq:~A~
IN
BITS
SUBTYP
~----~----~----~/// /
+ +
(optional)
FAR
6lH
VAR
TYP
~ER
OF ELE1jNT I
TYPE
77H ELEMENTS INDEX
~--~----~--~//r-~--~/
PROGRAMMING HINTS
7.1 INTRODUCTION
Interrupts
System Calls
Device Management
Memory Management
Process Management
Miscellaneous
7. 2 INTERRUPTS
Never explicitly issue Interrupt 22H (Terminate Process Exit
Address) •
This should only be done by the DOS. To change the
terminate address, use Function 35H (Get Interrupt
Vector) to get the current address and save it, then
use Function 25H (Set Interrupt Vector) to change
the Interrupt 22H entry in the vector table to point
to the new terminate address.
PROGRAMMING HINTS Page 7-2
7.8 MISCELLANEOUS
Avoid timing dependencies.
BASE • • . • . . 6-8
BIN format file 2-2
BIOS Parameter Block (BPB) 2-13, 2-18, 2-25
Bit 8 . . . . . 2-10
Bit 9 • • . . . 2-11
Block devices
device drivers • • . 2-21
disk drives • 2-3
example. 2-30
installation . 2-13
Boot sector • 2-25
BPB pointer • . • . • 2-12 to 2-13
Buffered Keyboard Input (Function OAH) 1-61
BUILD BPB . • . 2-7, 2-18
Busy bit • • . . • • 2-11, 2-21, 2-23
COMMAND.COM • • • • . . • 3-1
COMMENT RECORD • • • . . . 6-45
Compatibility, ensuring • 7-1
Complete name, LSEG . 6-5
COMSPEC • 4-3
CON device . . • . • • • . 2-4
CONFIG.SYS • • • . . . . • 2-1, 2-5
Control blocks • • . . . • 4-1
Control information • 5-1
Control-C Address (Interrupt 23H) 3-1
Control-C Check (Function 33H) 1-127
Control-C Handler Address (Interrupt 23H) 1-36
Create Directory (Function 39H) 1-138
Create File (Function 16H) 1-82
Create Handle (Function 3CH) 1-144
Create New File (Function 5BH) 1-217
Create New PSP (Function 26H) 1-102
Create Temporary File (Function 5AH) 1-214
Critical Error Handler Address (Interrupt 24H)
1-37, 3-1
Delete Directory Entry (Function 41H) 1-156
Delete File (Function 13H) 1-76
Device control • • • 1-11
Device drivers
block • • • • . . . 2-3
creating . . • . . • • • 2-4, 3-6
dumb • . . . • 2-14
example . • . • • 2-30, 2-44
installable . • 2-1
installing . • 2-5
non-resident • 2-1
preserving registers • . 2-29
resident • • 2-1
smart . • • • • • 2-14
Device handles • . • 1-8
Device header . . 2-6
Device interrupt routine • 2-5
Device management, programming hints 7-3
Device strategy routine • 2-5
Device-related function requests 1-11
Direct Console I/O (Function 06H) 1-56
Direct Console Input (Function 07H) 1-58
Directory entry . • • • • 1-12
Directory-related function requests 1-11 to 1-12
Disk allocation • 3-2
Disk Directory • • • 3-3
Disk formats
IBM . • • • • • • • 3-9
standard MS-DOS • 3-9
Disk Transfer Address (DTA) 1-80, 1-200, 4-3
Dispatch table • . • • • . 2-28
Display Character (Function 02H) 1-50
Display String (Function 09H) 1-60
Done bit • • • • . • • • • 2-10, 2-29
Page Index-3
Function requests
alphabetic order . • 1-29
calling •••• • • 1-20
definition • • • • • 1-1, 1-20
device-related • • • 1-11
directory-related • 1-11 to 1-12
file-related • • 1-9
file-sharing • • 1-10
Function OOH • 1-47
Function 01H • • 1-49
Function 02H • • 1-50
Function 03H 1-51
Function 04H • 1-52
Function 05H • • 1-53
Function 06H 1-56
Function 07H • 1-58
Function 08H • 1-59
Function 09H • 1-60
Function OAH 1-61
Function OBH • 1-63
Function OCH • • 1-64
Function ODH • 1-65, 1-80
Function OEH • 1-66
Function OFH • • 1-68
Function 10H • 1-70
Function IlH • 1-72
Function 12H • 1-74
Function 13H 1-76
Function 14H • • 1-78
Function 15H • 1-80
Function 16H • 1-82
Function 17H • 1-84
Function 19H • • 1-86
Function lAH • • 1-87
Function IBH • 1-89
Function lCH • 1-91
Function 21H 1-93
Function 22H • • 1-95
Function 23H • 1-98
Function 24H • • 1-100
Function 25H • • 1-35 to 1-37, 1-101
Function 26H • • 1-102
Function 27H • 1-104
Function 28H • • 1-107
Function 29H • • 1-110
Function 2AH 1-113
Function 2BH • • 1-115
Function 2CH • 1-117
Function 2DH • 1-119
Function 2EH • 1-121
Function 2FH • • 1-123
Function 30H • • 1-124
Function 31H • • 1-125
Function 33H • 1-127
Function 35H • • 1-35 to 1-36, 1-129
Function 36H • • 1-131
Page Index-5
Function 38H
· · 1-133, 1-136
Function 39H
Function 3AH ·· · ·
·
1-138
1-140
Function 3BH
· 1-142
Function 3CH
· 1-144
Function 3DH
Function 3EH ·· · 1-146
1-150
Function 3FH
Function 40H ·
·
·
···
1-152
1-154
Function 41H
· · 1-156
Function 42H
· ··· 1-158
Function 43H
·
Function 44H, Codes OOH · 1-160
and 01H 1-162
Function 44H, Codes 02H and 03H 1-164
Function 44H, Codes 04H and 05H 1-166
Function 44H, Codes 06H and 07H 1-168
Function 44H, Code 08H 1-170
Function 44H, Code 09H
Function 44H, Code OAH · 1-172
1-174
Function 44H, Code OBH 1-176
Function 45H
Function 46H · · 1-178
1-180
Function 47H
· 1-182
Function 48H
Function 49H ·· ·
·· ·· · ·
1-184
1-186
Function 4AH
·
Function 4BH, Code OOH
1-188
1-190
Function 4BH, Code 03H 1-194
Function 4CH
· 1-197
Function 4DH
· · 1-199
Function 4EH
· ·· ·· ·· · 1-200
·
···
Function 4FH 1-202
Function 54H
· 1-204
Function 56H
· 1-205
Function 57H
· . ·· 1-207
Function 58H
· ·· ·· 1-209
Function 59H
· ··· 1-211
Function 5AH
Function 5BH · ·
1-214
1-217
Function 5CH, Code OOH 1-219
Function 5CH, Code 01H 1-222
Function 5EH, Code OOH 1-225
Function 5EH, Code 02H
Function 5FH, Code 02H · 1-227
1-229
Function 5FH, Code 03H 1-232
Function 5FH, Code 04H 1-235
Function 62H
· ·
handling errors
1-237
1-21
memory management 1-4
network-related
· 1-14
numeric order
process management
· · 1-27
1-5
standard character I/O 1-2
system-management 1-15
Page Index-6
LEDATA • • • • • • • . • • 6-35
Length of Record Field • • 2-9
LIDATA • • • • • 6-36
LINE NUMBERS RECORD • 6-34
LINNUM • • . • • • • · 6-34
List of Names Record • • • 6-20
LNAMES • • • • • • 6-20
Load and Execute Program (Function 4BH, Code OOH)
1-190
Load module . • • • • • • 5-1, 5-3
Load Overlay (Function 4BH, Code 03H) 1-194
Loadsize • • • . • • • • • 5-3
LOBYTE • • • . • • • • • • 6-9
Local buffering • • • • • 2-5
LOCATION, types • • 6-8
Lock (Function 5CH, Code OOH) 1-219
LOGICAL ENUMERATED DATA RECORD 6-35
LOGICAL ITERATED DATA RECORD 6-36
Logical sector . • • • • • 3-6
Logical sector numbers • • 3-8
Logical Segment • • 6-3
LSEG • • • • • . • • 6-3
Make Assign List Entry (Function 5FH, Code 03H)
1-232
MAS • • • • • . • • 6-2
Maxa110c • • . • . • . • • 5-3
Page Index-8
T-MODULE • • • • . . • • • 6-2
T-module Header Record (THEADR) 6-19
TARGET . • • • • . • • • • 6-10
Terminate But Stay Resident (Interrupt 27H) 1-45
Terminate Process Exit Address (Interrupt 22H) 1-35
Terminate Program (Function OOH) 1-47
THEADR • • • • • • • • • . 6-19
Transfer address • • • • • 2-28
TYPDEF • • . • • • • • 6-25
Type Definition Record • • 6-25
Type-ahead buffer • • • • 2-24
Unit code field • • 2-9
Unlock (Function 5CH, Code 01H) 1-222
Unopened FCB • . . • • • • 1-16
Page Index-II