1           ' 0RRqrrDOS.DFV                                                             PLAIN   s@   iSS  pVersion1.0(12.6.1990)	TechnicalReferenceIBM-PCPage-
.Anfang Verzeichnis V.
INTRODUCTION 	9
DISCLAIMER	10
HARDWARE 	12
PORT-Assignments 	12
SYSTEM MEMORY MAP - OVERALL 	12
PC Port Assignment, Intel 8088, 80C88, 8086, 80286, 80386 CPUs 	14
I/O Port Map 	14
I/O Port Detail 	15
CMOS Storage Layout 	16
Enhanced Graphics Adapter I/O Ports 	20
Reserved Memory Locations in the IBM PC 	24
At Absolute Addresses 	29
ROM-Scan 	32
The IBM PC System Interrupts -Overview 	33
The IBM-PC System Interrupts - in detail 	35
Interrupt 00h Divide by Zero (processor error). 	35
Interrupt 01h Single step 	35
Interrupt 02h Non-maskable interrupt 	35
Interrupt 03h Breakpoint 	35
Interrupt 04h Divide overflow 	35
Interrupt 05h Print Screen	35
Interrupt 06h Reserved by IBM 	35
Interrupt 07h Reserved by IBM 	35
Interrupt 08h Timer 	35
Interrupt 09h Keyboard 	36
Interrupt 0Ah EGA Vertical Retrace 	36
Interrupt 0Bh Communications Controller (serial port) hdw. entry 	37
Interrupt 0Ch Communications Controller (serial port) hdw. entry 	37
Interrupt 0Dh Alternate Printer, PC/AT 80287 	37
Interrupt 0Eh Diskette - indicates that a seek is in progress 	37
Interrupt 0Fh Reserved by IBM 	37
THE PC ROM BIOS 	37
Interrupt 10h Video I/O - services to handle video output 	37
Interrupt 11h Equipment Check 	53
Interrupt 12h Memory Size 	53
Interrupt 13h Disk I/O - access the disk drives (floppy and hard disk) 	53
Interrupt 14h Initialize and Access Serial Port For Int 14 	59
Interrupt 15h Cassette I/O 	62
Interrupt 16h Keyboard I/O 	74
Interrupt 17h Printer 	76
Interrupt 18h ROM BASIC 	76
Interrupt 19h Bootstrap Loader 	76
Interrupt 1Ah Time of Day 	76
Interrupt 1Bh Control-Break 	78
Interrupt 1Ch Timer Tick 	78
Interrupt 1Dh Vector of Video Initialization Parameters. 	79
Interrupt 1Eh Vector of Diskette Controller Parameters 	80
Interrupt 1Fh Pointer to Graphics Character Extensions (Graphics Set 2) 	80
DOS TECHNICAL INFORMATION 	80
SOME HISTORY 	80
THE OPERATING SYSTEM HIERARCHY 	82
DOS STRUCTURE 	82
DOS Initialization 	83
DOS INTERRUPTS AND FUNCTION CALLS 	84
DOS REGISTERS 	84
INTERRUPTS 	84
Interrupt 20h PROGRAM TERMINATE 	85
Interrupt 21h FUNCTION CALL REQUEST 	85
DOS Functions 	87
DOS Interrupts 	88
System Information Functions 	88
Character I/O Functions 	88
Handle-Oriented File I/O 	88
Traditional FCB File I/O 	89
Directory and File Functions 	89
Process Control Functions 	89
Memory Control Functions 	90
Miscellaneous DOS Functions 	90
CALLING THE DOS SERVICES 	90
INT 21H DOS services 	91
00h Terminate Program 	91
01h Get Keyboard Input 	91
02h Display Output 	92
03h Auxiliary Input 	92
04h Auxiliary Output 	92
05h Printer Output 	92
06h Direct Console I/O 	92
07h Direct Console Input Without Echo (does not check BREAK) 	93
08h Console Input Without Echo (checks BREAK) 	93
09h Print String 	93
0Ah Buffered Keyboard Input 	93
0Bh Check Standard Input (STDIN) status 	94
0Ch Clear Keyboard Buffer & Invoke a Keyboard Function (FCB) 	94
0Dh Disk Reset 	94
0Eh Select Disk 	95
10h Close File (FCB) 	95
11h Search For First Matching Entry (FCB) 	96
12h Search For Next Entry Using FCB 	96
13h Delete File Via FCB 	97
14h Sequential Disk File Read (FCB) 	97
15h Sequential Disk Write (FCB) 	97
16h Create A Disk File (FCB) 	98
17h Rename File Specified by File Control Block (FCB) 	98
18h Internal to DOS 	98
19h Get Current Disk Drive 	98
1Ah Set Disk Transfer Area Address (DTA) 	98
1Bh Get Current Drive File Allocation Table Information 	99
1Ch Get File Allocation Table Information for Specific Device 	99
1Dh Not Documented by Microsoft 	99
1Eh Not Documented by Microsoft 	99
1Fh Get Default Drive Parameter Block 	99
20h Unknown 	100
21h Random Read from File Specified by FCB 	100
22h Random Write to File Specified by FCB 	100
23h Get File Size (FCB) 	100
24h Set Relative Record Field (FCB) 	101
25h Set Interrupt Vector 	101
26h Create New Program Segment Prefix (PSP) 	101
27h Random Block Read From File Specified by FCB 	102
28h Random Block Write to File Specified in FCB 	102
29h Parse the Command Line for Filename (FCB) 	103
2Ah Get Date 	104
2Bh Set Date 	104
2Ch Get Time 	104
2Dh Set Time 	104
2Eh Set/Reset Verify Switch 	105
2Fh Get Disk Transfer Address (DTA) 	105
30h Get DOS Version Number 	105
31h Terminate Process and Stay Resident 	105
32h Read DOS Disk Block 	106
33h Control-Break Check 	106
34h Return INDOS Flag 	107
35h Get Vector 	107
36h Get Disk Free Space 	108
37h SWITCHAR / AVAILDEV 	109
38h Return Country Dependent Information 	109
38h Get Country Dependent Information 	109
38h Set Country Dependent Information 	111
39h Create Subdirectory (MKDIR) 	111
3Ah Remove Subdirectory (RMDIR) 	111
3Bh Change Current Directory 	111
3Ch Create A File (CREAT) 	112
3Dh Open A File 	112
3Eh Close A File Handle 	113
3Fh Read From A File Or Device 	113
40h Write To A File Or Device 	113
41h Delete A File From A Specified Subdirectory 	113
42h Move a File Read/Write Pointer 	114
43h Get/Set file attributes 	114
44h I/O Control for Devices (IOCTL) 	115
45h Duplicate a File Handle (DUP) 	116
46h Force Duplicate of a Handle (FORCEDUP or CDUP) 	117
47h Get Current Directory 	117
48h Allocate Memory 	117
49h Free Allocated Memory 	117
4Ah Modify Allocated Memory Blocks (SETBLOCK) 	117
4Bh Load or Execute a Program 	118
4Ch Terminate a Process (EXIT) 	120
4Dh Get Return Code of a Subprocess (WAIT) 	120
4Eh Find First Matching File (FIND FIRST) 	121
4Fh Find Next Matching File (FIND NEXT) 	121
50h Set PSP 	122
51h Get Program Segment Prefix 	122
52h IN-VARS 	123
53h Translate BPB 	124
54h Get Verify Setting 	124
55h Create "Child" PSP 	124
56h Rename a File 	124
57h Get/Set a File's Date and Time 	125
58h Get/Set Allocation Strategy 	125
59h Get Extended Error Code (DOS 3.x) 	125
5Ah Create Temporary File 	129
5Bh Create a New File 	129
5Ch Lock/Unlock File Access 	130
5Dh Set Extended Error Information 	130
5Eh Network Printer (Partially documented by Microsoft) 	131
5Fh Network Redirection 	132
60h Parse pathname (DOS 3.x) 	132
61h No Information Availible (DOS 3.x) 	133
62h Get Program Segment Prefix (PSP) 	133
63h Get Lead Byte Table (MS-DOS 2.25 only) 	133
64h Internal 	133
65h Get Extended Country Information (DOS 3.3+) 	133
66h Get/Set Global Code Page Table (DOS 3.3+) 	134
67h Set Handle Count (DOS 3.3+) 	134
68h Commit File (DOS 3.3+) 	134
69h Disk Serial Number DOS 4.0 (US) 	134
6Ah unknown (DOS 4.0?) 	135
6Bh unknown (DOS 4.0?) 	135
6Ch Extended Open/Create DOS 4.0 (US) 	135
89h DOS_Sleep 	135
Aftermarket Application Installed Function Calls: 	135
0DCh Novell NetWare 	135
0DDh Novell NetWare 	136
0DEh Novell NetWare 	136
0DFh Novell NetWare 	136
0E0h Novell NetWare 	136
0E1h Novell NetWare 	136
0E2h Novell NetWare 	136
0E3h Novell NetWare 	136
0E4h DoubleDOS 	136
0E4h Novell NetWare 	136
0E5h, 0E6h, 0E7h, 0E8h, 0E9h 	136
0EAh DoubleDOS 	136
0EAh Novell NetWare 	136
0EBh DoubleDOS 	136
0EBh Novell NetWare 	136
0ECh DoubleDOS 	136
0ECh Novell NetWare 	137
0EDh Novell NetWare 	137
0EEh DoubleDOS 	137
0EEh Novell NetWare 	137
0EFh, 0F0h, 0F1h, 0F2h, 0F3h Novell NetWare 	137
0FFh CED (CJ Dunford's DOS macro and command-line editor) 	137
Interrupts 22h Through 86h 	137
Interrupt 22h Terminate Address 	137
Interrupt 23h Ctrl-Break Exit Address 	138
Interrupt 24h Critical Error Handler 	138
Interrupt 25h Absolute Disk Read 	141
Interrupt 26h Absolute Disk Write 	141
Interrupt 27h Terminate And Stay Resident 	141
Interrupt 28h (not documented by Microsoft) 	142
Interrupt 29h (not documented by Microsoft) 	142
Interrupt 2Ah Microsoft Networks - Session Layer Interrupt 	143
Interrupt 2Bh (not documented by Microsoft) 	143
Interrupt 2Ch (not documented by Microsoft) 	143
Interrupt 2Dh (not documented by Microsoft) 	143
Interrupt 2Eh (undocumented by Microsoft) 	143
Interrupt 2Fh Multiplex Interrupt 	144
Interrupt 30h far jump instruction for CP/M-style calls 	151
Interrupt 31h Unknown 	151
Interrupt 32h Unknown 	151
Interrupt 33h Used by Microsoft Mouse Driver 	151
Interrupt 34h Turbo C/Microsoft languages - Floating Point emulation 	155
Interrupt 35h Turbo C/Microsoft languages - Floating Point emulation 	155
Interrupt 36h Turbo C/Microsoft languages - Floating Point emulation 	155
Interrupt 37h Turbo C/Microsoft languages - Floating Point emulation 	155
Interrupt 38h Turbo C/Microsoft languages - Floating Point emulation 	155
Interrupt 39h Turbo C/Microsoft languages - Floating Point emulation 	156
Interrupt 3Ah Turbo C/Microsoft languages - Floating Point emulation 	156
Interrupt 3Bh Turbo C/Microsoft languages - Floating Point emulation 	156
Interrupt 3Ch Turbo C/Microsoft languages - Floating Point emulation 	156
Interrupt 3Dh Turbo C/Microsoft languages - Floating Point emulation 	156
Interrupt 3Eh Turbo C/Microsoft languages - Floating Point emulation 	156
Interrupt 3Fh Overlay manager interrupt (Microsoft LINK.EXE) 	156
Interrupt 40h Hard Disk BIOS 	156
Interrupt 41h Hard Disk Parameters 	156
Interrupt 42h Pointer to screen BIOS entry (EGA, VGA, PS/2) 	156
Interrupt 43h Pointer to EGA initialization parameter table. The POST 	157
Interrupt 44h Pointer to EGA graphics character table (also PCjr). 	157
Interrupt 45h Reserved by IBM (not initialized) 	157
Interrupt 46h Pointer to second hard disk, parameter block (AT, XT/286, PS/2) 	157
Interrupt 47h Reserved by IBM (not initialized) 	157
Interrupt 48h Cordless Keyboard Translation (PCjr, XT [never delivered]) 	157
Interrupt 49h Non-keyboard Scan Code Translation Table Address (PCjr) 	157
Interrupt 4Ah Real-Time Clock Alarm (Convertible, PS/2) 	157
Interrupt 4Bh Reserved by IBM (not initialized) 	157
Interrupt 4Ch Reserved by IBM (not initialized) 	157
Interrupt 4Dh Reserved by IBM (not initialized) 	157
Interrupt 4Eh Reserved by IBM (not initialized) 	157
Interrupt 4Fh Reserved by IBM (not initialized) 	157
Interrupt 50-57 IRQ0-IRQ7 relocated by DesQview 	157
Interrupt 58h Reserved by IBM (not initialized) 	158
Interrupt 59h Reserved by IBM (not initialized) 	158
Interrupt 5Ah Reserved by IBM (not initialized) 	158
Interrupt 5Bh Reserved by IBM (not initialized) 	158
Interrupt 5Ah Cluster Adapter BIOS entry address 	158
Interrupt 5Bh Reserved by IBM (not initialized) (cluster adapter?) 	158
Interrupt 5Ch NETBIOS interface entry port 	158
Interrupt 5Dh Reserved by IBM (not initialized) 	158
Interrupt 5Eh Reserved by IBM (not initialized) 	158
Interrupt 5Fh Reserved by IBM (not initialized) 	158
Interrupt 60h-67h User Program Interrupts (availible for general use) 	158
Interrupt 67h Used by Lotus-Intel-Microsoft Expanded Memory Specification 	158
Interrupt 68h Not Used (not initialized) 	159
Interrupt 69h Not Used (not initialized) 	159
Interrupt 6Ah Not Used (not initialized) 	159
Interrupt 6Bh Not Used (not initialized) 	159
Interrupt 6Ch System Resume Vector (Convertible) (not initialized on PC) 	159
Interrupt 6Dh Not Used (not initialized) 	159
Interrupt 6Fh Not Used (not initialized) 	159
Interrupt 70h IRQ 8, Real Time Clock Interrupt (AT, XT/286, PS/2) 	159
Interrupt 71h IRQ 9, Redirected to IRQ 8 (AT, XT/286, PS/2) 	159
Interrupt 72h IRQ 10 (AT, XT/286, PS/2) Reserved 	159
Interrupt 73h IRQ 11 (AT, XT/286, PS/2) Reserved 	159
Interrupt 74h IRQ 12 Mouse Interrupt (AT, XT/286, PS/2) 	159
Interrupt 75h IRQ 13, Coprocessor Error, BIOS Redirect to int 2 (NMI) (AT) 	159
Interrupt 76h IRQ 14, Hard Disk Controller (AT, XT/286, PS/2) 	159
Interrupt 77h IRQ 15 (AT, XT/286, PS/2) Reserved 	159
Interrupt 78h Not Used 	159
Interrupt 79h Not Used 	159
Interrupt 7Ah Novell NetWare - LOW-LEVEL API 	159
Interrupt 7Bh-7Fh Not Used 	159
Interrupt 80h-85h Reserved by BASIC 	159
Interrupt 86h Relocated by NETBIOS int 18 	159
Interrupt 86h-0F0h Used by BASIC when BASIC interpreter is running 	159
Interrupt 0E0h CP/M-86 function calls 	159
Interrupt 0E4h Logitech Modula-2 v2.0 MONITOR 	159
Interrupts 0F1h-0FFh (absolute addresses 3C4-3FF) 	159
Interrupt 0F8h Set Shell Interrupt (OEM) 	160
Interrupt 0F9h First of 8 SHELL service codes, reserved for OEM shell (WINDOW); 	160
Interrupt 0FAh USART ready (RS-232C) 	160
Interrupt 0FBh USART RS ready (keyboard) 	160
Interrupt 0FCh Unknown 	160
Interrupt 0FDh reserved for user interrupt 	160
Interrupt 0FEh AT/XT286/PS50+ - destroyed by return from protected mode 	160
Interrupt 0FFh AT/XT286/PS50+ - destroyed by return from protected mode 	160
DOS CONTROL BLOCKS AND WORK AREAS 	160
The Disk Transfer Area (DTA) 	161
DOS Program Segment 	161
STANDARD FILE CONTROL BLOCK 	165
EXTENDED FILE CONTROL BLOCK 	167
MEMORY CONTROL BLOCKS 	167
CONTROL BLOCK 	167
MEMORY CONTROL BLOCKS 	168
DOS File Structure 	169
File Management Functions 	169
FCB FUNCTION CALLS 	170
HANDLE FUNCTION CALLS 	170
SPECIAL FILE HANDLES 	171
ASCII and BINARY MODE 	171
FILE I/O IN BINARY (RAW) MODE 	172
FILE I/O IN ASCII (COOKED) MODE 	172
NUMBER OF OPEN FILES ALLOWED 	173
RESTRICTIONS ON FCB USAGE 	173
RESTRICTIONS ON HANDLE USAGE 	173
ALLOCATING SPACE TO A FILE 	173
MSDOS / PCDOS DIFFERENCES 	173
.EXE FILE STRUCTURE 	174
THE RELOCATION TABLE 	175
"NEW" .EXE FORMAT (Microsoft Windows and OS/2) 	176
DOS DISK INFORMATION 	176
THE DOS AREA 	176
THE BOOT RECORD 	176
BIOS Parameter Block (BPB) 	176
THE DOS FILE ALLOCATION TABLE (FAT) 	177
USE OF THE 12 BIT FILE ALLOCATION TABLE 	178
USE OF THE 16 BIT FILE ALLOCATION TABLE 	178
DOS DISK DIRECTORY 	179
DIRECTORY ENTRIES 	179
File Attribute 	181
File Time/Date Format 	182
File Allocation Table 	182
THE DATA AREA 	182
Hard Disk Layout 	183
SYSTEM INITIALIZATION 	184
BOOT RECORD/PARTITION TABLE 	184
HARD DISK TECHNICAL INFORMATION 	185
DETERMINING FIXED DISK ALLOCATION 	186
MISCELANEOUS 	188
The CONFIG.SYS File 	188
DOS Error Codes 	190
File Handle 	193
DOS File Allocation Table (FAT) 	193
The DOS Environment 	196
Program Startup & Exit 	197
Standard I/O 	199
DOS Versions 	201
About DOS Functions 	203
Interrupts and ROM-BIOS Services 	203
INSTALLABLE DEVICE DRIVERS 	203
DEVICE DRIVER FORMAT 	203
TYPES OF DEVICES 	204
DEVICE HEADER 	204
POINTER TO NEXT DEVICE HEADER FIELD 	205
Device Header Layout 	205
ATTRIBUTE FIELD 	206
Device Request Layouts 	207
POINTER TO STRATEGY AND INTERRUPT ROUTINES 	207
NAME/UNIT FIELD 	207
CREATING A DEVICE DRIVER 	208
INSTALLING DEVICE DRIVERS 	208
INSTALLING CHARACTER DEVICES 	208
INSTALLING BLOCK DEVICES 	209
REQUEST HEADER 	209
UNIT CODE FIELD 	210
COMMAND CODE FIELD 	210
STATUS FIELD 	210
Device Driver Errors 	211
DEVICE DRIVER FUNCTIONS 	212
INIT 	212
MEDIA CHECK 	213
MEDIA DESCRIPTOR 	213
BUILD BPB (BIOS Parameter Block) 	214
INPUT / OUTPUT 	215
NONDESTRUCTIVE INPUT NO WAIT 	216
STATUS 	216
FLUSH 	217
OPEN or CLOSE (3.x) 	217
REMOVABLE MEDIA (DOS 3.x) 	217
THE CLOCK$ DEVICE 	218
LOTUS-INTEL-MICROSOFT EXPANDED MEMORY SPECIFICATION 	218
THE EXPANDED MEMORY MANAGER 	218
Expanded Memory Specification 	218
AST/QUADRAM/ASHTON-TATE ENHANCED EXPANDED MEMORY SPECIFICATION 	219
WRITING PROGRAMS THAT USE EXPANDED MEMORY 	220
EMS 4.0 SPECIFICATIONS 	222
TESTING FOR THE PRESENCE OF THE EXPANDED MEMORY MANAGER 	223
EXPANDED MEMORY SERVICES 	225
FUNCTIONS DEFINED IN EMS 3.2 SPECIFICATION 	225
Function 40h Get Manager Status 	225
Function 41h Get Page Frame Segment 	225
Function 42h Get Unallocated Page Count 	225
Function 43h Get Handle and Allocate Memory 	226
Function 44h Map Memory 	226
Function 45h Release Handle and Memory 	226
Function 46h Get EMM Version 	227
Function 47h Save Mapping Context 	227
Function 48h Restore Page Map 	228
Function 49h Reserved 	228
Function 4Ah Reserved 	228
Function 4Bh Get Number of EMM Handles 	228
Function 4Ch Get Pages Owned by Handle 	229
Function 4Dh Get Pages for All Handles 	229
Function 4Eh Get or Set Page Map 	230
FUNCTIONS NEW TO EMS 4.0 	231
Function 4Eh Get or Set Page Map 	231
Function 4Fh Get/Set Partial Page Map 	231
Function 50h Map/Unmap Multiple Pages 	232
Function 51h Reallocate pages 	232
Function 52h Get/Set Handle Attributes 	233
Function 53h Handle Name Functions 	233
Function 54h Handle Directory Functions 	234
Function 55h Alter Page Map and Jump (cross page branch) 	235
Function 56h Alter Page Map and Call (cross page call) 	235
Function 57h Move/Exchange Memory Region 	236
Function 58h Mappable Physical Address Array 	236
Function 59h Get Expanded Memory Hardware Information 	237
Function 5Ah Allocate Raw Pages 	238
Function 5Bh Alternate Map Register Set - DMA Registers 	239
Function 5Ch Prepare EMS Hardware for Warm Boot 	239
Function 5Dh Enable/Disable OS Function Set Functions 	240
Function 5Eh Unknown 	240
Function 5Fh Unknown 	240
Function 60h EEMS - Get Physical Window Array 	240
Function 61h Generic Accelerator Card Support 	240
Function 68h EEMS - Get Addresses of All Page Frames in System 	240
Function 69h EEMS - Map Page Into Frame 	241
Function 6Ah EEMS - Page Mapping 	241
EXPANDED MEMORY MANAGER ERROR CODES 	241
LIM 4.0 extended error codes: 	242
T A B L E S 	242
IBM PC KEYBOARD EXTENDED CODES 	242
BIOS keystroke codes, hexadecimal	245
Instruction Set Matrix	248
Secondary Opcode Space	249
Arithmetic Instructions	250
Data Transfer Instructions	251
Execution Control Instructions	252
Processor Control Instructions 	253
Protection Control Instructions 	253
String Operation Instructions 	254
Switch Settings 	255
PC Switch Settings 	255
XT Switch Settings 	258
AT Switch Settings 	259
<EGA> Switch Settingse 	260
ASCIIDecimalHexBinary Cross Reference	262
.Ende Verzeichnis V.
TECHNICAL REFERENCE IBM 
INTRODUCTION 
This manual is intended to replace the various (expensive) references needed to program for the DOS environment, that stack of magazines threatening to take over your work area, and those odd tables and charts you can never find when you need them. 
The various Microsoft and IBM publications and references don't always have the same information. This has caused some consternation about the "undocumented" features to be found in DOS. In general use, if a call doesn't appear in the IBM DOS Technical Reference it is considered "undocumented" although it may be in common use. 
Microsoft's offical policy toward DOS has been to put the burden of documenting and supporting their product to their vendors. Microsoft will not answer any questions concerning DOS directly since they don't officially support it. This leaves what information IBM and other OEMs (DEC, Zenith, et al) have chosen to publish, and the information obtained from programmers who've poked around inside it. 
Now that Microsoft is selling MSDOS 3.2 and 3.3 as Microsoft products they seem to be dragging their feet over whether they will have to support the generic version since it doesn't have an OEM name on it anymore. In view of their push to OS/2 (OS/2! Just Say No!) further support of DOS seems unlikely. 
The information here is valid for DOS 2.x and 3.x. Where there are differences between the two versions there are notes in the text. No effort was expended on DOS 1.x or networking features. 
As I write this there is still considerable furor over incompatibilities with DOS 4.0. Since a Technical Reference for 4.0 isn't availible yet, I don't have a whole lot of info on it. 
When I started writing this book, it was originally for my own personal use. Then I began expanding it with the idea of getting it published, since at that time there was *nothing* in print like it. If I had managed to send it off to the publishers early enough, I would have had it made. As it was I lost six months having a nice steel rod put in my leg, and half a dozen similar books were published by then, and nobody was interested in mine. Six months is a long time in the PC world. 
That's why I'm uploading this file as "user-supported." It gives me a chance to recoup a few bucks for the year or so I've been working on this thing, and it gives some advantages that a printed book can't - first, you can load it on your hard disk and use Vern Buerg's LIST or SideKick to scan through text. You can grab a peice of something and paste it into a document, etc. If you help support the PC Programmer's Reference you will always have the latest version availible; you can't "upgrade" printed books. 
A project this size takes a LOT of time and effort. I've tried to verify all the information I've received, but there's just too much for absolute certainty. If you find any typos, incorrect information, or want to see something else, let me know. If you have any more detailed information on something, PLEASE let me know! 
Dave Williams 
DISCLAIMER
The information presented here was gathered from megabytes of files found on BBS systems, conversations on a dozen different BBS systems, correspondence, and every reference book I could get my hands on. On occaision, a number of prestigious references didn't agree with each other. Where this has happened, I have used the latest references. There is too much information here for me to verify every fact personally. I have used my own judgement as to the reliability of the sources. 
This entire project was originally begun as a reference for myself, where I put all the little bits of information I culled from various sources into a whole and (hopefully) organized format so I could find them again when nescessary. If you find anything that is incorrect, I would greatly appreciate a card or letter telling me. 
As is common these days, I have to make a "Notice of Disclaimer". I take no responsibility for anything, and if anything you do with this book ruins you for life or makes your dog bite you, or anything else, that's just tough. 
I hope you find much use for this reference. It was a trip to write, too. 
Dave Williams 
References used in preparing this book: 
IBM Technical Reference         Personal Computer         p/n 6322507 IBM Publications 
IBM Technical Reference         Personal Computer - PCjr         p/n 1502293 IBM Publications 
IBM Technical Reference         Options and Adapters - Enhanced Graphics Adapter         p/n 6280131  IBM Publications Aug 1984 
IBM DOS Operations Manual Version 2.00 
MS-DOS Programmer's Reference         by Microsoft         p/n 135555-001 Intel Corp. 1984 
Lotus-Intel-Microsoft Expanded Memory Specification 4.0         Intel Corp.  1987 
Microsoft Extended Memory Specification v2.00         Microsoft Corporation,  1988 
X3.4-1977: American National Standard Code for Information Interchange         by American National Standards Institute (ANSI)         New York, NY  1977 
Microcomputer Products - 1987 Data Book         NEC Electronics, Inc.         p/n 500105      Aug 1987 
FastCard IV User Manual         Peripheral Marketing Inc         p/n 0527     Jan 1987 
Hercules Graphics Card User's Manual 
Programmer's Guide to the IBM PC         Peter Norton         Microsoft Press  1985 
Inside the IBM PC         Peter Norton 
Exploring the IBM PCjr         Peter Norton         Microsoft Press  1984 
Advanced MSDOS         Ray Duncan         Microsoft Press  1986 
The IBM Personal Computer from the Inside Out         Murray Sargent III and Richard L. Shoemaker         Addison-Wesley  1984 
DOS:The Complete Reference         Kris Jamsa         Osborne/McGraw-Hill  1987 
Mapping the IBM PC         Russ Davies/Compute! Magazine         Compute! Books   1986 
Tricks of the MS-DOS Masters         Waite Group 
Supercharging MS-DOS         Van Volverton         Microsoft Press  1986 
DOS Power Tools         Paul Somerson         Bantam Books  1988 
Running MS-DOS         Van Wolverton         Microsoft Press 
Microcomputer Interfacing         Bruce A. Artwick         Prentice Hall   1980 
The 8080a Bugbook         Tony-Larsen-Titus         Howard W. Sams   1977 
S-286 User Manual, version 2         Link Computer, 1988 
MPC Operations Guide,  Manual #1023         Columbia Data Products, Inc.         CDP  1983 
Assembly Language Subroutines for MSDOS Computers         Leo J. Scanlon         TAB Books   1986 
The Serious Assembler         Charles A. Crayne and Dian Gerard         Baen Books   1985 
Assembly Language Programming for the IBM Personal Computer         David J. Bradley         Prentice-Hall   1984 
The 8086 Book         Russell Rector and George Alexy         Osborne/McGraw-Hill  1980 
Compute!'s Guide to Assembly Language Programming on the IBM PC 
Dr. Dobb's Journal 
PC Magazine 
PC Resource 
PC Tech Journal 
Computer Language 
Programmer's Journal 
Byte Magazine 
various computer bulletin board systems, including 
Byte Information Exchange (BIX) 
Compuserve IBM SIG 
GEnie IBM RT 
GT Net international network 
FIDO Net international network 
PCanada BBS system               (Toronto, Canada) 
Pecan Pi RBBS, (404) 454-8756    (Atlanta, Georgia) 
Night Modulator, (408) 728-5598  (San Jose, California) 
various text files downloaded from BBS systems - INTERRUP.ARC, BIOSDOS.ZOO, DOSINFO.ARC, DOSERROR.DOC, DOSTIPS.TXT, etc. 
and all the people who have been good enough to furnish information 
HARDWARE 
PORT-Assignments 
SYSTEM MEMORY MAP - OVERALL 
The IBM PC handles its address space in 64k segments, divided into 16k fractions and then further as nescessary. 
start   start  end addr.   addr.  addr.              usage (dec)      (hex) 
00000 **** 640k *************** system data, drivers....                         0000:0000  hardware interrupt vectors                         0000:0040  BIOS interrupt vectors 0k      start of RAM |  0000:0080  DOS interrupt vector table 16k     00000-03FFF  |  0000:0300  Stack area during POST and bootstrap routine 32k     04000-07FFF  |  0000:0400  BIOS Data Area 48k     08000-0BFFF  |  0000:04F0  Intra-Application Communications Area                      | 64k     10000-13FFF  |  0000:0500  DOS reserved communication area 80k     14000-17FFF  |  xxxx:0000  IO.SYS - DOS interface to ROM I/O routines 96k     18000-1BFFF  |  xxxx:0000  MSDOS.SYS - DOS interrupt handlers, service 112k    1C000-1FFFF  |             routines (int 21 functions)                      | 128k    20000-23FFF  |  xxxx:xxxx  DOS buffers, control areas, and installed 144k    24000-27FFF  |             device drivers. 160k    28000-2BFFF  |  xxxx:0000  resident portion of COMMAND.COM, interrupt 176k    2C000-2FFFF  |             handlers for int 22h, 23h,24h, and code to                      |             reload the transient portion 192k    30000-33FFF  |  xxxx:0000  master environment block, default 64 bytes 208k    34000-37FFF  |  xxxx:0000  environment for next program 224k    38000-3BFFF  |  xxxx:0000  external commands or utilities (COM or EXE 240k    3C000-3FFFF  |             files)                      | 256k    40000-43FFF  |  ----:----  application programs 272k    44000-47FFF  |  xxxx:0000  user stack for COM files (256 bytes) 288k    48000-4BFFF  |  xxxx:0000  transient portion of COMMAND.COM 304k    4C000-4FFFF  |                      | 320k    50000-53FFF  | 336k    54000-57FFF  | 352k    58000-5BFFF  | 368k    5C000-5FFFF  |                      | 384k    60000-63FFF  | 400k    64000-67FFF  | 416k    68000-6BFFF  | 432k    6C000-6FFFF  |                      | 448k    70000-73FFF  | 464k    74000-77FFF  | 480k    78000-7BFFF  | 496k    7C000-7FFFF  |                      | 512k    80000-83FFF  | 528k    84000-87FFF  | 544k    88000-8BFFF  | original IBM PC-1 BIOS limited memory to 544k 560k    8C000-8FFFF  |                      | 576k    90000-93FFF  | 592k    94000-97FFF  | 609k    98000-9BFFF  | 624k    9C000-9FFFF  | to 640k (top of RAM address space) A0000 ***** 64k *************** EGA address 640k    A0000-A95B0  MCGA 320x200 256 color video buffer               AF8C0  MCGA 640x480 2 color video buffer              -A3FFF 656k    A4000-A7FFF 672k    A8000-ABFFF 688k    AC000-AFFFF B0000 ***** 64k *************** mono and CGA address 704k    B0000-B3FFF  mono uses only 4k        | The PCjr and early Tandy 1000 720k    B4000-B7FFF                           | BIOSs revector direct writes to 736k    B8000-BBFFF  CGA uses entire 16k      | the B8 area to the Video Gate 756k    BC000-BFFFF                           | Array and reserved system RAM 

B000:0000-B000:7FFF Hercules, P.1B000:8000-B000:FFFF Hercules, P.2B800:0000-B800:3FFF CGA-GraphicB800:0000-B800:0FFF CGA-P.1(Text)B800:1000-B800:1FFF CGA-P.2(Text)B800:2000-B800:2FFF CGA-P.3(Text)B800:3000-B800:3FFF CGA-P.4(Text)
C0000 ***** 64k *************** expansion ROM 768k    C0000-C3FFF  16k EGA BIOS C000:001E EGA BIOS signature (the letters IBM) 784k    C4000-C5FFF         C6000-C63FF  256 bytes Professional Graphics Display communication area         C6400-C7FFF 800k    C8000-CBFFF  16k hard disk controller BIOS, drive 0 default 816k    CC000-CDFFF  8k  IBM PC Network NETBIOS         CE000-CFFFF 
D0000 ***** 64k *************** expansion ROM | PCjr first ROM cartridge 832k    D0000-D7FFF  32k IBM Cluster Adapter  | address area.         DA000        voice communications     | 848k    D4000-D7FFF                           | Common expanded memory board 864k    D8000-DBFFF                           | paging area. 880k    DC000-DFFFF                           | 
E0000 ***** 64k *************** expansion ROM |    PCjr second ROM 896k    E0000-E3FFF                           |    cartridge address 912k    E4000-E7FFF                           |    area 928k    E8000-EBFFF                           | 944k    EC000-EFFFF                           | 
F0000 ***** 64k *************** system        |    PCjr optional ROM 960k    F0000-F3FFF  reserved by IBM          |    cartridge address 976k    F4000-                                |    area (cartridge         F6000        ROM BASIC Begins         |    BASIC) 992k    F8000-FB000                           | 1008k   FC000-FFFFF  ROM BASIC and original   |                      BIOS (Compatibility BIOS |                      in PS/2)                 | 1024k   FFFFF   end of memory (1024k) for 8088 machines F000:FFF5 BIOS release date F000:FFFE PC model identification 
384k    100000-15FFFF  80286/AT extended memory area, 1Mb motherboard 15Mb    100000-FFFFFF  80286/AT extended memory address space 
15Mb    160000-FDFFFF  Micro Channel RAM expansion (15Mb extended memory) 128k    FE0000-FFFFFF  system board ROM            (PS/2 Advanced BIOS) 
PC Port Assignment, Intel 8088, 80C88, 8086, 80286, 80386 CPUs 
hex addr.                    Function 
I/O Port Map 
      Ports 000H-0ffH are reserved for and used by the system board       Ports 100H-3ffH are decoded on the I/O bus for use by adapter cards       Ports 400H and up are not available on the system bus 
The following table summarizes I/O port usage for the PC/XT and AT.  Many of the ports listed here have further information available under the topic: 
I/O Port Detail 
Individual ports covered in greater detail are marked with a menu selection. 
 AT    PC/XT  Description                                More Information        000-01f  000-00f  DMA controller #1, 8237A-5.                DMA Ports 020-03f  020-021  Interrupt controller, 8259A. 040-05f  040-043  Timer 8253-5 (AT: 8254.2).          060-063  PPI (Programmable Peripheral Interface)                    keyboard, equipment switches, timer 060-06f           Keyboard controller 8042                   AT Keyboard 060H  PC/XT  PPI port A.  Read keyboard scan code:       IN   al,60H  ;fetches most recent scan code.  See INT 09H and Scan Code 
      AT keyboard data register.                       See AT Keyboard 
061H  PC/XT PPI (Programmable Peripheral Interface) port B.       76543210            0         ҽ bit                > 0: Timer 2 gate (speaker)  > OR 03H=speaker ON               > 1: Timer 2 data  ͼ  AND 0fcH=speaker OFF            > 3: 1=read high switches; 0=read low switches (see 62H)           > 4: 0=enable RAM parity checking; 1=disable          > 5: 0=enable I/O channel check         > 6: 0=hold keyboard clock low        > 7: 0=enable keyboard; 1=disable keyboard 
062H  PC/XT PPI port C.       76543210          0equip't       Ľ bit             > 0-3: values of DIP switches.    See  Equipment List          > 5: 1=Timer 2 channel out         > 6: 1=I/O channel check        > 7: 1=RAM parity check error occurred. 
063H  PC/XT PPI Command/Mode Register.  Selects which PPI ports are input       or output.  BIOS sets to 99H (Ports A and C are input, B is output). 
064H  AT keyboard command register.  This port communicates with the 8042       which runs an on-chip control program for the keyboard.  It accepts       command codes and data bytes.                  For commands and programming details,   See AT Keyboard 
070-07f           Real-time clock, CMOS Memory, NMI mask     CMOS Memory 070H  AT register address (write-only) for Real-Time Clock and CMOS RAM. 
070H  AT NMI mask.  Use this port to mask the Non-maskable Interrupt.            An OUT with bit 7=0 enables the NMI; with bit 7=1 disables NMI:       OUT  70H,2dH  ;enable NMI--2dH is a "reserved address" in the CMOS Memory       OUT  70H,0adH ;disable NMI 
080               manufacture's diagnostic checkpoint 080H  AT page register used during POST to accumulate errors 080-09f  080-083  DMA page register 74LS612                  DMA Ports          0a0      NMI (Non-maskable Interrupt) mask 0a0-0bf           Interrupt Controller #2, 8259A 0a0H  PC/XT  NMI mask. Enable/disable Non-maskable Interrupt (RAM parity err)      OUT  0a0H,80H  ;enable NMI      OUT  0a0H,0    ;disable NMI 
0c0-0df           DMA controller #2, 8237A-5                 DMA Ports 0c0H-0dfH  AT DMA controller access to 16-bit DMA      See DMA Ports 0f0-0ff           Math Coprocessor 0f0H  AT 80287 latch clear.  'Busy' gets latched upon an unmasked 287 error.       OUT  0f0H,0  ;clears the latch 
0f1H  AT 80287 Reset.  Coprocessor is reset from protected mode to real mode.       OUT  0f1H,0  ;resets the 80287 to real mode 0f8H-0fcH  AT 80287 data. 286 sends opcodes and operands and receives results. 170-177           Hard disk (secondary)                      AT Hard Disk Ports 1f0-1f7           Hard disk                                  AT Hard Disk Ports 200-207  200-20f  Game I/O (joystick A/D port)               Joystick Port          210-217  Expansion Box 210H  XT Expansion chassis control port 213H  XT Expansion chassis enable 215H  XT Expansion chassis data bus register 215H  XT Expansion chassis address register (high byte) 216H  XT                                   (low byte) 278-27f  278-27f  Parallel Printer #2 (#3 with MDA)          Printer Ports 2c0-2df  2c0-2df  EGA #2                                     EGA I/O Ports 2f8-2ff  2f8-2ff  Asynchronous Adapter Port #2               Serial Ports 300-31f           Prototype card          320-32f  Hard disk                                  XT Hard Disk Ports 370-377           Diskette Controller (secondary)            FDC Ports 378-37f  378-37f  Parallel Printer #1 (#2 with MDA)          Printer Ports 1f0-1f7           Hard disk                                  AT Hard Disk Ports 200-207  200-20f  Game I/O (joystick A/D port)               Joystick Port          210-217  Expansion Box 278-27f  278-27f  Parallel Printer #2 (#3 with MDA)          Printer Ports 2c0-2df  2c0-2df  EGA #2                                     EGA I/O Ports 2f8-2ff  2f8-2ff  Asynchronous Adapter Port #2               Serial Ports 300-31f           Prototype card          320-32f  Hard disk                                  XT Hard Disk Ports 370-377           Diskette Controller (secondary)            FDC Ports 378-37f  378-37f  Parallel Printer #1 (#2 with MDA)          Printer Ports 380-38f  380-38f  Synchronous Data Link Control (SDLC) 3a0-3af  3a0-3a9  bisynchronous port #1 3b0-3bf  3b0-3bf  Monochrome Display Adapter/Printer #1      Printer Ports 3bcH-3bdH Parallel Printer on MDPA                       See Printer Ports 3b4H-3baH Monochrome Display Adapter (MDA) display control ports. 3c0-3cf  3c0-3cf  Enhanced Graphics Adapter (EGA) #1         EGA I/O Ports 3d0-3df  3d0-3df  Color/Graphics Adapter (CGA) and EGA       CGA I/O Ports 3f0-3f7  3f0-3f7  Diskette controller                        FDC Ports 3f8-3ff  3f8-3ff  Asynchronous Adapter Port #1               Serial Ports 
CMOS Storage Layout 
AT-class PCs contain a battery-powered real-time clock (RTC) and 64-bytes of low-power, non-volatile CMOS memory. 
This memory contains a variety of information, including the current time and date, along with hardware configuration and a shut-down status byte (the shutdown byte is used in the mechanism which permits the AT to restart where it left off after issuing a processor reset to exit from protected mode). 
When you see the "Run Setup" prompt during POST  it is because some hardware did not match the configuration record or because of some other problem with the CMOS RAM. 
Address Summary (detailed information follows)   00H-0dH used by real-time clock 0eH     POST diagnostics status byte 0fH     shutdown status byte 10H     diskette drive type      Ŀ 11H     reserved                       12H     hard disk drive type           13H     reserved                      > checksum-protected 14H     equipment byte                   configuration record (10H-20H) 15H-16H Base memory size               17H-18H extended memory above 1M       19H     hard disk 1 type (if > 15)     1aH     hard disk 2 type (if > 15)     1bH-2dH reserved                  2eH-2fH storage for checksum of CMOS addresses 10H through 20H 30H-31H extended memory above 1M 32H     current century in BCD (eg, 19H) 33H     miscellaneous info. 34H-3fH reserved 
Ŀ Using CMOS Data   To read a byte from CMOS, do an OUT 70H,addr; followed by IN 71H. To write a byte to CMOS,  do an OUT 70H,addr; followed by OUT 71H,value. 
Example: ;------- read what type of hard disk is installed          mov     al,12H          out     70H,al        ;select CMOS address 12H          jmp     $+2           ;this forces a slight delay to settle things          in      al,71H        ;AL now has drive type (0-15) 
Addresses 10H thru 20H are protected by a checksum methodology to be able to detect when the battery has died or invalid information has been written into the configuration record.  This a simple 16-bit sum of the protected bytes. 
Ŀ CMOS Memory Layout Detail   
Addr Description    0   current second for real-time clock           Ŀ  1   alarm second                                  Note: for more info on the   2   current minute for real-time clock            real-time clock, refer to    3   alarm minute                                  Motorolla MC146818 specs.    4   current minute for real-time clock             5   alarm hour  6   current day of week for real-time clock  7   current date of month for real-time clock  8   current month for real-time clock  9   current year for real-time clock 
0aH  RTC status register A      76543210                         Ľ        ͼ > rate selector (set to 0110)          > 22-stage divider (set to 010)       > Update in progress (UIP) flag.  0 means OK to read. 
0bH  RTC status register B      76543210                    ҽ              > daylight savings enable.  0=standard time (set to 0)             > 12 or 24-hr.  0=12-hr mode (set to 1)            > BCD date mode. 1=binary, 0=BCD.  (set to 0)           > Square wave enable. 1=turn on square wave. (set to 0)          > enable update-ended int. 0 disables. (set to 0)         > enable alarm int. 0 disables (set to 0) See INT 1aH        > enable periodic int. 0 disables (set to 0)       > Update in progress (UIP) flag.  0 means OK to read. 
0cH  RTC status register C.  Read-only interrupt status bits. 
0dH  RTC status register D. Bit 7=1 when a CMOS-RAM is receiving power                                  =0 to indicate a dead battery. 
0eH  POST diagnostics status byte      76543210            0 0      Ľ            > Time valid (After POST, 1 means it's not Feb 30)           > Hard disk bad.  1 means can't boot from hard disk          > RAM size not right. 1 = POST found different RAM size         > Configuration record not right.  1=different equipment        > Checksum invalid.  1 means bad checksum in CMOS RAM       > Power Lost.  1 means real-time clock battery died 
0fH  shutdown status byte      This byte is read upon startup after processor reset in order to determine      if the reset was used as a way to get out of 80286 protected mode.          0 = soft reset (Ctrl-Alt-Del) or unexpected shutdown          1 = shutdown after memory size is determined          2 = shutdown after memory test is performed          3 = shutdown after memory error (parity check 1 or 2)          4 = shutdown with bootstrap loader request          5 = shutdown with FAR JMP (restart int controller and jmp to 0:[0467H])      6,7,8 = shutdown after passing a protected mode test          9 = shutdown after performing block move.  See INT 15H SubFn 87H        0aH = shutdown with FAR JMP (immediate jmp to address at 0:[0467H]) 
10H  diskette drive type      76543210                          Ľ                             0000 = no drive       ͼ > first diskette drive > 0001 = 360K drive          > second diskette drive ͼ   0000 = hi-capacity drive 
11H  reserved 
12H  hard disk drive type  (for drives C: and D:, when between 1 and 14)      76543210                          Ľ       ͼ > first hard disk (drive C:) > 0000 = not present          > second hard disk (drive D:) ͼ   else = type ID (below)                                                          1111 = use Addr 19H/1aH 
     These drive types are pre-defined by the ROM-BIOS. The vectors for INT 41H      and INT 46H are initially set to a ROM table containing the information for      the types of drive(s) installed.  See Hard Disk Parameter Table 
                   Write   Land                       Write   Land      Type Cyls Hds PreComp Zone Size    Type Cyls Hds PreComp Zone Size                           1   306  4   128     305   10M    16   612  4   0        663  21M       2   615  4   300     615   21M    17   977  5   300      977  42M       3   615  4   300     615   32M    18   977  7   0ffffH   977  59M       4   940  8   512     940   65M    19  1024  7   512     1023  62M       5   940  6   512     940   49M    20   733  5   300      732  31M       6   615  4   0ffffH  733   21M    21   733  7   300      732  44M       7   462  8   256     511   32M    22   733  5   300      733  31M       8   733  5   0ffffH  733   31M    23   306  4   0        336  10M       9   900 15   0ffffH  901  117M    24-47 reserved      10   820  3   0ffffH  820   21M      11   855  5   0ffffH  855   37M    If the disk-type nibble is 0fH (15),      12   855  7   0ffffH  855   52M    then the disk type is stored in CMOS      13   306  8   128     319   21M    address 19H (drive C:) or address 1AH      14   733  7   0ffffH  733   44M    (drive D:)      15   reserveddon't use 
     Notes:  Type 1 is the original XT hard disk              Type 2 is the standard 20M AT hard disk (and a good first guess)              Types 16-23 were added to ROM-BIOS dated 11/15/85 
13H  reserved 14H  Equipment byte      76543210      drvdspn/a7d      Ľ       ˼ ˼      > 1 = diskette drive(s) installed                 > 1 = 80287 math co-processor installed           > primary display 00 = none or <EGA>                                        01 = 40-clm CGA                                        10 = 80-clm CGA                                        11 = TTL Monochrome        > diskette drives-1 (00=1, 01=2, 10=3, 11=4) 
15H  Base memory (low byte)  > 0100H=256K, 0200H=512K, 0280H=640K 16H  Base memory (high byte)  ͼ 17H  extended memory above 1M (low byte)  > (in K bytes. 0-3c00H) 18H  extended memory (high byte)  ͼ   See INT 15H SubFn 88H 
19H  disk 0 (drive C:) hard disk type if (CMOS addr 12H & 0fH) is 0fH 1aH  disk 1 (drive D:) hard disk type if (CMOS addr 12H & f0H) is f0H 
1bH-2dH reserved 
2eH  checksum of CMOS addresses 10H through 20H  (high byte) 2fH                                              (low byte) 
30H  extended memory above 1M (low byte)  > (in K bytes. 0-3c00H) 31H  extended memory (high byte)  ͼ   See INT 15H SubFn 88H 
32H  century in BCD (eg, 19H) 19H  disk 0 (drive C:) hard disk type if (CMOS addr 12H & 0fH) is 0fH 1aH  disk 1 (drive D:) hard disk type if (CMOS addr 12H & f0H) is f0H 
1bH-2dH reserved 
2eH  checksum of CMOS addresses 10H through 20H  (high byte) 2fH                                              (low byte) 
30H  extended memory above 1M (low byte)  > (in K bytes. 0-3c00H) 31H  extended memory (high byte)  ͼ   See INT 15H SubFn 88H 
32H  century in BCD (eg, 19H) 
33H  miscellaneous info.  Bit 7=IBM 128K memory option installed                           Bit 6=used by "Setup" utility 
34H-3fH reserved.  Put your name here for everlasting amusement. 
Enhanced Graphics Adapter I/O Ports 
The Enhanced Graphics Adapter is upwardly-compatible with the CGA when accessed through the BIOS.  The <EGA> is far more complex at the hardware level, but it does include emulation of many CGA registers/operations.  See CGA I/O Ports This topic covers the EGA changes and extensions to CGA I/O usage. 
Perhaps the most significant change for an applications programmer is that you don't need to check for retrace when writing to the screen.  The EGA will not allow "video snow" in any case. 
        EGA #1 decodes ports 3c0H through 3dfH         EGA #2 decodes ports 2c0H through 2dfH 
The EGA can generate interrupt level 2 (IRQ 2) during the overscan at the start of the vertical retrace.   IRQ 2 is vectored to INT 0aH.   If you use this interrupt, be aware that the AT uses IRQ 2 as a cascade request for a whole class of IRQs (IRQ 8-15).  Techniques for handling multiple hardware interrupts through the same IRQ are covered in the AT Tech Ref 6183355 (Revised Edition, March 1986). 
Note:  BIOS stores mirrors of the current CRTC port values and other EGA        information in <EGA> Data Areas   To change values, you should read        the appropriate variable, set the bit, perform the OUT, and store the new        value in the variable. 
Port  Description    3c0H  Write: Attribute Controller (ATC) address and data port              Perform  IN al,3daH      ;(or IN 3baH) to force address mode                       OUT 3c0H,reg_no ;select ATC register (toggle to data mode)                       OUT 3c0H,value  ;store a value in an ATC register              Note: bits 0-4: select an ATC register                    bit 5:    1=enable display; 0=set register 
           After selecting a register, perform another OUT 3c0H,data as below:            ATC Reg Data description                         00-0fH  palette registers: select colors for this attribute                    76543210                       rgbRGB             Note: R,G,B are 2/3-intensity                    ҽ bit               r,g,b are 1/3-intensity                              > 0: Red                             > 1: Green                            > 2: Blue                           > 3: blue' (also MDA-emulation underline)                          > 4: green' (also CGA-emulation intensity)                         > 5: red'             10H    mode control                    76543210                                                   ҽ bit                                > 0: 1=graphics modes, 0=text                               > 1: 1=MDA attributes, 0=color attributes                              > 2: 1=9th dot is 8th dot for line/box chars                                         0=use bkgd color as 9th dot of char                             > 3: 1=enable blink, 0=allow 4-bit bkgd             11H   select overscan (border) color.  Same rgbRGB as palette regs             12H   enable color planes                    76543210                                                     Ľ bit                         ˼ > 0-3: set bits to enable color planes 0-3                          > 4-5: video status to multiplex                                            00=R&B, 01=b&G, 10=r&g, 11=unused             13H   horizontal pixel panning                   Number of dots to shift data left.  Bits 0-3 valid (0-0fH) 
3c2H  Write: miscellaneous control functions       76543210                       ҽ bit            ˼  > 0: 1=select 3BxH (emulate MDA); 0=select 3DxH (CGA)               > 1: 1=enable RAM; 0=disable RAM             > 2-3: Dot clock: 00=14mHz; 01=16mHz; 10=external; 11=res           > 4: 1=select feature output; 0=select internal          > 5: Page bit for odd/even mode         > 6: Horizontal retrace polarity: 1=negative, 0=positive        > 7: Vertical retrace polarity: 1=negative, 0=positive 
3c4H  Write: sequencer address register 3c5H  Write: sequencer data register              Perform OUT 3c4H,reg_no; then OUT 3c5H,data            Seq Reg Data description                           00    sequencer reset.                    Bits 0-1 indicate asynchronous/synchronous reset.              01    clocking mode                    76543210                                                   ҽ bit                                > 0: 1=8 dots per character; 0=9 dots/char                               > 1: CRT bandwidth: 1=low; 0=high                              > 2: 1=shift every char; 0=every 2nd char                             > 3: dot clock: 1=halved; 0=normal              02   map mask: bits 0-3 enable writes to bit planes 0-3              03   character map select:                   bits 0-1 select Map B (for when attribute bit 3=0)                   bits 2-3 select Map A (for when attribute bit 3=1)              04   memory mode                    76543210                                                    ҽ bit                                 > 0: 1=text char generator; 0=graphics                                > 1: 1=EGA ram > 64K; 0=64K                               > 2: 1=sequential; 0=odd/even (as in CGA) 
3caH  Write: graphics 2 position (must be 0 for EGA) 3ccH  Write: graphics 1 position (must be 1 for EGA) 
3ceH  Write: graphics 1 and 2 address register 3cfH  Write: graphics controller data register              Perform OUT 3ceH,reg_no; then OUT 3cfH,data            GDC Reg Data description                            00   set/reset. bits 0-3 select planes for write mode 00               01   enable set/reset               02   color compare.  Bits 0-3 select color for read mode 01               03   data rotate and function select for write mode 00                    bits 0-2: set rotate count for write mode 00                         3-4: fn select for write modes 00 and 02                              00=no change; 01=AND; 10=OR; 11=XOR               04   read map select.  Bits 0-2 select map number for read mode 00               05   mode register                    76543210                                                  Ľ bit                             > 0-1: Write mode 0-2                            > 2: test condition                           > 3: read mode: 1=color compare, 0=direct                          > 4: 1=use odd/even RAM addressing                         > 5: 1=use CGA mid-res layout (2-bits/pixel)               06   miscellaneous graphics control                    76543210                                                    ҽ bit                             ˼  > 0: 1=graphics; 0=enable char gen (text)                                > 1: 1=chain odd maps after even maps                              > 2: memory mapping for CPU                                          00=a000H (128K);    01=a000H (64K)                                          10=b000H (32K MDA); 11=b800H (32K CGA)               07   color masking disable                    bits 0-3 disable planes from compare logic in read mode 01               08   bit mask.  Bits 0-7 select bits to be masked in all planes 
3b4H or 3d4H  CRT controller address 3b5H or 3d5H  CRT controller internal registers               Note: Port 3c0H bit 0 selects which port address-pair to use.                     (3bxH is normal for MDA; 3dxH is normal for CGA).               Perform OUT 3x4H,reg_no; then OUT 3x5H,data            CRTC Rg Data description                         00-11H  See Video Parameter Table and CGA I/O Ports   Exceptions:             02     start horizontal blanking (character count)             03     end horizontal blanking                    bits 0-4 are blank width; bits 5-6 are skew enable (0 to 3)             04     start horizontal retrace (character position)             05     end horizontal retrace                    76543210                                                     Ľ bit                      ˼ > 0-4: horizontal retrace width                       > 5-6: retrace delay 0-3 character-clocks                     > 7: 1=start panning on odd address; 0=even             06     vertical total (scan lines)             07     bit 8 for certain CRTC registers                    76543210                                                 ҽ bit                              > 0: vertical total (CRTC Reg 06)                             > 1: vert disp'd enable end (CRTC Reg 12H)                            > 2: vertical retrace start (CRTC Reg 10H)                           > 3: start vertical blanking (CRTC Reg 15H)                          > 4: line compare (CRTC Reg 18H)                         > 5: cursor location (CRTC Reg 0aH)             08     preset row scan first scan line after vertical retrace             10H    Write: vertical retrace start             11H    Write: vertical retrace end                    76543210                                                    Ľ bit                           > 0-3: retrace width in scan lines                          > 4: 0=clear vertical interrupt                         > 5: 0=enable vertical interrupt IRQ2             12H    vertical displayed end (scan line)             13H    vertical displayed adjustment             14H    underline location.  Bits 0-5 are scan line number.             15H    start vertical blanking (scan line)             16H    end vertical blanking             17H    mode control                    76543210                                                ҽ bit                            > 0: 0=CGA graphics addr compatibility mode                           > 1: select row scan counter                          > 2: horiz retrace: 1=double vertical res                         > 3: 1=use char clock /2 for word refresh                        > 4: 1=force high impedance on output                       > 5: address wrapping mode                      > 6: 1=byte addressing mode; 0=word mode                     > 7: 0=hardware reset; 1=normal operations             18H    line compare (scan line)  Used for split screen operations. 
3baH or 3daH  Write: bits 0-1 control Feature Control outputs FC0 and FC1               Note: Port 3c0H bit 0 selects which port address to use.       Read:  status bits are same as MDA (port 3baH) or CGA (port 3daH)       76543210                         ҽ bit                   > 0: retrace.  1=display is in vert or horiz retrace.                  > 1: 1=light pen is triggered; 0=armed                 > 2: 1=light pen switch is open; 0=closed                > 3: 1=vertical sync pulse is occurring.       Note:  With EGA, you don't need to synchronize with retrace when writing              to video RAM. 
3bdH or 3dbH  Write: light pen latch reset.  Any OUT clears the latch. 3bcH or 3dcH  Write: light pen latch set.  Any OUT arms the latch. 
Reserved Memory Locations in the IBM PC 
addr.  size            description 000h-3FFh      DOS interrupt vector table 30:00h-        used as a stack area during POST and bootstrap routines. This 3F:FFh         stack area may be revectored by an application program.                The BIOS Data Area  addr. from 400h to 4FFh 40:00  word    COM1 port address |   These addresses are zeroed out in the 40:02  word    COM2 port address |   OS/2 DOS Compatibility Box if any of 40:04  word    COM3 port address |   the OS/2 COM??.SYS drivers are loaded. 40:06  word    COM4 port address | 40:08  word    LPT1 port address 40:0A  word    LPT2 port address 40:0C  word    LPT3 port address 40:0E  word    LPT4 port address        (not valid in PS/2 machines) 40:0E  word    PS/2 pointer to 1k extended BIOS Data Area at top of RAM 
40:10  word    equipment flag (see int 11h)                bits:                0        1 if floppy drive present (see bits 6&7)  0 if not                1        1 if 80x87 installed  (not valid in PCjr)                2,3      system board RAM   (not used on AT or PS/2)                         00      16k                         01      32k                         10      48k                         11      64k                4,5      initial video mode                         00      no video adapter                         01      40 column color  (PCjr)                         10      80 column color                         11      MDA                6,7      number of diskette drives                         00      1 drive                         01      2 drives                         10      3 drives                         11      4 drives                8        0       DMA present                         1       DMA not present (PCjr)                9,A,B    number of RS232 serial ports                C        game adapter  (joystick)                         0       no game adapter                         1       if game adapter                D        serial printer (PCjr only)                         0       no printer                         1       serial printer present                E,F      number of parallel printers installed        note 1) The IBM PC and AT store the settings of the system board                switches or CMOS RAM setup information (as obtained by the BIOS                in the Power-On Self Test (POST)) at addresses 40:10h and                40:13h. 00000001b indicates "on", 00000000b is "off".             2) CMOS RAM map, PC/AT:               offset               contents                 00h         Seconds                 01h         Second Alarm                 02h         Minutes                 03h         Minute Alarm                 04h         Hours                 05h         Hour Alarm                 06h         Day of the Week                 07h         Day of the Month                 08h         Month                 09h         Year                 0Ah         Status Register A                 0Bh         Status Register B                 0Ch         Status Register C                 0Dh         Status Register D                 0Eh         Diagnostic Status Byte                 0Fh         Shutdown Status Byte                 10h         Disk Drive Type for Drives A: and B:                             The drive-type bytes use bits 0:3 for the first                             drive and 4:7 for the other                             Disk drive types:                             00h         no drive present                             01h         double sided 360k                             02h         high capacity (1.2 meg)                             03h-0Fh     reserved                 11h         (AT):Reserved    (PS/2):drive type for hard disk C:                 12h         (PS/2):drive type for hard disk D:                             (AT, XT/286):hard disk type for drives C: and D:                             Format of drive-type entry for AT, XT/286:                             0       number of cyls in drive (0-1023 allowed)                             2       number of heads per drive (0-15 allowed)                             3       starting reduced write compensation (not                                     used on AT)                             5       starting cylinder for write compensation                             7       max. ECC data burst length, XT only                             8       control byte                                     Bit                                     7       disable disk-access retries                                     6       disable ECC retries                                     5-4     reserved, set to zero                                     3       more than 8 heads                                     2-0     drive option on XT (not used by AT)                             9       timeout value for XT (not used by AT)                             12      landing zone cylinder number                             14      number of sectors per track (default 17,                                     0-17 allowed)                 13h         Reserved                 14h         Equipment Byte (corresponds to sw. 1 on PC and XT)                 15h-16h     Base Memory Size      (low,high)                 17h-18h     Expansion Memory Size (low,high)                 19h-20h     Reserved                             (PS/2) POS information Model 50 (60 and 80 use a 2k                             CMOS RAM that is not accessible through software)                 21h-2Dh     Reserved (not checksumed)                 2Eh-2Fh     Checksum of Bytes 10 Through 20  (low,high)                 30h-31h     Exp. Memory Size as Det. by POST (low,high)                 32h         Date Century Byte                 33h         Information Flags (set during power-on)                 34h-3Fh     Reserved             3) The alarm function is used to drive the BIOS wait function (int                15h function 90h).             4) To access the configuration RAM write the byte address (00-3Fh)                you need to access to I/O port 70h, then access the data via I/O                port 71h.             5) CMOS RAM chip is a Motorola 146818             6) The equipment byte is used to determine the configuration for the                power-on diagnostics.             7) Bytes 00-0Dh are defined by the chip for timing functions, bytes                0Eh-3Fh  are defined by IBM. 40:12  byte    number of errors detected by infrared keyboard link (PCjr only) 40:13  word    availible memory size in Kbytes (less display RAM in PCjr)                this is the value returned by int 12h 40:17  byte    keyboard flag byte 0 (see int 9h)                bit 7  insert mode on      3  alt pressed                    6  capslock on         2  ctrl pressed                    5  numlock on          1  left shift pressed                    4  scrollock on        0  right shift pressed 40:18  byte    keyboard flag byte 1 (see int 9h)                bit 7  insert pressed      3  ctrl-numlock (pause) toggled                    6  capslock pressed    2  PCjr keyboard click active                    5  numlock pressed     1  PCjr ctrl-alt-capslock held                    4  scrollock pressed   0 40:19  byte    storage for alternate keypad entry (not normally used) 40:1A  word    pointer to keyboard buffer head character 40:1C  word    pointer to keyboard buffer tail character 40:1E  32bytes 16 2-byte entries for keyboard circular buffer, read by int 16h 40:3E  byte    drive seek status - if bit=0, next seek will recalibrate by                repositioning to Track 0.                bit 3  drive D          bit 2  drive C                    1  drive B              0  drive A 40:3F  byte    diskette motor status                bit 7  1, write in progress 3  1, D: motor on (floppy 3)                    6                       2  1, C: motor on (floppy 2)                    5                       1  1, B: motor on                    4                       0  1, A: motor on 40:40  byte    motor off counter                starts at 37 and is decremented 1 by each system clock tick.                motor is shut off when count = 0. 40:41  byte    status of last diskette operation     where:                bit 7 timeout failure            bit 3 DMA overrun                    6 seek failure                   2 sector not found                    5 controller failure             1 address not found                    4 CRC failure                    0 bad command 40:42  7 bytes NEC status 40:49  byte    current CRT mode (hex value)                    00h 40x25 BW      (CGA)          01h 40x25 color   (CGA)                    02h 80x25 BW      (CGA)          03h 80x25 color   (CGA)                    04h 320x200 color (CGA)          05h 320x200 BW    (CGA)                    06h 640x200 BW    (CGA)          07h monochrome    (MDA)                extended video modes (EGA/MCGA/VGA or other)                    08h lores,16 color               09h med res,16 color                    0Ah hires,4 color                0Bh n/a                    0Ch med res,16 color             0Dh hires,16 color                    0Eh hires,4 color                0Fh hires,64 color 40:4A  word    number of columns on screen, coded as hex number of columns                20 col = 14h  (video mode 8, low resolution 160x200 CGA graphics)                40 col = 28h                80 col = 46h 40:4C  word    screen buffer length in bytes                (number of bytes used per screen page, varies with video mode) 40:4E  word    current screen buffer starting offset (active page) 40:50  8 words cursor position pages 1-8                the first byte of each word gives the column (0-19, 39, or 79)                the second byte gives the row (0-24) 40:60  byte    end line for cursor   (normally 1) 40:61  byte    start line for cursor (normally 0) 40:62  byte    current video page being displayed  (0-7) 40:63  word    base port address of 6845 CRT controller or equivalent                for active display           3B4h=mono, 3D4h=color 40:65  byte    current setting of the CRT mode register 40:66  byte    current palette mask setting  (CGA) 40:67  5 bytes temporary storage for SS:SP during shutdown (cassette interface) 40:6C  word    timer counter low word 40:6E  word    timer counter high word 40:69  byte    HD_INSTALL (Columbia PCs) (not valid on most clone computers)                bit  0 = 0  8 inch external floppy drives                         1  5-1/4 external floppy drives                   1,2 =    highest drive address which int 13 will accept                            (since the floppy drives are assigned 0-3, subtract                            3 to obtain the number of hard disks installed) 
                  4,5 =    # of hard disks connected to expansion controller                   6,7 =    # of hard disks on motherboard controller                            (if bit 6 or 7 = 1, no A: floppy is present and                            the maximum number of floppies from int 11 is 3) 40:70  byte    24 hour timer overflow 1 if timer went past midnight                it is reset to 0 each time it is read by int 1Ah 40:71  byte    BIOS break flag (bit 7 = 1 means break key hit) 40:72  word    reset flag (1234 = soft reset, memory check will be bypassed)                PCjr keeps 1234h here for softboot when a cartridge is installed 40:74  byte    status of last hard disk operation; PCjr special diskette control 40:75  byte    # of hard disks attached (0-2)    ; PCjr special diskette control 40:76  byte    hd control byte; temporary holding area for 6th param table entry 40:77  byte    port offset to current hd adapter ; PCjr special diskette control 40:78  4 bytes timeout value for LPT1,LPT2,LPT3,LPT4 40:7C  4 bytes timeout value for COM1,COM2,COM3,COM4 (0-FFh seconds, default 1) 40:80  word    pointer to start of circular keyboard buffer, default 03:1E 40:82  word    pointer to end of circular keyboard buffer, default 03:3E 40:84  byte    rows on the screen (EGA only) 40:84  byte    PCjr interrupt flag; timer channel 0  (used by POST) 40:85  word    bytes per character (EGA only) 40:85  2 bytes (PCjr only) typamatic char to repeat 40:86  2 bytes (PCjr only) typamatic initial delay 40:87  byte    mode options (EGA only)                Bit 1   0 = EGA is connected to a color display                        1 = EGA is monochrome.                Bit 3   0 = EGA is the active display,                        1 = "other" display is active.                   Mode combinations:                   Bit3  Bit1     Meaning                     0     0   EGA is active display and is color                     0     1   EGA is active display and is monochrome                     1     0   EGA is not active, a mono card is active                     1     1   EGA is not active, a CGA is active 40:87  byte    (PCjr only) current Fn key code 40:88  byte    feature bit switches (EGA only) 0=on, 1=off                bit 3 = switch 4                bit 2 = switch 3                bit 1 = switch 2                bit 0 = switch 1 40:88  byte    (PCjr only) special keyboard status byte                bit 7 function flag      3 typamatic (0=enable,1=disable)                    6 Fn-B break         2 typamatic speed (0=slow,1=fast)                    5 Fn pressed         1 extra delay bef.typamatic (0=enable)                    4 Fn lock            0 write char, typamatic delay elapsed 40:89  byte    PCjr, current value of 6845 reg 2 (horiz.synch) used by                ctrl-alt-cursor screen positioning routine in ROM 40:8A  byte    PCjrCRT/CPU Page Register Image, default 3Fh 40:8B  byte    last diskette data rate selected 40:8C  byte    hard disk status returned by controller 40:8D  byte    hard disk error returned by controller 40:8E  byte    hard disk interrupt (bit 7=working int) 40:90  4 bytes media state drive 0, 1, 2, 3 40:94  2 bytes track currently seeked to drive 0, 1 40:96  byte    keyboard flag byte 3 (see int 9h) 40:97  byte    keyboard flag byte 2 (see int 9h) 40:98  dword   pointer to users wait flag 40:9C  dword   users timeout value in microseconds 40:A0  byte    real time clock wait function in use 40:A1  byte    LAN A DMA channel flags 40:A2  2 bytes status LAN A 0,1 40:A4  dword   saved hard disk interrupt vector 40:A8  dword   EGA pointer to parameter table 40:B4  byte    keyboard NMI control flags (Convertible) 40:B5  dword   keyboard break pending flags (Convertible) 40:B9  byte    port 60 single byte queue (Convertible) 40:BA  byte    scan code of last key (Convertible) 40:BB  byte    pointer to NMI buffer head (Convertible) 40:BC  byte    pointer to NMI buffer tail (Convertible) 40:BD  16bytes NMI scan code buffer (Convertible) 40:CE  word    day counter (Convertible and after) to -04:8F               end of BIOS Data Area 40:90-40:EF             reserved by IBM 40:F0 16 bytes Intra-Application Communications Area (for use by applications 40:FF          to transfer data or parameters to each other) 
50:00  byte    DOS print screen status flag                         00h    not active or successful completion                         01h    print screen in progress                         0FFh   error during print screen operation 50:01          Used by BASIC 50:02-03       PCjr POST and diagnostics work area 50:04  byte    Single drive mode status byte                         00     logical drive A                         01     logical drive B 50:05-0E       PCjr POST and diagnostics work area 50:0F          BASIC: SHELL flag (set to 02h if there is a current SHELL) 50:10  word    BASIC: segment address storage (set with DEF SEG) 50:12  4 bytes BASIC: int 1Ch clock interrupt vector segment:offset storage 50:16  4 bytes BASIC: int 23h ctrl-break interrupt segment:offset storage 50:1A  4 bytes BASIC: int 24h disk error interrupt vector segment:offset storage 50:1B-1F       Used by BASIC for dynamic storage 50:20-21       Used by DOS for dynamic storage 50:22-2C       Used by DOS for diskette parameter table. See int 1Eh for values 50:30-33       Used by MODE command 50:34-FF       Unknown - Reserved for DOS 
At Absolute Addresses 
0008:0047 IO.SYS or IBMBIO.COM IRET instruction. This is the dummy routine that           interrupts 01h, 03h, and 0Fh are initialized to during POST. C000:001E EGA BIOS signature (the letters IBM) F0000-FFFFF ROM-BIOS, ROM-BASIC
F000:0000-F000:5FFF 24k ungenutztF000:6000-F000:DFFF 32k BASICF000:E000-F000:FFFF  8k BIOSF000:E05B loc ResetF000:E2C3 loc NMI Entry Point
Hard Disk Information Tables
Each sub-table contains a a set of 16 bytes for each particular disk type. Type number specified may differ with manufactures specification. The hard disk table shown here assumes the first entry is type 0. 
F000:E331 dw hdsk_cylinders Number of cylinders, hdsk_type_0F000:E333 db hdsk_heads Number of headsF000:E334 dw hdsk_lo_wrt_cyl Low write current cyl begin (XT)F000:E336 dw hdsk_precompcyl Write pre-compensation cylinderF000:E338 db hdsk_err_length Error correction burst length (XT)F000:E339 db hdsk_misl_bits
Miscellaneous bit functions:bits 0-2 disk option, XT only (XT)     0-2 unused, all others     3 = 1 if > 8 heads     4   unused     5 = 1 for bad map at last cylinder + 1     6 or 7 = 1 no retries
F000:E33A db hdsk_timeout Normal timeout  (XT)F000:E33B db hdsk_fmt_timout Format timeout  (XT)F000:E33C db hdsk_chk_timout Check timeout   (XT)F000:E33D dw hdsk_parkng_cyl Parking cylinder numberF000:E33F db hdsk_sectr_trac Number of sectors per trackF000:E340 db hdsk_unused UnusedF000:E331 ds hdsk_type_F000:E6F2 loc Bootstrap Load
System Configuration Table F000:E6F5 dw Config_tbl_size  Size of table in bytesF000:E6F7 db Config_model Model type  0F8h = 80386 model 70-80 types  0FCh = 80286 model 50-60 types, also most 80286/80386 compatibles  0FAh = 8088/86 model 25-30 typeF000:E6F8 db Config_sub_model Sub-Model type F000:E6F9 db Config_BIOS_rev BIOS revsion numberF000:E6FA db Config_features Feature information  bit 7=1, hard disk uses DMA 3  bit 6=1, dual interrupt chips  bit 5=1, has real-time-clock  bit 4=1, int 15h, ah=4Fh is supported (keyboard)  bit 3=1, external wait support  bit 2=1, has extended BIOS RAM  bit 1=1, micro-channel  bit 0=1, unusedF000:E6FB db Config_info_bytes Information bytes (future use)
Baud Rate TableTable of hex divsors  for the serial ports. Table divisors for bauds 110 to 19,200. F000:E729 dw baud_110, baud_rate_tblF000:E72B dw baud_150F000:E72D dw baud_300F000:E72F dw baud_600F000:E731 dw baud_1200F000:E733 dw baud_2400F000:E735 dw baud_4800F000:E737 dw baud_9600F000:E739 dw baud_19200F000:E82E loc Keyboard Function CallF000:E987 loc Keyboard Hardware InterruptF000:EC59 loc Floppy Disk Function CallF000:EF57 loc Floppy Disk ISR
Floppy Disk ParametersF000:EFC7 db dsk_info_1 Start of ROM BIOS data areas  hi nibble = stepping rate in ms  lo nibble = head unload time, msF000:EFC8 db         dsk_info_2 2nd info byte bit 0 = 0 for DMAF000:EFC9 db         dsk_motor_delay Delay after use for motor offF000:EFCA db         dsk_sectr_bytesBytes per sector  0 =  128 bytes                  1 =  256 bytes                  2 =  512 bytes                  3 = 1024 bytesF000:EFCB db dsk_sector_trac Number of sectors per trackF000:EFCC db dsk_head_gap Gap LengthF000:EFCD db dsk_data_length Data LengthF000:EFCE db dsk_format_gap Format Gap LengthF000:EFCF db dsk_format_byte Format write byteF000:EFD0 db dsk_settlg_time Head load time, in millisecondsF000:EFD1 db dsk_startup_tim Motor startup wait time * .125msF000:EFD2 LPT-Fuction-CallF000:F065 Video Function Call
Video Hardware RegistersF000:F0A4 db video_hdwr_tbl1 mode CGA 40 columns x 25 linesF000:F0B4 db video_hdrw_tbl2 mode CGA 80 columns x 25 linesF000:F0C4 db video_hdwr_tbl3 mode CGA graphicsF000:F0D4 db video_hdwr_tbl4 mode MDA 80 columns x 25 linesF000:F0E4 dw video_buf_size1 Video buffer bytes CGA 40x25F000:F0E6 dw video_buf_size2 Video buffer bytes CGA 80x25F000:F0E8 dw video_buf_size3 Video buffer bytes CGA GraphicsF000:F0EA dw video_buf_size4 Video buffer bytes CGA GraphicsF000:F0EC db video_columntbl Video columns per modes 0-7F000:F0F4 db video_hdwr_mode Video hardware modes (0-7)F000:F841 loc Memory size Function callF000:F84D loc Equipment Check Function callF000:F859 loc Cassette Function CallF000:FA6E db video_char_tbl Video characters in graphic modesF000:FE6E loc Timer Function  CallF000:FEA5 loc Timer Hardware InterruptF000:FEF3 dw int_vec_table Initial interrupt vectorsF000:FF1D dw int_data_tableF000:FF21 dw video_ptrF000:FF23 dw int_vec_table_2F000:FF53 loc Dummy Interrupt return
This routine processes invalid and unused interrupt requests. The hardware IRQ number is loaded into gen_int_occured, and the interrupt cleared. For software calls to an unused interrupt, a value 0FFh is loaded into gen_int_occured, and the routine returns to the caller without changing registers. Alternatively, some systems simply return (iret).
F000:FF54 loc Print Screen Function CallF000:FFF0 loc power_on_reset SYSTEM RESET
Reset the computer system. General operation includes a test of the CPU, ROM checksum, and initialization of hardware including:
   Memory system   Timer/Counter (which is also used for RAM refresh)   Interrupt Controller(s)   DMA Controller(s)   Keyboard Controller   Video Controller & Video RAM   Floppy Controller   Hard Disk Controller (if present)
Portions of the hardware may also have specific tests made to insure reliable operation. Test failures may display error code on the screen if the video subsystem is operational, or generate beeps or LED blinks to signify the error.
Note: A soft reset uses the warm_boot_flag to skip the memory tests. (i.e. from pressing Ctrl-Alt-Del).
The system checks for installed ROMs by searching memory from C000h to the beginning of the BIOS, in 2K chunks. ROM memory is identified if it starts with the word AA55h. It is followed a one byte field length of the ROM (divided by 512). If ROM is found, the BIOS will call the ROM at an offset of 3 from the beginning. This feature was not supported in the earliest PC machines.
The last task turns control over to the bootstrap loader (assuming the floppy controller is operational)
F000:FFF5 BIOS release date F000:FFFE PC model identification              date      model byte            submodel byte    revision            04/24/81     FF = PC-0 (16k)         --              --            10/19/81     FF = PC-1 (64k)         --              --            08/16/82     FF = PC, XT, XT/370     --              --                              (256k motherboard)            10/27/82     FF = PC, XT, XT/370     --              --                              (256k motherboard)            11/08/82     FE = XT, Portable PC    --              --                              XT/370, 3270PC            01/10/86     FB = XT                 00              01            01/10/86     FB = XT-2 (early)            05/09/86     FB = XT-2 (640k)        00              02            06/01/83     FD = PCjr               --              --            01/10/84     FC = AT                 --              --            06/10/85     FC = AT                 00              01            11/15/85     FC = AT                 01              00            04/21/86     FC = XT/286             02              00            09/13/85     F9 = Convertible        00              00            09/02/86     FA = PS/2 Model 30      00              00            11/15/86     FC = AT, Enhanced 8mHz            02/13/87     FC = PS/2 Model 50      04              00            02/13/87     FC = PS/2 Model 60      05              00            1987         F8 = PS/2 Model 80      00              00                         2D = Compaq PC (4.77)   --              --                         9A = Compaq Plus (XT)   --              -- 
                  00FC 7531/2 Industrial AT              06FC 7552 Gearbox 
F000:FFFF db  model_sub_type
ROM-Scan 
During cold-boot, after the POST and installation of all default interrupt handlers, BIOS makes a check for external ROMs found on feature cards (boards installed in a PC slot).  This testing is informally called ROM-scan. 
Note: ROM-scan was NOT implemented in the earliest BIOS and the oldest PCs (those with a maximum of 64K on the motherboard) will not have this feature unless a later version of the ROM-BIOS has been installed. 
External ROM modules may be present between addresses c800:0000 and e000:0000. Each 2K block in this range is checked for a signature and is in this format: 
Offset Size Contents                Ŀ  +0      1  55H         Signature of BIOS-accessible ROM module             Ĵ         (first word in segment is aa55H)  +1      1  aaH             Ĵ  +2      1  len         length of ROM module in 512-byte increments               Ŀ  +3      ?            executable code                (often a NEAR jump to initialization code)             |   |         (a dummy byte usually exists to validate checksum) 
When BIOS finds a ROM signature, it performs a checksum on the defined module. Each byte is summed modulo 100H and the sum must be exactly 0.  When a module is verified to be valid, BIOS performs a FAR CALL to offset 0003H of its segment and the ROM must eventually return to the BIOS via a FAR RET. 
Typically, the ROM module will perform any hardware initialization tasks necessary and insert its own address into one or more interrupt vectors. 
The ROM sockets U17 and U37 on the AT motherboard are addressed starting at e000:0000.  A scan occurs in 64K blocks for a valid module.  If present, a module will have the aa55H signature, an unused length byte, executable code starting at xxxx:0003 and a checksum of 0 modulo 100H at e000:ffff. 
The IBM PC System Interrupts -Overview 
The interrupt table is stored in the very lowest location in memory, starting at 0000:0000h. The locations are offset from segment 0, ie location 0000h has the address for int 0, etc. Each address is four bytes long and its location in memory can be found by multiplying the interrupt number by 4. For example, int 7 could be found by (7x4=28) or 1Bh (0000:001Bh).  These interrupt vectors normally point to ROM tables or are taken over by DOS when an application is run. Some applications revector these interrupts to their own code to change the way the system responds to the user. 
Interrupt Address    Function  Number    (Hex)     0      00-03    CPU   Divide by Zero     1      04-07    CPU   Single Step     2      08-0B    CPU   Nonmaskable     3      0C-0F    CPU   Breakpoint     4      10-13    CPU   Overflow     5      14-17    BIOS  Print Screen     6      18-1B    hdw   Reserved     7      1C-1F    hdw   Reserved     8      20-23    hdw   Time of Day     9      24-27    hdw   Keyboard     A      28-2B    hdw   Reserved     B      2C-2F    hdw   Communications [8259]     C      30-33    hdw   Communications     D      34-37    hdw   Disk     E      38-3B    hdw   Diskette     F      3C-3F    hdw   Printer    10      40-43    BIOS  Video    11      44-47    BIOS  Equipment Check    12      48-4B    BIOS  Memory    13      4C-4F    BIOS  Diskette/Disk    14      50-53    BIOS  Serial Communications    15      54-57    BIOS  Cassette, System Services    16      58-5B    BIOS  Keyboard    17      5C-5F    BIOS  Parallel Printer    18      60-63    BIOS  Resident BASIC    19      64-67    BIOS  Bootstrap Loader    1A      68-6B    BIOS  Time of Day    1B      6C-6F    BIOS  Keyboard Break    1C      70-73    BIOS  Timer Tick    1D      74-77    BIOS  Video Initialization    1E      78-7B    BIOS  Diskette Parameters    1F      7C-7F    BIOS  Video Graphics Characters, second set    20      80-83    DOS   General Program Termination    21      84-87    DOS   DOS Services Function Request    22      88-8B    DOS   Called Program Termination Address    23      8C-8F    DOS   Control Break Termination Address    24      90-93    DOS   Critical Error Handler    25      94-97    DOS   Absolute Disk Read    26      98-9B    DOS   Absolute Disk Write    27      9C-9F    DOS   Terminate and Stay Resident    28-3F   A0-FF    DOS   Reserved for DOS    40-43   100-115  BIOS  Reserved for BIOS    44      116-119  BIOS  First 128 Graphics Characters    45-47   120-131  BIOS  Reserved for BIOS    48      132-135  BIOS  PCjr Cordless Keyboard Translation    49      136-139  BIOS  PCjr Non-Keyboard Scancode Translation Table    50-5F   140-17F  BIOS  Reserved for BIOS    60-67   180-19F  Reserved for User Software Interrupts    68-7F   1A0-1FF  Reserved by IBM    80-85   200-217  ROM BASIC    86-F0   218-3C3  Used by BASIC Interpreter When BASIC is Running    F1-FF   3C4-3FF  Reserved by IBM 
For consistency in this volume, all locations and offsets are in hexadecimal unless otherwise specified. All hex numbers are prefaced with a leading zero if they begin with an alphabetic character, and are terminated with a lowercase H (h). The formats vary according to common usage. 
The IBM-PC System Interrupts - in detail 
Interrupt 00h Divide by Zero (processor error). 
(0:0000h) Automatically called at end of DIV or IDIV operation that results in error. Normally set by DOS to display an error message and abort the program. 
Interrupt 01h Single step 
(0:0004h) Taken after every instruction when CPU Trap Flag indicates single-step mode (bit 8 of FLAGS is 1). This is what makes the T command of DEBUG work for single stepping. Is not generated after MOV to segment register or POP of segment register. (unless you have a very early 8088 with the microcode bug). 
Interrupt 02h Non-maskable interrupt 
(0:0008h) Vector not disabled via CLI. Used by parity check routine in POST, 8087 coprocessor, PCjr infrared keyboard link. 
Interrupt 03h Breakpoint 
(0:000Ch) Taken when CPU executes the 1-byte int 3 (0CCh).      Generated by opcode 0CCh. Similar to 8080's RST instruction. Generally used to set breakpoints for DEBUG. 
Interrupt 04h Divide overflow 
(0:0010h) Generated by INTO instruction if OF flag is set. If flag is not set, INTO is effectively a NOP. Used to trap any arithmetic errors when program is ready to handle them rather than immediately when they occur. 
Interrupt 05h Print Screen 
(0:0014h) Print Screen - service dumps the screen to the printer. Invoked by int 9 for shifted key 55 (PrtSc). Automatically called by keyboard scan when PrtSc key is pressed. Normally executes routine to print the screen, but may call any routine that can safely be executed from inside the keyboard scanner. Status and result byte are at address 0050:0000. 
entry   AH      05h return  absolute address 50:0         00h     print screen has not been called, or upon return from a call                 there were no errors.         01h     print screen is already in progress.         0FFh    error encountered during printing. note 1) Uses BIOS services to read the screen      2) Output is directed to LPT1      3) Revectored into GRAPHICS.COM if GRAPHICS.COM is loaded 
Interrupt 06h Reserved by IBM 
(0:0018h) 
Interrupt 07h Reserved by IBM 
(0:00C0h) 
Interrupt 08h Timer 
(0:0020h) - 55ms timer "tick" taken 18.2 times per second. Updates (IRQ0)  BIOS clock and turns off diskette drive motors after 2 seconds of inactivity. 
entry   AH      08h return  absolute addresses:         40:6C   number of interrupts since power on (4 bytes)         40:70   number of days since power on (1 byte)         40:67   day counter on all products after AT         40:40   motor control count - gets decremented and shuts off diskette                 motor if zero note    Int 1Ch invoked as a user interrupt. 
Interrupt 09h Keyboard 
(0:0024h) - taken whenever a key is pressed or released. (IRQ1)  Stores characters/scan-codes in status at [0040:0017,18] 
entry   AH      09h return  at absolute memory addresses:         40:17   bit                 0       right shift key depressed                 1       left shift key depressed                 2       control key depressed                 3       alt key depressed                 4       ScrollLock state has been toggled                 5       NumLock state has been toggled                 6       CapsLock state has been toggled                 7       insert state is active         40:18   bit                 0       left control key depressed                 1       left alt key depressed                 2       SysReq key depressed                 3       Pause key has been toggled                 4       ScrollLock key is depressed                 5       NumLock key is depressed                 6       CapsLock key is depressed                 7       Insert key is depressed         40:96   bit                 0       last code was the E1h hidden code                 1       last code was the E0h hidden code                 2       right control key down                 3       right alt key down                 4       101 key Enhanced keyboard installed                 5       force NumLock if rd ID & kbx                 6       last character was first ID character                 7       doing a read ID (must be bit 0)         40:97   bit                 0       ScrollLock indicator                 1       NumLock indicator                 2       CapsLock indicator                 3       circus system indicator                 4       ACK received                 5       resend received flag                 6       mode indicator update                 7       keyboard transmit error flag         40:1E   keyboard buffer (20h bytes)         40:1C   buffer tail pointer         40:72   1234h if ctrl-alt-del pressed on keyboard      AL   scan code note 1) Int 05h invoked if PrtSc key pressed      2) Int 1Bh invoked if Ctrl-Break key sequence pressed      3) Int 15h, AH=85h invoked on AT and after if SysReq key is pressed      4) Int 15h, AH=4Fh invoked on machines after AT 
Interrupt 0Ah EGA Vertical Retrace 
(0:0028h)  (IRQ2)  used by EGA vertical retrace, hard disk 
Interrupt 0Bh Communications Controller (serial port) hdw. entry 
(0:002Ch)  (IRQ3)  Serial Port 2 (com2) note    IRQ 3 may be used by SDLC (synchronous data-link control) or         bisynchronous communications cards instead of a serial port. 
Interrupt 0Ch Communications Controller (serial port) hdw. entry 
(0:0030h)  (IRQ4)  Serial Port 1 (com1) note    IRQ 4 may be used by SDLC (synchronous data-link control) or         bisynchronous communications cards instead of a serial port. 

Interrupt 0Dh Alternate Printer, PC/AT 80287 
(0:0034h)  (IRQ5)  used by hard disk, 60 Hz RAM refresh, LPT2 on AT, XT/286,             and PS/2, dummy CRT vertical retrace on PCjr 
Interrupt 0Eh Diskette - indicates that a seek is in progress 
(0:0038h)  (IRQ6)  (sets bit 8 of 40:3E) 
Interrupt 0Fh Reserved by IBM 
(0:003Ch)  (IRQ7)  IRQ7 used by PPI interrupt (LPT1, LPT2) 
THE PC ROM BIOS 
Interrupt 10h Video I/O - services to handle video output 
(0:0040h)       The ROM video routines in the original PC BIOS are designed for                 use with the Color Graphics Adapter and incorporate code to test                 for the horizontal retrace before writing. The check is                 performed no matter what actual display adapter is installed.                 The ROM character table for the first 128 characters is located                 at 0FA6Eh in the PC. Int 01Fh can be used to point to a second                 table of 128 characters.                  CS, SS, DS, ES, BX, CX, DX are preserved during call. All                 others are destroyed. 
Function 00h    Determine or Set Video State entry   AH      00h     set video mode         AL      display mode:                    CGA|PCjr|MDA|MCGA|EGA|VGA|8514                 00h     40x25 B/W text           CGA|PCjr|   |    |EGA|   |   16 color      01h     40x25 color text         CGA|PCjr|   |    |EGA|   |                 02h     80x25 B/W text           CGA|PCjr|   |    |EGA|   |   16 color      03h     80x25 color text         CGA|PCjr|   |    |EGA|VGA|   4 color       04h     320x200 color graphics   CGA|PCjr|   |    |EGA|   |   4 tone gray   05h     320x200 B/W graphics     CGA|PCjr|   |    |EGA|   |   2 color       06h     640x200 B/W graphics     CGA|PCjr|   |    |EGA|   |   monochrome    07h     80x25 monochrome text       |    |MDA|    |EGA|   |   16 color      08h     160x200 color graphics   CGA|PCjr|   |    |   |   |   16 color      09h     320x200 color graphics      |PCjr|   |    |   |VGA|   4 color       0Ah     640x200 color graphics      |PCjr|   |    |   |   |      N/A        0Bh     BIOS font load              |    |   |    |EGA|VGA|      N/A        0Ch     BIOS font load              |    |   |    |EGA|VGA|   16 color      0Dh     320x200 graphics            |    |   |    |EGA|VGA|   16 color      0Eh     640x200 graphics            |    |   |    |EGA|VGA|   monochrome    0Fh     640x350 graphics            |    |   |    |EGA|VGA|   16 & 64 color 10h     640x350 color hi-res        |    |   |    |EGA|VGA|   2 color       11h     640x480 graphics            |    |   |MCGA|   |VGA|   16 color      12h     640x480 graphics            |    |   |    |   |VGA|   256 color     13h     320x200 graphics            |    |   |MCGA|   |VGA|8514                 14h-20h used by EGA and VGA graphics modes                 18h     132x44 8x8 char mono        | Tseng Labs EVA                 19h     132x25 8x14 char mono       | Tseng Labs EVA                 1Ah     132x28 8x13 char mono       | Tseng Labs EVA  monochrome     21h     Hercules Graphics, Graphics Page 1  monochrome     22h     Hercules Graphics, Graphics Page 2                 22h     132x44                      | Tseng, Ahead                 23h     132x25                      | Tseng Labs EVA                         132x25                      | Ahead Systems EGA2001                         132x25                      | ATI EGA Wonder                 24h     132x28                      | Tseng Labs EVA                 25h     80x60  640x480              | Tseng Labs EVA  16 color               640x480                     | VEGA VGA                 26h     80x60                       | Tseng Labs EVA                         80x60   640x480             | Ahead Systems EGA2001  16 color       27h     720x512                     | VEGA VGA  monochrome             132x25                      | ATI EGA Wonder                 28h     unknown                     | VEGA VGA  16 color       29h     800x600                     | VEGA VGA  256 color      2Dh     640x350                     | VEGA VGA  256 color      2Eh     640x480                     | VEGA VGA  256 color      2Fh     720x512                     | VEGA VGA  256 color      30h     800x600                     | VEGA VGA                         unknown                     | AT&T 6300  16 color       36h     960x720                     | VEGA VGA  16 color       37h     1024x768                    | VEGA VGA  monochrome             132x44                      | ATI EGA Wonder  2 color        40h     640x400                     | AT&T 6300                         80x43                       | VEGA VGA  16 color       41h     640x200                     | AT&T 6300                         132x25                      | VEGA VGA  16 color       42h     640x400                     | AT&T 6300                         132x43                      | VEGA VGA                 43h     unsupported 640x200 of 640x400 viewport  AT&T 6300                         80x60                       | VEGA VGA                 44h     disable VDC and DEB output  | AT&T 6300                         100x60                      | VEGA VGA                 48h     80x50   640x400             | AT&T 6300                 4Dh     120x25                      | VEGA VGA                 4Eh     120x43                      | VEGA VGA                 4Fh     132x25                      | VEGA VGA  monochrome     50h     132x25                      | Ahead Systems EGA2001  16 color               640x480                     | Paradise EGA-480  monochrome             80x43                       | VEGA VGA                         640x480 mono?               | Taxan 565 EGA                 51h     80x30                       | Paradise EGA-480  monochrome             132x25                      | VEGA VGA                         640x480 ?                   | ATI EGA Wonder  monochrome     52h     132x44                      | Ahead Systems EGA2001  monochrome             132x43                      | VEGA VGA                         752x410 ?                   | ATI EGA Wonder                 53h     800x560 ?                   | ATI EGA Wonder                 54h     132x43                      | Paradise EGA-480  16 color               132x43                      | Paradise VGA  16 color               132x43                      | Paradise VGA on multisync                         132x43                      | Taxan 565 EGA                 55h     132x25                      | Paradise EGA-480  16 color               132x25                      | Paradise VGA  16 color               132x25                      | Paradise VGA on multisync                         132x25                      | Taxan 565 EGA                 56h     132x43                      | NSI Smart EGA+                         132x43                      | Paradise VGA                         132x43                      | Paradise VGA on multisync  monochrome             132x43                      | Taxan 565 EGA                 57h     132x25                      | NSI Smart EGA+                         132x25                      | Paradise VGA                         132x25                      | Paradise VGA on multisync  monochrome             132x25                      | Taxan 565 EGA                 58h     100x75   800x600 16/256k    | Paradise VGA                 59h     100x75   800x600            | Paradise VGA                 5Eh     640x400                     | Paradise VGA,VEGA VGA                 5Fh     640x480                     | Paradise VGA                 60h     80x???   ???x400            |  Corona/Cordata BIOS v4.10+                         752x410                     | VEGA VGA                 60h     400 line graphics+80 col text |(Corona/Cordata)                 61h     400 line graphics           | Corona/Cordata BIOS v4.10+                         720x540                     | VEGA VGA                 62h     800x600                     | VEGA VGA  16 color       71h     100x35 800x600              | NSI Smart EGA+                 74h     640x400 graphics            | Toshiba 3100                 82h     80x25 B&W                   | AT&T VDC overlay mode *                 83h     80x25                       | AT&T VDC overlay mode *                 86h     640x200 B&W                 | AT&T VDC overlay mode *                 C0h     640x400   2/prog pallet     | AT&T VDC overlay mode *                 C4h     disable output              | AT&T VDC overlay mode *                 D0h     640x400                     | DEC VAXmate AT&T mode                 unknown 640x225                     | Z-100                 unknown 640x400                     | Z-100 
note 1) If the high bit in AL is set, the display buffer is not cleared when a         new mode is selected. This may be used to mix modes on the display;         for example, characters of two difference sizes might be displayed      2) Modes 8-10 are available on the PCjr, Tandy 1000, and PS/2      3) IBM claims 100% software and hardware emulation of the CGA with the         MCGA chipset. All registers may be read and written as CGA. All         characters are double-scanned to give 80x25 with 400 line resolution.         The attributes for setting border color may be set on MCGA, but the         borders will remain the default color (they cannot actually be set)      4) The IBM Color Graphics Adapter (CGA) is too slow for the screen to         be updated before the vertical retrace of the monitor is completed.         If the video RAM is addressed directly, the screen will have "snow"         or interference. IBM's default is to turn the adapter off when it is         being updated, ie "flickering" when the display is scrolled.      5) The vertical retrace signal may be ignored when using the MCGA adapter.         The MCGA will not generate snow when written to. There is no flicker         with the MCGA.      6) The PCjr Video Gate Array uses a user-defined block of main system RAM         from 4 to 32k in size instead of having dedicated memory for the         display. Vertical retrace may be ignored when writing to the PCjr.         There is no flicker with the PCjr display.      7) The Hercules Graphics Card has 750x348 resolution      8) The Hercules Graphics Card takes 32k beginning at B:000 (same as MDA)      9) The CGA, MCGA, and VGA adapters use hardware address B:800     10) The BIOS clears the screen when the mode is set or reset.     11) For AT&T VDC overlay modes, BL contains the DEB mode, which may be 06h,         40h, or 44h 
Function 01h    Set Cursor Type - set the size of the cursor or turn it off entry   AH      01h         CH      bit values:                 bits 0-4  top line for cursor in character cell                 bits 5-6  blink attribute                           00    normal                           01    invisible (no cursor)                           10    slow      (not used on original IBM PC)                           11    fast         CL      bit values:                 bits 0-4  bottom line for cursor in character cell return  none note 1) The ROM BIOS default cursors are:  start    end                      monochrome mode 07h:    11     12                       text modes 00h-03h:     6      7      2) The blinking in text mode is caused by hardware and cannot be turned         off, though some kludges can temporarily fake a nonblinking cursor      3) The cursor is automatically turned off in graphics mode      4) Another method of turning off the cursor in text mode is to position it         to a nondisplayable address, such as (X,Y)=(0,25)      5) Buggy on EGA systems - BIOS remaps cursor shape in 43 line modes, but         returns unmapped cursor shape 
Function 02h    Set Cursor Position - reposition the cursor to (X,Y) entry   AH      02h         BH      video page                 00h     graphics mode                 03h     modes 2 and 3                 07h     modes 0 and 1         DH      row    (Y=0-24)         DL      column (X=0-79 or 0-39) return  none note 1) (0,0) is upper left corner of the screen 
Function 03h    Read Cursor Position - return the position of the cursor entry   AH      03h         BH      page number                 00h     in graphics modes                 03h     in modes 2 & 3                 07h     in modes 0 & 1 return  CH      top line for cursor    (bits 4-0)         CL      bottom line for cursor (bits 4-0)         DH      row number    (Y=0-24)         DL      column number (X=0-79 or 0-39) 
Function 04h    Read Light Pen - fetch light pen information entry   AH      04h return  AH      00h     light pen not triggered         AH      01h     light pen is triggered, values in resgisters         BX      pixel column               (X=0-319 or 0-639)  graphics mode         CH      raster line                (Y=0-199)        old graphics modes         CX      (EGA) raster line (0-nnn)                   new graphics modes         DH      row of current position    (Y=0-24)            text mode         DL      column of current position (X=0-79 or 0-39)    text mode note    Not supported on PS/2 
Function 05h    Select Active Page - set page number for services 6 and 7 entry   AH      05h         AL      number of new active page                 0-7     modes 00h and 01h (CGA)                 0-3     modes 02h and 03h (CGA)                 0-7     modes 02h and 03h (EGA)                 0-7     mode 0Dh (EGA)                 0-3     mode 0Eh (EGA)                 0-1     mode 0Fh (EGA)                 0-1     mode 10h (EGA) for PCjr only:         AL      80h to read CRT/CPU page registers                 81h to set CPU page register to value in BL                 82h to set CRT page register to value in BH                 83h to set both CPU and page registers                     (and Corona/Cordata BIOS v4.10+)         BH      CRT page number for subfunctions 82h and 83h         BL      CPU page register for subfunctions 81h and 83h return  standard PC  none         PCjr         if called with AH bit 7=1 then                      BH      CRT page register                      BL      CPU page register         DX      segment of graphics bitmap buffer (video modes 60h,61h; AL0Fh) note 1) Mono adapter has only one display page      2) CGA has four 80x25 text pages or eight 40x25 text pages      3) A separate cursor is maintained for each display page      4) Switching between pages does not affect their contents      5) Higher page numbers indicate higher memory positions 
Function 06h    Scroll Page Up - scroll up or clear a display "window" entry   AH      06h         AL      number of lines blanked at bottom of page                 0 = blank entire window         BH      attributes to be used on blank line         CH      row    (Y) of upper left corner or window         CL      column (X) of upper left corner of window         DH      row    (Y) of lower right corner of window         DL      column (X) of lower right corner of window return  none note 1) Push BP before scrolling, pop after      2) If in CGA text mode, affects current page only 
Function 07h    Scroll Page Down - scroll down or clear a display "window" entry   AH      07h         AL      number of lines to be blanked at top of page                 0 = blank entire window         BH      attributes to be used on blank line         CH      row    (Y) of upper left corner or window         CL      column (X) of upper left corner of window         DH      row    (Y) of lower right corner of window         DL      column (X) of lower right corner of window return  none note 1) Push BP before scrolling, pop after      2) If in CGA text mode, affects current page only 
Function 08h    Read Character Attribute - of character at current cursor pos. entry   AH      08h         BH      display page number - text mode return  AH      character attribute - text mode         AL      ASCII code of character at current cursor position 
Function  09h   Write Character and Attribute - at current cursor position entry   AH      09h         AL      ASCII code of character to display         BH      display page number - text mode         BL      attribute/color of character         CX      number of characters to write return  none note 1) CX should not exceed actual rows availible, or results may be erratic      2) Setting CX to zero will cause runaway      3) All values of AL result in some sort of display; the various control         characters are not recognized as special and do not change the current         cursor position      4) Does not change cursor position when called - the cursor must be         advanced with int 10 function 0Ah.      5) If used to write characters in graphics mode with bit 7 of AH set to 1         the character will by XORed with the current display contents.      6) In graphics mode the bit patterns for ASCII character codes 80h-0FFh         are obtained from a table. On the standard PC and AT, the location is at         interrupt vector 01Fh (0000:007C). For ASCII characters 00h-07Fh, the         table is at an address in ROM. On the PCjr the table is at interrupt         vector 44h (0000:00110) and is in addressable RAM (may be replaced by         the user)      7) All characters are displayed, including CR, LF, and BS 
Function 0Ah    Write Character - display character(s) (use current attribute) entry   AH      0Ah         AL      ASCII code of character to display         BH      display page - text mode         BL      color of character (graphics mode, PCjr only)         CX      number of times to write character return  none note 1) CX should not exceed actual rows availible, or results may be erratic      2) All values of AL result in some sort of display; the various control         characters are not recognized as special and do not change the current         cursor position      3) If used to write characters in graphics mode with bit 7 of AH set to 1         the character will by XORed with the current display contents.      4) In graphics mode the bit patterns for ASCII character codes 80h-0FFh         are obtained from a table. On the standard PC and AT, the location is at         interrupt vector 01Fh (0000:007C). For ASCII characters 00h-07Fh, the         table is at an address in ROM. On the PCjr the table is at interrupt         vector 44h (0000:00110) and is in addressable RAM (may be replaced by         the user)      5) In EGA in graphics modes, replication count in CX works correctly only         if all characters written are contained on the same row      6) All characters are displayed, including CR, LF, and BS 
Function 0Bh    Set Color Palette - set palette for graphics or text border entry   AH      0Bh         BH      00h     select border (text mode)         BL      color 0-15, 16-31 for high-intensity characters         BH      01h     set graphics palette with value in BL  (CGA)  BL      0       green/red/yellow                 1       cyan/magenta/white  (EGA) (graphics modes)         BH      0         BL      has border color (0-15) & high intensity bkgr'd color (16-31)         BH      1         BL      contains palette being selected (0-1) return  none note 1) Valid in CGA mode 04h, PCjr modes 06h, 08h-0Ah      2) Although the registers in the MCGA may be set as if to change the         border, the MCGA will not display a border no matter what register         settings are used. 
Function 0Ch    Write Dot - plot one graphics pixel entry   AH      0Ch         AL      dot color code  (0/1 in mode 6, 0-3 in modes 4 and 5)                 (set bit 7 to XOR the dot with current color)                 0-3 mode 04h, 05h                 0-1 mode 06h         BH      page number (ignored if adapter supports only one page)         CX      column (X=0000h - 027Fh)                 (0 - 319 in modes 4,5,13,  0 - 639 in modes 6,14,15,16)         DX      row    (Y=0000h - 00C7h) (0 - 199 CGA) return  none note    Video graphics modes 4-6 only 
Function 0Dh    Read Dot - determine the color of one graphics pixel entry   AH      0Dh         CX      column (X=0000h - 027Fh)  (0-319 or 639)         DX      row    (Y=0000h - 00C7h)  (0-199) return  AL      color of dot note    Only valid in graphics mode 
Function 0Eh    Write TTY - write one character and update cursor. Also handles                 CR (0Dh), beep (07h), backspace (10h), and scrolling entry   AH      0Eh         AL      ASCII code of character to be written         BH      page number (text)         BL      foreground color (video modes 6 & 7 only) (graphics) return  none note 1) The ASCII codes for bell, backspace, carriage return, and linefeed are         recognized and appropriate action taken. All other characters are         written to the screen and the cursor is advanced to the next position      2) Text can be written to any CGA page regardless of current active page      3) Automatic linewrap and scrolling are provided through this function      4) This is the function used by the DOS CON console driver.      5) This function does not explicitly allow the use of attributes to the         characters written. Attributes may be provided by first writing an ASCII         27h (blank) with the desired attributes using function 09h, then         overwriting with the actual character using this function. While clumsy         this allows use of the linewrap and scrolling services provided by         this function 
Function 0Fh    Return Current Video State - mode and size of the screen entry   AH      0Fh return  AH      number of character columns on screen         AL      mode currently set (see AH=00h for display mode codes)         BH      current active display page note    If mode was set with bit 7 set ("no blanking"), the returned mode will         also have bit 7 set 
Function 10h    Set Palette Registers                 PCjr, Tandy 1000, EGA, MCGA, VGA entry   AH      10h         AL      00h     set individual palette register                 01h     set border color palette register                 02h     set all palette registers and overscan                 03h     toggle blink/intensity bit           (EGA, MCGA, VGA)                 04h     unknown                 05h     unknown                 06h     unknown                 07h     read individual palette register                 (VGA)                 08h     read overscan (order color)                      (VGA)                 09h     read all palette registers and overscan register (VGA)                 10h     set individual video DAC color register    (MCGA, VGA)                 11h     unknown                 12h     set block of video DAC color registers     (MCGA, VGA)                 13h     set video DAC color page                         (VGA)                 14h     unknown                 15h     read individual video DAC color register   (MCGA, VGA)                 16h     unknown                 17h     read block of video DAC color registers    (MCGA, VGA)                 18h     unknown                 19h     unknown                 1Ah     read video DAC color-page state                  (VGA)                 1Bh     perform gray-scale summing                       (VGA)         BH      color value         BL      if AL=00h       palette register to set (00h-0Fh)                 if AL=03h       0       to enable intensity                                 1       to enable blinking         ES:DX   if AL=02h       pointer to 16-byte table of register values                                 followed by the overscan value:                                 bytes 0-15     values for palette registers 0-15                                 byte 16        value for border register return  none note    DAC is Digital to Analog Convertor circuit in MCGA/VGA chips 
           Palette register values for SubFn 0,1,and 2:            76543210Ŀ            NotUsed r   g  b/I  R   G   B  (6-bits = 64 possible colors)                                          > bit 3 acts as Intensity in CGA-compatible modes 
Function 11h    Character Generator Routine (EGA and after) entry   AH      11h                 The following functions will cause a mode set, completely                 resetting the video environment, but without clearing the video                 buffer.                 AL      00h, 10h  load user-specified patterns                         ES:BP   pointer to user table                         CX      count of patterns to store                         DX      character offset into map 2 block                         BL      block to load in map 2                                 BL = font block selector (4 bits, 0-0fH)                    76543210Ŀ                        not used   block# block#                                                           ͼ   > selected when attr bit 3=0                                        > used when attr bit 3=1                         BH      number of bytes per character pattern 
                AL      01h, 11h  load ROM monochrome patterns (8 by 14)                         BL      block to load                 AL      02h, 12h  load ROM 8 by 8 double-dot patterns                         BL      block to load                 AL      03h       set block specifier                         BL      block specifier                 AL      04h       load 8x16 text characters (MCGA, VGA)                 AL      14h       set 8x16 text characters (MCGA, VGA)                 The routines called with AL=1x are designed to be called only                 immediately after a mode set and are similar to the routines                 called with AL=0x, except that:                         Page 0 must be active.                         Bytes/character is recalculated.                         Max character rows is recalculated.                         CRT buffer length is recalculated.                         CRTC registers are reprogrammed as follows:                         reg09h    bytes/char-1; max scan line (mode 7 only)                         reg0Ah    bytes/char-2; cursor start                         reg0Bh    0           ; cursor end                         reg12h    ((rows+1)*(bytes/char))-1                                               ; vertical display end                         reg14h    bytes/char  ; underline loc                                   (*** BUG: should be 1 less ***)                 The following functions are meant to be called only after a                 mode set:                 AL      20h     user 8 by 8 graphics characters (INT 1FH)                                 ES:BP = pointer to user table                 AL      21h     user graphics characters                         ES:BP   pointer to user table                         CX      bytes per character                         BL      row specifier                                 0       user set - DL = number of rows                                 1       14 rows                                 2       25 rows                                 3       43 rows                 AL      22h     ROM 8 by 14 set                         BL      row specifier                 AL      23h     ROM 8 by 8 double dot                         BL      row specifier                 AL      24h     load 8x16 graphics characters (MCGA, VGA)                 AL      30h     return information                         BH      pointer specifier                                 0       int 1Fh pointer                                 1       int 44h pointer                                 2       ROM 8 by 14 character font pointer                                 3       ROM 8 by 8 double dot font pointer                                 4       ROM 8 by 8 DD font (top half)                                 5       ROM text alternate (9 by 14) pointer return  ES:BP   specified pointer value         CX      bytes/character         DL      character rows on screen 
Function 12h    Alternate Select (EGA and after) entry   AH      12h         AL      00h     unknown                 01h     unknown                 02h     select 400 line mode                            (VGA)         BL      10h     return EGA information                 20h     select alternate print screen routine                 30h     select vertical resolution for text modes       (VGA)                 31h     enable/disable default palette loading    (MCGA, VGA)                 32h     enable/disable video addressing           (MCGA, VGA)                 33h     enable/disable default gray scale summing (MCGA, VGA)                 34h     enable/diable text cursor emulation             (VGA)                 35h     display-switch interface return  BH      00h     if color mode is in effect                 01h     if mono mode is in effect         BL      00h     if 64k EGA memory                 01h     if 128k EGA memory                 02h     if 192k EGA memory                 03h     if 256k EGA memory         CH      feature bits         CL      switch settings 
Function 13h    Write String, Don't Move Cursor              (AT, XT/286, PS/2) entry   AH      13h         AL      00h         BH      display page number         BL      attribute         CX      length of string         DX      starting cursor position         ES:BP   pointer to start of string return  none Function 13h    Write String, Move Cursor                    (AT, XT/286, PS/2) entry   AH      13h         AL      01h         BH      display page number         BL      attribute         DX      starting cursor position         CX      length of string         ES:BP   pointer to start of string return  none 
Function 13h    Write String of Alternating Characters and Attributes;                 Don't Move Cursor                            (AT, XT/286, PS/2) entry   AH      13h         AL      02h                 bit 0: set in order to move cursor after write                 bit 1: set if string contains alternating chars and attributes         BH      display page number         BL      attribute if AL bit 1 clear         CX      length of string         DH      row of starting cursor position         DL      column of starting cursor position         ES:BP   pointer to start of string return  none note    Recognizes CR, LF, BS, and bell 
Function 14h    Load LCD Character Font                      (Convertible) entry   AH      14h         AL      00h     load user specified font 
        BH      number of bytes per character         BL      00h     load main font (block 0)                 01h     load alternate font (block 1) 
        AL      01h     load system ROM default font         BL      00h     load main font (block 0)                 01h     load alternate font (block 1) 
        AL      02h     set mapping of LCD high intensity attribute         BL      00h     ignore high intensity attribute                 01h     map high intensity to underscore                 02h     map high intensity to reverse video                 03h     map high intensity to seleected alternate font         ES:DI   pointer to character font         CX      number of characters to store         DX      character offset into RAM font area 
Function 15h    Return Physical Display Parameters           (Convertible) return  AX      Alternate display adapter type         ES:DI   pointer to parameter table:                 word #  information                 01h     monitor model number                 02h     vertical pixels per meter                 03h     horizontal pixels per meter                 04h     total number of vertical pixels                 05h     total number of horizontal pixels                 06h     horizontal pixel separation in micrometers                 07h     vertical pixel separation in micrometers 
Function 1Ah    Display Combination Code                     (PS/2)                 Using the compatibility BIOS of the PS/2 Models 50, 60, 80 there                 is a way to determine which video controller and attached                 display are on the system.  The Display Combination Code (DCC)                 is a Video BIOS function that provides the capability. entry   AH      1Ah         AL      00h     read display combination code                 01h     write display combination code return  AL      1Ah     indicates Compatibility BIOS is supported,                          any other value is invalid         BH      alternate display device                 where:                 00h     no display                 01h     IBM monochrome display and printer adapter                 02h     IBM color/graphics monitor adapter                 03h     reserved                 04h     IBM EGA (color display)                 05h     IBM EGA (monochrome)                 06h     IBM PGA                 07h     VGA (analog monochrome display)                 08h     VGA (analog color display)                 09h     reserved                 0Ah     reserved                 0Bh     IBM PS/2 Model 30 (analog monochrome display)                 0Ch     IBM PS/2 Model 30 (analog color display)         BL      active display device 
Function 1Bh    Functionality/State Information              (MCGA, VGA) entry   AH      1Bh return  unknown Function 1Ch    Save/Restore Video State                     (VGA) entry   AH      1Ch         AL      00h     return state buffer size                 01h     save video state                 02h     restore video state return  unknown note    VGA only 
Function 70h    Get Video RAM Address                        (Tandy 1000) entry   AH      70h return  AX      segment addresses of the following                 BX      offset address of green plane                 CX      segment address of green plane                 DX      segment address of red/blue plane note    (red offset = 0, blue offset = 4000) 
Function 71h    Get INCRAM Addresses                         (Tandy 1000) entry   AH      71h return  AX      segment address of the following                 BX = segment address of INCRAM                 CX = offset address of INCRAM 
Function 72h    Scroll Screen Right                          (Tandy 1000) entry   AH      72h         AL      number of columns blanked at left of page                 00h     blank window         BH      attributes to be used on blank columns         CH,CL   row, column address of upper left corner         DH,DL   row, column address of lower right corner 
Function 73h    Scroll Screen Left                           (Tandy 1000) entry   AH      73h         AL      number of columns blanked at right of page                 00h     blank window         BH      attributes to be used on blank columns         CH,CL   row, column address of upper left corner         DH,DL   row, column address of lower right corner 
Function 81h    DESQview video - Get something? entry   AH      81h         DX      4456h ('DV') return  ES    segment of DESQview data structure for video buffer         byte ES:[0] = current window number note    This function is probably meant for internal use only, due to the         magic value required in DX 
Function 82h    DESQview - Get Current Window Info entry   AH      82h         DX      4456h ('DV') return  AH      unknown         AL      current window number         BH      unknown         BL      direct screen writes                 0       program does not do direct writes                 1       program does direct writes, so shadow buffer not usable         CH      unknown         CL      current video mode         DS      segment in DESQview for data structure                 in DV 2.00,                   byte DS:[0] = window number                   word DS:[1] = segment of other data structure                   word DS:[3] = segment of window's object handle         ES      segment of DESQview data structure for video buffer note    This function is probably meant for internal use only, due to the magic         value required in DX 
Function 0F0h   Microsoft Mouse driver EGA support - Read One Register entry   AH      0F0h         BL      register number         DX      group index             Pointer/data chips                00h CRT Controller (25 reg) 3B4h mono modes, 3D4h color modes                08h Sequencer (5 registers) 3C4h                10h Graphics Controller (9 registers) 3CEh                18h Attribute Controller (20 registers) 3C0h             Single registers                20h Miscellaneous Output register 3C2h                28h Feature Control register (3BAh mono modes, 3DAh color modes)                30h Graphics 1 Position register 3CCh                38h Graphics 2 Position register 3CAh return  BL      data 
Function 0F1h   Microsoft Mouse driver EGA support - Write One Register entry   AH      0F1h         DX      group index (see function F0h)         BL      register number         BH      value to write return  BL      data 
Function 0F2h   Microsoft Mouse driver EGA support - Read Register Range entry   AH      0F2h         CH      starting register number         CL      number of registers (>1)         DX      group index                 00h     CRTC (3B4h mono modes, 3D4h color modes)                 08h     Sequencer 3C4h                 10h     Graphics Controller 3CEh                 18h     Attribute Controller 3C0h         ES:BX   pointer to buffer, CL bytes 
Function 0F3h   Microsoft Mouse driver EGA support - Write Register Range entry   AH      0F3h         CH      starting register         CL      number of registers (>1)         DX      group index                 00h     CRTC (3B4h mono modes, 3D4h color modes)                 08h     Sequencer 3C4h                 10h     Graphics Controller 3CEh                 18h     Attribute Controller 3C0h         ES:BX   pointer to buffer, CL bytes 
Function 0F4h   Microsoft Mouse driver EGA support - Read Register Set entry   AH      0F4h         CX      number of registers (>1)         ES:BX   pointer to table of records in this format:              bytes 1-2 group index                 Pointer/data chips                    00h CRTC (3B4h mono modes, 3D4h color modes)                    08h Sequencer 3C4h                    10h Graphics Controller 3CEh                    18h Attribute Controller 3C0h                 Single registers                    20h Miscellaneous Output register 3C2h                    28h Feature Control register (3BAh mono modes, 3DAh color)                    30h Graphics 1 Position register 3CCh                    38h Graphics 2 Position register 3CAh              byte 3 register number (0 for single registers)              byte 4 register value 
Function 0F5h   Microsoft Mouse driver EGA support - Read Register Set entry   AH      0F5h         CX      number of registers (>1)         ES:BX   pointer to table of records in this format:              bytes 1-2 port number                 Pointer/data chips                    00h CRTC (3B4h mono modes, 3D4h color modes)                    08h Sequencer 3C4h                    10h Graphics Controller 3CEh                    18h Attribute Controller 3C0h                 Single registers                    20h Miscellaneous Output register 3C2h                    28h Feature Control register (3BAh mono modes, 3DAh color)                    30h Graphics 1 Position register 3CCh                    38h Graphics 2 Position register 3CAh              byte 3 register number (0 for single registers)              byte 4 register value 
Function 0F6h   Microsoft Mouse driver EGA support                 Revert to Default Registers entry   AH      0F6h return  unknown 
Function 0F7h   Microsoft Mouse driver EGA support                 Define Default Register Table entry   AH      0F7h         DX      port number            Pointer/data chips               00h CRTC (3B4h mono modes, 3D4h color modes)               08h Sequencer 3C4h               10h Graphics Controller 3CEh               18h Attribute Controller 3C0h            Single registers               20h Miscellaneous Output register 3C2h               28h Feature Control register (3BAh mono modes, 3DAh color modes)               30h Graphics 1 Position register 3CCh               38h Graphics 2 Position register 3CAh         ES:BX address of table of one byte entries, one byte               to be written to each register 
Function 0FAh   Microsoft Mouse driver EGA support - Interrogate Driver entry   AH      0FAh         BX      00h return  BX      00h     if mouse driver not present         ES:BX   pointer to EGA Register Interface version number, if present:                 byte 1  major release number                 byte 2  minor release number 
Function 0FEh   Get Alternate Screen Buffer Address (text mode only)                                                     (Topview/DesQview/Taskview) entry   AH     0FEh         ES:DI  segment:offset of assumed video buffer return: ES:DI  segment:offset of actual video buffer note 1) This alternate video buffer can be written to directly, in the same         manner as writing to B:000 or B:800. The MT program will manage the         actual display.      2) There is no need to synchronize vertical retrace when writing to the         alternate buffer; this is managed by the MT program      3) If TopView or DESQview is not running, ES:DI is returned unchanged.      4) TopView requires that function 0FFh be called every time you write into         the buffer to tell TopView that something changed 
Function 0FFh   Update Real Display (text mode only)                  (TopView)                 Update Video Buffer                 (Topview/DesQview/Taskview) entry   AH      0FFh         CX      number of sequential characters that have been modified        DI      offset of first character that has been modified        ES      segment of video buffer return  unknown note 1) DesQview supports this call, but does not require it     2) Avoid CX=0
            TTL Monochrome Monitors         One-color Composite Monitors            01H underline                     07H normal (white on black)           07H normal (white on black)       08H grey on black                     09H bright underline              0fH bold (bright white on black)      0fH bold (bright white on black)  70H reverse (black on white)          70H reverse (black on white)      78H grey on white                     81H blinking underline            7fH bright white on white             87H blinking normal               87H blinking normal                   89H blinking bright underline     8fH blinking bold                     8fH blinking bold                                                       

Interrupt 11h Equipment Check 
(0:0044h)       fetch a code describing active peripherals. entry   AH      11h return  AX      Equipment listing word          Bits are:                0       number of floppy drives                        0       no drives                        1       bootable diskette installed                1       math chip                        0       no math coprocessor (80x87) present                        1       math coprocessor (80x87) present         (PS/2) 2       0       mouse not installed                        1       mouse installed          (PC)  2,3     system board RAM                        0,0     16k    (PC-0, PC-1)                        1,1     64k    (PC-2, XT)                        note 1) not commonly used. Set both bits to 1                             2) both bits always 1 in AT                4,5     initial video mode                        0,0     no video installed (use with dumb terminal)                        0,1     40x25 color      (CGA)                        1,0     80x25 color      (CGA)                        1,1     80x25 monochrome (MDA or Hercules)                6,7     number of diskette drives (only if bit 0  1)                        0,0     1 drives                        0,1     2 drives                        1,0     3 drives                        1,1     4 drives                8       0       DMA present                        1       no DMA on system (PCjr, some Tandy 1000s)                9,A,B   number of RS232 serial ports (0-3)                        0,0,0   none                        0,0,1   1                        0,1,0   2                        0,1,1   3                        1,0,0   4                C       0       no game I/O attached                        1       game I/O attached (default for PCjr)                D       serial accessory installation                        0       no serial accessories installed                        1       Convertible - internal modem installed                        1       PCjr - serial printer attached                E,F     number of parallel printers                        0,0     none                        0,1     one   (LPT1, PRN)                        1,0     two   (LPT2)                        1,1     three (LPT3)                        note    Models before PS/2 would allow a fourth                                parallel printer. Remapping of the BIOS in the                                PS/2s does not allow the use of LPT4. 
Interrupt 12h Memory Size 
(0:0048h)       get system memory return  AX      number of contiguous 1K RAM blocks note 1) This service does not depend on the setting of the motherboard switches     2) This is the same value stored in absolute address 04:13h 
Interrupt 13h Disk I/O - access the disk drives (floppy and hard disk) 
(0:004Ch)      does not try rereading disk if an error is returned 
Function 00h    Reset - reset the disk controller chip entry   AH      00h        DL      drive (if bit 7 is set both hard disks and floppy disks reset) return  AH      status note 1) Forces controller chip to recalibrate read/write heads     2) Some systems (Sanyo 55x) this resets all drives 
Function 01h    Get Status of disk system entry  AH      01h        DL      drive (hard disk if bit 7 set) return AL      status of most recent operation                00h     successful completion                01h     bad command                02h     address mark not found                03h     tried to write on write-protected disk                04h     sector not found                05h     reset failed (hard disk)                06h     diskette removed or changed                07h     bad parameter table (hard disk)                08h     DMA overrun                09h     attempt to DMA across 64K boundary                0Ah     bad sector detected (hard disk)                0Bh     bad track detected (hard disk)                0Ch     unsupported track                0Dh     invalid number of sectors on format (hard disk)                0Eh     control data address mark detected (hard disk)                0Fh     DMA arbitration error (hard disk)                10h     bad CRC/EEC on read                11h     data ECC corrected                20h     controller failure                40h     seek failed                80h     timeout                0AAh    drive not ready (hard disk)                0BBh    undefined error (hard disk)                0CCh    write fault     (hard disk)                0E0h    status error    (hard disk)                0FFh    sense operation failed (hard disk) 
Function 02h    Read Sectors - read one or more sectors from diskette entry  AH      02h        AL      number of sectors to read        BX      address of buffer (ES=segment)        CH      track number (0-39 or 0-79 for floppies)                (for hard disk, bits 8,9 in high bits of CL)        CL      sector number (1 to 18, not value checked)        DH      head number (0 or 1)        DL      drive (0=A, 1=B, etc.) (bit 7=0)  (drive 0-7)        ES:BX   address to store/fetch data  (buffer to fill)       [0000:0078]  dword pointer to diskette parms return CF      clear (0) for successful                set (1) failure                AH      status (00h, 02h, 03h, 04h, 08h, 09h, 10h, 0Ah, 20h,                        40h, 80h)        AL      number of sectors transferred note 1) Number of sectors begins with 1, not 0     2) Trying to read zero sectors is considered a programming error; results        are not defined 
Function 03h    Write Sectors - write from memory to disk entry  AH      03h        AL      number of sectors to write (1-8)        CH      track number (for hard disk, bits 8,9 in high bits of CL)        CL      beginning sector number                (if hard disk, high two bits are high bits of track #)        DH      head number        DL      drive number (0-7)        ES:BX   address of buffer for data return CF      set if error                AH      status (see above)        AL      number of sectors written note 1) Number of sectors begins with 1, not 0     2) Trying to write zero sectors is considered a programming error; results        are not defined 
Function 04h    Verify - verify that a write operation was successful entry  AH      04h        AL      number of sectors to verify (1-8)        CH      track number  (for hard disk, bits 8,9 in high bits of CL)        CL      beginning sector number        DH      head number        DL      drive number (0-7) return CF      set on error                AH      status (see above)        AL      number of sectors verified 
Function 05h    Format Track - write sector ID bytes for 1 track entry  AH      05h        AL      number of sectors to create on this track        CH      track (or cylinder) number        CL      sector number        DH      head number (0, 1)        DL      drive number (0-3)        ES:BX   pointer to 4-byte address field (C-H-R-N)                byte 1 = (C) cylinder or track                byte 2 = (H) head                byte 3 = (R) sector                byte 4 = (N) bytes/sector (0 = 128, 1 = 256, 2 = 512, 3 = 1024) return CF      set if error occurred                AH      status code (see above) note    Not valid for ESDI hard disks on PS/2 
Function 06h    Hard Disk - format track and set bad sector flags                                                     (PC2, PC-XT, and Portable) entry  AH      06h        AL      interleave value (XT only)        CH      cylinder number (bits 8,9 in high bits of CL)        CL      sector number        DH      head        DL      drive        ES:BX   512 byte format buffer                the first 2*(sectors/track) bytes contain f,n for each sector                   f  00Fh for good sector                      80h for bad sector                   n  sector number return  AH      status code 
Function 07h    Hard Disk - format the drive starting at the desired track                                                      (PC2, PC-XT and Portable) entry  AH      07h        AL      interleave value (XT only) (01h-10h)        CH      cylinder number (bits 8,9 in high bits of CL) (00h-03FFh)        CL      sector number        DH      head number (0-7)        DL      drive number (80h-87h, 80h=C, 81h=D,...)        ES:BX   format buffer, size = 512 bytes                the first 2*(sectors/track) bytes contain f,n for each sector                f=00h for good sector                  80h for bad sector                n=sector number return  AH      status code (see above) 
Function 08h    Read Drive Parameters             (XT, CONV, AT, XT/286, PS/2) entry  AH      08h        DL      drive number (0-2) return CF      set on error                AH      status code (see above)        BL      drive type (see AH=17h below) (AT/PS2 floppies only)        CH      maximum useable value for cylinder number        CL      maximum useable value for sector number or cylinder number        DH      maximum usable value for head number        DL      number of consecutive acknowledging drives (0-2)        ES:DI   drive parameter table 
Function 09h    Initialize Two Fixed Disk Base Tables    (XT, AT, XT/286, PS/2)                (install nonstandard drive) entry   AH      09h return  CF      set on error                AH      status code (see above)                data block definitions:                +0   maximum number of cylinders (dw)                +2   maximum number of heads (db)                +3   starting reduced write current cylinder  (dw - XT only)                +5   starting write precomp cylinder (dw)                +7   maximum ECC data burst length (db - XT only)                +8   control byte: Bits                     0,1,2  drive option                     3,4,5 - always zero                         6 - disable ECC retries                         7 - disable access retries note 1) Int 41h points to table for drive 0      2) Int 46h points to table for drive 1      3) 41h used by XT, 41h and 46h used by AT 
Function 0Ah    Read Long   (Hard disk)                 (XT, AT, XT/286, PS/2) entry  AH      0Ah        CH      cylinder number (bits 8,9 in high bits of CL)        CL      sector number        DL      drive ID        DH      head number        ES:BX   pointer to buffer to fill return CF      set on error                AH      status code (see above)        AL      number of sectors actually transferred note 1) A "long" sector includes a 4 byte EEC (Extended Error Correction) code      2) Used for diagnostics only on PS/2 systems 
Function 0Bh    Write Long                              (XT, AT, XT/286, PS/2) entry  AH      0Bh        CH      cylinder (bits 8,9 in high bits of CL)        CL      sector number        DH      head number        DL      drive ID        ES:BX   pointer to buffer containing data return CF      set on error                AH      status code (see above)        AL      number of sectors actually transferred note 1) A "long" sector includes a 4 byte EEC (Extended Error Correction) code      2) Used for diagnostics only on PS/2 systems 
Function 0Ch    Seek To Cylinder                (except PC, PCjr) entry  AH      0Ch        CH      cylinder number (bits 8,9 in high bits of CL)        DH      head number        DL      drive ID return CF      set on error                AH      status code (see above) note 1) Positions heads over a particular cylinder 
Function 0Dh    Alternate Disk Reset                    (except PC, PCjr) entry  AH      0Dh        DL      drive ID return CF      set on error        AH      status code (see above) note    Not for PS/2 ESDI hard disks 
Function 0Eh    Read Sector Buffer                         (XT, Portable PS/2) entry  AH      0Eh        AL      number of sectors        CH      cylinder (bits 8,9 in top two bits of CL)        CL      sector number        DH      head number        DL      drive number        ES:BX   pointer to buffer return CF      set on error                AH      status code (see above)        AL      number of sectors actually transferred note 1) Transfers controller's sector buffer.  No data is read from the drive      2) Used for diagnostics only on PS/2 systems 
Function 0Fh    Write sector buffer                          (XT, Portable) entry  AH      0Fh        AL      number of sectors        CH      cylinder (bits 8,9 in top two bits of CL)        CL      sector number        DH      head number        DL      drive number        ES:BX   pointer to buffer return CF      set if error                AH      status code        AL      number of sectors actually transferred note 1) Should be called before formatting to initialize the controller's        sector buffer.      2) Used for diagnostics only on PS/2 systems 
Function 10h    Test For Drive Ready entry   AH      10h         DL      drive ID return  CF      set on error                AH      status code (see above) 
Function 11h    Recalibrate Drive entry   AH      11h         DL      drive ID return  CF      set on error                AH      status code (see above) 
Function 12h    Controller RAM Diagnostic                (XT, Portable, PS/2) entry   AH      12h return  CF      set on error                AH      status code (see AH=1 above) note    Used for diagnostics only on PS/2 systems 
Function 13h    Drive Diagnostic                             (XT, Portable) entry   AH      13h return  CF      set on error         AH      status code (see above) note    Used for diagnostics only on PS/2 systems 
Function 14h    Controller Internal Diagnostic               (AT, XT/286) entry   AH      14h return  CF      set on error         AH      status code (see above) note 1) OEM is Western Digital 1003-WA2 hard/floppy combination controller         in AT and XT/286.      2) Used for diagnostics only in PS/2 systems 
Function 15h    Get Disk Type                                (except PC and XT) entry   AH      15h         DL      drive ID return  AH      disk type                00h     no drive is present                01h     diskette, no change detection present                02h     diskette, change detection present                03h     fixed disk        CX:DX   number of 512-byte sectors when AH = 03h 
Function 16h    Change of Disk Status (diskette)             (except PC and XT) entry   AH      16h return  AH      disk change status                 00h     no disk change                 01h     disk changed         DL      drive that had disk change 
Function 17h    Set Disk Type for Format (diskette)          (except PC and XT) entry   AH      17h         AL      00h     no disk                 01h     360kb diskette in 360Kb drive                 02h     360kb diskette in 1.2M drive                 03h     1.2M diskette in 1.2M drive                 04h     720kb diskette in 720Kb drive         DL      drive number return  AH      status of operation note    This function is probably enhanced for the PS/2 series to detect        1.44 in 1.44 and 720k in 1.44. 
Function 18h    Set Media Type For Format  (diskette)        (AT, XT/286, PS/2) entry   AH      18h         CH      lower 8 bits of number of tracks         CL      high 2 bits of number of tracks (6,7) sectors per track                (bits 0-5)         DL      drive number return  AH      00h      if requested combination supported                 01h      if function not available                 0Ch      if not suppported or drive type unknown                 80h      if there is no media in the drive         ES:DI   pointer to 11-byte parm table 
Function 19h    Park Hard Disk Heads                         (XT/286, PS/2) entry   AH      19h         DL      drive return  CF      set on error         AH      error code 
Function 1Ah    ESDI Hard Disk - Format                         (PS/2) entry   AH      1Ah         AL      defect table count         CL      format modifiers                 bit 0:  ignore primary defect map                 bit 1:  ignore secondary defect map                 bit 2:  update secondary defect map                 bit 3:  perform surface analysis                 bit 4:  generate periodic interrupt         DL      drive         ES:BX   pointer to defect table return  CF      set on error                AH      status (see AH=1 above) note    If periodic interrupt selected, int 15h/AH=0Fh is called after each        cylinder is formatted 
Interrupt 14h Initialize and Access Serial Port For Int 14 
(0:0050h)       the following status is defined: 
       serial status byte:        bits    0 delta clear to send                1 delta data set ready                2 trailing edge ring detector                3 delta receive line signal det.                4 clear to send                5 data set ready                6 ring indicator                7 receive line signal detect 
       line status byte:        bits    0 data ready                1 overrun error                2 parity error                3 framing error                4 break detect                5 transmit holding reg. empty                6 transmit shift register empty                7 time out  note: if bit 7 set then other bits are invalid 
All routines have AH=function number and DX=RS232 card number (0 based). AL=character to send or received character on exit, unless otherwise noted. 
entry   AH      00h     Initialize And Access Serial Communications Port                        bit pattern: BBBPPSLL                        BBB = baud rate:   110,150,300,600,1200,2400,4800,9600                        PP  = parity:      01 = odd, 11 = even                        S   = stop bits:   0 = 1, 1 = 2                        LL  = word length: 10 = 7-bits, 11 = 8-bits        AL      parms for initialization:                bit pattern:                0       word length                1       word length                2       stop bits                3       parity                4       parity                5       baud rate                6       baud rate                7       baud rate                word length     10      7 bits                                11      8 bits                stop bits       0       1 stop bit                                1       2 stop bits                parity          00      none                                01      odd                                11      even                baud rate       000     110 baud                                001     150 baud                                010     300 baud                                011     600 baud                                100     1200 baud                                101     2400 baud                                110     4800 baud                                111     9600 baud  (4800 on PCjr)        DX      port number return AH      line status        AL      modem status 
Function 01h    Send Character in AL to Comm Port DX (0 or 1) entry   AH      01h         AL      character         DX      port number (0 or 1) return  AH      RS232 status code                bit     0       data ready                        1       overrun error                        2       parity error                        3       framing error                        4       break detected                        5       transmission buffer register empty                        6       transmission shift register empty                        7       timeout         AL      modem status                bit                        0       delta clear-to-send                        1       delta data-set-ready                        2       trailing edge ring detected                        3       change, receive line signal detected                        4       clear-to-send                        5       data-set-ready                        6       ring received                        7       receive line signal detected 
Function 02h    Wait For A Character From Comm Port DX entry   AH      02h return  AL      character received         AH      error code (see above)(00h for no error) 
Function 03h    Fetch the Status of Comm Port DX (0 or 1) entry   AH      03h return  AH      set bits (01h) indicate comm-line status                bit     7       timeout                bit     6       empty transmit shift register                bit     5       empty transmit holding register                bit     4       break detected ("long-space")                bit     3       framing error                bit     2       parity error                bit     1       overrun error                bit     0       data ready        AL      set bits indicate modem status                bit     7       received line signal detect                bit     6       ring indicator                bit     5       data set ready                bit     4       clear to send                bit     3       delta receive line signal detect                bit     2       trailing edge ring detector                bit     1       delta data set ready                bit     0       delta clear to send 
Function 04h    Extended Initialize                             (PC Convertible) entry   AH      04h 
       AL      break status                01h     if break                00h     if no break        BH      parity                00h     no parity                01h     odd parity                02h     even parity                03h     stick parity odd                04h     stick parity even        BL      number of stop bits                00h     one stop bit                01h     2 stop bits (1 if 5 bit word length)        CH      word length                00h     5 bits                01h     6 bits                02h     7 bits                03h     8 bits        CL      baud rate                00h     110                01h     150                02h     300                03h     600                04h     1200                05h     2400                06h     4800                07h     9600                08h     19200 return  AL      modem status         AH      line control status 
Function 05h    Extended Communication Port Control             (PS/2) entry  AH      05h        AL      00h     read modem control register                return  BL      modem control reg (see AL=1)        AL      01h     write modem control register        BL      modem control register: (for AL=00 and AL=01)  bits                0       data terminal ready                1       request to send                2       out1                3       out2                4       loop                5,6,7   reserved return  AH      status 
Interrupt 15h Cassette I/O 
(0:0054h)       Renamed "System Services" on PS/2 line 
Function 00h    Turn Cassette Motor On                          (PC, PCjr only) entry   AH      00h return  AH      86h     no cassette present         CF      set on error note    NOP for systems where cassette not supported 
Function 01h    Turn Cassette Motor Off                         (PC, PCjr only) entry   AH      01h return  AH      86h     no cassette present         CF      set on error note    NOP for systems where cassette not supported 
Function 02h    Read Blocks From Cassette                       (PC, PCjr only) entry   AH      02h         CX      count of bytes to read         ES:BX   pointer to data buffer return  CF      set on error                AH      error code                        01h     CRC error                        02h     bad tape signals                        03h     no data found on tape                        04h     no data                        80h     invalid command                        86h     no cassette present        DX      count of bytes actually read        ES:BX   pointer past last byte written note 1) NOP for systems where cassette not supported      2) Cassette operations normally read 256 byte blocks 
Function 03h    Write Data Blocks to Cassette                   (PC, PCjr only) entry   AH      03h         CX      count of bytes to write         ES:BX   pointer to data buffer return  CF      set on error                AH      error code (see 02h)        CX      0        ES:BX   pointer to last byte written+1 note 1) NOP for systems where cassette not supported      2) The last block is padded to 256 bytes with zeroes if needed      3) No errors are returned by this service 
Function 0Fh    ESDI Format Unit Periodic Interrupt          (PS/2 50, 60, 80) entry   AH      0Fh         AL      phase code                00h     reserved                01h     surface analysis                02h     formatting return  CF      clear   if formatting should continue                set     if it should terminate note    Called during ESDI drive formatting after each cylinder is completed 
Function 10h    TopView API Function Calls                      (TopView) entry   AX      00h     PAUSE   Give Up CPU Time                        return  00h     after other processes run                01h     GETMEM  allocate "system" memory                        BX      number of bytes to allocate                        return  ES:DI pointer to block of memory                02h     PUTMEM  deallocate "system" memory                        ES:DI   pointer to previously allocated block                        return  block freed                03h     PRINTC  display character/attribute on screen                        BH      attribute                        BL      character                        DX      segment of object handle for window                        note    BX=0 does not display anything, it only                                positions the hardware cursor                10h     unknown                        AL      04h thru 12h                        return  TopView - unimplemented in DV 2.0x                                pops up "Programming error" window in DV 2.0x                11h     unknown                12h     unknown                13h     GETBIT  define a 2nd-level interrupt handler                        ES:DI   pointer to FAR service routine                        return  BX      bit mask indicating which bit was                                        allocated                                        0 if no more bits available                14h     FREEBIT undefine a 2nd-level interrupt handler                        BX      bit mask from int 15/AH 13h                15h     SETBIT  schedule one or more 2nd-level interrupts                        BX      bit mask for interrupts to post                        return  indicated routines will be called at next ???                16h     ISOBJ   verify object handle                        ES:DI   possible object handle                        return   BX     -1 if ES:DI is a valid object handle                                         0 if ES:DI is not                17h     TopView - unimplemented in DV 2.00                        return  pops up "Programming Error" window in DV 2.00                18h     LOCATE  Find Window at a Given Screen Location                        BH      column                        BL      row                        ES      segment of object handle for ???                                (0 = use default)                        return  ES      segment of object handle for window                                        which is visible at the indicated                                        position                19h     SOUND   Make Tone                        BX      frequency in Hertz                        CX      duration in clock ticks (18.2 ticks/sec)                        return  immediately, tone continues to completion                        note    If another tone is already playing, the new tone                                does not start until completion of the previous                                one. In DV 2.00, it is possible to enqueue                                about 32 tones before the process is blocked                                until a note completes.                                In DV 2.00, the lowest tone allowed is 20 Hz                1Ah     OSTACK  Switch to Task's Internal Stack                        return  stack switched                1Bh     BEGINC  Begin Critical Region                        return  task-switching temporarily disabled                        note    Will not task-switch until END CRITICAL REGION                                (AH=1Ch) is called                1Ch     ENDC    End Critical Region                        return  task-switching enabled                1Dh     STOP    STOP TASK                        ES      segment of object handle for task to be stopped                                (== handle of main window for that task)                        return  indicated task will no longer get CPU time                          note    At least in DV 2.00, this function is ignored                                 unless the indicated task is the current task.                 1Eh     START   Start Task                         ES      segment of object handle for task to be started                                 (== handle of main window for that task)                         return  Indicated task is started up again                 1Fh     DISPEROR Pop-Up Error Window                         BX      bit fields:                                 0-12    number of characters to display                                 13,14   which mouse button may be pressed to                                         remove window                                         00      either                                         01      left                                         10      right                                         11      either                                 15      beep if 1                         DS:DI   pointer to text of message                         CH      width of error window (0 = default)                         CL      height of error window (0 = default)                         DX      segment of object handle                         return  BX      status:                                         1       left button pressed                                         2       right button pressed                                         27      ESC key pressed                         note    Window remains on-screen until ESC or indicated                                 mouse button is pressed                 20h     TopView - unimplemented in DV 2.0x                         return  pops up "Programming Error" window in DV 2.0x                 21h     PGMINT  Interrupt Another Task                         BX      segment of object handle for task to interrupt                         DX:CX   address of FAR routine to jump to next time                                 task is run                         return  nothing?                         note    The current ES, DS, SI, DI, and BP are passed                                 to the FAR routine                 22h     GETVER  Get Version                         BX      00h                         return  BX      nonzero, TopView or compatible loaded                                 BH      minor version                                 BL      major version                         notes   TaskView returns BX = 0001h                                 DESQview 2.0 returns BX = 0A01h                 23h     POSWIN  Position Window                         BX      segment of object handle for parent window                                 within which to position the window (0 = full                                 screen)                         CH      # columns to offset from position in DL                         CL      # rows to offset from position in DL                         DL      bit flags                                 0,1     horizontal position                                         00      current                                         01      center                                         10      left                                         11      right                                 2,3     vertical position                                         00      current                                         01      center                                         10      top                                         11      bottom                                 4       don't redraw screen if set                                 5-7     not used                         ES      segment of object handle for window to be                                 positioned                         return  nothing                 24h     GETBUF  Get Virtual Screen Information                         BX      segment of object handle for window (0=default)                         return  CX      size of virtual screen in bytes                                 DL      0 or 1, unknown                                 ES:DI   address of virtual screen                 25h     USTACK  Switch Back to User's Stack                         return  stack switched back                         note    Call only after int 15h,fn1Ah                 26h            thru 2Ah     DesQview (TopView?) - unimplemented in DV 2.0x                         return  pops up "Programming Error" window in DV 2.0x                 2Bh     POSTTASK  Awaken Task       DesQview 2.0 (TopView?)                         BX      segment of object handle for task                         return  nothing                 2Ch     Start New Application in New Process                         DesQview 2.0 (TopView?)                         ES:DI   pointer to contents of .PIF/.DVP file                         BX      size of .PIF/.DVP info                         return  BX      segment of object handle for new task                 2Dh     Keyboard Mouse Control       DesQview 2.0                         BL      subfunction                                 00h     determine whether using keyboard mouse                                 01h     turn keyboard mouse on                                 02h     turn keyboard mouse off                         return  (calling BL was 00h)                                 BL      0       using real mouse                                         1       using keyboard mouse 
Function 20h    PRINT.COM  (DOS internal)        (AT, XT-286, PS/2 50+) entry   AH      20h         AL      subfunction                 00h     unknown (PRINT)                 01h     unknown (PRINT)                 10h     sets up SysReq routine on AT, XT/286, PS/2                 11h     completion of SysReq routine (software only) note 1) AL=0 or 1 sets or resets some flags which affect what PRINT does when         it tries to access the disk 
Function 21h    Power-On Self Test (POST) Error Log             (PS/2 50+) entry   AH      21h         AL       00h    read POST log                  01h    write POST log                         BH      device ID                         BL      error code return  CF      set on error         AH      status                 00h    OK                 01h    list full                 80h    invalid cmd                 86h    unsupported         if function 00h:                 BX      number of error codes stored                 ES:DI   pointer to error log note:   The log is a series of words, the first byte of which identifies the         error code and the second the device. 
Function 40h    Read/Modify Profiles                            (Convertible) entry   AH      40h         AL      00h     read system profile in CX,BX                 01h     write system profile from CX, BX                 02h     read internal modem profile in BX                 03h     write internal modem profile from BX         BX      profile info return  BX      internal modem profile (from 02h)         CX,BX   system profile (from 00h) 
Function 41h    Wait On External Event                          (Convertible) entry   AH      41h         AL      condition type                 bits 0-2: condition to wait for                           0 any external event                           1 compare and return if equal                           2 compare and return if not equal                           3 test and return if not zero                           4 test and return if zero                 bit 3:    reserved                 bit 4:    1=port address, 0=user byte                 bits 5-7: reserved         BH      condition compare or mask value                 condition codes:                 0       any external event                 1       compare and return if equal                 2       compare and return if not equal                 3       test and return if not zero                 4       test and return if zero         BL      timeout value times 55 milliseconds                 0 if no time limit         DX      I/O port address (if AL bit 4 = 1)         ES:DI   pointer to user byte (if AL bit 4 = 0) 
Function 42h    Request System Power Off                        (Convertible) entry   AH      42h         AL      00h     to use system profile                 01h     to force suspend regardless of profile 
Function 43h    Read System Status                              (Convertible) entry   AH      43h return  AL      status bits:                 0       LCD detached                 1       reserved                 2       RS232/parallel powered on                 3       internal modem powered on                 4       power activated by alarm                 5       standby power lost                 6       external power in use                 7       battery low 
Function 44h    (De)activate Internal Modem Power               (Convertible) entry   AH      44h         AL      00h      to power off                 01h      to power on 
Function 4Fh    Keyboard Intercept                    (except PC, PCjr, and XT) entry   AH      4Fh         AL      scan code, CF set return  AL      scan code, CF set if processing desired note    Called by int 9 handler to translate scan codes 
Function 80h    Device Open                                  (AT, XT/286, PS/2) entry   AH      80h         BX      device ID         CX      process ID return  CF      set on error         AH      status 
Function 81h    Device Close                                 (AT, XT/286, PS/2) entry   AH      81h         BX      device ID         CX      process ID return  CF      set on error         AH      status 
Function 82h    Program Termination                          (AT, XT/286, PS/2)         AH      82h         BX      device ID return: CF      set on error         AH      status note    Closes all devices opened with function 80h 
Function 83h    Event Wait                       (AT, XT/286, Convertible, PS/2) entry   AH      83h         AL      00h     to set interval                 10h     to cancel         CX,DX   number of microseconds to wait (granularity is 976 microseconds)         ES:BX   pointer to memory flag (bit 7 is set when interval expires)                 (pointer is to caller's memory) return  CF      set (1) if function already busy 
Function 84h    Read Joystick Input Settings                 (AT, XT/286, PS/2) entry   AH      84h         DX      00h     to read the current switch settings  (return in AL)                 01h     to read the resistive inputs return  AX      A(X) value         BX      A(Y) value         CX      B(X) value         DX      B(Y) value         AL      switch settings (bits 7-4) 
Function 85h    System Request (SysReq) Key Pressed        (except PC, PCjr, XT) entry   AH      85h return  AL      00h      key pressed                 01h      key released note    Called by keyboard decode routine 
Function 86h    Elapsed Time Wait                          (except PC, PCjr, XT)         AH      86h         CX,DX   number of microseconds to wait return  CF      clear   after wait elapses         CF      set     immediately due to error note    Only accurate to 977 microseconds 
Function 87h    Extended Memory Block Move              (286/386 machines only)         AH      87h         CX      number of words to move         ES:SI   pointer to Global Descriptor Table (GDT)                 offset 00h      null descriptor                        08h      uninitialized, will be made into GDT descriptor                        10h      descriptor for source of move                        18h      descriptor for destination of move                        20h      uninitialized, used by BIOS                        28h      uninitialized, will be made into SS descriptor return  CF      set on error         AH      status                 00h     source copied into destination                 01h     parity error                 02h     interrupt error                 03h     address line 20 gating failed 
Function 88h    Extended Memory Size Determine                (AT, XT/286, PS/2) entry   AH      88h return  AX      # of contiguous 1K blocks of memory starting at address 1024k 
Function 89h    Switch Processor to Protected Mode            (AT, XT/286, PS/2) entry   AH      89h         BH      interrupt number of IRQ 8 (IRQ 9Fh use next 7 interrupts)         BL      interrupt number of IRQ 0 (IRQ 17h use next 7 interrupts)         CX      offset into protected mode CS to jump to         DS:SI   pointer to Global Descriptor Table for protected mode                 offset  00h     null descriptor                         08h     GDT descriptor                         10h     IDT descriptor                         18h     DS                         20h     ES                         28h     SS                         30h     CS                         38h     uninitialized, used to build descriptor for                                 BIOS CS return  AH      0FFh  error enabling address line 20         CF      set on error 
Function 90h    Device Busy Loop                         (except PC, PCjr, XT) entry   AH      90h         AL      type code:                 00h     disk                 01h     diskette                 02h     keyboard                 03h     PS/2 pointing device                 80h     network (ES:BX = ncb)                 0FCh    disk reset                 0FDh    diskette motor start                 0FEh    printer         ES:BX   pointer to request block for type codes 80h through 0BFh return  CF      1 (set) if wait time satisfied                 0 (clear) if driver must perform wait note    Used by NETBIOS         Type codes are allocated as follows:         00h-7Fh non-reentrant devices; OS must arbitrate access         80h-BFh reentrant devices; ES:BX points to a unique control block         C0h-FFh wait-only calls, no complementary int 15,fn91h call 
Function 91h    Set Flag and Complete Interrupt          (except PC, PCjr, XT) entry   AH      91h         AL      type code (see AH=90h above)         ES:BX    pointer to request block for type codes 80h through 0BFh return  AH       0 note    Used by NETBIOS Function 0C0h   Get System Configuration      (XT after 1/10/86, PC Convertible,                                                XT/286, AT, PS/2) entry   AH      0C0h return  CF      1 if BIOS doesn't support call         ES:BX   pointer to ROM system descriptor table                 dword   number of bytes following                 byte    ID byte: PC    FF                                  XT    FE or FB                                  PCjr  FD                 byte    secondary ID distingushes between AT and XT/286, etc.                 byte    BIOS revision level, 0 for 1st release, 1 for 2nd, etc.                 byte    feature information                         80h     DMA channel 3 used by hard disk BIOS                         40h     2nd 8259 installed                         20h     realtime clock installed                         10h     int 15h,fn 04h called upon int 09h                         08h     wait for external event supported                         04h     extended BIOS area allocated at 640k                         03h     reserved                         02h     bus is Micro Channel instead of PC                         01h     reserved                         00h     reserved                 word    unknown (set to 0)                 word    unknown (set to 0) note    Int 15h is also used for the Multitask Hook on PS/2 machines. No         register settings availible yet.         The 1/10/86 XT BIOS returns an incorrect value for the feature byte. 
Function 0C1h   System - Return Extended-BIOS Data-Area Segment Address (PS/2) entry   AH      0C1h return  CF      set on error         ES      segment of data area 
Function 0C2h   Pointing Device BIOS Interface      (DesQview 2.x)    (PS/2) entry   AH      0C2h         AL      00h     enable/disable                         BH      00h    disable                 01h     reset                         return  BH     device ID                 02h     set sampling rate                         BH      00h    10/second                                 01h    20/second                                 02h    40/second                                 03h    60/second                                 04h    80/second                                 05h    100/second                                 06h    200/second                 03h set resolution                         BH     00h     one count per mm                                01h     two counts per mm                                02h     four counts per mm                                03h     eight counts per mm                 04h     get type                         return  BH      device ID                 05h     initialize                         BH      data package size (1 - 8 bytes)                 06h     get/set scaling factor                         BH      00h return device status                                 return  BL      status                                         bit 0: right button pressed                                         bit 1: reserved                                         bit 2: left button pressed                                         bit 3: reserved                                         bit 4: 0=1:1 scaling, 1=2:1 scaling                                         bit 5: device enabled                                         bit 6: 0=stream mode, 1=remote mode                                         bit 7: reserved                                         CL      resolution (see function 03h)                                         DL      sample rate, reports per second                                 01h     set scaling at 1:1                                 02h     set scaling at 2:1                 07h     set device handler address                         ES:BX   user device handler                         return  AL      00h return  CF      set on error         AH      status                 00h     successful                 01h     invalid function                 02h     invalid input                 03h     interface error                 04h     need to resend                 05h     no device handler installed note    The values in BH for those functions that take it as input are stored         in different locations for each subfunction 
Function 0C3h   Enable/Disable Watchdog Timeout                 (PS/2 50+) entry   AH      0C3h         AL      00h     disable                 01h     enable                         BX      timer counter return  CF      set on error note    The watchdog timer generates an NMI 
Function 0C4h   Programmable Option Select                      (PS/2 50+) entry   AH      04Ch         AL      00h     return base POS register address                 01h     enable slot                         BL      slot number                 02h     enable adapter return  CF      set on error         DX      base POS register address (if function 00h) 
Function 0DEh   DesQview Services                             (DesQview) entry   AH      0DEh         AL      00h     Get Program Name                         return  AX      offset into DESQVIEW.DVO of current                                         program's record:                                         byte    length of name                                         n bytes name                                         2 bytes keys to invoke program (second                                                 = 00h if only one key used)                                         word    ? (I see 0 always)                                         byte    end flag: 00h for all but last                                                 entry, which is 0FFh                 01h     Update "Open Window" Menu                         return  none                         note    Reads DESQVIEW.DVO, disables Open menu if file                                 not in current directory                 02h     unimplemented in DV 2.0x                         return  nothing (NOP in DV 2.0x)                 03h     unimplemented in DV 2.0x                         return  nothing (NOP in DV 2.0x)                 04h     Get Available Common Memory                         return  BX      bytes of common memory available                                 CX      largest block available                                 DX      total common memory in bytes                 05h     Get Available Conventional Memory                         return  BX      K of memory available                                 CX      largest block available                                 DX      total conventional memory in K                 06h     Get Available Expanded Memory                         return  BX      K of expanded memory available                                 CX      largest block available                                 DX      total expanded memory in K                 07h     APPNUM  Get Current Program's Number                         return  AX      number of program as it appears on the                                         "Switch Windows" menu                 08h     GET (unknown)                         return  AX      0       unknown                                         1       unknown                 09h     unimplemented in DV 2.00                         return  nothing (NOP in DV 2.00)                 0Ah     DBGPOKE Display Character on Status Line                         BL      character                         return  character displayed, next call will display in                                 next position (which wraps back to the start of                                 the line if off the right edge of screen)                         note 1) Displays character on bottom line of *physical*                                 screen, regardless of current size of window                                 (even entirely hidden)                              2) Does not know about graphics display modes,                                 just pokes the characters into display memory                 0Bh     APILEVEL Define Minimum API Level Required                         BL      API level                                 >2 pops up "You need a newer version" error                                 window in DV 2.00                         BH      unknown                         return  AX      maximum API level?                 0Ch     GETMEM  Allocate "System" Memory                         BX      number of bytes                         return  ES:DI   pointer to allocated block                 0Dh     PUTMEM  Deallocate "System" Memory                         ES:DI   pointer to previously allocated block                         return  nothing                 0Eh     Find Mailbox by Name    (DV 2.0+)                         ES:DI   pointer to name to find                         CX      length of name                         return  BX      0       not found                                         1       found                                 DS:SI   object handle                 0Fh     Enable DesQview Extensions      (DV 2.0+)                         return  AX and BX destroyed (seems to be bug, weren't                                 saved & restored)                         note 1) Sends a manager stream with opcodes AEh, BDh,                                 and BFh to task's window                              2) Enables an additional mouse mode                 10h     PUSHKEY  PUT KEY INTO KEYBOARD INPUT STREAM  (DV 2.0+)                         BH      scan code                         BL      character                         return  BX      unknown (sometimes, but not always,                                         same as BX passed in)                         note    A later read will get the keystroke as if it                                 had been typed by the user                 11h     ENABLE/DISABLE AUTO JUSTIFICATION OF WINDOW (DV 2.0+)                         BL      0       viewport will not move automatically                                 nonzero viewport will move to keep cursor                                         visible                         return  none                 12h     unknown (DV 2.0+)                         BX      0       clear something?                                 nonzero set something?                         return  none 
Interrupt 16h Keyboard I/O 
(0:0058h)       access the keyboard 
Function  00h   Get Keyboard Input - read the next character in keyboard buffer,                 if no key ready, wait for one. entry   AH      00h return  AH      scan code         AL      ASCII character 
Function  01h   Check Keystroke Buffer - Do Not Clear entry   AH      01h return  ZF      0 (clear) if character in buffer                 1 (set)   if no character in buffer         AH      scan code of character (if ZF=0)         AL      ASCII character if applicable note    Keystroke is not removed from buffer 
Function  02h   Shift Status - fetch bit flags indicating shift status entry   AH      02h return  AL      bit codes (same as [0040:0017])                 bit 7   Insert state                 bit 6   CapsLock state                 bit 5   NumLock state                 bit 4   ScrollLock state                 bit 3   Alt key                 bit 2   Control key                 bit 1   Left shift (left caps-shift key)                 bit 0   Right shift (right caps-shift key) note    other codes found at [0040:0018]                 bit 7   Insert shift (Ins key)                 bit 6   Caps shift (CapsLock key)                 bit 5   Num shift (NumLock key)                 bit 4   Scroll shift (ScrollLock key)                 bit 3   Hold state (Ctrl-NumLock is in effect) 
Function 03h    Keyboard - Set Repeat Rate            (PCjr, AT, XT/286, PS/2) entry   AH      03h         AL      00h     reset typematic             (PCjr)                 01h     increase initial delay      (PCjr)                 02h     increase continuing delay   (PCjr)                 03h     increase both delays        (PCjr)                 04h     turn off typematic          (PCjr)                 05h     set typematic rate          (AT, PS/2)         BH      00h-03h for delays of 250ms, 500ms, 750ms, or 1s         BL      00h-1Fh for typematic rates of 30cps down to 2cps 
Function 04h    Keyboard Click Toggle                 (PCjr and Convertible) entry   AH      04h         AL      00h     for click off                 01h     for click on 
Function 05h    Keyboard Buffer Write            (AT or PS/2 with enhanced kbd)                 (XT/286, PS/2, AT with "Enhanced" keyboard) entry   AH      05h         CH      scan code         CL      ASCII character return  AL      01h if buffer full 
Function 10h    Get Enhanced Keystroke And Read      (F11, F12 Enhanced Keyb'd)                 (XT/286, PS/2, AT with "Enhanced" keyboard) entry   AH      10h return  AH      scan code         AL      ASCII character if applicable 
Function 11h    Check Enhanced Keystroke         (F11-F12 on enhanced keyboard)                 (XT/286, PS/2, AT with "Enhanced" keyboard) entry   AH      11h return  ZF      0       (clear) if key pressed                 1       if buffer empty         AH      scan code (when ZF=0)         AL      ASCII character if applicable (when ZF=0) note    Keystroke is not removed from buffer 
Function 12h    Extended Get Shift Status         (F11, F12 Enhanced keyboard) entry    AH     12h return   AL     bit                 0       right Shift key depressed                 1       left Shift key depressed                 2       Control key depressed                 3       Alt key depressed                 4       ScrollLock state active                 5       NumLock state active                 6       CapsLock state active                 7       insert state is active         AH      0       left Control key pressed                 1       left Alt key depressed                 2       right Control key pressed                 3       right Alt key depressed                 4       Scroll Lock key depressed                 5       NumLock key depressed                 6       CapsLock key depressed                 7       SysReq key depressed 
Function 0F0h   Set CPU speed (Compaq 386) entry   AH      0F0h     set speed return  unknown note    used by Compaq DOS MODE command.         parameters not availible 
Interrupt 17h Printer 
(0:005Ch)       access the parallel printer(s)                 AH is changed. All other registers left alone. 
Function  00h   Print Character/send AL to printer DX (0, 1, or 2) entry   AH      00h         AL      character         DX      printer to be used (0,1,2) return  AH      status byte                 bit                 0       time out                 1       unused                 2       unused                 3       I/O error                 4       selected                 5       out of paper                 6       acknowledge                 7       not busy 
Function 01h    Initialize Printer - set init line low, send 0Ch to printer DX entry   AH      01h         DX      printer port to be initialized (0,1,2) return  status as below 
Function  02h   Printer Status - read status of printer DX into AH entry   AH      02h         DX      printer port to be used (0,1,2) return  AH      bit flags       bit 7   0 = printer is busy                                 bit 6   ACKnowledge line state                                 bit 5   out-of-paper line state                                 bit 4   printer selected line state                                 bit 3   I/O error                                 bit 2   unused                                 bit 1   unused                                 bit 0   time-out error 
Interrupt 18h ROM BASIC 
(0:0060h)       Execute ROM BASIC at address 0F600h:0000h note 1) Often reboots a compatible 
Interrupt 19h Bootstrap Loader 
(0:0064h)       Reads track 0, sector 1 into address 0000h:7C00h, then transfers                 control to that address. If no diskette drive available,                 transfers to ROM-BASIC or displays loader error message.                 Causes reboot of disk system if invoked while running.                 (no memory test performed). 
Interrupt 1Ah Time of Day 
(0:0068h)       access the PC internal clock 
Function 00h    Read System Time Counter entry   AH      00h return  CX      high word of clock count         DX      low word of clock count         AL      00h if clock was read or written (via AH=0,1) within the current                 24-hour period. Otherwise, AL > 0 
Function 01h    Set Clock - set # of 55ms clock ticks in system time counter entry   AH      01h         CX:DX   high word/low word count of timer ticks return  none note 1) The clock ticks are incremented by timer interrupt at 18.2065 times         per second or 54.9254milliseconds/count. Therefore:                 counts per second = 18      (12h)                 counts per minute = 1092    (444h)                 counts per hour   = 65543   (10011h)                 counts per day    = 1573040 (1800B0h)      2) counter is zeroed when system is rebooted 
     2) IBM and Microsoft recommend using int 21 Fn 4Ch. Using int 20 is         officially frowned upon since the introduction of DOS 2.0 
Function 02h    Read Real Time Clock Time                       (AT and after) entry   AH      02h return  CH      hours in BCD         CL      minutes in BCD         DH      seconds in BCD         DL      1 (set) if daylight savings time option         CF      1 (set) if clock not operating 
Function 03h    Set Real Time Clock Time                        (AT and after) entry   AH      03h         CH      hours in BCD         CL      minutes in BCD         DH      seconds in BCD         DL      0 (clear) if standard time                 1 (set) if daylight savings time option return  none 
Function 04h    Read Real Time Clock Date                       (AT and after) entry   AH      04h return  CH      century in BCD (19 or 20)         CL      year in BCD         DH      month in BCD         DL      day in BCD         CF      1 (set) if clock not operating 
Function 05h    Set Real Time Clock Date                        (AT and after) entry   AH      05h         CH      century in BCD (19 or 20)         CL      year in BCD         DH      month in BCD         DL      day in BCD return  none 
Function 06h    Set Real Time Clock Alarm                       (AT and after) entry   AH      06h         CH      hours in BCD         CL      minutes in BCD         DH      seconds in BCD return  CF      set if alarm already set or clock inoperable note    Int 4Ah occurs at specified alarm time every 24hrs until reset 
Function 07h    Reset Real Time Clock Alarm                     (AT and after) entry   AH      07h return  none 
Function 08h    Set Real Time Clock Activated Power On Mode     (Convertible) entry   AH      08h         CH      hours in BCD         CL      minutes in BCD         DH      seconds in BCD 
Function 09h    Read Real Time Clock Alarm Time and Status                                                 (Convertible and PS/2 Model 30) entry   AH      09h return  CH      hours in BCD         CL      minutes in BCD         DH      seconds in BCD         DL      alarm status:                 00h     if alarm not enabled                 01h     if alarm enabled but will not power up system                 02h     if alarm will power up system 
Function 0Ah    Read System-Timer Day Counter   (XT-2 [640k motherboard], PS/2) entry   AH      0Ah return  CF      set on error         CX      count of days since Jan 1,1980 
Function 0Bh    Set System-Timer Day Counter    (XT-2 [640k motherboard], PS/2) entry   AH      0Bh         CX      count of days since Jan 1,1980 return  CF      set on error 
Function 80h    Set Up Sound Multiplexor                (PCjr) (Tandy 1000?) entry   AH      80h         AL      00h     source is 8253 channel 2                 01h     source is cassette input                 02h     source is I/O channel "audio in"                 03h     source is TI sound generator chip 
Interrupt 1Bh Control-Break 
(0:006Ch)       This interrupt is called when the keyboard scanner of the IBM                 machines detects Ctrl and Break pressed at the same time. 
note 1) If the break occurred while processing an interrupt, one or more         end of interrupt commands must be send to the 8259 Programmable         Interrupt Controller.      2) All I/O devices should be reset in case an operation was underway at         the time.      3) It is normally pointed to an IRET during system initialization so that         it does nothing, but some programs change it to return a ctrl-C scan         code and thus invoke int 23h. 
Interrupt 1Ch Timer Tick 
(0:0070h) note 1) Taken 18.2065 times per second      2) Normally vectors to dummy IRET unless PRINT.COM has been installed.      3) If an application moves the interrupt pointer, it is the responsibility         of that application to save and restore all registers that may be         modified. 
Interrupt 1Dh Vector of Video Initialization Parameters. 
(0:0074h)       This doubleword address points to 3 sets of 16-bytes containing                 data to initialize for video modes for video modes 0 & 1 (40                 column), 2 & 3 (80 column), and 4, 5 & 6 (graphics) on the                 Motorola 6845 CRT controller chip.  6845 registers:         R0      horizontal total (horizontal sync in characters)         R1      horizontal displayed (characters per line)         R2      horizontal sync position (move display left or right)         R3      sync width (vertical and horizontal pulse: 4-bits each)         R4      vertical total (total character lines)         R5      vertical adjust (adjust for 50 or 60 Hz refresh)         R6      vertical displayed (lines of chars displayed)         R7      vertical sync position (lines shifted up or down)         R8      interlace (bits 4 and 5) and skew (bits 6 and 7)         R9      max scan line addr (scan lines per character row)         R10     cursor start (starting scan line of cursor)         R11     cursor stop (ending scan line of cursor)         R12     video memory start address high byte (6-bits)         R13     video memory start address low byte (8-bits)         R14     cursor address high byte (6-bits)         R15     cursor address low byte (8-bits) 
6845 Video Init Tables:         table for modes 0 and 1   \         table for modes 2 and 3    \ each table is 16 bytes long and         table for modes 4,5, and 6 / contains values for 6845 registers         table for mode 7          /         4 words:   size of video RAM for modes 0/1, 2/3, 4/5, and 6/7         8 bytes:   number of columns in each mode         8 bytes:   video controller mode byte for each mode note 1) There are 4 separate tables, and all 4 must be initialized if all         video modes will be used.      2) The power-on initialization code of the computer points this vector         to the ROM BIOS video routines.      3) IBM recommends that is this table needs to be modified, it should be         copied into RAM and only the nescessary changes made. 
Interrupt 1Eh Vector of Diskette Controller Parameters 
(0:0078h)       Dword address points to data base table that is used by BIOS.                 Default location is at 0F000:0EFC7h. 11-byte table format:                 bytes:                 00h     4-bit step rate, 4-bit head unload time                 01h     7-bit head load time, 1-bit DMA flag                 02h     54.9254 ms counts - delay till motor off (37-38 typ)                 03h     sector size:                         00h     128 bytes                         01h     256 bytes                         02h     512 bytes                         03h     1024 bytes                 04h     last sector on track (8 or 9 typical)                 05h     gap between sectors on read/write (42 typical)                 06h     data length for DMA transfers (0FFh typical)                 07h     gap length between sectors for format (80 typical)                 08h     sector fill byte for format (0F6h typical)                 09h     head settle time (in milliseconds) (15 to 25 typical)                         DOS 1.0   0                         DOS 2.10  15                         DOS 3.1   1                 10h     motor start time (in 1/8 second intervals) (2 to 4 typ.)                         DOS 2.10  2 note 1) This vector is pointed to the ROM BIOS diskette tables on system         initialization      2) IBM recommends that is this table needs to be modified, it should be         copied into RAM and only the nescessary changes made. 
Interrupt 1Fh Pointer to Graphics Character Extensions (Graphics Set 2) 
(0:007Ch)       This is the pointer to data used by the ROM video routines to                 display characters above ASCII 127 while in CGA medium and high                 res graphics modes. 
note 1) Doubleword address points to 1K table composed of 28 8-byte character         definition bit-patterns. First byte of each entry is top row, last byte         is bottom row.      2) The first 128 character patterns are located in system ROM.      3) This vector is set to 000:0 at system initialization      4) Used by DOS' external GRAFTABL command 
DOS TECHNICAL INFORMATION 
SOME HISTORY 
Development of MSDOS/PCDOS began in October 1980, when IBM began searching the market for an operating system for the yet-to-be-introduced IBM PC. Microsoft had no real operating system to sell, but after some research licensed Seattle Computer Products' 86-DOS, which had been written by a man named Tim Paterson for use on the company's line of 8086, S100 bus micros. This was hurriedly polished up and presented to IBM for evaluation. IBM had originally intended to use Digital Research's CP/M operating system, which was the industry standard at the time. Folklore reports everything from obscure legal entanglements to outright snubbing of the IBM representatives by Digital, irregardless, IBM found itself left with Microsoft's offering of "Microsoft Disk Operating System 1.0". An agreement was reached between the two, and "IBM PC-DOS 1.0" was ready for the introduction of the IBM PC in October 1981. IBM subjected the operating system to an extensive quality-assurance program, found well over 300 bugs, and decided to rewrite the programs. This is why PC-DOS is copyrighted by both IBM and Microsoft. 
It is sometimes amusing to reflect on the fact that the IBM PC was not originally intended to run MSDOS. The target operating system at the end of the development was for a (not yet in existence) 8086 version of CP/M. On the other hand, when DOS was originally written the IBM PC did not yet exist! Although PC-DOS was bundled with the computer, Digital Research's CP/M-86 would probably have been the main operating system for the PC except for two things - Digital Research wanted $495 for CP/M-86 (considering PC-DOS was essentially free) and many software developers found it easier to port existing CP/M software to DOS than to the new version of CP/M. 
MSDOS and PC-DOS have been run on more than just the IBM-PC and clones. There was an expansion board for the Apple ][ that allowed one to run (some) well - behaved DOS programs. There are expansion boards for the Commodore Amiga 2000, the Apple MacIntosh II, and the IBM RT PC allowing them to run DOS, and the IBM 3270 PC, which ran DOS on a 68000 microprocessor. The Atari STs can run an emulator program and boot MSDOS. Specific Versions of MS/PC-DOS: 
DOS version nomenclature: major.minor.minor.  The digit to the left of the decimal point indicates a major DOS version change. 1.0 was the first version. 2.0 added subdirectories, etc. 3.0 added file handles and network support.  The first minor version indicates customization for a major application. For example, 2.1 for the PCjr, 3.3 for the PS/2s. The second minor version does not seem to have any particular meaning. 
The main versions of DOS are: 
 PC-DOS 1.0   October  1981  original release  PC-DOS 1.1   June     1982  bugfix, double sided drive support  MS-DOS 1.25  June     1982  for early compatibles  PC-DOS 2.0   March    1983  for PC/XT, many UNIX-like functions  PC-DOS 2.1   October  1983  for PCjr, bugfixes for 2.0  MS-DOS 2.11  October  1983  compatible equivalent to 2.1  PC-DOS 3.0   August   1984  for PC/AT, network support  PC-DOS 3.1   November 1984  bugfix for 3.0  MS-DOS 2.25  October  1985  compatible; extended foreign language support  PC-DOS 3.2   July     1986  3.5 inch drive support for Convertible  PC-DOS 3.3   April    1987  for PS/2 series 
Some versions of MS-DOS varied from PC-DOS in the availible external commands. Some OEMs only licensed the basic operating system code (the xxxDOS and xxxBIO programs, and COMMAND.COM) from Microsoft, and either wrote the rest themselves or contracted them from outside software houses like Phoenix. Most of the external programs for DOS 3.x are written in "C" while the 1.x and 2.x utilities were written in assembly language. Other OEMs required customized versions of DOS for their specific hardware configurations, such as Sanyo 55x and early Tandy computers, which were unable to exchange their DOS with the IBM version. 
At least two versions of DOS have been modified to be run entirely out of ROM. The Sharp PC5000 had MSDOS 1.25 in ROM, and the Toshiba 1100 and some Tandy models have MSDOS 2.11 in ROM. 
THE OPERATING SYSTEM HIERARCHY 
The Disk Operating System (DOS) and the ROM BIOS serve as an insulating layer between the application program and the machine, and as a source of services to the application program.  The system heirarchy may be thought of as a tree, with the lowest level being the actual hardware. The 8088 or V20 processor sees the computer's address space as a ladder two bytes wide and one million bytes long. Parts of this ladder are in ROM, parts in RAM, and parts are not assigned. There are also 256 "ports" that the processor can use to control devices.  The hardware is normally addressed by the ROM BIOS, which will always know where everything is in its particular system. The chips may usually also be written to directly, by telling the processor to write to a specific address or port. This sometimes does not work as the chips may not always be at the same addresses or have the same functions from machine to machine. 
DOS STRUCTURE 
DOS consists of four components: 
 * The boot record  * The ROM BIOS interface  (IBMBIO.COM or IO.SYS)  * The DOS program file    (IBMDOS.COM or MSDOS.SYS)  * The command processor   (COMMAND.COM or aftermarket replacement)  * The Boot Record 
The boot record begins on track 0, sector 1, side 0 of every diskette formatted by the DOS FORMAT command.  The boot record is placed on diskettes to produce an error message if you try to start up the system with a nonsystem diskette in drive A.  For hard disks, the boot record resides on the first sector of the DOS partition.  All media supported by DOS use one sector for the boot record. * Read Only Memory (ROM) BIOS Interface 
The file IBMBIO.COM or IO.SYS is the interface module to the ROM BIOS. This file provides a low-level interface to the ROM BIOS device routines and may contain extensions or changes to the system board ROMs. Some compatibles do not have a ROM BIOS to extend, and load the entire BIOS from disk. (Sanyo 55x, Viasyn) 
* The DOS Program File 
The actual DOS program is file IBMDOS.COM or MSDOS.SYS. It provides a high- level interface for user (application) programs. This program consists of file management routines, data blocking/deblocking for the disk routines, and a variety of built-in functions easily accessible by user programs.  When a user program calls these function routines, they accept high-level information by way of register and control block contents. For device operations, the functions translate the requirement into one or more calls to IBMBIO.COM or MSDOS.SYS to complete the request. 
* The Command Interpreter 
The Command interpreter, COMMAND.COM, consists of these parts: 
Resident Portion: 
The resident portion resides in memory immediately following IBMDOS.COM and its data area. This portion contains routines to process interrupts 22h (Terminate Address), 23h (Ctrl-Break Handler), and 24h (Critical Error Handler), as well as a routine to reload the transient portion if needed. For DOS 3.x, this portion also contains a routine to load and execute external commands, such as files with exensions of COM or EXE. 
When a program terminates, a checksum is used to determine if the application program overlaid the transient portion of COMMAND.COM. If so, the resident portion will reload the transient portion from the area designated by COMSPEC= in the DOS environment. If COMMAND.COM cannot be found, the system will halt. 
NOTE: DOS 3.3 checks for the presence of a hard disk, and will default to COMSPEC=C:\. Previous versions default to COMSPEC=A:\. Under some DOS versions, if COMMAND.COM is not immediately availible for reloading (i.e., swapping to a floppy with COMMAND.COM on it) DOS may crash. 
All standard DOS error handling is done within the resident portion of COMMAND.COM.  This includes displaying error messages and interpreting the replies of Abort, Retry, Ignore, Fail. 
An initialization routine is included in the resident portion and assumes control during startup. This routine contains the AUTOEXEC.BAT file handler and determines the segment address where user application programs may be loaded. The initialization routine is then no longer needed and is overlaid by the first program COMMAND.COM loads. 
NOTE: AUTOEXEC.BAT may be a hidden file. 
A transient portion is loaded at the high end of memory. This is the command processor itself, containing all of the internal command processors and the batch file processor. For DOS 2.x, this portion also contains a routine to load and execute external commands, such as files with extensions of COM or EXE. 
This portion of COMMAND.COM also produces the DOS prompt (such as "A>"), reads the command from the standard input device (usually the keyboard or a batch file), and executes the command. For external commands, it builds a command line and issues an EXEC function call to load and transfer control to the program. 
NOTE: COMMAND.COM may be a hidden file. 
NOTE: For Dos 2.x, the transient portion of the command processor contains the EXEC routine that loads and executes external commands. For DOS 3.x, the resident portion of the command processor contains the EXEC routine. 
DOS Initialization 
The system is initialized by a software reset (Ctrl-Alt-Del), a hardware reset (reset button), or by turning the computer on. The Intel 80x8x series processors always look for their first instruction at the end of their address space (0FFFF0h) when powered up or reset. This address contains a jump to the first instruction for the ROM BIOS.  Built-in ROM programs (Power-On Self-Test, or POST, in the IBM) check machine status and run inspection programs of various sorts. Some machines set up a reserved RAM area with bytes indicating installed equipment (AT and PCjr).  The ROM routine looks for a disk drive at A: or an option ROM (usually a hard disk) at absolute address C:800h. If no floppy drive or option ROM is found, the BIOS calls int 19h (ROM BASIC if it is an IBM) or displays error message.  If a bootable disk is found, the ROM BIOS loads the first sector of information from the disk and then jumps into the RAM location holding that code. This code normally is a routine to load the rest of the code off the disk, or to "boot" the system.  The following actions occur after a system initialization: 
1.The boot record is read into memory and given control. 
2.The boot record then checks the root directory to assure that the first two files are IBMBIO.COM and IBMDOS.COM. These two files must be the first two files, and they must be in that order (IBMBIO.COM first, with its sectors in contiguous order). NOTE: IBMDOS.COM need not be contiguous in version 3.x. 
3.The boot record loads IBMBIO.COM into memory. 
4.The initialization code in IBMBIO.COM loads IBMDOS.COM, determines equipment status, resets the disk system, initializes the attached devices, sets the system parameters and loads any installable device drivers according to the CONFIG.SYS file in the root directory (if present), sets the low-numbered interrupt vectors, relocates IBMDOS.COM downward, and calls the first byte of DOS. NOTE: CONFIG.SYS may be a hidden file. 
5.DOS initializes its internal working tables, initializes the interrupt vectors for interrupts 20h through 27h, and builds a Program Segment Prefix for COMMAND.COM at the lowest available segment. For DOS versions 3.10 up, DOS initializes interrupt vectors for interrupts 0Fh through 3Fh. 
6.IBMBIO.COM uses the EXEC function call to load and start the top-level command processor. The default command processor is COMMAND.COM. 
DOS INTERRUPTS AND FUNCTION CALLS 
DOS REGISTERS 
DOS uses the following registers, pointers, and flags when it executes interrupts and function calls: 
GENERAL REGISTERS    register        definition                         AX      accumulator (16 bit)                         AH      accumulator high-order byte (8 bit)                         AL      accumulator low order byte (8 bit)                         BX      base (16 bit)                         BH      base high-order byte (8 bit)                         BL      base low-order byte (8 bit)                         CX      count (16 bit)                         CH      count high order byte (8 bit)                         CL      count low order byte (8 bit)                         DX      data (16 bit)                         DH      date high order byte (8 bit)                         DL      data low order byte (8 bit) 
FLAGS                   AF, CF, DF, IF, OF, PF, SF, TF, ZF 
POINTERS             register        definition                         SP      stack pointer (16 bit)                         BP      base pointer (16 bit)                         IP      instruction pointer (16 bit) 
SEGMENT REGISTERS    register       definition                         CS      code  segment (16 bit)                         DS      data  segment (16 bit)                         SS      stack segment (16 bit)                         ES      extra segment (16 bit) 
INDEX REGISTERS      register        definition                         DI      destination index (16 bit)                         SI      stack       index (16 bit) 
INTERRUPTS 
Microsoft recommends that a program wishing to examine or set the contents of any interrupt vector use the DOS function calls 35h and 25h provided for those purposes and avoid referencing the interrupt vector locations directly.  DOS reserves interrupt numbers 20h to 3Fh for its own use. This means absolute memory locations 80h to 0FFh are reserved by DOS. The defined interrupts are as follows with all values in hexadecimal. 
Interrupt 20h PROGRAM TERMINATE 
(0:0080h) Issue int 20h to exit from a program. This vector transfers to the logic in DOS to restore the terminate address, the Ctrl-Break address,and the critical error exit address to the values they had on entry to the program. All the file buffers are flushed and all handles are closed. You should close all files changed in length (see function calls 10h and 3Eh) before issuing this interrupt. If the changed file is not closed, its length, time, and date are not recorded correctly in the directory.  For a program to pass a completion code or an error code when terminating, it must use either function call 4Ch (Terminate a Process) or 31h (Terminate Process and Stay Resident). These two methods are preferred over using int 20h and the codes returned by them can be interrogated in batch processing. Important: Before you issue an interrupt 20h, your program must ensure that the CS register contains the segment of its program segment prefix. 
Interrupt 20h   DOS - Terminate Program entry   no parameters return  none 
Interrupt 20h   Minix - Send/Receive Message entry   AX      process ID of other process         BX      pointer to message         CX      1       send                 2       receive                 3       send&receive note    The message contains the system call number (numbered as in V7 Unix)         and the call parameters 
Interrupt 21h FUNCTION CALL REQUEST 
(0:0084h) 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 more. They are grouped as follows: 
          call              description         00h             program terminate         01h-0Ch         character device I/O, CP/M compatibility format         0Dh-24h         file management,      CP/M compatibility format         25h-26h         nondevice functions,  CP/M compatibility format         27h-29h         file management,      CP/M compatibility format         2Ah-2Eh         nondevice functions,  CP/M compatibility format         2Fh-38h         extended functions         39h-3Bh         directory group         3Ch-46h         extended file management         47h             directory group         48h-4Bh         extended memory management         54h-57h         extended functions         5Eh-5Fh         networking         60h-62h         extended functions         63h-66h         enhanced foreign language support 
List of DOS services:   * = undocumented         00h     terminate program         01h     get keyboard input         02h     display character to STDIO         03h     get character from STDAUX         04h     output character to STDAUX         05h     output character to STDPRN         06h     direct console I/O - keyboard to screen         07h     get char from std I/O without echo         08h     get char from std I/O without echo, checks for ^C         09h     display a string to STDOUT         0Ah     buffered keyboard input         0Bh     check STDIN status         0Ch     clear keyboard buffer and invoke keyboard function         0Dh     flush all disk buffers         0Eh     select disk         0Fh     open file with File Control Block         10h     close file opened with File Control Block         11h     search for first matching file entry         12h     search for next matching file entry         13h     delete file specified by File Control Block         14h     sequential read from file specified by File Control Block         15h     sequential write to file specified by File Control Block         16h     find or create firectory entry for file         17h     rename file specified by file control block         18h*    unknown         19h     return current disk drive         1Ah     set disk transfer area (DTA)         1Bh     get current disk drive FAT         1Ch     get disk FAT for any drive         1Dh*    unknown         1Eh*    unknown         1Fh*    read DOS disk block, default drive         20h*    unknown         21h     random read from file specified by FCB         22h     random write to file specified by FCB         23h     return number of records in file specified by FCB         24h     set relative file record size field for file specified by FCB         25h     set interrupt vector         26h     create new Program Segment Prefix (PSP)         27h     random file block read from file specified by FCB         28h     random file block write to file specified by FCB         29h     parse the command line for file name         2Ah     get the system date         2Bh     set the system date         2Ch     get the system time         2Dh     set the system time         2Eh     set/clear disk write VERIFY         2Fh     get the Disk Transfer Address (DTA)         30h     get DOS version number         31h     TSR, files opened remain open         32h*    read DOS Disk Block         33h     get or set Ctrl-Break         34h*    INDOS  Critical Section Flag         35h     get segment and offset address for an interrupt         36h     get free disk space         37h*    get/set option marking character (SWITCHAR)         38h     return country-dependent information         39h     create subdirectory         3Ah     remove subdirectory         3Bh     change current directory         3Ch     create and return file handle         3Dh     open file and return file handle         3Eh     close file referenced by file handle         3Fh     read from file referenced by file handle         40h     write to file referenced by file handle         41h     delete file         42h     move file pointer (move read-write pointer for file)         43h     set/return file attributes         44h     device IOCTL (I/O control) info         45h     duplicate file handle         46h     force a diuplicate file handle         47h     get current directory         48h     allocate memory         49h     release allocated memory         4Ah     modify allocated memory         4Bh     load or execute a program         4Ch     terminate prog and return to DOS         4Dh     get return code of subprocess created by 4Bh         4Eh     find first matching file         4Fh     fine next matching file         50h*    set new current Program Segment Prefix (PSP)         51h*    puts current PSP into BX         52h*    pointer to the DOS list of lists         53h*    translates BPB (Bios Parameter Block, see below)         54h     get disk verification status (VERIFY)         55h*    create PSP: similar to function 26h         56h     rename a file         57h     get/set file date and time         58h     get/set allocation strategy             (DOS 3.x)         59h     get extended error information         5Ah     create a unique filename         5Bh     create a DOS file         5Ch     lock/unlock file contents         5Dh*    network         5Eh*    network printer         5Fh*    network redirection         60h*    parse pathname         61h*    unknown         62h     get program segment prefix (PSP)         63h*    get lead byte table                     (DOS 2.25)         64h*    unknown         65h*    get extended country information        (DOS 3.3)         66h*    get/set global code page table          (DOS 3.3)         67h*    set handle count                        (DOS 3.3)         68h*    commit file                             (DOS 3.3) 
DOS Functions 
 DOS Fn Groups    DOS Interrupts 
 00H Terminate    11H Fnd1st FCB  27H ReadRdmBlk 38H CntryInfo    49H Mem Free  01H Kybd Input   12H FndNxt FCB  28H WritRdmBlk 39H MkDir        4aH Mem SetBlk  02H Dspl Char    13H Delete FCB  29H Parse Fnam 3aH RmDir        4bH Exec  03H Aux Input    14H ReadSeqFCB  2aH Get Date   3bH ChDir        4cH Exit  04H Aux Output   15H WritSeqFCB  2bH Set Date   3cH Create File  4dH Wait  05H Prn Output   16H Create FCB  2cH Get Time   3dH Open File    4eH Fnd1stFile  06H Console I/O  17H Rename FCB  2dH Set Time   3eH Close File   4fH FndNxtFile  07H NoEchoUf Inp 19H Get CurDsk  2eH Set Verify 3fH Read File    54H Get Verify  08H NoEcho Inp   1aH Set DTA     2fH Get DTA    40H Write File   56H Rename  09H Dspl String  1bH GetFAT Cur  30H Get Versn  41H Delete File  57H Time Stamp  0aH Bufrd Input  1cH GetFAT Dsk  31H Keep Proc  42H Lseek File   59H Xtnded Err  0bH Input Status 21H ReadRdmRec  32H Disk Info  43H ChMod (attr) 5aH Temp File  0cH Clr & Input  22H WritRdmRec  33H Break Chk  44H Ioctl        5bH New File  0dH Reset Disk   23H FileSizFCB  34H DOSActive  45H Dup Handle   5cH Lock File  0eH Set CurDisk  24H SetRndmBlk  35H GetVector  46H Redir(Cdup)  5eH Netwk Misc  0fH Open FCB     25H Set Vector  36H Disk Free  47H Get CurDir   5fH NetwkRedir  10H Close FCB    26H Create PSP  37H Switchar   48H Mem Alloc    62H Get PSP 
DOS Interrupts 
           INT 20H Terminate a program            INT 21H DOS Services            INT 25H/26H Absolute Disk Read/Write            INT 27H Terminate but Stay Resident            INT 28H DOS Timeslice (UNDOCUMENTED)            INT 2eH Perform DOS Command (UNDOCUMENTED)            INT 2fH Multiplex Interrupt (print spooler control) 
Address Pointers (not used as software interrupts)            INT 22H Terminate address            INT 23H Control-Break address            INT 24H Critical Error Handler address 
System Information Functions 
 30H DOS version number              2fH current DTA address  2aH current system date             62H current PSP address  2cH current system time             35H current value of an interrupt vector  19H current default disk            4dH exit code of a process  47H current default directory       59H extended error information  38H country-dependant information   44H IOCTL: device/file status 
 54H disk verify mode                37H switch character  33H Ctrl-Break checking state       34H DOS reentrancy status address 
 36H  1bH  1cH disk size & available bytes  32H a potpourri of disk information 
 57H time/date of a file 
 4eH  4fH   11H  12H  search for files 
Character I/O Functions 
 01H keyboard input ...................................... 3fH (BX=0)  08H keyboard input (no output echo)  07H unfiltered keyboard input (no output echo)  06H console input and output 
 02H display one character ............................... 40H (BX=1 or BX=2)  09H display a string of characters ...................... 40H (BX=1 or BX=2) 
 0bH get input status (and process any pending Ctrl-Break)  0cH clear keyboard buffer and wait for input  0aH buffered keyboard input (input string) .............. 3fH (BX=0) 
 03H AUX (serial port) input ............................. 3fH (BX=3)  04H AUX (serial port) output ............................ 40H (BX=3) 
 05H PRN (printer) output ................................ 40H (BX=4)  INT 2fH  Multiplex (print spooler) Functions 
Handle-Oriented File I/O 
These functions are preferred over the Traditional FCB File I/O functions unless you must maintain compatibility with DOS version 1.10.  They're easier to use. 
 3cH CREATE file  5bH create new file (must not exist)   5aH create unique/temporary file 
 3dH OPEN file  3eH CLOSE file  41H DELETE file 
 42H LSEEK set read/write pointer (also use to get file size)  3fH READ from file/device  40H WRITE to file/device  44H IOCTL (can be used to test for End Of File) 
 45H DUPlicate file handle  46H REDIRECT file handle I/O 
Traditional FCB File I/O 
These functions operate on the DOS default directory only.  In most cases, it is wise to use the Handle-Oriented File I/O functions. 
 16H create file                      29H parse text into FCB-type filename  0fH open file                        11H  12H search current directory via FCB  10H close file  13H delete file 
 14H read sequential file  15H write sequential file 
 21H read record from random access file  27H read multiple records from random access file 
 22H write record to random access file  28H write multiple-records to random access file (also use to change file size)  24H set random record block field 
Directory and File Functions 
 39H MKDIR: create a new directory       0eH select current default disk  3aH RMDIR: remove a directory           19H query current default disk  3bH CHDIR: select default directory  47H get current default directory 
 56H  17H RENAME file  57H      set/query file TIME/DATE  42H  23H query file SIZE  28H      set file size (Fn 42H can be used to expand a file's length)  43H      CHMOD: change/query the ATTRIBUTE of a file 
 5cH      lock/unlock file access 
 4eH  4fH SEARCH for files via ASCIIZ filename  11H  12H search current directory via FCB 
 29H      parse text into FCB-type filename 
Process Control Functions 
 4bH  EXEC: execute a child process  26H  create Program Segment Prefix (PSP)  62H  Get address of PSP of current process 
 31H and INT 27H  Terminate but Stay Resident 
 00H and INT 20H  traditional program TERMINATE 
 4cH TERMINATE, passing an exit code to the parent process  4dH retrieve exit code of terminated process 
 INT 23H termination via Ctrl-Break  INT 24H termination via Critical Error Handler 
 Program Startup & Exit  conditions when a program starts  Program Segment Prefix (PSP)  EXE File Header Layout 
Memory Control Functions 
 48H ALLOCATE a block of memory (or determine largest available block)  49H FREE an allocated block of memory  4aH SETBLOCK: shrink/expand a memory block  Program Startup & Exit describes memory considerations when a program starts  MCB details the undocumented layout of DOS Memory Control Blocks  PSP fields MemTop and MemAvail are relevant  INT 12H returns total system memory 
Miscellaneous DOS Functions 
 1aH set Disk Transfer Address (DTA)     5cH lock/unlock file access  25H set interrupt vector                5eH network miscellaneous functions  0eH select DOS default disk             5fH network device redirection  0dH reset disk (flush buffers)  29H parse text into FCB-type filename  2bH set system DATE  2dH set system TIME  57H query time/date of a file  2eH set verify status  37H SWITCHAR: set the command 'switch character'  38H select current country  44H IOCTL:channel to communicate with a device driver 
CALLING THE DOS SERVICES 
The DOS services are invoked by placing the number of the desired function in register AH, subfunction in AL, setting the other registers to any specific requirements of the function, and invoking int 21h. 
On return, the requested service will be performed if possible. Most codes will return an error; some return more information. Details are contained in the listings for the individual functions. Extended error return may be obtained by calling function 59h (see 59h). 
Register settings listed are the ones used by DOS. Some functions will return with garbage values in unused registers. Do not test for values in unspecified registers; your program may exhibit odd behavior. 
DS:DX pointers are the data segment register (DS) indexed to the DH and DL registers (DX). DX always contains the offset address, DS contains the segment address. 
The File Control Block services (FCB services) were part of DOS 1.0. Since the release of DOS 2.0, Microsoft has recommended that these services not be used. A set of considerably more enhanced services (handle services) were introduced with DOS 2.0. The handle services provide support for wildcards and subdirectories, and enhanced error detection via function 59h. 
The data for the following calls was compiled from various Intel, Microsoft, IBM, and other publications. There are many subtle differences between MSDOS and PCDOS and between the individual versions. Differences between the versions are noted as they occur. 
There are various ways of calling the DOS functions. For all methods, the function number is loaded into register AH, subfunctions and/or parameters are loaded into AL or other registers, and call int 21 by one of the following methods: 
 A) call interrupt 21h directly  B) perform a long call to offset 50h in the program's PSP.     1) This method will not work under DOS 1.x  C) place the function number in CL and perform an intrasegment call to     location 05h in the current code segment. This location contains a long     call to the DOS function dispatcher.     1) IBM recommends this method be used only when using existing programs        written for different calling conventions. This method should be avoided        unless you some specific use for it     2) AX is always destroyed by this method     3) This method is valid only for functions 00h-24h. 
INT 21H DOS services 
          Function (hex) 
* Indicates Functions not documented in the IBM DOS Technical Reference.  Note some functions have been documented in other Microsoft or licensed OEM documentation. 
00h Terminate Program 
      Ends program, updates, FAT, flushes buffers, restores registers entry   AH      00h         CS      segment address of PSP return  none note 1) Program must place the segment address of the PSP control block in CS         before calling this function.      2) The terminate, ctrl-break,and critical error exit addresses (0Ah, 0Eh,         12h) are restored to the values they had on entry to the terminating         program, from the values saved in the program segment prefix at         locations PSP:000Ah, PSP:000Eh, and PSP:0012h.      3) All file buffers are flushed and the handles opened by the process are         closed.      4) Any files that have changed in length and are not closed are not         recorded properly in the directory.      5) Control transfers to the terminate address.      6) This call performs exactly the same function as int 20h.      7) All memory used by the program is returned to DOS. 
01h Get Keyboard Input 
        Waits for char at STDIN (if nescessary), echoes to STDOUT entry   AH      01h return  AL      char from STDIN (8 bits) note 1) Checks char for Ctrl-C, if char is Ctrl-C, executes int 23h.      2) For function call 06h, extended ASCII codes require two function calls.         The first call returns 00h as an indicator that the next call will be an         extended ASCII code.      3) Input and output are redirectable. If redirected, there is no way to         detect EOF. 
02h Display Output 
      Outputs char in DL to STDOUT entry   AH      02h         DL      8 bit data (usually ASCII character) return  none note 1) If char is 08 (backspace) the cursor is moved 1 char to the left         (nondestructive backspace).      2) If Ctrl-C is detected after input, int 23h is executed.      3) Input and output are redirectable. If redirected, there is no way to         detect disk full. 
03h Auxiliary Input 
      Get (or wait until) character from STDAUX entry   AH      03h return  AL      char from auxiliary device note 1) AUX, COM1, COM2 is unbuffered and not interrupt driven      2) This function call does not return status or error codes. For greater         control it is recommended that you use ROM BIOS routine (int 14h) or         write an AUX device driver and use IOCTL.      3) At startup, PC-DOS initializes the first auxiliary port (COM1) to 2400         baud, no parity, one stop bit, and an 8-bit word. MSDOS may differ.      4) If Ctrl-C is has been entered from STDIN, int 23h is executed. 
04h Auxiliary Output 
      Write character to STDAUX entry   AH      04h         DL      char to send to AUX return  none note 1) This function call does not return status or error codes. For greater         control it is recommended that you use ROM BIOS routine (int 14h) or         write an AUX device driver and use IOCTL.      2) If Ctrl-C is has been entered from STDIN, int 23h is executed.      3) Default is COM1 unless redirected by DOS.      4) If the device is busy, this function will wait until it is ready. 
05h Printer Output 
      Write character to STDPRN entry   AL      05h         DL      character to send return  none note 1) If Ctrl-C is has been entered from STDIN, int 23h is executed.      2) Default is PRN or LPT1 unless redirected with the MODE command.      3) If the printer is busy, this function will wait until it is ready. 
06h Direct Console I/O 
      Get character from STDIN; echo character to STDOUT entry   AH      06h         DL      0FFh for console input, or 00h-0FEh for console output return  ZF      zero flag set   (1) = no character                 zero flag clear (0) = character recieved         AL      character note 1) Extended ASCII codes require two function calls. The first call returns         00h to indicate the next call will return an extended code.      2) If DL is not 0FFh, DL is assumed to have a valid character that is         output to STDOUT.      3) This function does not check for Ctrl-C or Ctrl-PrtSc.      4) Does not echo input to screen      5) If I/O is redirected, EOF or disk full cannot be detected. 
07h Direct Console Input Without Echo (does not check BREAK) 
      Get or wait for char at STDIN, returns char in AL entry   AH      07h return  AL      character from standard input device note 1) Extended ASCII codes require two function calls. The first call returns         00h to indicate the next call will return an extended code.      2) No checking for Ctrl-C or Ctrl-PrtSc is done.      3) Input is redirectable. 
08h Console Input Without Echo (checks BREAK) 
      Get or Wait for char at STDIN, return char in AL entry   AH      08h return  AL      char from standard input device note 1) Char is checked for ctrl-C. If ctrl-C is detected, executes int 23h.      2) For function call 08h, extended ASCII characters require two function         calls. The first call returns 00h to signify an extended ASCII code.         The next call returns the actual code.      3) Input is redirectable. If redirected, there is no way to check EOF. 
09h Print String 
      Outputs Characters in the Print String to the STDOUT entry   AH      09h         DS:DX   pointer to the Character String to be displayed return  none note 1) The character string in memory must be terminated by a $ (24h)         The $ is not displayed.      2) Output to STDOUT is the same as function call 02h. 
0Ah Buffered Keyboard Input 
      Reads characters from STDIN and places them in the buffer beginning       at the third byte. entry   AH      0Ah         DS:DX   pointer to an input buffer return  none note 1) Min buffer size = 1, max = 255      2) Char is checked for ctrl-C. If ctrl-C is detected, executes int 23h.      3) Format of buffer DX:         byte       contents          1      Maximum number of chars the buffer will take, including CR.                 Reading STDIN and filling the buffer continues until a carriage                 return (<Enter> or 0Dh) is read. If the buffer fills to one less                 than the maximum number the buffer can hold, each additional                 number read is ignored and ASCII 7 (BEL) is output to the                 display until a carriage return is read. (you must set this                 value)          2      Actual number of characters received, excluding the carriage                 return, which is always the last character. (the function sets                 this value)          3-n    Characters received are placed into the buffer starting here.                 Buffer must be at least as long as the number in byte 1.      4) Input is redirectable. If redirected, there is no way to check EOF.      5) The string may be edited with the standard DOS editing commands as it         is being entered.      6) Extended ASCII characters are stored as 2 bytes, the first byte being         zero. 
0Bh Check Standard Input (STDIN) status 
      Checks for character availible at STDIN entry   AH      0Bh return  AL      0FFh    if a character is availible from STDIN                 00h     if no character is availible from STDIN note 1) Checks for Ctrl-C. If Ctrl-C is detected, int 23h is executed      2) Input can be redirected.      3) Checks for character only, it is not read into the application 
0Ch Clear Keyboard Buffer & Invoke a Keyboard Function (FCB) 
      Dumps buffer, executes function in AL (01h,06h,07h,08h,0Ah only) entry   AH      0Ch         AL      function number (must be 01h, 06h, 07h, 08h, or 0Ah) return  AL      00h     buffer was flushed, no other processing performed                 other   any other value has no meaning note 1) Forces system to wait until a character is typed.      2) Flushes all typeahead input, then executes function specified by AL (by         moving it to AH and repeating the int 21 call).      3) If AL contains a value not in the list above, the keyboard buffer is         flushed and no other action is taken. 
0Dh Disk Reset 
      Flushes all currently open file buffers to disk entry   AH      0Dh return          none note 1) Does not close files. Does not update directory entries; files changed         in size but not closed are not properly recorded in the directory      2) Sets DTA address to DS:0080h      3) Should be used before a disk change, Ctrl-C handlers, and to flush         the buffers to disk. 
0Eh Select Disk 
      Sets the drive specified in DL (if valid) as the default drive entry   AL      0Eh         DL      new default drive number (0=A:,1=B:,2=C:,etc.) return  AL      total number of logical drives (not nescessarily physical) note 1) For DOS 1.x and 2.x, the minimum value for AL is 2.      2) For DOS 3.x, the minimum value for AL is 5.      3) The drive number returned is not nescessarily a valid drive.      4) For DOS 1.x: 16 logical drives are availible. A-P.         For DOS 2.x: 63 logical drives are availible. (Letters are only used for                      the first 26 drives. If more than 26 logical drives are                      used, further drive letters will be other ASCII characters                      ie {,], etc.         For DOS 3.x: 26 logical drives are availible. A-Z. 0Fh   Open Disk File;                                                    (FCB)       Searches current directory for specified filename and opens it entry   AH      0Fh         DS:DX   pointer to an unopened FCB return  AL      00h     if file found                 0FFh    if file not not found note 1) If the drive code was 0 (default drive) it is changed to the actual         drive used (1=A:,2=B:,3=C:, etc). This allows changing the default drive         without interfering with subsequent operations on this file.      2) The current block field (FCB bytes C-D, offset 0Ch) is set to zero.      3) The size of the record to be worked with (FCB bytes E-F, offset 0Eh) is         set to the system default of 80h. The size of the file (offset 10h) and         the date (offset 14h) are set from information obtained in the root         directory. You can change the default value for the record size (FCB         bytes E-F) or set the random record size and/or current record field.         Perform these actions after the open but before any disk operations.      4) The file is opened in compatibility mode.      5) Microsoft recommends handle function call 3Dh be used instead.      6) This call is also used by the APPEND command in DOS 3.2+      7) Before performing a sequential disk operation on the file, you must         set the Current Record field (offset 20h). Before performing a random         disk operation on the file, you must set the Relative Record field         (offset 21h). If the default record size of 128 bytes is incorrect, set         it to the correct value. 
10h Close File (FCB) 
     Closes a File After a File Write entry   AH      10h         DS:DX   pointer to an opened FCB return  AL      00h     if the file is found and closed                 0FFh    if the file is not found in the current directory note 1) This function call must be done on open files that are no longer needed,         and after file writes to insure all directory information is updated.      2) If the file is not found in its correct position in the current         directory, it is assumed that the diskette was changed and AL returns         0FFh. This error return is reportedly not completely reliable with DOS         version 2.x.      3) If found, the directory is updated to reflect the status in the FCB, the         buffers to that file are flushed, and AL returns 00h. 
11h Search For First Matching Entry (FCB) 
      Searches current disk & directory for first matching filename entry   AH      11h         DS:DX   pointer to address of FCB return  AL      00h     successful match                 0FFh    no matching filename found note 1) The FCB may contain the wildcard character ? under Dos 2.x, and ? or *         under 3.x.      2) The original FCB at DS:DX contains information to continue the search         with function 12h, and should not be modified.      3) If a matching filename is found, AL returns 00h and the locations at the         Disk Transfer Address are set as follows:         a) If the FCB provided for searching was an extended FCB, then the first            byte at the disk transfer address is set to 0FFh followed by 5 bytes            of zeroes, then the attribute byte from the search FCB, then the            drive number used (1=A, 2=B, etc) then the 32 bytes of the directory            entry. Thus, the disk transfer address contains a valid unopened FCB            with the same search attributes as the search FCB.         b) If the FCB provided for searching was a standard FCB, then the first            byte is set to the drive number used (1=A,2=b,etc), and the next 32            bytes contain the matching directory entry. Thus, the disk transfer            address contains a valid unopened normal FCB.      4) If an extended FCB is used, the following search pattern is used:         a) If the FCB attribute byte is zero, only normal file entries are            found. Entries for volume label, subdirectories, hidden or system            files, are not returned.         b) If the attribute byte is set for hidden or system files, or            subdirectory entries, it is to be considered as an inclusive search.            All normal file entries plus all entries matching the specified            attributes are returned. To look at all directory entries except the            volume label, the attribute byte may be set to hidden + system +            directory (all 3 bits on).         c) If the attribute field is set for the volume label, it is considered            an exclusive search, and ONLY the volume label entry is returned.      5) This call is also used by the APPEND command in DOS 3.2+ 
12h Search For Next Entry Using FCB 
      Search for next matching filename entry   AH      12h         DS:DX   pointer to the unopened FCB specified from the previous Search                 First (11h) or Search Next (12h) return  AL      00h     if matching filename found                 0FFh    if matching filename was not found note 1) After a matching filename has been found using function call 11h,         function 12h may be called to find the next match to an ambiguous         request. For DOS 2.x, ?'s are allowed in the filename. For DOS 3.x,         global (*) filename characters are allowed.      2) The DTA contains info from the previous Search First or Search Next.      3) All of the FCB except for the name/extension field is used to keep         information nescessary for continuing the search, so no disk operations         may be performed with this FCB between a previous function 11h or 12h         call and this one.      4) If the file is found, an FCB is created at the DTA address and set up to         open or delete it. 
13h Delete File Via FCB 
      Deletes file specified in FCB from current directory entry   AH      13h         DS:DX   pointer to address of FCB return  AL      00h     file deleted                 0FFh    if file not found or was read-only note 1) All matching current directory entries are deleted. The global filename         character "?" is allowed in the filename.      2) Will not delete files with read-only attribute set      3) Close open files before deleting them.      4) Requires Network Access Rights 
14h Sequential Disk File Read (FCB) 
      Reads record sequentially from disk via FCB entry   AH  14h         DS:DX   pointer to an opened FCB return  AL      00h     successful read                 01h     end of file (no data read)                 02h     Data Transfer Area too small for record size specified                         or segment overflow                 03h     partial record read, EOF found note 1) The record size is set to the value at offset 0Eh in the FCB.      2) The record pointed to by the Current Block (offset 0Ch) and the Current         Record (offset 20h) fields is loaded at the DTA, then the Current Block         and Current Record fields are incremented.      3) The record is read into memory at the current DTA address as specified         by the most recent call to function 1Ah. If the size of the record and         location of the DTA are such that a segment overflow or wraparound would         occur, the error return is set to AL=02h      4) If a partial record is read at the end of the file, it is passed to the         requested size with zeroes and the error return is set to AL=03h. 
15h Sequential Disk Write (FCB) 
      Writes record specified by FCB sequentially to disk entry   AH      15h         DS:DX   pointer to address of FCB return  AL      00h     successful write                 01h     diskette full, write canceled                 02h     disk transfer area (DTA) too small or segment wrap note 1) The data to write is obtained from the disk transfer area      2) The record size is set to the value at offset 0Eh in the FCB.      3) This service cannot write to files set as read-only      4) The record pointed to by the Current Block (offset 0Ch) and the Current         Record (offset 20h) fields is loaded at the DTA, then the Current Block         and Current Record fields are incremented.      5) If the record size is less than a sector, the data in the DTA is written         to a buffer; the buffer is written to disk when it contains a full         sector of data, the file is closed, or a Reset Disk (function 0Dh) is         issued.      6) The record is written to disk at the current DTA address as specified         by the most recent call to function 1Ah. If the size of the record and         location of the DTA are such that a segment overflow or wraparound would         occur, the error return is set to AL=02h 
16h Create A Disk File (FCB) 
      Search and open or create directory entry for file entry   AH      16h         DS:DX   pointer to an FCB return  AL      00h     successful creation                 0FFh    no room in directory note 1) If a matching directory entry is found, the file is truncated to zero         bytes.      2) If there is no matching filename, a filename is created.      3) This function calls function 0Fh (Open File) after creating or         truncating a file.      4) A hidden file can be created by using an extended FCB with the attribute         byte (offset FCB-1) set to 2. 
17h Rename File Specified by File Control Block (FCB) 
      Renames file in current directory entry   AH      17h         DS:DX   pointer to an FCB (see note 4) return  AL      00h     successfully renamed                 0FFh    file not found or filename already exists note 1) This service cannot rename read-only files      2) The "?" wildcard may be used.      3) If the "?" wildcard is used in the second filename, the corresponding         letters in the filename of the directory entry are not changed.      4) The FCB must have a drive number, filename, and extension in the usual         position, and a second filename starting 6 bytes after the first, at         offset 11h.      5) The two filenames cannot have the same name.      6) FCB contains new name starting at byte 17h. 
18h Internal to DOS 
 *   Unknown entry   AH      18h return  AL      0 
19h Get Current Disk Drive 
      Return designation of current default disk drive entry   AH      19h return  AL      current default drive (0=A, 1=B,etc.) note    Some other DOS functions use 0 for default, 1=A, 2=B, etc. 
1Ah Set Disk Transfer Area Address (DTA) 
      Sets DTA address to the address specified in DS:DX entry   AH      1Ah         DS:DX   pointer to buffer return  none note 1) The default DTA is 128 bytes at offset 80h in the PSP. DOS uses the         DTA for all file I/O.      2) Registers are unchanged.      3) No error codes are returned.      2) Disk transfers cannot wrap around from the end of the segment to the         beginning or overflow into another segment. 
1Bh Get Current Drive File Allocation Table Information 
      Returns information from the FAT on the current drive entry   AH      1Bh exit    AL      number of sectors per allocation unit (cluster)         DS:BX   address of the current drive's media descriptor byte         CX      number of bytes per sector         DX      number of allocation units (clusters) for default drive note 1) Save DS before calling this function.      2) This call returned a pointer to the FAT in DOS 1.x. Beginning with         DOS 2.00, it returns a pointer only to the table's ID byte.      3) IBM recommends programmers avoid this call and use int 25h instead. 
1Ch Get File Allocation Table Information for Specific Device 
      Returns information on specified drive entry   AH      1Ch         DL      drive number (1=A, 2=B, 3=C, etc) return  AL      number of sectors per allocation unit (cluster)         DS:BX   address of media descriptor byte for drive in DL         CX      sector size in bytes         DX      number of allocation units (clusters) note 1) DL = 0 for default.      2) Save DS before calling this function.      3) Format of media-descriptor byte:         bits:   0       0   (clear)   not double sided                         1   (set)     double sided                 1       0   (clear)   not 8 sector                         1   (set)     8 sector                 2       0   (clear)   nonremovable device                         1   (set)     removable device                 3-7     always set (1)      4) This call returned a pointer to the FAT in DOS 1.x. Beginning with         DOS 2.00, it returns a pointer only to the table's ID byte.      5) IBM recommends programmers avoid this call and use int 25h instead. 
1Dh Not Documented by Microsoft 
 *    Unknown entry   AH      1Dh return  AL      0 
1Eh Not Documented by Microsoft 
 *    Unknown entry   AH      1Eh return  AL      0 note    Apparently does nothing 
1Fh Get Default Drive Parameter Block 
 *  Same as function call 32h (below), except that the table is accessed from     the default drive entry   AH      1Fh         other registers unknown return  AL      00h     no error                 0FFh    error         DS:BX   points to DOS Disk Parameter Block for default drive. note 1) Unknown vector returned in ES:BX.      2) For DOS 2.x and 3.x, this just invokes function 32h (undocumented,         Read DOS Disk Block) with DL=0 
20h Unknown 
 *   Internal - does nothing? entry   AH      20h return  AL      0 
21h Random Read from File Specified by FCB 
     Reads one record as specified in the FCB into the current DTA. entry   AH      21h         DS:DX   address of the opened FCB return  AL      00h     successful read operation                 01h     end of file (EOF), no data read                 02h     DTA too small for the record size specified                 03h     end of file (EOF), partial data read note 1) The current block and current record fields are set to agree with the         random record field. Then the record addressed by these fields is read         into memory at the current Disk Transfer Address.      2) The current file pointers are NOT incremented this function.      3) If the DTA is larger than the file, the file is padded to the requested         length with zeroes. 
22h Random Write to File Specified by FCB 
     Writes one record as specified in the FCB to the current DTA entry   AH      22h         DS:DX   address of the opened FCB return  AL      00h     successful write operation                 01h     disk full; no data written (write was canceled)                 02h     DTA too small for the record size specified (write was                         canceled) note 1) This service cannot write to read-only files.      2) The record pointed to by the Current Block (offset 0Ch) and the Current         Record (offset 20h) fields is loaded at the DTA, then the Current Block         and Current Record fields are incremented.      3) If the record size is less than a sector, the data in the DTA is written         to a buffer; the buffer is written to disk when it contains a full         sector of data, the file is closed, or a Reset Disk (function 0Dh) is         issued.      4) The current file pointers are NOT incremented this function.      5) The record is written to disk at the current DTA address as specified         by the most recent call to function 1Ah. If the size of the record and         location of the DTA are such that a segment overflow or wraparound would         occur, the error return is set to AL=02h 
23h Get File Size (FCB) 
     Searches current subdirectory for matching file, returns size in FCB entry   AH      23h         DS:DX   address of an unopened FCB return  AL      00h file found                 0FFh file not found note 1) Record size field (offset 0Eh) must be set before invoking this function      2) The disk directory is searched for the matching entry. If a matching         entry is found, the random record field is set to the number of records         in the file. If the value of the Record Size field is not an even         divisor of the file size, the value set in the relative record field is         rounded up. This gives a returned value larger than the actual file size      3) This call is used by the APPEND command in DOS 3.2+ 
24h Set Relative Record Field (FCB) 
     Set random record field specified by an FCB entry   AH      24h         DS:DX   address of an opened FCB return  Random Record Field of FCB is set to be same as Current Block         and Current Record. note 1) You must invoke this function before performing random file access.      2) The relative record field of FCB (offset 21h) is set to be same as the         Current Block (offset 0Ch) and Current Record (offset 20h).      3) No error codes are returned.      4) The FCB must already be opened. 
25h Set Interrupt Vector 
     Sets the address of the code DOS is to perform each time the specified      interrupt is invoked. entry   AH      25h         AL      int number to reassign the handler to         DS:DX   address of new interrupt vector return  none note 1) Registers are unchanged.      2) No error codes are returned.      3) The interrupt vector table for the interrupt number specified in AL         is set to the address contained in DS:DX. Use function 35h (Get Vector)         to get the contents of the interrupt vector and save it for later use.      4) When you use function 25 to set an interrupt vector, DOS 3.2 doesn't         point the actual interrupt vector to what you requested. Instead, it         sets the interrupt vector to point to a routine inside DOS, which does         this:                 1. Save old stack pointer                 2. Switch to new stack pointer allocated from DOS's stack pool                 3. Call your routine                 4. Restore old stack pointer         The purpose for this was to avoid possible stack overflows when there         are a large number of active interrupts. IBM was concerned (this was an         IBM change, not Microsoft) that on a Token Ring network there would be         a lot of interrupts going on, and applications that hadn't allocated         very much stack space would get clobbered. 
26h Create New Program Segment Prefix (PSP) 
     This service copies the current program-segment prefix to a new memory      location for the creation of a new program or overlay. Once the new PSP is      in place, a DOS program can read a DOS COM or overlay file into the memory      location immediately following the new PSP and pass control to it. entry   AH      26h         DX      segment number for the new PSP return  none note 1) Microsoft recommends you use the newer DOS service 4Bh (EXEC) instead.      2) The entire 100h area at location 0 in the current PSP is copied into         location 0 of the new PSP. The memory size information at location 6         in the new segment is updated and the current termination, ctrl-break,         and critical error addresses from interrupt vector table entries for         ints 22h, 23h, and 24 are saved in the new program segment starting at         0Ah. They are restored from this area when the program terminates.      3) Current PSP is copied to specified segment 
27h Random Block Read From File Specified by FCB 
     Similar to 21h (Random Read) except allows multiple files to be read. entry   AH      27h         CX      number of records to be read         DS:DX   address of an opened FCB return  AL      00h     successful read                 01h     end of file, no data read                 02h     DTA too small for record size specified (read canceled)                 03h     end of file         CX      actual number of records read (includes partial if AL=03h) note 1) The record size is specified in the FCB. The service updates the Current         Block (offset 0Ch) and Current Record (offset 20h) fields to the next         record not read.      2) If CX contained 0 on entry, this is a NOP.      3) If the DTA is larger than the file, the file is padded to the requested         length with zeroes.      4) This function assumes that the FCB record size field (0Eh) is correctly         set. If not set by the user, the default is 128 bytes.      5) The record is written to disk at the current DTA address as specified         by the most recent call to function 1Ah. If the size of the record and         location of the DTA are such that a segment overflow or wraparound would         occur, the error return is set to AL=02h 
28h Random Block Write to File Specified in FCB 
     Similar to 27h (Random Write) except allows multiple files to be read. entry   AH      28h         CX      number of records to write         DS:DX   address of an opened FCB return  AL      00h     successful write                 01h     disk full, no data written                 02h     DTA too small for record size specified (write canceled)         CX      number of records written note 1) The record size is specified in the FCB.      2) This service allocates disk clusters as required.      3) This function assumes that the FCB Record Size field (offset 0Eh) is         correctly set. If not set by the user, the default is 128 bytes.      4) The record size is specified in the FCB. The service updates the Current         Block (offset 0Ch) and Current Record (offset 20h) fields to the next         record not read.      5) The record is written to disk at the current DTA address as specified         by the most recent call to function 1Ah. If the size of the record and         location of the DTA are such that a segment overflow or wraparound would         occur, the error return is set to AL=02h      6) If called with CX=0, no records are written, but the FCB's File Size         entry (offset 1Ch) is set to the size specified by the FCB's Relative         Record field (offset 21h). 
29h Parse the Command Line for Filename (FCB) 
     Parses a text string into the fields of a File Control Block entry   AH      29h         DS:SI   pointer to string to parse         ES:DI   pointer to memory buffer to fill with unopened FCB         AL      bit mask to control parsing                 bit 0 = 0: parsing stops if file seperator found                         1: causes service to scan past leading chars such as                            blanks. Otherwise assumes the filename begins in                            the first byte                     1 = 0: drive number in FCB set to default (0) if string                            contains no drive number                         1: drive number in FCB not changed                     2 = 0: filename in FCB set to 8 blanks if no filename in                            string                         1: filename in FCB not changed if string does not                            contain a filename                     3 = 0: extension in FCB set to 3 blanks if no extension in                            string                         1: extension left unchanged                     4-7    must be zero return  AL      00h     no wildcards in name or extension                 01h     wildcards appeared in name or extension                 0FFh    invalid drive specifier         DS:SI   pointer to the first character after the parsed string         ES:DI   pointer to the unopened FCB note 1) If the * wildcard characters are found in the command line, this service         will replace all subsequent chars in the FCB with question marks.      2) This service uses the characters as filename separators         DOS 1       : ; . , + / [ ] = " TAB SPACE         DOS 2,3     : ; . , + = TAB SPACE      3) This service uses the characters         : ; . , + < > | / \ [ ] = " TAB SPACE         or any control characters as valid filename separators      4) A filename cannot contain a filename terminator. If one is encountered,         all processing stops. The handle functions will allow use of some of         these characters.      5) If no valid filename was found on the command line, ES:DI +1 points         to a blank (ASCII 32).      6) This function cannot be used with filespecs which include a path      7) Parsing is in the form D:FILENAME.EXT. If one is found, a corresponding         unopened FCB is built at ES:DI 
2Ah Get Date 
     Returns day of the week, year, month, and date entry   AH      2Ah return  CX      year    (1980-2099)         DH      month   (1-12)         DL      day     (1-31)         AL      weekday 00h     Sunday                         01h     Monday                         02h     Tuesday                         03h     Wednesday                         04h     Thursday                         05h     Friday                         06h     Saturday note 1) Date is adjusted automatically if clock rolls over to the next day,         and takes leap years and number of days in each month into account.      2) Although DOS cannot set an invalid date, it can read one, such as         1/32/80, etc.      3) DesQview also accepts CX = 4445h and DX = 5351h, i.e. 'DESQ' as valid      4) DOS will accept CH=0 (midnight) as a valid time, but if a file's time         is set to exactly midnight the time will not be displayed by the DIR         command. 
2Bh Set Date 
     set current system date entry   AH      2Bh         CX      year    (1980-2099)         DH      month   (1-12)         DL      day     (1-31) return  AL      00h     no error (valid date)                 0FFh    invalid date specified note 1) On entry, CX:DX must have a valid date in the same format as returned         by function call 2Ah      2) DOS 3.3 also sets CMOS clock 
2Ch Get Time 
     Get current system time from CLOCK$ driver entry   AH      2Ch return  CH      hours   (0-23)         CL      minutes (0-59)         DH      seconds (0-59)         DL      hundredths of a second (0-99) note 1) Time is updated every 5/100 second.      2) The date and time are in binary format 
2Dh Set Time 
     Sets current system time entry   AH      2Dh         CH      hours   (0-23)         CL      minutes (0-59)         DH      seconds (0-59)         DL      hundredths of seconds (0-99) return  AL      00h     if no error                 0FFh    if bad value sent to routine note 1) DOS 3.3 also sets CMOS clock      2) CX and DX must contain a valid time in binary 
2Eh Set/Reset Verify Switch 
     Set verify flag entry   AH      2Eh         AL      00      to turn verify off (default)                 01      to turn verify on return  none note 1) This is the call invoked by the DOS VERIFY command      2) Setting of the verify switch can be obtained by calling call 54h      3) This call is not supported on network drives      4) DOS checks this flag each time it accesses a disk 
2Fh Get Disk Transfer Address (DTA) 
     Returns current disk transfer address used by all DOS read/write operations entry   AH      2Fh return  ES:BX   address of DTA note 1) The DTA is set by function call 1Ah      2) Default DTA address is a 128 byte buffer at offset 80h in that program's         Program Segment Prefix 
30h Get DOS Version Number 
     Return DOS version and/or user number entry   AH      30h return  AH      minor version number  (i.e., DOS 2.10 returns AX = 0A02h)         AL      major version number         BH      OEM ID number                 00h     IBM                 16h     DEC         BL:CX   24-bit user serial number note 1) If AL returns a major version number of zero, the DOS version is         below 1.28 for MSDOS and below 2.00 for PCDOS.      2) IBM PC-DOS always returns 0000h in BX and CX. 
31h Terminate Process and Stay Resident 
     KEEP, or TSR entry   AH      31h         AL      exit code         DX      program memory requirement in 16 byte paragraphs return  AX      return code (retrieveable by function 4Dh) note 1) Files opened by the application are not closed when this call is made      2) Memory can be used more efficiently if the block containing the copy of         the DOS environment is deallocated before terminating. This can be done         by loading ES with the segment contained in 2Ch of the PSP and issuing         function call 49h (Free Allocated Memory).      3) Unlike int 27h, more than 64k may be made resident with this call 
32h Read DOS Disk Block 
 *   Retrieve the pointer to the drive parameter block for a drive entry   AH      32h         DL      drive (0=default, 1=A:, etc.). return  AL      00h     if drive is valid                 0FFh    if drive is not valid         DS:BX   points to DOS Drive Parameter Table.  Format of block:                 Bytes   Type        Value                 00h     byte    Drive: 0=A:, 1=B:, etc.                 01h     byte    Unit within drive (0, 1, 2, etc.)                 02h-03h word    Bytes per sector                 04h     byte    Sectors per cluster - 1                 05h     byte    Cluster to sector shift (i.e., how far to shift-                                 left the bytes/sector to get bytes/cluster)                 06h-07h word    Number of reserved (boot) sectors                 08h     byte    Number of FATs                 09h-0Ah word    Number of root directory entries                 0Bh-0Ch word    Sector # of 1st data. Should be same as # of                                 sectors/track.                 0Dh-0Eh word    # of clusters + 1 (=last cluster #)                 0Fh     byte    Sectors for FAT                 10h-11h word    First sector of root directory                 12h-15h dword   Address of device driver header for this drive                 16h     byte    Media Descriptor Byte for this drive                 17h     byte    Zero if disk has been accessed                 18h-1Bh dword   address of next DOS Disk Block (0FFFFh means                                 last in chain)                 22h     byte    Current Working Directory (2.0 only) (64 bytes) note 1) Use [BX+0D] to find no. of clusters (>1000H, 16-bit FAT; if not, 12-bit         (exact dividing line is probably a little below 1000h to allow for         bad sectors, EOF markers, etc.)      2) Short article by C.Petzold, PC Magazine  Vol.5,no.8, and the article         "Finding Disk Parameters" in the May 1986 issue of PC Tech Journal.      3) This call is mostly supported in OS/2 1.0's DOS Compatibility Box. The         dword at 12h will not return the address of the next device driver when         in the Compatibility Box. 
33h Control-Break Check 
     Get or set control-break checking at CON entry   AH      33h         AL      00h     to test for break checking                 01h     to set break checking                         DL      00h     to disable break checking                                 01h     to enable break checking                 02h     internal, called by PRINT.COM (DOS 3.1) return  DL      00h     if break=off                 01h     if break=on         AL      0FFh    error 
34h Return INDOS Flag 
 *   Returns ES:BX pointing to Critical Section Flag, byte indicating whether      it is safe to interrupt DOS. entry   AH      34h return  ES:BX   points to DOS "critical section flag" note 1) If byte is 0, it is safe to interrupt DOS. This was mentioned in some         documentation by Microsoft on a TSR standard, and PC Magazine reports         it functions reliably under DOS versions 2.0 through 3.3. Chris         Dunford (of CED fame) and a number of anonymous messages on the BBSs         indicate it may not be totally reliable.      2) The byte at ES:BX+1 is used by the Print program for this same purpose,         so it's probably safer to check the WORD at ES:BX.      3) Reportedly, examination of DOS 2.10 code in this area indicates that the         byte immediately following this "critical section flag" must be 00h to         permit the PRINT.COM interrupt to be called. For DOS 3.0 and 3.1 (except         Compaq DOS 3.0), the byte before the "critical section flag" must be         zero; for Compaq DOS 3.0, the byte 01AAh before it must be zero.      4) In DOS 3.10 this reportedly changed to word value, with preceding byte.      5) This call is supported in OS/2 1.0's DOS Compatibility Box      6) Gordon Letwin of Microsoft discussed this call on ARPAnet in 1984. He         stated:         a) this is not supported under any version of the DOS         b) it usually works under DOS 2, but there may be circumstances            when it doesn't (general disclaimer, don't know of a specific            circumstance)         c) it will usually not work under DOS 3 and DOS 3.1; the DOS is            considerably restructured and this flag takes on additional            meanings and uses         d) it will fail catastrophically under DOS 4.0 and forward.         Obviously this information is incorrect since the call works fine         through DOS 3.3. Microsoft glasnost? 
35h Get Vector 
     Get interrupt vector entry   AH      35h         AL      interrupt number (hexadecimal) return  ES:BX   address of interrupt vector note    Use function call 25h to set the interrupt vectors 
36h Get Disk Free Space 
     get information on specified drive entry   AH      36h         DL      drive number (0=default, 1=A:, 2=B:, etc) return  AX      number of sectors per cluster                 0FFFFh means drive specified in DL is invalid         BX      number of availible clusters         CX      bytes per sector         DX      clusters per drive note 1) Mult AX * CX * BX for free space on disk      2) Mult AX * CX * DX for total disk space      3) Function 36h returns an incorrect value after an ASSIGN command. Prior         to ASSIGN, the DX register contains 0943h on return, which is the free         space in clusters on the HC diskette. After ASSIGN, even with no         parameters, 0901h is returned in the DX register; this is an incorrect         value. Similar results occur with DD diskettes on a PC-XT or a PC-AT.         This occurs only when the disk is not the default drive. Results are as         expected when the drive is the default drive. Therefore, the         circumvention is to make the desired drive the default drive prior to         issuing this function call.      4) Int 21h, function call 36h returns an incorrect value after an ASSIGN         command. Prior to ASSIGN, the DX register contains 0943h on return,         which is the free space in clusters on the HC diskette. After ASSIGN,         even with no parameters, 0901h is returned in the DX register; this is         an incorrect value. Similar results occur with DD diskettes on a PC-XT         or a PC-AT. This occurs only when the disk is not the default drive.         Results are as expected when the drive is the default drive. Therefore,         the circumvention is to make the desired drive the default drive prior         to issuing this function call.      5) This function supercedes functions 1Bh and 1Ch. 
37h SWITCHAR / AVAILDEV 
 *   Get/set option marking character (is usually "/"), and device type entry   AH      37h         AL      00h     read switch character (returns current character in DL)                 01h     set character in DL as new switch character       (DOS 2.x) 02h     read device availability (as set by function AL=3) into                         DL. A 0 means devices that devices must be accessed in                         file I/O calls by /dev/device. A non-zero value means                         that devices are accessible at every level of the                         directory tree (e.g., PRN is the printer and not a file                         PRN).                         AL=2 to return flag in DL, AL=3 to set from DL (0 = set,                         1 = not set).       (DOS 2.x) 03h     get device availability, where:         DL      00h     means /dev/ must precede device names                 01h     means /dev/ need not precede device names return  DL      switch character (if AL=0 or 1)                 device availability flag (if AL=2 or 3)         AL      0FFh    the value in AL was not in the range 0-3. note 1) Functions 2 & 3 appear not to be implemented for DOS 3.x.      2) It is documented on page 4.324 of the MS-DOS (version 2) Programmer's         Utility Pack (Microsoft - published by Zenith).      3) Works on all versions of IBM PC-DOS from 2.0 through 3.3.1.      4) The SWITCHAR is the character used for "switches" in DOS command         arguments (defaults to '/', as in "DIR/P"). '-' is popular to make a         system look more like UNIX; if the SWITCHAR is anything other than '/',         then '/' may be used instead of '\' for pathnames      5) Ignored by XCOPY, PKARC, LIST      6) SWITCHAR may not be set to any character used in a filename      7) In DOS 3.x you can still read the "AVAILDEV" byte with subfunction 02h         but it always returns 0FFh even if you try to change it to 0 with         subfunction 03h.      8) AVAILDEV=0 means that devices must be referenced in an imaginary         subdirectory "\dev" (similar to UNIX's /dev/*); a filename "PRN.DAT"         can be created on disk and manipulated like any other. If AVAILDEV != 0         then device names are recognized anywhere (this is the default):         "PRN.DAT" is synonymous with "PRN:".      9) These functions reportedly are not supported in the same fashion in         various implementations of DOS. 
38h Return Country Dependent Information 
(PCDOS 2.0, 2.1, MSDOS 2.00 only) get country-dependent information 
entry   AH      38h         AL      function code  (must be 0 in DOS 2.x)         DS:DX   pointer to 32 byte memory area return  AX      error code if CF set         DS:DX   country data if CF not set                 word    date/time format                         0 = USA standard       H:M:S   M/D/Y                         1 = European standard  H:M:S   D/M/Y                         2 = Japanese standard  H:M:S   D:M:Y                 byte    ASCIIZ string currency symbol followed by byte of zeroes                 byte    ASCIIZ string thousands separator followed by byte of                         zeroes                 byte    ASCIIZ string decimal separator followed by byte of                         zeroes              24 bytes   reserved 
38h Get Country Dependent Information 
(PCDOS 3.x+, MSDOS 2.01+) get country-dependent information 
entry   AH      38h         AL      function code                 00h     to get current country information                 code    country code to get information for, for countries                         with codes less than 255                 0FFh    to get country information for countries with a code                         greater than 255         BX      16 bit country code if AL=0FFh         DS:DX   pointer to the memory buffer where the data will be returned return  CF      0 (clear) function completed                 1 (set) error                    AX   error code if CF set                         2  invalid country code (no table for it)         BX      country code (usually international telephone code)         DS:DX   country data if CF not set                 word    date/time format                         0 = USA standard       H:M:S   M/D/Y                         1 = European standard  H:M:S   D/M/Y                         2 = Japanese standard  H:M:S   D:M:Y               5 bytes   currency symbol null terminated               2 bytes   thousands separator null terminated               2 bytes   decimal separator null terminated               2 bytes   date separator null terminated               2 bytes   time separator null terminated                 byte    bit field currency format                         bit 0 = 0  if currency symbol precedes the value                                 1  if currency symbol is after the value                         bit 1 = 0  no spaces between value and currency symbol                                 1  one space between value and currency symbol                         bits 2-7   not defined by Microsoft                 byte    number of significant decimal digits in currency                         (number of places to right of decimal point)                 byte    time format                         bit 0 = 0  12 hour clock                         bit 0 = 1  24 hour clock               2 words   case map call address                         entry   AL  ASCII code of character to be converted to                                     uppercase                         return  AL  ASCII code of the uppercase input character               2 bytes   data list separator null terminated               5 words   reserved note 1) When an alternate keyboard handler is invoked, the keyboard routine is         loaded into user memory starting at the lowest portion of availible         user memory. The BIOS interrupt vector that services the keyboard is         redirected to the memory area where the new routine resides. Each new         routine takes up about 1.6K of memory and has lookup tables that return         values unique to each language. (KEYBxx in the DOS book)          Once the keyboard interrupt vector is changed by the DOS keyboard         routine, the new routine services all calls unless the system is         returned to the US format by the ctrl-alt-F1 keystroke combination. This         does not change the interrupt vector back to the BIOS location; it         merely passes the table lookup to the ROM locations.      2) Ctrl-Alt-F1 will only change systems with US ROMS to the US layout.         Some systems are delivered with non-US keyboard handler routines in ROM      3) Case mapping call: the segment/offset of a FAR procedure that performs         country-specific lower-to-upper case mapping on ASCII characters 80h to         0FFh. It is called with the character to be mapped in AL. If there is         an uppercase code for the letter, it is returned in AL, if there is no         code or the function was called with a value of less than 80h AL is         returned unchanged. 
38h Set Country Dependent Information 
     set country-dependent information entry   AH      38h         AL      code    country code to set information for, for countries                         with codes less than 255                 0FFh    to set country information for countries with a code                         greater than 255         BX      16 bit country code if AL=0FFh         DX      0FFFFh return  CF      clear   successful                 set     if error                         AX      error code if CF flag set 
39h Create Subdirectory (MKDIR) 
     Makes a subdirectory along the indicated path entry   AH      39h         DS:DX   address of ASCIIZ pathname string return  flag CF 0       successful                 1       error                         AX      error code if any  (3, 5) note 1) The ASCIIZ string may contain drive and subdirectory.      2) Drive may be any valid drive (not nescessarily current drive)      3) The pathname cannot exceed 64 characters 
3Ah Remove Subdirectory (RMDIR) 
     remove a directory entry entry   AH      3Ah         DS:DX   address of ASCIIZ pathname string return  CF      clear     successful                 set       AX      error code if any  (3, 5, 16) note 1) The ASCIIZ string may contain drive and subdirectory.      2) Drive may be any valid drive (not nescessarily current drive)      3) The pathname cannot exceed 64 characters 
3Bh Change Current Directory 
     (CHDIR) entry   AH      3Bh         DS:DX   address of ASCIIZ string return  flag CF 0       successful                 1       error         AX      error code if any (3) note 1) The pathname cannot exceed 64 characters      2) The ASCIIZ string may contain drive and subdirectory.      3) Drive may be any valid drive (not nescessarily current drive) 
3Ch Create A File (CREAT) 
     create a file with handle entry   AH      3Ch         CX      attributes for file                 00h     normal                 01h     read only                 02h     hidden                 03h     system         DS:DX   address of ASCIIZ filename string return  flag CF 0       successful creation                 1       error         AX      16 bit file handle                 or error code  (3, 4, 5) note 1) The ASCIIZ string may contain drive and subdirectory.      2) Drive may be any valid drive (not nescessarily current drive)      3) If the volume label or subdirectory bits are set in CX, they are ignored      4) The file is opened in read/write mode      5) If the file does not exist, it is created. If one of the same name         exists, it is truncated to a length of 0. 
3Dh Open A File 
     Open disk file with handle entry   AH      3Dh         AL      access code byte (DOS 2.x)       bits 0-2  file attribute                 000     read only                 001     write only                 010     read/write                 bits 3-7 should be set to zero (DOS 3.x)       bits 0-2  file attribute                 000     read only                 001     write only                 010     read/write                 bit 3   reserved                 0       should be set to zero                 bits 4-6 sharing mode (network)                 000     compatibility mode (the way FCBs open files)                 001     read/write access denied (exclusive)                 010     write access denied                 011     read access denied                 100     full access permitted                 bit 7   inheritance flag                 0       file inherited by child process                 1       file private to child process         DS:DX   address of ASCIIZ pathname string return  flag CF set on error                 AX      error code                 1       error         AX      16 bit file handle                 or error code (1, 2, 4, 5, 0Ch) note 1) Opens any normal, system, or hidden file      2) Files that end in a colon are not opened      3) The rear/write pointer is set at the first byte of the file and the         record size of the file is 1 byte (the read/write pointer can be changed         through function call 42h). The returned file handle must be used for         all subsequent input and output to the file.      4) If the file handle was inherited from a parent process or was         duplicated by DUP or FORCEDUP, all sharing and access restrictions are         also inherited.      5) A file sharing error (error 1) causes an int 24h to execute with an         error code of 2 
3Eh Close A File Handle 
     Close a file and release handle for reuse entry   AH      3Eh         BX      file handle return  flag CF 0       successful close                 1       error         AX      error code if error (6) note 1) When executed, the file is closed, the directory is updated, and all         buffers for that file are flushed. If the file was changed, the time         and date stamps are changed to current      2) If called with the handle 00000, it will close STDIN (normally the         keyboard). 
3Fh Read From A File Or Device 
     Read from file with handle entry   AH      3Fh         BX      file handle         CX      number of bytes to read         DS:DX   address of buffer return  flag CF 0       successful read                 1       error         AX      0       pointer was already at end of file                         or number of bytes read                         or error code (5, 6) note 1) This function attempts to transfer the number of bytes specified in CX         to a buffer location. It is not guaranteed that all bytes will be read.         If AX < CX a partial record was read.      2) If performed from STDIN (file handle 0000), the input can be redirected      3) If used to read the keyboard, it will only read to the first CR      4) The file pointer is incremented to the last byte read. 
40h Write To A File Or Device 
     Write to file with handle entry   AH      40h         BX      file handle         CX      number of bytes to write         DS:DX   address of buffer return  flag CF 0       successful write                 1       error         AX      number of bytes written                 or error code  (5, 6) note 1) This call attempts to transfer the number of bytes indicated in CX         from a buffer to a file. If CX and AX do not match after the write,         an error has taken place; however no error code will be returned for         this problem. This is usually caused by a full disk.      2) If the write is performed to STDOUT (handle 0001), it may be redirected      3) To truncate the file at the current position of the file pointer, set         the number of bytes in CX to zero before calling int 21h. The pointer         can be moved to any desired position with function 42h.      4) This function will not write to a file or device marked read-only. 
41h Delete A File From A Specified Subdirectory 
     (UNLINK) entry   AH      41h         DS:DX   pointer to ASCIIZ filespec to delete return  CF      0       successful                 1       error                 AX      error code if any  (2, 5) note 1) This function will not work on a file marked read-only      2) Wildcards are not accepted 
42h Move a File Read/Write Pointer 
     (LSEEK) entry   AH      42h         AL      method code                 00h     offset from beginning of file                 01h     offset from present location                 02h     offset from end of file         BX      file handle         CX      most significant half of offset         DX      least significant half of offset return  AX      low offset of new file pointer         DX      high offset of new file pointer         CF      0       successful move                 1       error                 AX      error code (1, 6) 
note 1) If pointer is at end of file, reflects file size in bytes.      2) The value in DX:AX is the absolute 32 bit byte offset from the beginning         of the file 
43h Get/Set file attributes 
     (CHMOD) entry   AH      43h         AL      00h     get file attributes                 01h     set file attributes                 CX      file attributes to set                         bit 0       read only                         1       hidden file                         2       system file                         3       volume label                         4       subdirectory                         5       written since backup         DS:DX   pointer to full ASCIIZ file name return  CF      set if error         AX      error code  (1, 2, 3, 5)         CX      file attributes on get                 attributes:                 01h     read only                 02h     hidden                 04h     system                 0FFh    archive 
44h I/O Control for Devices (IOCTL) 
     Get or set device information entry   AH      44h         AL      00h     get device information (from DX)                         BX      file or device handle                         return  DX      device info                                         If bit 7 set: (character device)                                            bit 0: console input device                                                1: console output device                                                2: NUL device                                                3: CLOCK$ device                                                4: device is special                                                5: binary (raw) mode                                                6: Not EOF                                               12: network device (DOS 3.x)                                               14: can process IOCTL control                                                   strings (func 2-5)                                          If bit 7 clear: (file)                                          bits 0-5 are block device number                                                 6: file has not been written                                                12: Network device (DOS 3.x)                                             15: file is remote (DOS 3.x)                 01h     set device information (DH must be zero for this call)                         DX bits:                         0    1  console input device                         1    1  console output device                         2    1  null device                         3    1  clock device                         4    1  reserved                         5    0  binary mode - don't check for control chars                              1  cooked mode - check for control chars                         6    0  EOF - End Of File on input                         7       device is character device if set, if not, EOF                                 is 0 if channel has been written, bits 0-5 are                                 block device number                         12      network device                         14   1  can process control strings (AL 2-5, can only be                                 read, cannot be set)                         15   n  reserved                 02h     read CX bytes to device in DS:DX from BX control chan                 03h     Write Device Control String                         BX      device handle                         CX      number of bytes to write                         DS:DX   pointer to buffer                         return  AX      number of bytes written                 04h     read from block device (drive number in BL)                         BL      drive number (0=default)                         CX      number of bytes to read                         DS:DX   pointer to buffer                         return  AX      number of bytes read 
                05h     write to block device  (drive number in BL)                         AX      number of bytes transfered                 06h     get input handle status                 07h     get output handle status                         AX      0FFh    for ready                                 00h     for not ready                 08h     removable media bit (DOS 3.x)                         return  AX      00h     device is removable                                         01h     device is nonremovable                                         0Fh     invalid drive specification                 09h     test local or network device in BL (DOS 3.x)                         BL      drive number (0=default)                         return  DX      attribute word, bit 12 set if device is                                         remote                 0Ah     is handle in BX local or remote? (DOS 3.x)                         BX     file handle                         return DX (attribute word) bit 15 set if file is remote                 0Bh     change sharing retry count to DX (default=3), (DOS 3.x)                         CX     delay (default 1)                         DX     retry count (default 3)                 0Ch     general IOCTL (DOS 3.3 [3.2?]) allows a device driver to                         prepare, select, refresh, and query Code Pages                 0Dh     Block Device Request (DOS 3.3+)                         BL      drive number (0=default)                         CH      major subfunction                         CL      minor subfunction                                 40h set device parameters                                 41h write logical device track                                 42h format and verify logical device track                                 60h get device parameters                                 61h read logical device track                                 62h verify logical device track                         DS:DX   pointer to parameter block                 0Eh     GET LOGICAL DEVICE (DOS 3.3+)                         BL      drive number (0=default)                         return  AL=0 block device has only one logical drive                                 assigned 1..n the last letter used to reference                                 the device (1=A:,etc)                 0Fh     Set Logical Device (DOS 3.3+)         BL      drive number:  0=default, 1=A:, 2=B:, etc.         BX      file handle         CX      number of bytes to read or write         DS:DX   data or buffer         DX      data return  AX      number of bytes transferred                 or error code (call function 59h for extended error codes)                 or status                         00h     not ready                         0FFh    ready         CF      set if error 
45h Duplicate a File Handle (DUP) 
     Create duplicate handle entry   AH      45h         BX      file handle to duplicate return  CF      clear   AX      duplicate handle                 set     AX      error code  (4, 6) note 1) If you move the pointed of one handle, the pointer of the other will         also be moved.      2) The handle in BX must be open 
46h Force Duplicate of a Handle (FORCEDUP or CDUP) 
     forces handle in CX to refer to the same file at the same position as BX entry   AH      46h         BX      existing file handle         CX      new file handle return  CF      clear   both handles now refer to existing file                 set     error                 AX      error code (4, 6) note 1) If CX was an open file, it is closed first      2) If you move the read/write pointer of either file, both will move      3) The handle in BX must be open 
47h Get Current Directory 
     places full pathname of current directory/drive into a buffer entry   AH      47h         DL      drive (0=default, 1=A:, etc.)         DS:SI   points to 64-byte buffer area return  CF      clear   DS:DI   pointer to ASCIIZ pathname of current directory                 set     AX      error code (0Fh) note   String does not begin with a drive identifier or a backslash 
48h Allocate Memory 
     allocates requested number of 16-byte paragraphs of memory entry   AH      48h         BX      number of 16-byte paragraphs desired return  CF      clear   AX      segment address of allocated space                         BX      maximum number paragraphs available                 set     AX      error code (7, 8) note    BX indicates maximum memory availible only if allocation fails 
49h Free Allocated Memory 
     frees specified memory blocks entry   AH      49h         ES      segment address of area to be freed return  CF      clear   successful                 set     AX      error code (7, 9) note 1) This call is only valid when freeing memory obtained by function 48h.      2) A program should not try to release memory not belonging to it. 
4Ah Modify Allocated Memory Blocks (SETBLOCK) 
     expand or shrink memory for a program entry   AH      4AH         BX      new size in 16 byte paragraphs         ES      segment address of block to change return  CF      clear   nothing                 set     AX      error code (7, 8, 9)                     or  BX      max number paragraphs available note 1) Max number paragraphs availible is returned only if the call fails      2) Memory can be expanded only if there is memory availible 
4Bh Load or Execute a Program 
     (EXEC) entry   AH      4Bh         AL      00h     load and execute program. A PSP is built for the program                         the ctrl-break and terminate addresses are set to the                         new PSP.                *01h     load but don't execute  (note 1)                *02h     load (internal) but do not execute                 03h     load overlay (do not create PSP, do not begin execution)         DS:DX   points to the ASCIIZ string with the drive, path, and filename                 to be loaded         ES:BX   points to a parameter block for the load                (AL=00h) word    segment address of environment string to be                                 passed                         dword   pointer to the command line to be placed at                                 PSP+80h                         dword   pointer to default FCB to be passed at PSP+5Ch                         dword   pointer to default FCB to be passed at PSP+5Ch                (AL=03h) word    segment address where file will be loaded                         word    relocation factor to be applied to the image return  CF      clear   successful                 set     error                 AX      error code (1, 2, 8, 0Ah, 0Bh) note 1) If you make this call with AL=1 the program will be loaded as if you         made the call with AL=0 except that the program will not be executed.         Additionally, with AL=1 the stack segment and pointer along with the         program's CS:IP entry point are returned to the program which made the         4B01h call. These values are put in the four words at ES:BX+0eh. On         entry to the call ES:BX points to the environment address, the command         line and the two default FCBs. This form of EXEC is used by DEBUG.COM.      2) Application programs may invoke a secondary copy of the command         processor (normally COMMAND.COM) by using the EXEC function.  Your         program may pass a DOS command as a parameter that the secondary         command processor will execute as though it had been entered from the         standard input device.         The procedure is:          A. Assure that adequate free memory (17k for 2.x and 3.0, 23k for 3.1             up) exists to contain the second copy of the command processor and             the command it is to execute. This is accomplished by executing             function call 4Ah to shrink memory allocated to that of your current             requirements. Next, execute function call 48h with BX=0FFFFh. This             returns the amount of memory availible.         B. Build a parameter string for the secondary command processor in the            form:                          1 byte   length of parameter string                         xx bytes  parameter string                          1 byte   0Dh (carriage return)            For example, the assembly language statement below would build the            string to cause execution of the command FOO.EXE:                               DB 19, "/C C:FOO" , 13         C. Use the EXEC function call (4Bh), function value 0 to cause execution            of the secondary copy of the command processor. (The drive,            directory, and name of the command processor can be gotten from the            COMSPEC variable in the DOS environment passed to you at PSP+2Ch.)         D. Remember to set offset 2 of the EXEC control block to point to the            string built above.      3) All open files of a process are duplicated in the newly created         process after an EXEC, except for files originally opened with the         inheritance bit set to 1.      4) The environment is a copy of the original command processor's         environment. Changes to the EXECed environment are not passed back to         the original. The environment is followed by a copy of the DS:DX         filename passed to the child process. A zero value will cause the         child process to inherit the environment of the calling process. The         segment address of the environment is placed at offset 2Ch of the         PSP of the program being invoked.      5) This function uses the same resident part of COMMAND.COM, but makes a         duplicate of the transient part.      6) How EXEC knows where to return to:  Basically the vector for int 22h         holds the terminate address for the current process.  When a process         gets started, the previous contents of int 22h get tucked away in the         PSP for that process, then int 22h gets modified.  So if Process A         EXECs process B, while Process B is running, the vector for int 22h         holds the address to return to in Process A, while the save location in         Process B's PSP holds the address that process A will return to when         *it* terminates.  When Process B terminates by one of the usual legal         means, the contents of int 22h are (surmising) shoved onto the stack,         the old terminate vector contents are copied back to int 22h vector from         Process B's PSP, then a RETF or equivalent is executed to return control         to process A. 
4Ch Terminate a Process (EXIT) 
     Quit with exit code entry   AH      4Ch         AL      exit code in AL when called, if any, is passed to next process return  none note 1) Control passes to DOS or calling program      2) return code from AL can be retrieved by ERRORLEVEL or function 4Dh      3) all files opened by this process are closed, buffers are flushed, and         the disk directory is updated      4) Restores Terminate vector from PSP:000Ah                  Ctrl-C vector from PSP:000Eh                  Critical Error vector from PSP:0012h 
4Dh Get Return Code of a Subprocess (WAIT) 
     gets return code from functions 31h and 4Dh  (ERRORLEVEL) entry   AH      4Dh return  AL      exit code of subprogram (functions 31h or 4Ch)         AH      circumstance which caused termination                 00h     normal termination                 01h     control-break                 02h     critical device error                 03h     terminate and stay resident (function 31h) note    The exit code is only returned once 
4Eh Find First Matching File (FIND FIRST) 
     Find first ASCIIZ entry   AH      4Eh         CX      search attributes         DS:DX   pointer to ASCIIZ filename (with attributes) return  CF      set     AX      error code (2, 12h)                 clear   data block written at current DTA                         format of block is:   documented by Micro-  |00h   1 byte   attribute byte of search   soft as "reserved for |01h   1 byte   drive used in search   DOS' use on subsquent |02h   11 bytes the search name used   Find Next calls"      |0Ch   2 bytes  word value of last entry   function 4Fh          |0Fh   4 bytes  dword pointer to this DTA                         |13h   2 bytes  word directory start                          15h   1 byte   file attribute                          16h   2 bytes  file time                          18h   2 bytes  file date                          1Ah   2 bytes  low word of file size                          1Ch   2 bytes  high word of file size                          1Eh  13 bytes  name and extension of file found, plus                                         1 byte of 0s. All blanks are removed                                         from the name and extension, and if an                                         extension is present it is preceded by a                                         period. note 1) Will not find volume label      2) This function does not support network operations      3) Wildcards are allowed in the filespec      4) If the attribute is zero, only ordinary files are found. If the volume         label bit is set, only volume labels will be found. Any other attribute         will return that attribute and all normal files together.      5) To look for everything except the volume label, set the hidden, system,         and subdirectory bits all to 1 
4Fh Find Next Matching File (FIND NEXT) 
     Find next ASCIIZ entry   AH      4Fh return  CF      clear   data block written at current DTA                 set     AX      error code (2, 12h) note 1) If file found, DTA is formatted as in call 4Eh      2) Volume label searches using 4Eh/4Fh reportedly aren't 100% reliable         under DOS 2.x. The calls sometime report there's a volume label and         point to a garbage DTA, and if the volume label is the only item they         often won't find it      3) This function does not support network operations      4) Use of this call assumes that the original filespec contained wildcards 
50h Set PSP 
 *    Set new Program Segment Prefix; current process ID entry   AH      50h         BX      segment address of new PSP return  none - swaps PSP's regarded as current by DOS note 1) By putting the PSP segment value into BX and issuing call 50h DOS stores         that value into a variable and uses that value whenever a file call is         made.      2) Note that in the PSP (or PDB) is a table of 20 (decimal) open file         handles. The table starts at offset 18h into the PSP. If there is an         0FFh in a byte then that handle is not in use. A number in one of the         bytes is an index into an internal FB table for that handle. For         instance the byte at offset 18h is for handle 0, at offset 19h handle         1, etc. up to 13h. If the high bit is set then the file associated by         the handle is not shared by child processes EXEC'd with call 4Bh.      3) Function 50h is dangerous in background operations prior to DOS 3.x as         it uses the wrong stack for saving registers.  (same as functions         0..0Ch in DOS 2.x)      4) Under DOS 2.x, this function cannot be invoked inside an int 28h handler         without setting the Critical Error flag      5) Open File information, etc. is stored in the PSP DOS views as current.         If a program (eg. a resident program) creates a need for a second PSP,         then the second PSP should be set as current to make sure DOS closes         that as opposed to the first when the second application finishes.      6) See PC Mag Vol.5, No 9, p.314 for discussion. 
51h Get Program Segment Prefix 
 *    Returns the PSP address of currently executing program entry   AH      51h return  BX      address of currently executing program note 1) Used in DOS 2.x, 3.x uses 62h      2) Function 51h is dangerous in background operations prior to DOS 3.x as         it uses the wrong stack for saving registers.  (same as functions         0..0Ch in DOS 2.x)      3) 50h and 51h might be used if you have more than one process in a PC.         For instance if you have a resident program that needs to open a file         you could first call 51h to save the current id and then call 50h to set         the ID to your PSP.      4) Under DOS 2.x, this function cannot be invoked inside an int 28h handler 
52h IN-VARS 
 *      returns a pointer to a set of DOS data variables MCB chain, pointer to         first device driver and a pointer to disk parameter blocks (first one) entry   AH      52h return  ES:BX   pointer to the DOS list of lists, for disk information. Does not                 access the disk, so information in tables might be incorrect if                 disk has been changed. Returns a pointer to the following array                 of longword pointers:                 Bytes   Value                 -2h,-1h segment of first memory control block                 0h-3h   pointer to first DOS disk block (see function 36h)                 4h-7h   partially unknown. Pointer to a device driver. Maybe                         first resident driver?                 8h-0Bh  pointer to CLOCK$ device driver, whether installable or                         resident                 0Ch-0Fh pointer to actual CON: device driver, whether                         installable or resident         (DOS 2.x)                 10      Number of logical drives in system                 11-12   Maximum bytes/block of any block device                 13-16   unknown                 17      Beginning (not a pointer. The real beginning!) of NUL                         device driver. This is the first device on DOS's linked                         list of device drivers.         (DOS 3.x)                 10h-11h maximum bytes/block of any block device (0200h)                 12h-15h unknown. Pointer to current directory block?                 16h-19h partially undefined: Pointer to array of drive info:                         51h bytes per drive, starting with A: ...                         00h-3Fh current path as ASCIIZ, starting with 'x:\'                         40h-43h unknown    zeros always                         44h     unknown    flags? Usually 40h, except for                                 entry after last valid entry = 00h                         45h-48h pointer to DOS disk block for this drive                         49h-4Ah unknown. Current track or block?                                 -1 if never accessed                         4Bh-4Eh unknown  -1 always                         4Fh-52h unknown   2 always                 1Ah-1Dh unknown. Pointer to data area, maybe including cluster                         allocation table?                 1Eh-1Fh unknown. Zero always                 20h     Number of block devices                 21h     value of LASTDRIVE command in CONFIG.SYS (default 5)                 22h     Beginning (not a pointer. The real beginning!) of NUL                         device driver. This is the first device on DOS's linked                         list of device drivers. note    This call is not supported in OS/2 1.0's DOS Compatibility Box 
53h Translate BPB 
 *   Translates BPB (BIOS Parameter Block, see below) into a DOS Disk Block (see      function call 32h). entry   AH      53h         DS:SI   pointer to BPB         ES:BP   pointer to area for DOS Disk Block.                 Layout of Disk Block:                 bytes   value                 00h-01h bytes per sector, get from DDB bytes 02h-03h.                 02h     sectors per cluster, get from (DDB byte 4) + 1                 03h-04h reserved sectors, get from DDB bytes 06h-07h                 05h     number of FATs, get from DDB byte 08h                 06h-07h number of root dir entries, get from DDB bytes 09h-0Ah                 08h-09h total number of sectors, get from:                         ((DDB bytes 0Dh-0Eh) - 1) * (sectors per cluster (BPB                         byte 2)) + (DDB bytes 0Bh-0Ch)                 0Ah     media descriptor byte, get from DDB byte 16h                 0Bh-0Ch number of sectors per FAT, get from DDB byte 0Fh return  unknown 
54h Get Verify Setting 
     Get verify flag status entry   AH      54h return  AL      00h if flag off                 01h if flag on note    Flag can be set with function 2Eh 
55h Create "Child" PSP 
 *   Create PSP: similar to function 26h (which creates a new Program Segment      Prefix at segment in DX) except creates a "child" PSP rather than copying      the existing one. entry   AH      55h         DX      segment number at which to create new PSP. return  unknown note 1) This call is similar to call 26h which creates a PSP except that unlike         call 26h the segment address of the parent process is obtained from the         current process ID rather than from the CS value on the stack (from the         INT 21h call). DX has the new PSP value and SI contains the value to be         placed into PSP:2 (top of memory).      2) Function 55 is merely a substitute for function 26h. It will copy the         current PSP to the segment address DX with the addition that SI is         assumed to hold the new memory top segment. This means that function         26h sets SI to the segment found in the current PSP and then calls         function 55h. 
56h Rename a File 
     if the first file exists, it is renamed to the name in ES:DI entry   AH      56h         DS:DX   pointer to ASCIIZ old pathname         ES:DI   pointer to ASCIIZ new pathname return  CF      clear   successful rename                 set     AX      error code (2, 3, 5, 11h) note 1) Works with files in same drive only      2) Global characters not allowed in filename      3) The name of a file is its full pathname. The file's full pathname can         be changed, while leaving the actual FILENAME.EXT unchanged. Changing         the pathname allows the file to be "moved" from subdirectory to         subdirectory on a logical drive without actually copying the file.      4) DOS 3.x allows renaming of directories 
57h Get/Set a File's Date and Time 
     read or modify time and date stamp on a file's directory entry entry   AH      57h         AL      function code                 00h     get date and time                 01h     set date and time                         CX      time to be set                         DX      date to be set         BX      file handle return  CF     clear    CX      time of last write (if AL = 0)                         DX      date of last write (if AL = 0)                set      AX      error code (1, 6) note    Date/time formats are:         CX bits 0Bh-0Fh hours (0-23)    DX bits 09h-0Fh year (relative to 1980)                 05h-0Ah minutes (0-59)          05h-08h month (0-12)                 00h-04h #2 sec. incr. (0-29)   00h-04h day of the month (0-31) 
58h Get/Set Allocation Strategy 
      DOS 3.x entry   AH      58h         AL      0       set current strategy                 1       set new current strategy         BX      new strategy if AH=1                 0       first fit - chooses the lowest block in memory which                         will fit (this is the default). (use first memory block                         large enough)                 1       best fit - chooses the smallest block which will fill                         the request.                 2       last fit - chooses the highest block which will fit. return  CF      clear   (0)     successful                 set     (1)     error (1)                                 AX      error code         AX      strategy code (CF=0) note 1) Documented in Zenith DOS version 3.1, some in Advanced MSDOS      2) The set subfunction accepts any value in BL; 2 or greater means last         fit. The get subfunction returns the last value set, so programs should         check whether the value is greater than or equal to 2. 
59h Get Extended Error Code (DOS 3.x) 
returns additional error information when requested 
The Get Extended Error function call (59h) is intended to provide a common set of error codes and to supply more extensive information about the error to the application. The information returned from function call 59h, in addition to the error code, is the error class, the locus, and the recommended action. The error class provides information about the error type (hardware, internal, system, etc.). The locus provides information about the area involved in the failure (serial device, block device, network, or memory). The recommended action provides a default action for programs that do not understand the specific error code. 
Newly written programs should use the extended error support both from interrupt 24h hard error handlers and after any int 21h function calls. FCB function calls report an error by returning 0FFh in AL. Handle function calls report an error by setting the carry flag and returning the error code in AX. Int 21h handle function calls for DOS 2.x continue to return error codes 0-18. Int 24h handle function calls continue to return error codes 0-12. But the application can obtain any of the error codes used in the extended error codes table by issuing function call 59h. Handle function calls for DOS 3.x can return any of the error codes. However, it is recommended that the function call be followed by function call 59h to obtain the error class, the locus, and the recommended action. 
The Get Extended Error function (59h) can always be called, regardless of whether the previous DOS call was old style (error code in AL) or new style (carry bit). It can also be used inside an int 24h handler. 
You can either check AL or the carry bit to see if there was no error, and call function 59h only if there was an error, or take the simple approach of always calling 59h and letting it tell you if there was an error or not. When you call function 59h it will return with AX=0 if the previous DOS call was successful. 
entry   AH      59h         BX      version code (0000 for DOS 3.0 and 3.1) return  AX      extended error code:                 01h     Invalid function number                 02h     File not found                 03h     Path not found                 04h     Too many open files, no file handles left                 05h     Access denied                 06h     Invalid handle                 07h     Memory control blocks destroyed                 08h     Insufficient memory                 09h     Invalid memory block address                 0Ah     Invalid environment                 0Bh     Invalid format                 0Ch     Invalid access code                 0Dh     Invalid data                 0Eh     Reserved                 0Fh     Invalid drive was specified                 10h     Attempt to remove the current directory                 11h     Not same device                 12h     No more files                 13h     Attempt to write on write-protected diskette                 14h     Unknown unit                 15h     Drive not ready                 16h     Unknown command                 17h     Bad CRC check                 18h     Bad request structure length                 19h     Seek error                 1Ah     Unknown media type                 1Bh     Sector not found                 1Ch     Printer out of paper                 1Dh     Write fault                 1Eh     Read fault                 1Fh     General Failure                 20h     Sharing violation                 21h     Lock violation                 22h     Invalid disk change                 23h     FCB unavailible                 24h     Sharing buffer overflow                 25h     Reserved                 26h        "                 27h        "                 28h        "                 29h        "                 2Ah        "                 2Bh        "                 2Ch        "                 2Dh        "                 2Eh        "                 2Fh        "                 30h        "                 31h     Reserved                 32h     Network: request not supported (DOS 3.1 + MS Networks)                 33h     Remote computer not listening                 34h     Duplicate name on network                 35h     Network: name not found                 36h     Network: busy                 37h     Network: device no longer exists                 38h     NETBIOS command limit exceeded                 39h     Network: adapter hardware error                 3Ah     Incorrect response from network                 3Bh     Unexpected network error                 3Ch     Incompatible remote adapter                 3Dh     Print queue full                 3Eh     Not enough space for print file                 3Fh     Print file was deleted                 40h     Network: name was deleted                 41h     Network: Access denied                 42h     Network: device type incorrect                 43h     Network: name not found                 44h     Network: name limit exceeded                 45h     NETBIOS session limit exceeded                 46h     Temporarily paused                 47h     Network: request not accepted                 48h     Print or disk redirection paused (DOS 3.1 + MS Networks)                 49h     Reserved                 4Ah        "                 4Bh        "                 4Ch        "                 4Dh        "                 4Eh        "                 4Fh     Reserved                 50h     File exists                 51h     Reserved                 52h     Cannot make directory entry                 53h     Fail on interrupt 24h                 54h     Too many redirections                 55h     Duplicate redirection                 56h     Invalid password                 57h     Invalid parameter                 58h     Network: device fault         BH      class of error:                 01h     Out of resource                 02h     Temporary situation                 03h     Authorization (denied access)                 04h     Internal                 05h     Hardware failure                 06h     System failure                 07h     Application program error                 08h     Not found                 09h     Bad format                 0Ah     Locked                 0Bh     Media error (wrong volume ID, disk failure)                 0Ch     Already exists                 0Dh     Unknown         BL      suggested action code:                 01h     Retry                 02h     Delayed retry                 03h     Prompt user                 04h     Abort after cleanup                 05h     Immediate abort                 06h     Ignore                 07h     Retry after user intervention         CH      locus (where error occurred):                 01h     Unknown or not appropriate                 02h     Block device                 03h     Network related                 04h     Serial device                 05h     Memory related 
note 1) Not all DOS functions use the carry flag to indicate an error. Carry         should be tested only on those functions which are documented to use it.      2) None of the DOS functions which existed before 2.0 use the carry         indicator.  Many of them use register AL as an error indication instead,         usually by putting 0FFh in AL on an error. Most, but not all, the "new"         (2.x, 3.x) functions do use carry, and most, but not all, of the "old"         (1.x) functions use AL.      3) On return, CL, DI, DS, DX, ES, BP, and SI are destroyed - save before         calling this function if required.      4) DOS 2.x Error Codes:  If you are using function calls 38h-57h with DOS         2.x, to check if an error has occurred, check for the following error         codes in the AX register:         call    error code      call    error code      call    error code         38h     2               41h     2,3,5           4Ah     7,8,9         39h     3,5             42h     1,6             4Bh     1,2,3,5,8,10,11         3Ah     3,5,15          43h     1,2,3,5         4Eh     2,3,18         3Bh     3               44h     1,3,5,6         4Fh     18         3Ch     3,4,5           45h     4,6             56h     2,3,5,17         3Dh     2,3,4,5,12      46h     4,6             57h     1,6         3Eh     6               47h     15         3Fh     5,6             48h     7,8         40h     5,6             49h     7,9      5) note that extended error codes 13h through 1Fh correspond to error         codes 00h through 0Ch returned by int 24h 
5Ah Create Temporary File 
     Create unique filename (for temporary use) (DOS 3.x) entry   AH      5Ah         DS:DX   pointer to ASCIIZ directory pathname ending with a backslash (\)         CX      file attribute return  CF      clear   DS:DX   new ASCIIZ path name                         AX      handle                 set     AX      error code (3 or 5) 
note 1) The file created is not truly "temporary". It must be removed by the         user.      2) If the filename created already exists in the current directory, this         function will call itself again with another unique filename until         a unique filename is found 
5Bh Create a New File 
     (DOS 3.x) entry   AH      5Bh         DS:DX   pointer to directory ASCIIZ path name         CX      file attribute return  CF      clear   AX      file handle                         DS:DX   new ASCIIZ path name                 set     AX      error code (3, 4, 5, 50h) 
note 1) Unlike function 3Ch, function 5Bh will fail if the file already exists.      2) The new file is opened in read/write mode 
5Ch Lock/Unlock File Access 
     (DOS 3.x) entry   AH      5Ch         AL      00h     to lock file                 01h     to unlock file         BX      file handle         CX:DX   starting offset of region to lock         SI:DI   size of region  to lock return  CF      clear   successful                 set     AX      error code (1, 6, 21h) 
note 1) Close all files before exiting or undefined results may occur      2) Programs spawned with EXEC inherit all the parent's file handles but         not the file locks 
5Dh Set Extended Error Information 
 *   DOS  Internal - partial (DOS 3.x) entry   AH      5dh         AL      subfunction                 06h     get address of critical error flag                         return  DS:SI   pointer to critical error flag                 08h     (unknown - used by command.com)                 09h     (unknown - used by command.com)                 0Ah     set error info (Error, Class, Action, and Locus)                         DS:DX   address of 11-word error information                                 words 0 to 7: values of AX,BX,CX,DX,SI,DI,DS,                                               ES that function 59h will return                                 words 8 to 10: zero (reserved) return: CX      unknown         DX      unknown         DS:SI   (for 06h) pointer to critical error flag note 1) This call seems to have many different functions      2) Function 0Ah; DOS 3.1+      3) Function 06h; setting CritErr flag allows use of functions 50h/51h from         int 28h under DOS 2.x by forcing use of correct stack 
5Eh Network Printer (Partially documented by Microsoft) 
        DOS 3.1+ with Networks software entry   AH      5Eh         AL      00      Get Machine Name                         DS:DX   pointer to buffer for ASCIIZ name                         return  CH      0       if name not defined                                 CL      NETBIOS name number if CH <> 0                                 DS:DX   pointer to identifier if CH <> 0                         note    the ASCIIZ name is a 15 byte string padded                                 to length with zeroes                 01      Set Machine Name                         DS:DX   pointer to ASCIIZ name                         CH      unknown                         CL      name number                 02      Set Printer Control String                         BX      redirection list index                         CX      length of setup string (max 64 bytes)                         DS:SI   pointer to string buffer                 03      Get Printer Control String                         BX      redirection list index                         ES:DI   pointer to string buffer                         return  CX      length of setup string (max 64 bytes) return  CF      clear   successful                 set     error                         AX      error code (1 for all listed subfunctions) note 1) Used in IBM's & Microsoft's Network programs      2) Partial documentation in Fall 1985 Byte      3) These services require that the network software be installed      4) Partial documentation in Advanced MS-DOS      5) SHARE must be loaded or results can be unpredictable on 00h, or fail         with 02h or 03h 
5Fh Network Redirection 
        (DOS 3.1 + Microsoft Networks) entry   AH      5Fh         AL     *00h     Unknown                *01h     Unknown                 02h     Get Redirection List Entry                         BX      redirection list index                         DS:SI   pointer to 16 byte buffer for local device name                         ES:DI   pointer to 128 byte buffer for network name                         return  BH      device status flag (bit 0 = 0 if valid)                                                           (bit 0 = 1 if invalid)                                 BL      device type                                         03      printer device                                         04      drive device                                 CX      stored parameter value                                 DS:SI   pointer to 16 byte local device name                                 ES:DI   pointer to 128 byte network name                         note    DX and BP are destroyed by this call!                 03h     Redirect Device                         BL      device type                                 03      printer device                                 04      file device                         CX      stored parameter value                         DS:SI   pointer to source device name                         ES:DI   pointer to destination ASCIIZ network path +                                 ASCIIZ password                 04h     Cancel Redirection                         DS:SI   pointer to ASCIIZ device name or network path return  CF      clear   successful                 set     if error                         AX      error code return  as above note 1) Used in IBM's Network program      2) Partial documentation in Fall 1985 Byte      3) These services require that the network software be installed      4) Partial documentation in Advanced MS-DOS      5) SHARE must be loaded or the call will fail      6) The network device name requires a password 
60h Parse pathname (DOS 3.x) 
 *      Translate - perform name processing on a string (internal to DOS) entry   AH      60h         DS:SI   pointer to source string (null terminated)         ES:DI   pointer to destination string buffer. return  ES:DI   buffer filled with qualified name         CF      0       no error                 1       error                         AX      error code note 1) Documented in Zenith 3.05 Tech Ref      2) All name processing is performed on the input string: string         substitution is performed on the components, current drive/directories         are prepended, .  and ..  are removed.      3) Example: If current drive/directory is c:\test,  myfile.x is translated         to c:\test\myfile.x; ..\source\sample.asm is tranlated to c:\source\         sample.asm      4) It is the caller's responsibility to make sure DS:SI does not point to         a null string. If it does, SI is incremented, a null byte is stored at         ES:DI, and the routine returns. 
61h No Information Availible (DOS 3.x) 
 *      internal to DOS - parameters not known entry   AH      61h return  AL      0 note    Supposedly documented in Zenith DOS 3.05 Tech Ref 
62h Get Program Segment Prefix (PSP) 
     Get PSP address (DOS 3.x) entry   AH      62h return  BX      segment address of PSP 
63h Get Lead Byte Table (MS-DOS 2.25 only) 
     added in MS-DOS version 2.25 for additional foreign character set support. entry   AH      63h         AL      subfunction                 00h     get system lead byte table address                 01h     set/clear interim console flag                         DL      0 to clear interim console flag                                 1 to set interim console flag                 02h     get interim console flag return  DS:SI   pointer to lead byte table (AL = 00h)         DL      interim console flag (AL = 02h) note    Function 63h destroys all registers on return. 
64h Internal 
     unknown (DOS 3.3+) entry   AH      64h 
65h Get Extended Country Information (DOS 3.3+) 
     returns information about the selected country formats, code pages, and      conversion tables entry   AH      65h         AL      info ID (1 - 6)         BX      code page (-1 = global code page)         CX      size of buffer         DX      country ID (-1 = current country)         ES:DI   pointer to country information buffer return  AX      error code if carry set, otherwise         CX      size of country information returned         CF      set on error         ES:DI   pointer to country information:                 1 byte info ID                 if info ID <> 1                     dword  pointer to information                 if info ID = 1                     word   size                     word   country ID                     word   code page                  34 bytes  (see function 38h) 
66h Get/Set Global Code Page Table (DOS 3.3+) 
      query/reset code page defaults entry   AH      66h         AL      00h     Get Global Code Page                 01h     Set Global Page                         BX      active code page                         DX      system code page (active page at boot time) return  CF      clear  successful                 set    AX       error code         if 00h         BX       active code page                        DX       system code page (active page at boot time) note    BX = active code page: 437 = US, 860 = Portugal, 863 = Canada (French)                                865 = Norway/Denmark 
67h Set Handle Count (DOS 3.3+) 
     supports more than 20 open files per process entry   AH      67h         BX      desired number of handles (max 255) return  CF      clear if OK         CF      set if error                 AX      error code 
68h Commit File (DOS 3.3+) 
     Write all buffered data to disk entry   AH      68h         BX      file handle return  CF      set     AX      error code                 clear   successful note    Faster and more secure method of closing a file in a network than         current close commands 
69h Disk Serial Number DOS 4.0 (US) 
        Places and reads "Volume Serial Number" on disks formatted with 4.0+ entry   unknown return  unknown note    A call for DOS function 69h (AL=0, possibly a subfunction) uses DS:DX         as a pointer to a table. On return, the table is filled in as follows:         word            unknown (zeroes on my system)         dword           disk serial number (binary)         char[11]        volume label or "NO NAME    " if none         char[8]         FAT type         The FAT type field returns "FAT16   " on hard disk formatted with DOS         3.3 and "FAT12   " on a 360K floppy. 
6Ah unknown (DOS 4.0?) 
6Bh unknown (DOS 4.0?) 
6Ch Extended Open/Create DOS 4.0 (US) 
        Combines functions available with Open, Create, Create New, and Commit entry   AH      6Ch         AL      00h  reserved  [which means there might be other subfunctions?]         BX      mode    format  0WF0 0000 ISSS 0AAA                                 AAA is access code (read, write, read/write)                                 SSS is sharing mode                                 I       0       pass handle to child                                         1       no inherit [interesting!]                                 F       0       use int 24h for errors                                         1       disable int 24h for all                                                 I/O on this handle; use own                                                 error routine                                 W       0       no commit                                         1       auto commit on all writes         CX      create attribute         DL      action if file exists/does not exists                 bits 7-4 action if file does not exist                          0000   fail                          0001   create                 bits 3-0 action if file exists                          0000    fail                          0001    open                          0010    replace/open         DH      0         DS:SI   pointer to ASCIIZ file name return  CF      set on error                 AX      error code                 clear                 AX      file handle                 CX      action taken                         01h     file opened                         02h     created/opened                         03h     replaced/opened 
89h DOS_Sleep 
 *   not documented by Microsoft entry   AH      89h return  unknown note 1) Function included in Microsoft C 4.0 startup code MSDOS.INC      2) Debugging shows that the first instruction on entry to DOS compares AH         with 64h (at least in DOS 3.2) and aborts the call if AH > 64.      3) Possibly used in European MSDOS 4.0? 
Aftermarket Application Installed Function Calls: 
0B6h, 0B8h, 0BBh, 0BCh, B0Eh, 0BFh, 0C0h, 0C1h, 0C2h, 0C3h, 0C4h, 0C5h, 0C6h, 0C7h, 0C8h, 0C9h, 0CAh, 0CBh, 0CCh, 0CDh, 0CEh, 0CFh, 0D0h, 0D1h, 0D2h, 0D3h, 0D4h, 0D5h, 0D6h, 0D7h, 0DAh, 0DBh         Used by Novell NetWare 
0DCh Novell NetWare 
        Get Station Number entry   AH      0DCh return  AL      station number                 00h     if NetWare not loaded or this machine is a non-                         dedicated server 
0DDh Novell NetWare 
0DEh Novell NetWare 
        Set Broadcast Mode 
0DFh Novell NetWare 
0E0h Novell NetWare 
0E1h Novell NetWare 
        Broadcast Messages entry   AH      E1h         AL      00h     send broadcast message                 01h     get broadcase message                 02h-09h unknown 
0E2h Novell NetWare 
0E3h Novell NetWare 
        Connection Control entry   AH      E3h         AL      00h-14h unknown                 15h     get object connection numbers                 16h     get connection information                 32h-47h unknown 
0E4h DoubleDOS 
        check status entry   AX      00h return  AL      <> 0 if DoubleDOS is active 
0E4h Novell NetWare 
0E5h, 0E6h, 0E7h, 0E8h, 0E9h 
        Novell NetWare 
0EAh DoubleDOS 
        turn off task switching entry   AX      EAh return  task switching turned off 
0EAh Novell NetWare 
0EBh DoubleDOS 
        turn on task switching entry   AH      EBh return  Task switching turned on 
0EBh Novell NetWare 
0ECh DoubleDOS 
        get virtual screen address entry   AH      ECh return  ES      segment of virtual screen note    Screen address can change if task switching is on! 
0ECh Novell NetWare 
0EDh Novell NetWare 
0EEh DoubleDOS 
        give away time to other tasks entry   AH      EEh         AL      number of 55ms time slices to give away return  Returns after giving away time slices 
0EEh Novell NetWare 
        Get Node Address entry   AH      EEh return  CX:BX:AX = six-byte address 
0EFh, 0F0h, 0F1h, 0F2h, 0F3h Novell NetWare 
Reportedly used by Novell NetWare. No parameters known 
0FFh CED (CJ Dunford's DOS macro and command-line editor) 
        CED installable commands entry   AH      0FFh         AL      00h     add installable command                 01h     remove installable command                 02h     reserved, may be used to test for CED installation         BL      mode    bit 0 = 1 callable from DOS prompt                         bit 1 = 1 callable from application         DS:SI   pointer to cr-terminated command name         ES:DI   pointer to far routine entry point return  CF      set on error         AX      01h     invalid function                 02h     command not found (subfunction 1 only)                 08h     insufficient memory (subfunction 0 only)                 0Eh     bad data (subfunction 0 only)         AH      0FFh    if CED not installed 
Interrupts 22h Through 86h 
Interrupt 22h Terminate Address 
(0:0088h)  This interrupt transfers control to the far (dword) address at this interrupt location when an application program terminates. The default address for this interrupt is 0:0088h through 0:008Bh. This address is copied into the program's Program Segment Prefix at bytes 0Ah through 0Dh at the time the segment is created and is restored from the PSP when the program terminates. The calling program is normally COMMAND.COM or an application. Do not issue this interrupt directly, as the EXEC function call does this for you. If an application spawns a child process, it must set the Terminate Address prior to issuing the EXEC function call, otherwise when the second program terminated it would return to the calling program's Terminate Address rather than its own. This address may be set with int 21, function 25h. 
Interrupt 23h Ctrl-Break Exit Address 
(0:008Ch)  If the user enters a Ctrl-Break during STDIN, STDOUT, STDPRN, or STDAUX, int 23h is executed. If BREAK is on, int 23h is checked on MOST function calls (notably 06h). If the user written Ctrl-Break routine saves all registers, it may end with a return-from-interrupt instruction (IRET) to continue program execution. If the user-written interrupt program returns with a long return, the carry flag is used to determine whether the program will be aborted. If the carry flag is set, the program is aborted, otherwise execution continues (as with a return by IRET). If the user-written Ctrl-Break interrupt uses function calls 09h or 0Ah, then ctrl-C/CR/LF are output. If execution is continued with an IRET, I/O continues from the start of the line. When the interrupt occurs, all registers are set to the value they had when the original function call to DOS was made. There are no restrictions on what the Ctrl-Break handler is allowed to do, including DOS function calls, as long as the registers are unchanged if an IRET is used. If the program creates a new segment and loads a second program which itself changes the Ctrl-Break address, the termination of the second program and return to the first causes the Ctrl-Break address to be restored from the PSP to the value it had before execution of the second program. 
Interrupt 24h Critical Error Handler 
(0:0090h)  When a critical error occurs within DOS, control is transferred to an error handler with an int 24h. This may be the standard DOS error handler (ABORT, RETRY, IGNORE) or a user-written routine.  On entry to the error handler, AH will have its bit 7=0 (high order bit) if the error was a disk error (probably the most common error), bit 7=1 if not.  BP:SI contains the address of a Device Header Control Block from which additional information can be retrieved (see below).  The register is set up for a retry operation and an error code is in the lower half of the DI register with the upper half undefined. These are the error codes: 
 The user stack is in effect and contains the following from top to bottom: 
        IP      DOS registers from issuing int 24h         CS      int 24h         flags         AX      user registers at time of signal         BX      int 21h request         CX         DX         SI         DI         BP         DS         ES         IP      from original int 21h         CS         flags 
To reroute the critical error handler to a user-writen critical error handler, the following should be done: 
Before an int 24h occurs: 1) The user application initialization code should save the int 24h vector and    replace the vector with one pointing to the user error routine. 
When the int 24h occurs: 2) When the user error routine received control it should push the flag    registers onto the stack and execute a far call to the original int 24h    vector saved in step 1. 3) DOS gives the appropriate prompt, and waits for user input (Abort, Retry,    Ignore, Fail). After the user input, DOS returns control to the user error    routine instruction following the far call. 4) The user error routine can now do any tasks nescessary. To return to the    original application at the point the error occurred, the error routine needs    to execute an IRET instruction. Otherwise, the user error routine should    remove the IP, CS, and flag registers from the stack. Control can then be    passed to the desired point. 
Int 24h provides the following values in registers on entry to interrupt handler: 
entry   AH      status byte             bit 7       0       disk I/O hard error                         1       other error - if block device, bad FAT                                 - if char device, code in DI                 6       unused                 5       0       if IGNORE is not allowed                         1       if IGNORE is allowed                 4       0       if RETRY  is not allowed                         1       if RETRY  is allowed                 3       0       if FAIL   is not allowed                         1       if FAIL   is allowed                 2 \     disk area of error  00 = DOS area  01 = FAT                 1 /                         10 = root dir  11 = data area                 0       0       if read operation                         1       if write operation         AL      drive number if AH bit 7 = 1, otherwise undefined                 If it is as hard error on disk (AH bit 7=0), register AL                 contains the failing drive number (0=A:, 1=B:, etc.).         BP:SI   address of a Device Header Control Block for which error                 occurred block device if high bit of BP:SI+4 = 1  low byte of DI: error code (note: high byte is undefined)                error code      description                 00h             attempt to write on write-protected diskette                 01h             unknown unit                 02h             drive not ready                 03h             unknown command                 04h             data error (bad CRC)                 05h             bad request structure length                 06h             seek error                 07h             unknown media type                 08h             sector not found                 09h             printer out of paper                 0Ah             write fault                 0Bh             read fault                 0Ch             general failure                 0Fh             invalid disk change (DOS 3.x) 
handler must return 
 The registers are set such that if an IRET is executed, DOS responds according to (AL) as follows:  AL     00h  ignore the error         01h  retry the operation         02h  terminate via int 22h         03h  fail the system call that is in progress (DOS 3.2+) note 1) Be careful when choosing to ignore a response because this causes DOS to         beleive that an operation has completed successfully when it may not         have.      2) If the error was a character device, the contents of AL are invalid. 
OTHER ERRORS 
If AH bit 7=1, 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.  If a character device is involved, the contents of AL are unpredictable, the error code is in DI as above. 
Notes: 1.  Before giving this routine control for disk errors, DOS performs several     retries. The number of retries varies according to the DOS version. 2.  For disk errors, this exit is taken only for errors occurring during an     int 21h function call. It is not used for errors during an int 25h or 26h. 3.  This routine is entered in a disabled state. 4.  All registers must be preserved. 5.  This interrupt handler should refrain from using DOS function calls. If     necessary, it may use calls 01h through 12h. Use of any other call destroys     the DOS stack and leaves DOS in an unpredictable state. 6.  The interrupt handler must not change the contents of the device header. 7.  If the interrupt handler handles errors itself rather than returning to DOS,     it should restore the application program's registers from the stack,     remove all but the last three words on the stack, then issue an IRET. This     will return to the program immediately after the int 21h that experienced     the error. Note that if this is done DOS will be in an unstable state until     a function call higher than 12h is issued, therefore not recommended. 8.  For DOS 3.x, IGNORE requests (AL=0) are converted to FAIL for critical     errors that occur on FAT or DIR sectors. 9.  For DOS 3.10 up, IGNORE requests (AL=0) are converted to FAIL requests     for network critical errors (50-79). 
The device header pointed to by BP:SI is as follows: 
DWORD Pointer to next device (0FFFFh if last device) 
WORD Attributes: 
Bit     15      1       if character device.                         If bit 15 is 1:                         Bit 0 = 1 if current standard input                         Bit 1 = 1 if current standard output                         Bit 2 = 1 if current NULL device                         Bit 3 = 1 if current CLOCK device                 0       if block device Bit 14 is the IOCTL bit WORD pointer to device driver strategy entry point WORD pointer to device driver interrupt entry point 8-BYTE character device named field for block devices. The first byte is the number of units.  To tell if the error occurred on a block or character device, look at bit 15 in the attribute field (WORD at BP:SI+4).  If the name of the character device is desired, look at the eight bytes starting at BP:SI+10. HANDLING OF INVALID RESPONSES (DOS 3.x) 
        A) If IGNORE (AL=0) is specified by the user and IGNORE is not allowed            (bit 5=0), make the response FAIL (AL=3).         B) If RETRY (AL=1) is specified by the user and RETRY is not allowed            (bit 4=0), make the response FAIL (AL=3).         C) If FAIL (AL=3) is specified by the user and FAIL is not allowed (bit            3=0), make the response ABORT. (AL=2) 
Interrupt 25h Absolute Disk Read 
Interrupt 26h Absolute Disk Write 
(0:0094h, 0:0098h) These transfer control directly to the device driver. On return, the original flags are still on the stack (put there by the INT instruction). This is necessary because return information is passed back in the current flags. 
The number of sectors specified is transferred between the given drive and the transfer address. Logical sector numbers are obtained by numbering each sector sequentially starting from track 0, head 0, sector 1 (logical sector 0) and continuing along the same head, then to the next head until the last sector on the last head of the track is counted.  Thus, logical sector 1 is track 0, head 0, sector 2; logical sector 2 is track 0, head 0, sector 3; and so on. Numbering then continues wih sector 1 on head 0 of the next track. Note that although the sectors are sequentially numbered (for example, sectors 2 and 3 on track 0 in the example above), they may not be physically adjacent on disk, due to interleaving. Note that the mapping is different from that used by DOS 1.10 for dual-sided diskettes. 
The request is as follows: 
int 25 for Absolute Disk Read, int 26 for Absolute Disk Write entry   AL      drive number (0=A:, 1=B:, etc)         CX      number of sectors to read         DS:BX   disk transfer address (buffer)         DX      first relative sector to read - beginning logical sector number return  CF      set if error         AL      error code issued to int 24h in low half of DI         AH      01h     bad command                 02h     bad address mark                 03h     write-protected disk                 04h     requested sector not found                 08h     DMA failure                 10h     data error (bad CRC)                 20h     controller failed                 40h     seek operation failed                 80h     attachment failed to respond note 1) Original flags on stack! Be sure to pop the stack to prevent         uncontrolled growth      2) Ints 25 and 26 will try rereading a disk if they get an error the first         time.      3) All registers except the segment registers are destroyed by these calls 
Interrupt 27h Terminate And Stay Resident 
(0:009Ch) (obsolete) This vector is used by programs that are to remain resident when COMMAND.COM regains control. After initializing itself, the program must set DX to its last address plus one relative to the program's initial DS or ES value (the offset at which other programs can be loaded), then execute interrupt 27h. DOS then considers the program as an extension of itself, so the program is not overlaid when other programs are executed. This is useful for loading programs such as utilities and interrupt handlers that must remain resident. 
entry   CS      current program segment         DX      last program byte + 1 return  none note 1) This interrupt must not be used by .EXE programs that are loaded into         the high end of memory.      2) This interrupt restores the interrupt 22h, 23h, and 24h vectors in the         same manner as interrupt 20h.  Therefore, it cannot be used to install         permanently resident Ctrl-Break or critical error handler routines.      3) The maximum size of memory that can be made resident by this method is         64K.      4) Memory can be more efficiently used if the block containing a copy of         the environment is deallocated before terminating. This can be done by         loading ES with the segment contained in 2Ch of the PSP, and issuing         function call 49h (Free Allocated Memory).      5) DOS function call 4Ch allows a program to pass a completion code to DOS,         which can be interpreted with processing (see function call 31h).      6) Terminate and stay resident programs do not close files.      7) Int 21, function 31h is the preferred method to cause a program to         remain resident because this allows return information to be passed and         allows a program larger than 64K to remain resident. 
Interrupt 28h (not documented by Microsoft) 
           *    DOS Idle Interrupt 
This interrupt is continuously called by DOS itself whenever it is in a wait state (i.e., when it is waiting for keyboard input) during a function call of 01h through 0Ch. DOS uses 3 separate internal stacks: one for calls 01h through 0Ch; another for calls 0Dh and above; and a third for calls 01h through 0Ch when a Critical Error is in progress. When int 28h is called, any calls above 0Ch can be executed without destroying the internal stack used by DOS at the time. 
It is used primarily by the PRINT.COM routines, but any number of other routines can be chained to it by saving the original vector and calling it with a FAR call (or just JMPing to it) at the end of the new routine. 
Int 28h is being issued it is usually safe to do DOS calls. You won't get int 28hs if a program is running that doesn't do its keyboard input through DOS. You should rely on the timer interrupt for these. 
Int 28h is not called at all when any non-trivial foreground task is running. As soon as a foreground program has a file open, INT28 no longer gets called. Could make a good driver for for abackground program that really works as long as there is nothing else going on in the machine. 
entry   no parameters availible return  none note 1) The int 28h handler may invoke any int 21h function except functions         00h through 0Ch (and 50h/51h under DOS 2.x).      2) Apparently int 28h is also called during screen writes      3) Until some program installs its own routine, this interrupt vector         simply points to an IRET opcode.      4) Supported in OS/2 1.0's DOS Compatibility Box 
Interrupt 29h (not documented by Microsoft) 
           *    Internal - Quick Screen Output 
 This method is extremely fast (much faster than DOS 21h subfunctions 2 and 9, for example), and it is portable, even to "non-compatible" MS-DOS computers. 
entry   AL      character to output to screen return  unknown note 1) Documented by Digital Research's DOS Reference as provided with the         DEC Rainbow      2) If ANSI.SYS is installed, character output is filtered through it.      3) Works on the IBM PC and compatibles, Wang PC, HP-150 and Vectra, DEC         Rainbow, NEC APC, Texas Instruments PC and others      4) This interrupt is called from the DOS's output routines if output is         going to a device rather than a file, and the device driver's attribute         word has bit 3 (04h) set to "1".      5) This call has been tested with MSDOS 2.11, PCDOS 2.1, PCDOS 3.1, PCDOS         3.2, and PCDOS 3.3.      6) Used in IBMBIO.COM as a vector to int 10, function 0Eh (write TTY)         followed by an IRET. 
Interrupt 2Ah Microsoft Networks - Session Layer Interrupt 
           *    (not documented by Microsoft) 
entry   AH      00h     check to see if network BIOS installed                         return: AH      <> 0 if installed                 01h     execute NETBIOS request                 02h     set net printer mode                 03h     get shared-device status (check direct I/O)                         AL      00h                         DS:SI   pointer to ASCIIZ disk device name                         return  CF      0 if allowed                 04h     execute NETBIOS                         AL      0 for error retry                                 1 for no retry                         ES:BX   pointer to ncb                         return  AX      0 for no error                                 AH      1 if error                                 AL      error code                 05h     get network resource information                         AL      00h                         return  AX      reserved                                 BX      number of network names                                 CX      number of commands                                 DX      number of sessions                 82h     unknown                         return  ?? note    called by the int 21h function dispatcher in DOS 3.10 
Interrupt 2Bh (not documented by Microsoft) 
           *    Unknown - Internal Routine for DOS (IRET) 
Interrupt 2Ch (not documented by Microsoft) 
           *    Unknown - Internal Routine for DOS (IRET) 
Interrupt 2Dh (not documented by Microsoft) 
           *    Unknown - Internal Routine for DOS (IRET) 
Interrupt 2Eh (undocumented by Microsoft) 
           *    Internal Routine for DOS  (Alternate EXEC) 
This interrupt passes a command line addressed by DS:SI to COMMAND.COM. The command line must be formatted just like the unformatted parameter area of a Program Segment Prefix. That is, the first byte must be a count of characters, and the second and subsequent bytes must be a command line with parameters, terminated by a carriage return character. 
When executed, int 2Eh will reload the transient part of the command interpreter if it is not currently in memory. If called from a program that was called from a batch file, it will abort the batch file. If executed from a program which has been spawned by the EXEC function, it will abort the whole chain and probably lock up the computer. Int 2Eh also destroys all registers including the stack pointer. 
Int 2Eh is called from the transient portion of the program to reset the DOS PSP pointers using the above Functions #81 & #80, and then reenters the resident program. 
When called with a valid command line, the command will be carried out by COMMAND.COM just as though you had typed it in at the DOS prompt. Note that the count does not include the carriage return. This is an elegant way to perform a SET from an application program against the master environment block for example. 
entry   DS:SI   pointer to an ASCIIZ command line in the form:                         count byte                         ASCII string                         carriage return                         null byte note 1) Destroys all registers including stack pointer      2) Seems to work OK in both DOS 2.x and 3.x      3) It is reportedly not used by DOS.      4) As far as known, int 2Eh is not used by DOS 3.1, although it was called         by COMMAND.COM of PCDOS 3.0, so it appears to be in 3.1 only for the         sake of compatibility. 
Interrupt 2Fh Multiplex Interrupt 
Interrupt 2Fh is the multiplex interrupt. A general interface is defined between two processes. It is up to the specific application using interrupt 2Fh to define specific functions and parameters. 
Every multiplex interrupt handler is assigned a specific multiplex number. The multiplex number is specified in the AH register; the AH value tells which program your request is directed toward. The specific function that the handler is to perform is placed in the AL register. Other parameters are places in the other registers as needed. The handlers are chained into the 2Fh interrupt vector and the multiplex number is checked to see if any other application is using the same multiplex number. There is no predefined method for assigning a multiplex number to a handler. You must just pick one. To avoid a conflict if two applications choose the same multiplex number, the multiplex numbers used by an application should be patchable. In order to check for a previous installation of the current application, you can search memory for a unique string included in your program. If the value you wanted in AH is taken but you don't find the string, then another application has grabbed that location. 
Int 2Fh was not documented under DOS 2.x. There is no reason not to use int 2Fh as the multiplex interrupt in DOS 2.x. The only problem is that DOS does not initialize the int 2Fh vector, so when you try to chain to it like you are supposed to, it will crash. But if your program checks the vector for being zero and doesn't chain in that case, it will work for you in 2.x just the same as 3.x.  Int 2Fh doesn't require any support from DOS itself for it to be used in application programs. It's not handled by DOS, but by the programs themselves. The only support DOS has to provide is to initialize the vector to an IRET. DOS 3.2 does itself contain some int 2Fh handlers - it uses values of 08h, 13h, and 0F8h. There may be more. 
entry   AH      01h     PRINT.COM                         AL      00h     PRINT  
Get Installed StateThis call must be defined by all int 2Fh handlers. It is used by the caller of the handler to determine if the handler is present. On entry, AL=0. On return, AL contains the installed state as follows:return  AL      0FFh    installed                        01h     not installed, not OK to install                00h     not installed, OK to install                01h     PRINT  Submit File                DS:DX   pointer to submit packetformat  BYTE    level                   DWORD   pointer to ASCIIZ filenamereturn  CF      set if error             AX      error code       note 1) A submit packet contains the level (BYTE) and a pointer        to the ASCIIZ string (DWORD in offset:segment form).        The ASCIIZ string must contain the drive, path, and        filename of the file you want to print. The filename        cannot contain global filename characters.                        02h     PRINT Cancel File                         On entry, AL=2 and DS:DX points to the ASCIIZ string for                         the print file you want to cancel. Global filename                         characters are allowed in the filename.                 DS:DX   pointer to ASCIIZ file name to cancel (wildcards OK)                 return  CF      set if error                                 AX      error code 
                        03h     PRINT remove all files                 return  CF      set if error                                 AX      error code 
                        04h     PRINT hold queue/get status                         This call holds the jobs in the print queue so that you                         can scan the queue. Issuing any other code releases the                         jobs. On entry, AL=4. On return, DX contains the error                         count. DS:SI points to the print queue. The print queue                         consists of a series of filename entries. Each entry is                         64 bytes long. The first entry in the queue is the file                         currently being printed. The end of the queue is marked                         by the entry having a null as the first character.                return   DX      error count                         DS:SI   pointer to print queue (null-string terminated                                 list of 64-byte ASCIIZ filenames)                         CF      set if error                                AX       error code                                         01h     function invalid                                         02h     file not found                                         03h     path not found                                         04h     too many open files                                         05h     access denied                                         08h     queue full                                         09h     spooler busy                                         0Ch     name too long                                         0Fh     drive invalid 
                        05h     PRINT restart queue                 return  CF      set if error                                 AX      error code 
        AH      05h     DOS 3.x critical error handler                 AL      00h     installation check                         return  AL      00h not installed, OK to install                                         01h not installed, can't install                                         0FFh installed                         note    This set of functions allows a user program to                                 partially or completely override the default                                 critical error handler in COMMAND.COM                 AL      01h     handle error - nonzero error code in AL                         return  CF      clear                                         ES:DI   pointer to ASCIIZ error message                                 CF      set     use default error handler                                 AL      (?) 
        AH      06h     ASSIGN                         00h     installation check                         return  AH <> 0 if installed 
                        01h     get memory segment                         return  ES      segment of ASSIGN work area 
        AH      10h     SHARE                         00h     installation check                         return  AL      00h    not installed, OK to install                                         01h    not installed, not OK to install                                         0FFh   installed 
        AH      11h     multiplex - network redirection                         00h     installation check                         return  AL      00h    not installed, OK to install                                         01h    not installed, not OK to install                                         0FFh   installed                         01h     unknown                         02h     unknown                         03h     unknown                         04h     unknown                         05h     unknown                         06h     close remote file                         07h     unknown                         08h     unknown                         09h     unknown                         0Ah     unknown                                 STACK: WORD (?)                                 return  CF      set on error                         0Bh     unknown                                 STACK: WORD (?)                                 return  CF      set on error(?)                         0Ch     unknown                         0Dh     unknown                         0Eh     unknown                                 STACK: WORD (?)                                 return  (?)                         0Fh     unknown                         11h     unknown                         13h     unknown                         16h     unknown                         17h     unknown                                 STACK: WORD (?)                                 return  (?)                         18h     unknown                                 STACK: WORD (?)                                 return  (?)                         19h     unknown                         1Bh     unknown                         1Ch     unknown                         1Dh     unknown                         1Eh     do redirection                                 STACK: WORD function to execute                                 return  CF      set on error                         1Fh     printer setup                                 STACK: WORD function(?)                                 return  CF      set on error(?)                         20h     unknown                         21h     unknown                         22h     unknown                         23h     unknown                         24h     unknown                         25h     unknown                                 STACK: WORD (?)                         26h     unknown 
        AH      12h     multiplex, DOS 3.x internal services                         00h     installation check                         return  AL      0FFh    for compatibility with other                                                 int 2Fh functions                         01h     close file (?)                                 stack   word value - unknown                                 return  BX      unknown                                         CX      unknown                                         ES:DI   pointer to unknown value                                 note    Can be called only from within DOS                         02h     get interrupt address                                 stack: word vector number                                 return  ES:BX pointer to interrupt vector                                         Stack unchanged                         03h     get DOS data segment                                 return  DS      segment of IBMDOS                         04h     normalize path separator                                 stack: word character to normalize                                 return  AL      normalized character (forward                                                 slash turned to backslash)                                         Stack unchanged                         05h     output character                                 stack: word character to output                                 return  Stack unchanged                                 note    Can be called only from within DOS                         06h     invoke critical error                                 return  AL      0-3 for Abort, Retry, Ignore,                                                 Fail                                 note    Can be called only from within DOS                         07h     move disk buffer (?)                                 DS:DI   pointer to disk buffer                                 return  buffer moved to end of buffer list                                 note    Can be called only from within DOS                         08h     decrement word                                 ES:DI   pointer to word to decrement                                 return  AX      new value of word                                 note    Word pointed to by ES:DI decremented,                                         skipping zero                         09h     unknown                                 DS:DI   pointer to disk buffer(?)                                 return  (?)                                 note    Can be called only from within DOS                         0Ah     unknown                                 note    Can be called only from within DOS                         0Bh     unknown                                 ES:DI   pointer to system file table entry(?)                                 return  AX      (?)                                 note    Can be called only from within DOS                         0Ch     unknown                                 note    Can be called only from within DOS                         0Dh     get date and time                                 return  AX      current date in packed format                                         DX      current time in packed format                                 note    Can be called only from within DOS                         0Eh     do something to all disk buffers (?)                                 return  DS:DI   pointer to first disk buffer                                 note    can be called only from within DOS                         0Fh     unknown                                 DS:DI   pointer to (?)                                 return  DS:DI pointer to (?)                                 note 1) Can be called only from within DOS                                      2) Calls on function 1207h                         10h     find dirty/clean(?) buffer                                 DS:DI   pointer to first disk buffer                                 return  DS:DI   pointer to first disk buffer                                                 which has (?) flag clear                                         ZF      clear if found                                                 set if not found                         11h     normalize ASCIIZ filename                                 DS:SI   pointer to ASCIZ filename to normalize                                 ES:DI   ptr to buffer for normalized filename                                 return  destination buffer filled with upper-                                         case filename, with slashes turned to                                         backslashes                         12h     get length of ASCIIZ string                                 ES:DI   pointer to ASCIZ string                                 return  CX      length of string                         13h     uppercase character                                 stack: word character to convert to uppercase                                 return  AL      uppercase character                                         Stack unchanged                         14h     compare far pointers                                 DS:SI   first pointer                                 ES:DI   second pointer                                 return  ZF      set if pointers are equal                                         ZF      clear if not equal                         15h     unknown                                 DS:DI   pointer to disk buffer                                 stack: word (?)                                 return  Stack unchanged                                 note    Can be called only from within DOS                         16h     get address of system FCB                                 BX      system file table entry number                                 return  ES:DI pointer to system file table entry                         17h     set default drive (?)                                 stack: word drive (0 = A:, 1 = B:, etc)                                 return  DS:SI   pointer to drive data block for                                                 specified drive                                         Stack unchanged                                 note    Can be called only from within DOS                         18h     get something (?)                                 return  DS:SI pointer to (?)                         19h     unknown                                 stack: word drive (0 = default, 1 = A:, etc)                                 return  (?)                                         Stack unchanged                                 note 1) Can be called only from within DOS                                      2) Calls function 1217h                         1Ah     get file's drive                                 DS:SI   pointer to filename                                 return  AL      drive                                         (0=default, 1=A:, etc, 0FFh=invalid)                         1Bh     set something (?)                                 CL      unknown                                 return  AL      (?)                                 note    Can be called only from within DOS                         1Ch     checksum memory                                 DS:SI   pointer to start of memory to checksum                                 CX      number of bytes                                 DX      initial checksum                                 return  DX      checksum                                 note    Can be called only from within DOS                         1Dh     unknown                                 DS:SI   pointer to (?)                                 CX      (?)                                 DX      (?)                                 return  AX      (?)                                         CX      (?)                                         DX    = (?)                         1Eh     compare filenames                                 DS:SI   pointer to first ASCIIZ filename                                 ES:DI   pointer to second ASCIIZ filename                                 return  ZF      set     if filenames equivalent                                                 clear   if not                         1Fh     build drive info block                                 stack: word drive letter                                 return  ES:DI pointer to drive info block                                               (will be overwritten by next call)                                         Stack unchanged                                 note    Can be called only from within DOS                         20h     get system file table number                                 BX      file handle                                 return  CF set on error                                         AL      6 (invalid file handle)                                         CF      clear if successful                                         byte ES:[DI] = system file table entry                                             number for file handle                         21h     unknown                                 DS:SI   pointer to (?)                                 return  (?)                                 note    Can be called only from within DOS                         22h     unknown                                 SS:SI   pointer to (?)                                 return  nothing(?)                                 note    Can be called only from within DOS                         23h     check if character device (?)                                 return  DS:SI   pointer to device driver with                                                 same name as (?)                                 note    Can be called only from within DOS                         24h     delay                                 return  after delay of (?) ms                                 note    Can be called only from within DOS                         25h     get length of ASCIIZ string                                 DS:SI   pointer to ASCIIZ string                                 return  CX      length of string 
        AH      43h     Microsoft Extended Memory Specification (XMS) 
        AH      64h     SCRNSAV2.COM                 AL      00h     installation check                         return  AL      00h     not installed                                         0FFh    installed                         note    SCRNSAV2.COM is a screen saver for PS/2's with                                 VGA by Alan Ballard 
        AH      7Ah     Novell NetWare                 AL      00h     installation check                         note    Returns address of entry point for IPX and SPX 
        AH      0AAh    VIDCLOCK.COM                 AL      00h     installation check                         return  AL      00h     not installed                                         0FFh    installed                         note    VIDCLOCK.COM is a memory-resident clock by                                 Thomas G. Hanlin III 
        AH      0B7h    APPEND                 AL      00h     APPEND installation check                                 return  AH <> 0 if installed                         01h     APPEND - unknown                         02h     APPEND - version check 
        AH      0B8h    Microsoft Networks                 AL      00h     network program installation check                         return  AH <> 0 if installed                                 BX      installed component flags (test in this                                         order!)                                 bit 6   server                                 bit 2   messenger                                 bit 7   receiver                                 bit 3   redirector                         01h     unknown                         02h     unknown                         03h     get current POST address                         return  ES:BX   POST address                         04h     set new POST address                         ES:BX   new POST address                         09h     version check 
        AH      0BBh    Network functions                 AL      00h     net command installation check                         03h     get server POST address                         04h     get server POST address 
        AH      0F7h    AUTOPARK.COM  (PD TSR hard disk parking utility)                 AL      00h     installation check                         return  AL      00h     not installed                                         0FFh    installed                         note    AUTOPARK is a TSR HD parker by Alan D. Jones                         01h     set parking delay                         BX:CX   32 bit count of 55ms timer ticks 
return  AX      Error                 Codes       Description                 01h     invalid function number                 02h     file not found                 03h     path not found                 04h     too many open files                 05h     access denied                 06h     invalid handle                 08h     queue full                 09h     busy                 0Ch     name too long                 0Fh     invalid drive was specified         CF      clear (0) if OK                 set (1) if error - error returned in AX note 1) The multiplex numbers AH=0h through AH=7Fh are reserved for DOS.         Applications should use multiplex numbers 80h through 0FFh.      2) When in the chain for int 2Fh, if your code calls DOS or if you execute         with interrupts enabled, your code must be reentrant/recursive. 
Interrupt 30h far jump instruction for CP/M-style calls 
not a vector! 
Interrupt 31h Unknown 
note    The CALL 5 entry point does a FAR jump to here 
Interrupt 32h Unknown 
Interrupt 33h Used by Microsoft Mouse Driver 
                Function Calls 
        00h     Reset Driver and Read Status         entry   AH      00h         return  AH      status                         0  hardware/driver not installed                         -1 hardware/driver installed                 BX      number of buttons                         -1      two buttons                         0       other than two                         3       Mouse Systems mouse 
        01h     Show Mouse Cursor         entry   AH      01h         return  unknown 
        02h     Hide Mouse Cursor         entry   AH      02h         return  unknown         note    multiple calls to hide the cursor will require multiple calls                 to function 01h to unhide it. 
        03h     Return Position and Button Status         entry   AH      03h         return  BX      button status                         bit 0   left button pressed if 1                         bit 1   right button pressed if 1                         bit 2   middle button pressed if 1 (Mouse Systems mouse)                 CX      column                 DX      row 
        04h     Position Mouse Cursor         entry   AH      04h                 CX      column                 DX      row                 return  unknown 
        05h     Return Button Press Data         entry   AH      05h                 BX      button                         0 left                         1 right                         2 middle (Mouse Systems mouse)         return  AH      button states                         bit 0   left button pressed if 1                         bit 1   right button pressed if 1                         bit 2   middle button pressed if 1 (Mouse Systems mouse)                 BX      no. of times specified button pressed since last call                 CX      column at time specified button was last pressed                 DX      row at time specified button was last pressed 
        06h     Return Button Release Data         entry   AH      06h                 BX      button                         0       left                         1       right                         2       middle (Mouse Systems mouse)         return  AH      button states                         bit 0   left button pressed if 1                         bit 1   right button pressed if 1                         bit 2   middle button pressed if 1 (Mouse Systems mouse)                 BX      no. of times specified button released since last call                 CX      column at time specified button was last released                 DX      row at time specified button was last released 
        07h     Define Horizontal Curos Range         entry   AH      0007h                 CX      minimum column                 DX      maximum column         return  unknown 
        08h     Define Vertical Cursor Range         entry   AH      08h                 CX      minimum row                 DX      maximum row                 return  unknown 
        09h     Define Graphics Cursor         entry   AH      09h                 BX      column of cursor hot spot in bitmap (-16 to 16)                 CX      row of cursor hot spot  (-16 to 16)                 ES:DX   pointer to bitmap                         16 words screen mask                         16 words cursor mask                 return  unknown                 note    Each word defines the sixteen pixels of a row, low bit                         rightmost 
        0Ah     Define Text Cursor         entry   AH      0Ah                 BX      hardware/software text cursor                         00h     software                                 CX      screen mask                                 DX      cursor mask                         01h     hardware                                 CX      start scan line                                 DX      end scan line         return  unknown         note    When the software cursor is selected, the char/attribute data                 at the current screen position is ANDed with the screen mask                 and the with the cursor mask 
        0BH     Read Motion Counters         entry   AH      0Bh         return  CX      number of mickeys mouse moved horiz. since last call                 DX      number of mickeys mouse moved vertically         note 1) A mickey is the smallest increment the mouse can sense.                 Positive values indicate up/right 
        0Ch     Define Interrupt Subroutine Parameters         entry   AH      0Ch                 CX      call mask bit                         bit 0   call if mouse moves                         bit 1   call if left button pressed                         bit 2   call if left button released                         bit 3   call if right button pressed                         bit 4   call if right button released                         bit 5   call if middle button pressed (Mouse Systems)                         bit 6   call if middle button released (Mouse Systems)                 ES:DX  address of FAR routine         return  unknown         note    when the subroutine is called, it is passed these values:                 AH      condition mask (same bit assignments as call mask)                 BX      button state                 CX      cursor column                 DX      cursor row                 DI      horizontal mickey count                 SI      vertical mickey count 
        0Dh     Light Pen Emulation On         entry   AH      0Dh         return  unknown 
        0Eh     Light Pen Emulation Off         entry   AH      0Eh         return  unknown 
        0Fh     Define Mickey/Pixel Ratio         entry   AH      0Fh                 CX      number of mickeys per 8 pixels horizontally                 DX      number of mickeys per 8 pixels vertically         return  unknown 
        10h     Define Screen Region for Updating         entry   AH      10h                 CX,DX   X,Y coordinates of upper left corner                 SI,DI   X,Y coordinates of lower right corner         return  unknown         note    Mouse cursor is hidden during updating, and needs to be                 explicitly turned on again 
        11h     not documented by Microsoft 
        12h     Set Large Graphics Cursor Block                 AH      12h                 BH      cursor width in words                 CH      rows in cursor                 BL      horizontal hot spot (-16 to 16)                 CL      vertical hot spot (-16 to 16)                 ES:DX   pointer to bit map of screen and cursor maps         return  AH      -1 if successful         note    PC Mouse. Not dodcumented by Microsoft 
        13h     Define Double-Speed Threshold         entry   AH      13h                 DX      threshold speed in mickeys/second,                         0 = default of 64/second         return  unknown         note    If speed exceeds threshold, the cursor's on-screen motion                 is doubled 
        14h     Exchange Interrupt Subroutines         entry   AH      14h         return  unknown 
        15h     Return Drive Storage Requirements         entry   AH      15h         return  BX      size of buffer needed to store driver state 
        16h     Save Driver State         entry   AH      16h                 ES:DX   pointer to buffer         return  unknown 
        17h     Restore Driver State         entry   AH      17h                 ES:DX   pointer to buffer containing saved state         return  unknown 
        18h     not documented by Microsoft 
        19h     not documented by Microsoft 
        1Ah     not documented by Microsoft 
        1Bh     not documented by Microsoft 
        1Ch     not documented by Microsoft 
        1Dh     Define Display Page Number         entry   AH      1Dh 
        1Eh     Return Display Page Number         entry   AH      1Eh         return  unknown 
        42h     PCMouse - Get MSmouse Storage Requirements                 AH      42h                 return  AX      0FFFFh successful                 BX      buffer size in bytes for functions 50h and 52h                         00h     MSmouse not installed                         42h     functions 42h, 50h, and 52h not supported 
        52h     PCMouse - Save MSmouse State         entry   AH      50h                 BX      buffer size                 ES:DX   pointer to buffer                 return  AX      0FFFFh if successful 
        52h     PCMouse - restore MSmouse state         entry   AH      52h                 BX      buffer size                 ES:DX   pointer to buffer                 return  AX      0FFFFh if successful Int 33: In addition, the following functions are appended to BIOS int 10h and         implemented as the EGA Register Interface Library: 
        0F0h    read one register         0F1h    write one register         0F2h    read consecutive register range         0F3h    write consecutive register range         0F4h    read non-consecutive register set         0F5h    write non-consecutive register set         0F6h    revert to default register values         0F7h    define default register values         0FAh    get driver status 
Interrupt 34h Turbo C/Microsoft languages - Floating Point emulation 
                This interrupt emulates opcode 0D8h 
Interrupt 35h Turbo C/Microsoft languages - Floating Point emulation 
                This interrupt emulates opcode 0D9h 
Interrupt 36h Turbo C/Microsoft languages - Floating Point emulation 
                This interrupt emulates opcode 0DAh 
Interrupt 37h Turbo C/Microsoft languages - Floating Point emulation 
                This interrupt emulates opcode 0DBh 
Interrupt 38h Turbo C/Microsoft languages - Floating Point emulation 
                This interrupt emulates opcode 0DCh 
Interrupt 39h Turbo C/Microsoft languages - Floating Point emulation 
                This interrupt emulates opcode 0DDh 
Interrupt 3Ah Turbo C/Microsoft languages - Floating Point emulation 
                This interrupt emulates opcode 0DEh 
Interrupt 3Bh Turbo C/Microsoft languages - Floating Point emulation 
                This interrupt emulates opcode 0DFh 
Interrupt 3Ch Turbo C/Microsoft languages - Floating Point emulation 
                This int emulates instructions with an ES segment override 
Interrupt 3Dh Turbo C/Microsoft languages - Floating Point emulation 
                This interrupt emulates a standalone FWAIT instruction 
Interrupt 3Eh Turbo C/Microsoft languages - Floating Point emulation 
Interrupt 3Fh Overlay manager interrupt (Microsoft LINK.EXE) 
Interrupt 40h Hard Disk BIOS 
                Pointer to disk BIOS entry when a hard disk controller is                 installed. The BIOS routines use int 30h to revector the                 diskette handler (original int 13h) here so int 40 may be used                 for hard disk control 
Interrupt 41h Hard Disk Parameters 
(XT,AT,XT2,XT286,PS except ESDI disks) 
                Pointer to first Hard Disk Parameter Block, normally located                 in the controller card's ROM. This table may be copied to RAM                 and changed, and this pointer revectored to the new table. note 1) format of parameter table is:         dw      cylinders         db      heads         dw      starting reduced write current cylinder (XT only, 0 for others)         db      maximum ECC burst length         db      control byte                   bits 0-2 drive option (XT only, 0 for others)                   bit 3    set if more than 8 heads                   bit 4    always 0                   bit 5    set if manufacturer's defect map on max cylinder+1                   bit 6    disable ECC retries                   bit 7    disable access retries         db      standard timeout (XT only, 0 for others)         db      formatting timeout (XT only, 0 for others)         db      timeout for checking drive (XT only, 0 for others)         dw      landing zone    (AT, PS/2)         db      sectors/track   (AT, PS/2)         db      0      2) normally vectored to ROM table when system is initialized. 
Interrupt 42h Pointer to screen BIOS entry (EGA, VGA, PS/2) 
                Relocated (by EGA, etc.) video handler (original int 10h).                 Revectors int 10 calls to EGA BIOS. 
Interrupt 43h Pointer to EGA initialization parameter table. The POST 
                initializes this vector pointing to the default table located                 in the EGA ROM BIOS. (PC-2 and up). Not initialized if EGA not                 present. 
Interrupt 44h Pointer to EGA graphics character table (also PCjr). 
(0:0110h) This table contains the dot patterns for the first 128 characters in video modes 4,5, and 6, and all 256 characters in all additional graphics modes. Not initialized if EGA not present. 
2) EGA/VGA/CONV/PS - EGA/PCjr fonts, characters 00h to 7Fh 3) Novell NetWare - High-Level Language API 
Interrupt 45h Reserved by IBM (not initialized) 
Interrupt 46h Pointer to second hard disk, parameter block (AT, XT/286, PS/2) 
                (see int 41h) (except ESDI hard disks) (not initialized unless                 specific user software calls for it) 
Interrupt 47h Reserved by IBM (not initialized) 
Interrupt 48h Cordless Keyboard Translation (PCjr, XT [never delivered]) 
(0:0120h)       This vector points to code to translate the cordless keyboard                 scancodes into normal 83-key values. The translated scancodes                 are then passed to int 9. (not initialized on PC or AT) 
Interrupt 49h Non-keyboard Scan Code Translation Table Address (PCjr) 
(0:0124h)       This interrupt has the address of a table used to translate                 non-keyboard scancodes (greater than 85 excepting 255). This                 interrupt can be revectored by a user application. IBM                 recommends that the default table be stored at the beginning                 of an application that required revectoring this interrupt,                 and that the default table be restored when the application                 terminates. (not initialized on PC or AT) 
Interrupt 4Ah Real-Time Clock Alarm (Convertible, PS/2) 
                (not initialized on PC or AT)                 Invoked by BIOS when real-time clock alarm occurs 
Interrupt 4Bh Reserved by IBM (not initialized) 
Interrupt 4Ch Reserved by IBM (not initialized) 
Interrupt 4Dh Reserved by IBM (not initialized) 
Interrupt 4Eh Reserved by IBM (not initialized) 
Interrupt 4Fh Reserved by IBM (not initialized) 
Interrupt 50-57 IRQ0-IRQ7 relocated by DesQview 
                (normally not initialized) 
Interrupt 58h Reserved by IBM (not initialized) 
Interrupt 59h Reserved by IBM (not initialized) 
                GSS Computer Graphics Interface (GSS*CGI)                 DS:DX   Pointer to block of 5 array pointers                 return  CF      0                         AX      return code                         CF      1                         AX      error code                 note 1) Int 59 is the means by which GSS*CGI language bindings                         communicate with GSS*CGI device drivers and the GSS*CGI                         device driver controller.                      2) Also used by the IBM Graphic Development Toolkit 
Interrupt 5Ah Reserved by IBM (not initialized) 
Interrupt 5Bh Reserved by IBM (not initialized) 
Interrupt 5Ah Cluster Adapter BIOS entry address 
                (normally not initialized) 
Interrupt 5Bh Reserved by IBM (not initialized) (cluster adapter?) 
Interrupt 5Ch NETBIOS interface entry port 
                ES:BX   pointer to network control block note 1) When the NETBIOS is installed, interrupts 13 and 17 are interrupted by         the NETBIOS; interrupt 18 is moved to int 86 and one of int 2 or 3 is         used by NETBIOS. Also, NETBIOS extends the int 15 function 90 and 91h         functions (scheduler functions)      2) Normally not initialized.      3) TOPS network card uses DMA 1, 3 or none. 
Interrupt 5Dh Reserved by IBM (not initialized) 
Interrupt 5Eh Reserved by IBM (not initialized) 
Interrupt 5Fh Reserved by IBM (not initialized) 
Interrupt 60h-67h User Program Interrupts (availible for general use) 
Interrupt 67h Used by Lotus-Intel-Microsoft Expanded Memory Specification 
        user    and Ashton-Tate/Quadram/AST Enhanced Expanded Memory                 specification (See Chapter 10) 
Interrupt 68h Not Used (not initialized) 
Interrupt 69h Not Used (not initialized) 
Interrupt 6Ah Not Used (not initialized) 
Interrupt 6Bh Not Used (not initialized) 
Interrupt 6Ch System Resume Vector (Convertible) (not initialized on PC) 
Interrupt 6Dh Not Used (not initialized) 
Interrupt 6Fh Not Used (not initialized) 
Interrupt 70h IRQ 8, Real Time Clock Interrupt (AT, XT/286, PS/2) 
Interrupt 71h IRQ 9, Redirected to IRQ 8 (AT, XT/286, PS/2) 
                LAN Adapter 1 (rerouted to int 0Ah by BIOS) 
Interrupt 72h IRQ 10 (AT, XT/286, PS/2) Reserved 
Interrupt 73h IRQ 11 (AT, XT/286, PS/2) Reserved 
Interrupt 74h IRQ 12 Mouse Interrupt (AT, XT/286, PS/2) 
Interrupt 75h IRQ 13, Coprocessor Error, BIOS Redirect to int 2 (NMI) (AT) 
Interrupt 76h IRQ 14, Hard Disk Controller (AT, XT/286, PS/2) 
Interrupt 77h IRQ 15 (AT, XT/286, PS/2) Reserved 
Interrupt 78h Not Used 
Interrupt 79h Not Used 
Interrupt 7Ah Novell NetWare - LOW-LEVEL API 
Interrupt 7Bh-7Fh Not Used 
Interrupt 80h-85h Reserved by BASIC 
note    interrupts 80h through ECh are apparently unused and not initialized. 
Interrupt 86h Relocated by NETBIOS int 18 
Interrupt 86h-0F0h Used by BASIC when BASIC interpreter is running 
Interrupt 0E0h CP/M-86 function calls 
Interrupt 0E4h Logitech Modula-2 v2.0 MONITOR 
entry   AX      05h     monitor entry                 06h     monitor exit         BX      priority 
Interrupts 0F1h-0FFh (absolute addresses 3C4-3FF) 
                      Location of Interprocess Communications Area 
Interrupt 0F8h Set Shell Interrupt (OEM) 
                Set OEM handler for int 21h calls from 0F9h through 0FFh entry   AH      0F8h         DS:DX   pointer to handler for Functions 0F9h thru 0FFh note 1) To reset these calls, pass DS and DX with 0FFFFh. DOS is set up to         allow ONE handler for all 7 of these calls. Any call to these handlers         will result in the carry bit being set and AX will contain 1 if they are         not initialized. The handling routine is passed all registers just as         the user set them. The OEM handler routine should be exited through an         IRET.      2) 10 ms interval timer (Tandy?) 
Interrupt 0F9h First of 8 SHELL service codes, reserved for OEM shell (WINDOW); 
                use like HP Vectra user interface? 
Interrupt 0FAh USART ready (RS-232C) 
Interrupt 0FBh USART RS ready (keyboard) 
Interrupt 0FCh Unknown 
Interrupt 0FDh reserved for user interrupt 
Interrupt 0FEh AT/XT286/PS50+ - destroyed by return from protected mode 
Interrupt 0FFh AT/XT286/PS50+ - destroyed by return from protected mode 
DOS CONTROL BLOCKS AND WORK AREAS 
When DOS loads a program, it first sets aside a section of memory for the program called the program segment, or code segment. Then it constructs a control block called the program segment prefix, or PSP, in the first 256 (100h) bytes. Usually, the program is loaded directly after the PSP at 100h. 
The PSP contains various information used by DOS to help run the program. The PSP is always located at offset 0 within the code segment. When a program recieves control certain registers are set to point to the PSP. For a COM file, all registers are set to point to the beginning of the PSP and the program begins at 100h. For the more complex EXE file structures, only DS and ES registers are set to point to the PSP. The linker passes the settings for the DS, IP, SS, and SP registers and may set the starting location in CS:IP to a location other than 100h. 
IBMBIO provides an IRET instruction at absolute address 847h for use as a dummy routine for interrupts that are not used by DOS. This lets the interrupts do nothing until their vectors are rerouted to ttheir appropriate handlers. 
A storage block is used by DOS to record the amount and location of allocated memory withion the machine's address spacd. 
A storage block, a Program Segment Prefix, and an environment area are built by FDOS for each program currently resident in the address space. The storage block is used by DOS to record the address range of memory allocated to a program. IOt us used by DOs to find th enext availible area to load  a program and to determine if there is a\enough memory to run that porogram. When a memory area is in use, it is said to be allocated. Then the program ends, or releases memory, it is said to bne deallocated. 
A storage block contains a pointer ro rhe Program Segment Prefix assoiciated with each program. This control block is constructed by IBMDOS for the purpose opf providing stanfdardized areas for DOS/program communication., Within ghr PSP are arsas which  are used to save interrupt vectors, pass parameters to the program, record disk directory information, and to buffer disk reads and writes. This control block is 100h bytes in lengrth and is followed by the program mopdule loaded by DOS. 
The PSP contains a pointer to the environment area for that program. This area contains a copy of the current DOS SET, PROMPT, COMSPEC, and PATH values as well as any user-set variables. The program may examine and modify this information as desired. 
Each storage block is 10h bytes long, although only 5 bytes are currently used by DOS. The first byte contains 4Dh (a capital M) to indicate that it contains a pointer to the next storage block. A 5Ah (a capital Z) in the first byte of a storage block indicatres there are no more storage blocks following this one (it is the end of the chain). The identifier byte is followeed by a 2 byte segment number for the associated PSP for that program. The next 2 bytes contain the number of segments what are allocated to the program. If this is not the last storage block, then another storage block follows the allocated memory area. 
When thge storage block contains zero for the nuymber of allocated segments, then no storage is allocated to thius block and the next storage block immediately follows this one. This can ha-p[en whjen memory is allocated and then deallocated repeatedly. 
IBMDOS constructs a storage block and PSP before loading the command interpreter (default is COMMAND.COM). If the copy of COMMAND.COM is a secondary copy, it will lack an environment address as PSP+2Ch. 
The Disk Transfer Area (DTA) 
DOS uses an area in memory to contain the data for all file reads and writes that are performed with FCB function calls. This are is known as the disk transfer area. This disk transfer area (DTA) is sometimes called a buffer. It can be located anywhere in the data area of your application program and should be set by your program. 
Only one DTA can be in effect at a time, so your program must tell DOS what memory location to use before using any disk read or write functions. Use function call 1Ah (Set Disk Transfer Address) to set the disk transfer address. Use function call 2Fh (Get Disk Transfer Address) to get the disk transfer address. Once set, DOS continues to use that area for all disk operations until another function call 1Ah is issued to define a new DTA. When a program is given control by COMMAND.COM, a default DTA large enough to hold 128 bytes is established at 80h into the program's Program Segment Prefix. 
For file reads and writes that are performed with the extended function calls, there is no need to set a DTA address. Instead, specify a buffer address when you issue the read or write call. 
DOS Program Segment 
When you enter an external command or call a program through the EXEC function call, DOS determines the lowest availible address space to use as the start of available memory for the program being started. This area is called the Program Segment. 
At offset 0 within the program segment, DOS builds the Program Segment Prefix control block. EXEC loads the program after the Program Segment Prefix (at offset 100h) and gives it control. 
The program returns from EXEC by a jump to offset 0 in the Program Segment Prefix, by issuing an int 20h, or by issuing an int 21h with register AH=00h or 4Ch, or by calling location 50h in the PSP with AH=00h or 4Ch. 
It is the responsibility of all programs to ensure that the CS register contains the segment address of the Program Segment Prefix when terminating by any of these methods except call 4Ch. 
All of these methods result in returning to the program that issued the EXEC. During this returning process, interrupt vectors 22h, 23h, and 24h (Terminate, Ctrl-Break, and Critical Error Exit addresses) are restored from the values saved in the PSP of the terminating program. Control is then given to the terminate address. When a program receives control, the following conditions are in effect: 
For all programs: 
1) The segment address of the passed environment is contained at offset 2Ch in    the Program Segment Prefix. 
2) The environment is a series of ASCII strings totalling less than 32k bytes    in the form:       NAME=parameter      The default environment is 160 bytes.     Each string is terminated by a byte of zeroes, and the entire set of strings    is terminated by abother byte of zeroes. Following the byte of zeroes that    terminates the set of environment string is a set of initial arguments passed    to a program that contains a word count followed by an ASCIIZ string. The    ASCIIZ string contains the drive, path, and filename.ext of the executable    program. Programs may use this area to determine where the program was loaded    from. The environment built by the command processor (and passed to all    programs it invokes) contains a COMSPEC=string at a minimum (the parameter on    COMSPEC is the path used by DOS to locate COMMAND.COM 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.     The environment that you are passed is actually a copy of the invoking    process's environment. If your application terminates and stays resident    through int 27h, you should be aware that the copy of the environment passed    to you is static. That is, it will not change even if subsequent PATH,    PROMPT, or SET commands are issued. 
   The environment can be used to transfer information between processes or to    store strings for later use by application programs. The environment is    always located on a paragraph boundary. This is its format:         byte    ASCIIZ string 1         byte    ASCIIZ string 2             ....         byte    ASCIIZ string n         byte    of zeros (0)    Typically the environment strings have the form:         parameter = value    Following the byte of zeros in the environment, a WORD indicates the number    of other strings following. 
   If the environment is part of an EXECed command interpreter, it is followed    by a copy of the DS:DX filename passed to the child process. A zero value    causes the newly created process to inherit the parent's environment. 
3) Offset 80h in the PSP contains code to invoke the DOS function dispatcher.    Thus, by placing the desired function number in AH, a program can issue a    long call to PSP+50h to invoke a DOS function rather than issuing an int 21h. 
4) The disk transfer address (DTA) is set to 80h (default DTA in PSP). 
5) File Control Blocks 5Ch and 6Ch are formatted from the first two parameters    entered when the command was invoked. Note that if either parameter contained    a path name, then the corresponding FCB will contain only a valid drive    number. The filename field will not be valid. 
6) An unformatted parameter area at 81h contains all the characters entered    after the command name (including leading and imbedded delimiters), with 80h    set to the number of characters. If the <, >, or | parameters were entered    on the command line, they (and the filenames associated with them) will not    appear in this area, because redirection of standard input and output is    transparent to applications. 
(For EXE files only) 7) DS and ES registers are set to point to the PSP. 
8) CS, IP, SS, and SP registers are set to the values passed by the linker. 
(For COM files only) 9) For COM files, offset 6 (one word) contains the number of bytes availible in    the segment. 
10) Register AX reflects the validity of drive specifiers entered with the     first two parameters as follows:         AL=0FFh is the first parameter contained an invalid drive specifier,                 otherwise AL=00h.         AL=0FFh if the second parameter contained an invalid drive specifier,                 otherwise AL=00h. 
11) All four segment registers contain the segment address of the inital     allocation block, that starts within the PSP control block. All of user     memory is allocated to the program. If the program needs to invoke another     program through the EXEC function call (4Bh), it must first free some memory     through the SETBLOCK function call to provide space for the program being     invoked. 
12) The Instruction Pointer (IP) is set to 100h. 
13) The SP register is set to the end of the program's segment. The segment size     at offset 6 is rounded down to the paragraph size. 
14) A word of zeroes is placed on top of the stack.  The PSP (with offsets in hexadecimal) is formatted as follows: 
Ŀ      P  R  O  G  R  A  M       S  E  G  M  E  N  T       P  R  E  F  I  X      Ĵ  offset   size                        C O N T E N T S                        Ĵ  0000h  2 bytes   int 20h                                                    Ĵ  0002h  2 bytes   segment address, end of allocation block                   Ĵ  0004h  1 byte    reserved, normally 0                                       Ĵ  0005h  5 bytes   long call to MSDOS function dispatcher                     Ĵ  000Ah  4 bytes   previous termination handler interrupt vector (int 22h)    Ĵ  000Eh  4 bytes   previous contents of ctrl-C interrupt vector (int 23h)     Ĵ  0012h  4 bytes   prev. critical error handler interrupt vector (int 24h)    Ĵ  0016h  22 bytes  reserved for DOS                                           Ĵ  002Ch  2 bytes   segment address of environment block                       Ĵ  002Eh  34 bytes  reserved, DOS work area                                    Ĵ           4 bytes   stores the calling process's stack pointer when                               switching to DOS's internal stack.                        Ĵ  0050h   3 bytes  int 21h, RETF instructions                                 Ĵ  0053h   2 bytes  reserved                                                   Ĵ  0055h   7 bytes  reserved, or FCB#1 extension                               Ĵ  005Ch            default File Control Block #1                              Ĵ  006Ch            default File Control Block #2 (overlaid if FCB #1 opened)  Ĵ  0080h   1 byte   parameter length                                           Ĵ  0081h            parameters                                                 Ĵ  00FFh  128 bytes command tail and default Disk Transfer Area (DTA)           
1. The first segment of availible memory is in segment (paragraph) form. For    example, 1000h would respresent 64k. 
2. The word at offset 6 contains the number of bytes availible in the segment. 
3. Offset 2Ch contains the segment address of the environment. 
4. Programs must not alter any part of the PSP below offset 5Ch. 
offset 0 contains hex bytes CD 20, the int 20h opcode. A program can end        by making a jump to this location when the CS points to the PSP.        For normal cases, int 21, function 4Ch should be used. 
offset 2 contains the segment-paragraph address of the end of memory as         reported by DOS. (which may not be the same as the real end of RAM).         Multiply this number by 10h or 16 to get the amount of memory availible. 
offset 4 reserved 
offset 05 contains a long call to the DOS function dispatcher. Programs may        jump to this address instead of calling int 21 if they wish. 
offsets 10, 14, 18  vectors 
offset 2C is the segment:offset address of the environment for the program        using this particular PSP. 
offset 2E The DWORD at PSP+2EH is used by DOS to store the calling process's        stack pointer when switching to DOS's own private stack - at the end of        a DOS function call, SS:SP is restored from this address. 
offset 50h contains a long call to the DOS function dispatcher. 
offsets 5C, 65, 6C  contain FCB information for use with FCB function calls.         The first FCB may overlay the second if it is an extended call; your         program should revector these areas to a safe place if you intend to         use them. 
offset 80h and 81h contain th elength and value of parameters passed on the        command line. 
offset FF contains the DTA 
STANDARD FILE CONTROL BLOCK 
 The standard file control block is defined as follows, with the offsets in decimal: 
Ŀ                  F I L E      C O N T R O L      B L O C K                     Ĵ  Bytes                            Function                                    Ĵ    0    Drive number. For example:                                                    Before open:    00h = default drive                                                           01h = drive A:                                                                02h = drive B: etc.                                           After open:     00h = drive C:                                                                01h = drive A:                                                                02h = drive B: etc.                                           0 is replaced by the actual drive number during open.                 Ĵ   1-8   Filename, left justified with trailing blanks. If a reserved device           name is placed here (such as PRN) do not include the optional colon.  Ĵ   9-11  Filename extension, left justified with trailing blanks.              Ĵ  12-13  Current block number relative to beginning of file, starting with 0           (set to 0 by the open function call). A block consists of 128                 records, each of the size specified in the logical record size field.         The current block number is used with the current record field                (below) for sequential reads and writes.                              Ĵ  14-15  Logical record size in bytes. Set to 80h by the OPEN function call.           If this is not correct, you must set the value because DOS uses it            to determine the proper locations in the file for all disk reads and          writes.                                                               Ĵ  16-19  File size in bytes. In this 2 word field, the first word is the               low-order part of the size.                                           Ĵ  20-21  Date the file was created or last updated. The mm/dd/yy are mapped            as follows:                                                                           15  14  13  12  11  10  9  8  7  6  5  4  3  2  1  0                          y   y   y   y   y   y   y  m  m  m  m  d  d  d  d  d                  where:            mm is 1-12                                                                    dd is 1-31                                                                    yy is 0-119 (1980-2099)                             Ĵ  22-31  Reserved for system use.                                              Ĵ   32    Current relative record number (0-127) within the current block.              (See above). You must set this field before doing sequential                  read/write operations to the diskette. This field is not initialized          by the open function call.                                                     If the record size is less than 64 bytes, both words are used.               Otherwise, only the first 3 bytes are used. Note that if you use the          File Control Block at 5Ch in the program segment, the last byte of            the FCB overlaps the first byte of the unformatted parameter area.     
note 1) An unopened FCB consists of the FCB prefix (if used), drive number, and         filename.ext properly filled in. An open FCB is one in which the         remaining fields have been filled in by the CREAT or OPEN function         calls.      2) Bytes 0-5 and 32-36 must be set by the user program. Bytes 16-31 are set         by DOS and must not be changed by user programs.      3) All word fields are stored with the least significant byte first. For         example, a record length of 128 is stored as 80h at offset 14, and 00h         at offset 15. 
EXTENDED FILE CONTROL BLOCK 
 The extended file control block is used to create or search for files in the disk directory that have special attributes. 
It adds a 7 byte prefix to the FCB, formatted as follows: 
Ŀ        E X T E N D E D     F I L E      C O N T R O L      B L O C K           Ĵ  Bytes                            Function                                    Ĵ    0    Flag byte containing 0FFh to indicate an extended FCB.                Ĵ   1-6   Reserved                                                              Ĵ   6-7   Attribute byte. Refer to function call 11h (search first) for                 details on using the attribute bits during directory searches. This           function is present to allow applications to define their own files           as hidden (and thereby excluded from normal directory searches) and           to allow selective directory searches.                                 
Any reference in the DOS function calls to an FCB, whether opened or unopened, may use either a normal or extended FCB. If you are using an extended FCB, the appropriate register should be set to the first byte of the prefix, rather than the drive-number field. 
MEMORY CONTROL BLOCKS 
DOS keeps track of allocated and availible memory blocks, and provides three function calls for application programs to communicate their memory needs to DOS. These calls are 48h to allocate a memory block, 49h to free a previously allocated memory block, and 4Ah (SETBLOCK) to change the size of an allocated memory block. 
CONTROL BLOCK 
DOS manages memory as follows: 
DOS build a control block for each block of memory, whether free or allocated. For example, if a program issues an "allocate" (48h), DOS locates a block of free memory that satisfies the request, and then "carves" the requested memory out of that block. The requesting program is passed the location of the first byte of the block that was allocated for it - a memory management control block, describing the allocated block, has been built for the allocated block and a second memory management control block describes the amount of space left in the original free block of memory. When you do a setblock to shrink an allocated block, DOS builds a memory management control block for the area being freed and adds it to the chain of control blocks. Thus, any program that changed memory that is not allocated to it stands a chance of destroying a DOS memory management control block. This causes unpredictable results that don't show up until an activity is performed where DOS uses its chain of control blocks. The normal result is a memory allocation error, which means a system reset will be required. 
When a program (command or application program) is to be loaded, DOS uses the EXEC function call 4Bh to perform the loading. 
This is the same function call that is availible to applications programs for loading other programs. This function call has two options: 
      Function 00h, to load and execute a program (this is what the command                     processor uses to load and execute external commands) 
      Function 03h, to load an overlay (program) without executing it. 
Although both functions perform their loading in the same way (relocation is performed for EXE files) their handling of memory management is different. FUNCTION 0: For function 0 to load and execute a program, EXEC first allocates the largest availible block of memory (the new program's PSP will be at offset 0 in that block). Then EXEC loads the program. Thus, in most cases, the new program owns all the memory from its PSP to the end of memory, including memory occupied by the transient parent of COMMAND.COM. If the program were to issue its own EXEC function call to load and execute another program, the request would fail because no availible memory exists to load the new program into. 
NOTE: For EXE programs, the amount of memory allocated is the size of the program's memory image plus the value in the MAX_ALLOC field of the file's header (offset 0Ch, if that much memory is availible. If not, EXEC allocates the size of the program's memory image plus the value in the MIN_ALLOC field in the header (offset 0Ah). These fields are set by the Linker). 
A well-behaved program uses the SETBLOCK function call when it receives control, to shrink its allocated memory block down to the size it really needs. A COM program should remember to set up its own stack before doing the SETBLOCK, since it is likely that the default stack supplied by DOS lies in the area of memory being used. This frees unneeded memory, which can be used for loading other programs. 
If the program requires additional memory during processing, it can obtain the memory using the allocate function call and later free it using the free memory function call. 
When a program is loaded using EXEC function call 00h exits, its initial allocation block (the block beginning with its PSP) is automatically freed before the calling program regains control. It is the responsibility of all programs to free any memory they allocate before exiting to the calling program. 
FUNCTION 3: For function 3, to load an overlay, no PSP is built and EXEC assumes the calling program has already allocated memory to load the new program into - it will NOT allocate memory for it. Thus the calling program should either allow for the loading of overlays when it determines the amount of memory to keep when issuing the SETBLOCK call, or should initially free as much memory as possible. The calling program should then allocate a block (based on the size of the program to be loaded) to hold the program that will be loaded using the "load overlay" call. Note that "load overlay" does not check to see if the calling program actually owns the memory block it has been instructed to load into - it assumes the calling program has followed the rules. If the calling program does not own the memory into which the overlay is being loaded, there is a chance the program being loaded will overlay one of the control blocks that DOS uses to keep track of memory blocks. 
Programs loaded using function 3 should not issue any SETBLOCK calls since they don't own the memory they are operating in. (This memory is owned by the calling program) 
Because programs loaded using function 3 are given control directly by (and return contrrol directly to) the calling program, no memory is automatically freed when the called program exits. It is up to the calling program to determine the disposition of the memory that had been occupied by the exiting program. Note that if the exiting program had itself allocated any memory, it is responsible for freeing that memory before exiting. 
MEMORY CONTROL BLOCKS 
Only the first 5 bytes of the memory control block are used. The first byte will always have the value of 4Dh or 5Ah. The value 5Ah indicates the block is the last in a chain, all memory above it is unused. 4Dh means that the block is intermediate in a chain, the memory above it belongs to the next program or to DOS. 
The next two bytes hold the PSP segment address of the program that owns the corresponding block of memory. A value of 0 means the block is free to be claimed, any other value represents a segment address. Bytes 3 and 4 indicate the size in paragraphs of the memory block. If you know the address of the first block, you can find the next block by adding the length of the memory block plus 1 to the segment address of the control block. 
Finding the first block can be difficult, as this varies according to the DOS version and the configuration. 
The remaining 11 bytes are not currently used by DOS, and may contain "trash" characters left in memory from previous applications. 
If DOS determines that the allocation chain of memory control blocks has been corrupted, it will halt the system and display the message "Memory Allocation Error", and the system will halt, requiring a reboot. 
Each memory block consists of a signature byte (4Dh or 5Ah) then a word which is the PSP value of the owner of the block (which allocated it), followed by a word which is the size in paragraphs of the block. The last block has a signature of 5Ah. All others have 4Dh. If the owner is 0000 then the block is free. 
User memory is allocated from the lowest end of available memory that will satisfy the request for memory. 
DOS File Structure 
File Management Functions 
Use DOS function calls to create, open, close, read, write, rename, find, and erase files. There are two sets of function calls that DOS provides for support of file management. They are: 
* File Control Block function calls   (0Fh-24h) * Handle function calls               (39h-62h) 
Handle function calls are easier to use and are more powerful than FCB calls. Microsoft recommends that the handle function calls be used when writing new programs. DOS 3.0 up have been curtailing use of FCB function calls; it is possible that future versions of DOS may not support FCB function calls. 
The following table compares the use of FCB calls to Handle function calls: 
                FCB Calls                       Handle Calls 
        Access files in current         Access files in ANY directory         directory only. 
        Requires the application        Does not require use of an FCB.         program to maintain a file      Requires a string with the drive,         control block to open,          path, and filename to open, create,         create, rename or delete        rename, or delete a file. For file         a file. For I/O requests,       I/O requests, the application program         the application program         must maintain a 16 bit file handle         also needs an FCB               that is supplied by DOS. 
The only reason an application should use FCB function calls is to maintain the ability to run under DOS 1.x. To to this, the program may use only function calls 00h-2Eh. 
FCB FUNCTION CALLS 
FCB function calls require the use of one File Control Block per open file, which is maintained by the application program and DOS. The application program supplies a pointer to the FCB and fills in ther appropriate fields required by the specific function call. An FCB function call can perform file management on any valid drive, but only in the current logged directory. By using the current block, current record, and record length fields of the FCB, you can perform sequential I/O by using the sequential read or write function calls. Random I/O can be performed by filling in the random record and record length fields. 
Several possible uses of FCB type calls are considered programming errors and should not be done under any circumstances to avoid problems with file sharing and compatibility with later versions of DOS.  Some errors are: 
1) If program uses the same FCB structure to access more than one open file. By    opening a file using an FCB, doing I/O, and then replacing the filename field    in the file control block with a new filename, a program can open a second    file using the same FCB. This is invalid because DOS writes control info-    rmation about the file into the reserved fields of the FCB. If the program    then replaces the filename field with the original filename and then tries to    perform I/O on this file, DOS may become confused because the control info-    rmation has been changed. An FCB should never be used to open a second file    without closing the one that is currently open. If more than one File Control    Block is to be open concurrently, separate FCBs should be used. 
2) A program should never try to use the reserved fields in the FCB, as the    function of the fields changes with different versions of DOS. 
3) A delete or a rename on a file that is currently open is considered an error    and should not be attempted by an application program. 
It is also good programming practice to close all files when I/O is done. This avoids potential file sharing problems that require a limit on the number of files concurrently open using FCB function calls. 
HANDLE FUNCTION CALLS 
The recommended method of file management is by using the extended "handle" set of function calls. These calls are not restricted to the current directory. Also, the handle calls allow the application program to define the type of access that other processes can have concurrently with the same file if the file is being shared. 
To create or open a file, the application supplies a pointer to an ASCIIZ string giving the name and location of the file. The ASCIIZ string contains an optional drive letter, optional path, mandatory file specification, and a terminal byte of 00h. The following is an example of an ASCIIZ string: 
                  format [drive][path] filename.ext,0 
                      DB "A:\path\filename.ext",0 
If the file is being created, the application program also supplies the attribute of the file. This is a set of values that defines the file read only, hidden, system, directory, or volume label. 
If the file is being opened, the program can define the sharing and access modes that the file is opened in. The access mode informs DOS what operations your program will perform on this file (read-only, write-only, or read/write) The sharing mode controls the type of operations other processes may perform concurrently on the file. A program can also control if a child process inherits the open files of the parent. The sharing mode has meaning only if file sharing is loaded when the file is opened. 
To rename or delete a file, the appplication program simply needs to provide a pointer to the ASCIIZ string containing the name and location of the file and another string with the neew name if the file is being renamed. 
The open or create function calls return a 16-bit value referred to as the file handle. To do any I/O to a file, the program uses the handle to reference the file. Once a file is opened, a program no longer needs to maintain the ASCIIZ string pointing to the file, nor is there any need to stay in the same directory. DOS keeps track of the location of the file regardless of what directory is current. 
Sequential I/O can be performed using the handle read (3Fh) or write (40h) function calls. The offset in the file that IO is performed to is automatically moved to the end of what was just read or written. If random I/O is desired, the LSEEK (42h) function call can be used to set the offset into the file where I/O is to be performed. 
SPECIAL FILE HANDLES 
DOS reserves five special file handles for use by itself and applications programs. They are: 
              0000h   STDIN   Standard Input Device               0001h   STDOUT  Standard Output Device               0002h   STDERR  Standard Error Output Device               0003h   STDAUX  Standard Auxiliary Device               0004h   STDPRN  Standard Printer Device 
These handles are predefined by DOS and can be used by an application program. They do not need to be opened by a program, although a program can close these handles. STDIN should be treated as a read-only file, and STDOUT and STDERR should be treated as write-only files. STDIN and STDOUT can be redirected. All handles inherited by a process can be redirected, but not at the command line. 
These handles are very useful for doing I/O to and from the console device. For example,  you could read input from the keyboard using the read (3Fh) function call and file handle 0000h (STDIN), and write output to the console screen with the write function call (40h) and file handle 0001h (STDOUT). If you wanted an output that could not be redirected, you could output it using file handle 0002h (STDERR). This is very useful for error messages that must be seen by a user. 
File handles 0003h (STDAUX) and 0004h (STDPRN) can be both read from and written to. STDAUX is typically a serial device and STDPRN is usually a parallel device. 
ASCII and BINARY MODE 
I/O to files is done in binary mode. This means that the data is read or written without modification. However, DOS can also read or write to devices in ASCII mode. In ASCII mode, DOS does some string processing and modification to the characters read and written. The predefined handles are in ASCII mode when initialized by DOS. All other file handles that don't refer to devices are in binary mode. A program, can use the IOCTL (44h) function call to set the mode that I/O is to a device. The predefined file handles are all devices, so the mode can be changed from ASCII to binary via IOCTL. Regular file handles that are not devices are always in binary mode and cannot be changed to ASCII mode. 
The ASCII/BINARY bit was called "raw" in DOS 2.x, but it is called ASCII/BINARY in DOS 3.x. 
The predefined file handles STDIN (0000h) and STDOUT (0001h) and STDERR (0002h) are all duplicate handles. If the IOCTL function call is used to change the mode of any of these three handles, the mode of all three handles is changed. For example, if IOCTL was used to change STDOUT to binary mode, then STDIN and STDERR would also be changed to binary mode. 
FILE I/O IN BINARY (RAW) MODE 
The following is true when a file is read in binary mode: 
1)  The characters ^S (scroll lock), ^P (print screen), ^C (control break) are     not checked for during the read. Therefore, no printer echo occurs if ^S or     ^P are read. 2)  There is no echo to STDOUT (0001h). 3)  Read the number of specified bytes and returns immediately when the last     byte is received or the end of file reached. 4)  Allows no editing of the ine input using the function keys if the input is     from STDIN (0000h). The following is true when a file is written to in binary mode: 
1)  The characters ^S (scroll lock), ^P (print screen), ^C (control break) are     not checked for during the write. Therefore, no printer echo occurs. 2)  There is no echo to STDOUT (0001h). 3)  The exact number of bytes specified are written. 4)  Does not caret (^) control characters. For example, ctrl-D is sent out as     byte 04h instead of the two bytes ^ and D. 5)  Does not expand tabs into spaces. 
FILE I/O IN ASCII (COOKED) MODE 
The following is true when a file is read in ASCII mode: 
1)  Checks for the characters ^C,^S, and ^P. 2)  Returns as many characters as there are in the device input buffer, or the     number of characters requested, whichever is less. If the number of     characters requested was less than the number of characters in the device     buffer, then the next read will address the remaining characters in the     buffer. 3)  If there are no more bytes remaining in the device input buffer, read a     line (terminated by ^M) into the buffer. This line may be edited with the     function keys. The characters returned terminated with a sequence of 0Dh,     0Ah (^M,^J) if the number of characters requested is sufficient to include     them. For example, if 5 characters were requested, and only 3 were entered     before the carriage return (0Dh or ^M) was presented to DOS from the console     device, then the 3 characters entered and 0Dh and 0Ah would be returned.     However, if 5 characters were requested and 7 were entered before the     carriage return, only the first 5 characters would be returned. No 0Dh,0Ah     sequence would be returned in this case. If less than the number of     characters requested are entered when the carriage return is received, the     characters received and 0Dh,0Ah would be returned. The reason the 0Ah     (linefeed or ^J) is added to the returned characters is to make the devices     look like text files. 4)  If a 1Ah (^Z) is found, the input is terminated at that point. No 0Dh,0Ah     (CR,LF) sequence is added to the string. 5)  Echoing is performed. 6)  Tabs are expanded. The following is true when a file is written to in ASCII mode: 
1)  The characters ^S,^P,and ^C are checked for during the write operation. 2)  Expands tabs to 8-character boundaries and fills with spaces (20h). 3)  Carets control characters, for example, ^D is written as two bytes, ^ and D. 4)  Bytes are output until the number specified is output or a ^Z is     encountered. The number actually output is returned to the user. 
NUMBER OF OPEN FILES ALLOWED 
The number of files that can be open concurrently is restricted by DOS. This number is determined by how the file is opened or created (FCB or handle function call) and the number specified by the FCBS and FILES commands in the CONFIG.SYS file. The number of files allowed open by FCB function calls and the number of files that can be opened by handle type calls are independent of one another. 
RESTRICTIONS ON FCB USAGE 
If file sharing is not loaded using the SHARE command, there are no restrictions on the nuumber of files concurrently open using FCB function calls. 
However, when file sharing is loaded, the maximum number of FCBs open is set by the the FCBS command in the CONFIG.SYS file. 
The FCBS command has two values you can specify, 'm' and 'n'. The value for 'm' specifies the number of files that can be opened by FCBs, and the value 'n' specifies the number of FCBs that are protected from being closed. 
When the maximum number of FCB opens is exceeded, DOS automatically closes the least recently used file. Any attempt to access this file results in an int 24h critical error message "FCB not availible". If this occurs while an application program is running, the value specified for 'm' in the FCBS command should be increased. 
When DOS determines the least recently used file to close, it does not include the first 'n' files opened, therefore the first 'n' files are protected from being closed. 
RESTRICTIONS ON HANDLE USAGE 
The number of files that can be open simultaneously by all processes is determined by the FILES command in the CONFIG.SYS file. The number of files a single process can open depends on the value specified for the FILES command. If FILES is greater than or equal to 20, a single process can open 20 files. If FILES is less than 20, the process can open less than 20 files. This value includes three predefined handles: STDIN, STDOUT, and STDERR. This means only 17 additional handles can be added. DOS 3.3 includes a function to use more than 20 files per application. 
ALLOCATING SPACE TO A FILE 
Files are not nescessarily written sequentially on a disk. Space is allocated as needed and the next location availible on the disk is allocated as space for the next file being written. Therefore, if considerable file generation has taken place, newly created files will not be written in sequential sectors. However, due to the mapping (chaining) of file space via the File Allocation Table (FAT) and the function calls availible, any file may be used in either a sequential or random manner. 
Space is allocated in increments called clusters. Cluster size varies according to the media type. An application program should not concern itself with the way that DOS allocates space to a file. The size of a cluster is only important in that it determines the smallest amount of space that can be allocated to a file. A disk is considered full when all clusters have been allocated to files. 
MSDOS / PCDOS DIFFERENCES 
There is a problem of compatibility between MS-DOS and IBM PC-DOS having to do with FCB Open and Create. The IBM 1.0, 1.1, and 2.0 documentation of OPEN (call 0Fh) contains the following statement: 
"The current block field (FCB bytes C-D) is set to zero [when an FCB is opened]." 
This statement is NOT true of MS-DOS 1.25 or MS-DOS 2.00. The difference is intentional, and the reason is CP/M 1.4 compatibility. Zeroing that field is not CP/M compatible. Some CP/M programs will not run when machine translated if that field is zeroed. The reason it is zeroed in the IBM versions is that IBM specifically requested that it be zeroed. This is the reason for the complaints from some vendors about the fact that IBM MultiPlan will not run under MS-DOS. It is probably the reason that some other IBM programs don't run under MS-DOS. 
NOTE: Do what all MS/PC-DOS Systems programs do: Set every single FCB field you want to use regardless of what the documentation says is initialized. 
.EXE FILE STRUCTURE 
The EXE files produced by the Linker program consist of two parts, control and relocation information and the load module itself. 
The control and relocation information, which is described below, is at the beginning of the file in an area known as the header. The load module immediately follows the header. The load module begins in the memory image of the module contructed by the Linker. 
When you are loading a file with the name *.EXE, DOS does NOT assume that it is an EXE format file. It looks at the first two bytes for a signature telling it that it is an EXE file. If it has the proper signature, then the load proceeds. Otherwise, it presumes the file to be a .COM format file. 
If the file has the EXE signature, then the internal consistency is checked. Pre-2.0 versions of MSDOS did not check the signature byte for EXE files. 
The .EXE format can support programs larger than 64K. It does this by allowing separate segments to be defined for code, data, and the stack, each of which can be up to 64K long. Programs in EXE format may contain explicit references to segment addresses. A header in the EXE file has information for DOS to resolve these references. The .EXE header is formatted as follows:
Ŀ  Offset                        C O N T E N T S                               Ĵ    00h    4Dh  This is the Linker's signature to mark the file as a valid   Ĵ .EXE file  (The ASCII letters M and Z, for Mark Zbikowski,      01h    5Ah  one of the major designers of DOS at Microsoft)              Ĵ  02h-03h  Length of the image mod 512 (remainder after dividing the load               module image by 512)                                               Ĵ  04h-05h  Size of the file in 512 byte pages including the header.           Ĵ  06h-07h  Number of relocation table items.                                  Ĵ  08h-09h  Size of the header in 16 byte increments (paragraphs). This is               used to locate the beginning of the load module in the file.       Ĵ  0Ah-0Bh  Minimum number of 16 byte paragraphs required above the end of               the loaded program.                                                Ĵ  0Ch-0Dh  Maximum number of 16 byte paragraphs required above the end of               the loaded program.                                                Ĵ  0Eh-0Fh  Displacement in paragraphs of stack segment within load module.    Ĵ  10h-11h  Offset to be in SP register when the module is given control.      Ĵ  12h-13h  Word Checksum - negative sum of all the words in the file,                   ignoring overflow.                                                 Ĵ  14h-15h  Offset to be in the IP register when the module is given control.  Ĵ  16h-17h  Displacement in paragraphs of code segment within load module.     Ĵ  18h-19h  Displacement in bytes of the first relocation item in the file.    Ĵ  1Ah-1Bh  Overlay number (0 for the resident part of the program)             
THE RELOCATION TABLE 
The word at 18h locates the first entry in the relocation table. The relocation table is made up of a variable number of relocation items. The number of items is contained at offset 06-07. The relocation item contains two fields - a 2 byte offset value, followed by a 2 byte segment value. These two fields represent the displacement into the load module before the module is given control. The process is called relocation and is accomplished as follows: 
1. A Program Segment Prefix is built following the resident portion of the    program that is performing the load operation. 
2. The formatted part of the header is read into memory (its size is at    offset 08-09) 
3. The load module size is determined by subtracting the header size from the    file size. Offsets 04-05 and 08-09 can be used for this calculation. The    actual size is downward adjusted based on the contents of offsets 02-03.    Note that all files created by the Linker programs prior to version 1.10    always placed a value of 4 at this location, regardless of the actual    program size. Therefore, Microsoft recommends that this field be ignored if    it contains a value of 4. Based on the setting of the high/low loader switch,    an appropriate segment is determined for loading the load module. This    segment is called the start segment. 
4. The load module is read into memory beginning at the start segment. The    relocation table is an ordered list of relocation items. The first relocation    item is the one that has the lowest offset in the file. 
5. The relocation table items are read into a work area one or more at a time. 
6. Each relocation table item segment value is added to the start segment value.    The calculated segment, in conjunction with the relocation item offset value,    points to a word in the load module to which is added the start segment    value. The result is placed back into the word in the load module. 
7. Once all the relocation items have been processed, the SS and SP registers    are set from the values in the header and the start segment value is added    to SS. The ES and DS registers are set to the segment address of the program    segment prefix. The start segment value is added to the header CS register    value. The result, along with the header IP value, is used to give the    module control. 
"NEW" .EXE FORMAT (Microsoft Windows and OS/2) 
The "old" EXE format is documented here. The "new" EXE format puts more information into the header section and is currently used in applications that run under Microsoft Windows. The linker that creates these files comes with the Microsoft Windows Software Development Kit and is called LINK4. If you try to run a Windows-linked program under DOS, you will get the error message "This program requires Microsoft Windows". 
DOS DISK INFORMATION 
THE DOS AREA 
All disks and diskettes formatted by DOS are created with a sector size of 512 bytes. The DOS area (entire area for a diskette, DOS partition for hard disks) is formatted as follows: 
        Boot record - 1 sector         First copy of the FAT - variable size         Second copy of the FAT - same size as first copy         Root directory - variable size         Data area 
The following sections describe each of the allocated areas: 
THE BOOT RECORD 
The boot record resides on track 0, sector 1, side 0 of every diskette formatted by the DOS FORMAT program. It is put on all disks to provide an error message is you try to start up with a nonsystem disk in drive A:. For hard disks the boot record resides on the first sector of the DOS partition. 
BIOS Parameter Block (BPB) 
This is a subset of data found in the Boot Sector Layout. The device driver 'Build BPB' request expects the driver to fill a block in this layout. 
Offset Size Contents             Ŀ  +0      2  SectSiz  bytes per sector               +2      1  ClustSiz  sectors per allocation unit (cluster)             Ŀ  +3      2  ResSecs  boot and reserved sectors               +5      1  FatCnt    number of File Allocation Tables  See FAT             Ŀ  +6      2  RootSiz  maximum number of 32-byte directory entries in root             Ĵ  +8      2  TotSecs  total number of sectors in media (DOS partition)              +0aH     1  Media     media descriptor (same as 1st byte in FAT)  +0      2  SectSiz  bytes per sector               +2      1  ClustSiz  sectors per allocation unit (cluster)             Ŀ  +3      2  ResSecs  boot and reserved sectors               +5      1  FatCnt    number of File Allocation Tables  See FAT             Ŀ  +6      2  RootSiz  maximum number of 32-byte directory entries in root             Ĵ  +8      2  TotSecs  total number of sectors in media (DOS partition)              +0aH     1  Media     media descriptor (same as 1st byte in FAT)             Ŀ +0bH     2  FatSize  number of sectors in one FAT               0dH        length of BPB is 13 bytes 
THE DOS FILE ALLOCATION TABLE (FAT) 
This section explains how DOS uses the FAT to convert the clusters of a file into logical sector numbers. We recommend that system utilities use the DOS handle calls rather than interpreting the FAT. 
The FAT is used by DOS to allocate disk space for files, one cluster at a time. 
The FAT consists of a 12 bit entry (1.5 bytes) for each cluster on the disk or a 16 bit (2 bytes) entry when a hard disk has more than 20740 sectors as is the case with fixed disks larger than 10Mb. 
The first two FAT entries map a portion of the directory; these FAT entries contain indicators of the size and format of the disk. The FAT can be in a 12 or 16 bit format. DOS determines whether a disk has a 12 or 16 bit FAT by looking at the total number of allocation units on a disk. For all diskettes and hard disks with DOS partitions less than 20,740 sectors, the FAT uses a 12 bit value to map a cluster. For larger partitions, DOS uses a 16 bit value. 
The second, third, and fourth bit applicable for 16 bit FAT bytes always contains 0FFFFh. The first byte is used as follows: 
     hex value              meaning                     normally used 
       0F8h      hard disk                         bootable hard disk at C:800                  double sided  18 sector diskette   PS/2 1.44 meg DSQD        0F9h      double sided  15 sector diskette   AT 1.2 meg DSQD                  double sided  9  sector diskette   Convertible 720k DSHD        0FCh      single sided  9  sector diskette   DOS 2.0, 180k SSDD        0FDh      double sided  9  sector diskette   DOS 2.0, 360k DSDD        0FEh      single sided  8  sector diskette   DOS 1.0, 160k SSDD        0FFh      double sided  8  sector diskette   DOS 1.1, 320k SSDD The third FAT entry begins mapping the data area (cluster 002). 
NOTE: These values are provided as a reference. Therefore, programs should not make use of these values. 
Each entry contains a hexadecimal character (or 4 for 16 bit FATs). () indicates the high order four bit value in the case of 16 bit FAT entries. They can be: 
            (0)000h  if the cluster is unused and availible 
(0F)FF8h - (0F)FFFh  to indicate the last cluster of a file 
            (X)XXXh  any other hexadecimal numbers that are the cluster number                      of the next cluster in the file. The cluster number is the                      first cluster in the file that is kept in the file's                      directory entry. 
The values (0F)FF0h - (0F)FF7h are used to indicate reserved clusters. (0F)FF7h indicates a bad cluster if it is not part of the allocation chain. (0F)FF8h - (0F)FFFh are used as end of file markers. 
The file allocation table always occupies the sector or sectors immediately following the boot record. If the FAT is larger than 1 sector, the sectors occupy consecutive sector numbers. Two copies of the FAT are written, one following the other, for integrity. The FAT is read into one of the DOS buffers whenever needed (open, allocate more space, etc). 
USE OF THE 12 BIT FILE ALLOCATION TABLE 
Obtain the starting cluster of the file from the directory entry. 
Now, to locate each subsequent sector of the file: 
1. Multiply the cluster number just used by 1.5 (each FAT entry is 1.5    bytes long). 2. The whole part of the product is offset into the FAT, pointing to the entry    that maps the cluster just used. That entry contains the cluster number of    the next cluster in the file. 3. Use a MOV instruction to move the word at the calculated FAT into a register. 4. If the last cluster used was an even number, keep the low order 12 bits of    the register, otherwise, keep the high order 12 bits. 5. If the resultant 12 bits are (0FF8h-0FFFh) no more clusters are in the file.    Otherwise, the next 12 bits contain the cluster number of the next cluster in    the file. 
  To convert the cluster to a logical sector number (relative sector, such as that used by int 25h and 26h and DEBUG): 
1. Subtract 2 from the cluster number 2. Multiply the result by the number of sectors per cluster. 3. Add the logical sector number of the beginning of the data area. 
USE OF THE 16 BIT FILE ALLOCATION TABLE 
Obtain the starting cluster of the file from the directory entry. Now to locate each subsequent cluster of the file: 
1.  Multiply the cluster number used by 2 (each FAT entry is 2 bytes long). 2.  Use the MOV word instruction to move the word at the calculated FAT offset     into a register. 3.  If the resultant 16 bits are (0FF8h-0FFFFh) no more clusters are in the     file. Otherwise, the 16 bits contain the cluster number of the next cluster     in the file. 
 Compaq DOS makes availible a new disk type (6) with 32 bit partition values, allowing 512 megabytes per hard disk (Compaq DOS 3.3.1) 
DOS DISK DIRECTORY 
The FORMAT command initially builds the root directory for all disks. Its location (logical sector number) and the maximum number of entries are availible through the device driver interfaces. 
DIRECTORY ENTRIES 
Since directories other than the root directory are actually files, there is no limit to the number of entries that they may contain. 
All directory entries are 32 bytes long, and are in the following format (byte and offset are decimal). The following paragraphs describe the directory entry bytes: 
*BYTES 0-7  Bytes 0-7 represent the filename. The first byte of the filename indicates the status of the filename. The status of a filename can contain the following values: 
   00h Filename never used. This is used to limit the length of directory        searches, for performance reasons.    05h Indicates that the first character of the filename actually has an 0Edh        character.   0E5h Filename has been used but the file has been erased.    2Eh This entry is for a directory. If the second byte is also 2Eh, the        cluster field contains the cluster number of this directory's parent        directory.  (0000h if the parent directory is the root directory). 
Any other character is the first character of a filename. 
*BYTES 8-10  These bytes indicate the filename extension. 
*BYTE 11  This byte indicates the file's attribute. The attribute byte is mapped as  follows (values are in hexadecimal): 
NOTE: Attributes 08h and 10h cannot be changed using function call 43h (CHMOD). 
The system files IBMBIO.COM and IBMDOS.COM (or customized equivalent) are marked as read-only, hidden, and system files. Files can be marked hidden when they are created. Also, the read-only, hidden, and system and archive attributes may be changed through the CHMOD function call. 
01h Indicates that the file is marked read-only. An attempt to open the file     for output using function call 3Dh results in an error code being returned.     This value can be used with other values below. 
02h Indicates a hidden file. The file is excluded from normal directory     searches. 
04h Indicates a system file. This file is excluded from normal directory     searches. 
08h Indicates that the entry contains the volume label in the first 11 bytes.     The entry contains no other usable information and may exist only in the     root directory. 
20h Indicates an archive bit. This bit is set on whenever the file is written     to and closed. It is used by BACKUP and RESTORE. 
All other bits are reserved, and must be 0. 
*BYTES 12-21  reserved by DOS *BYTES 22-23  These bytes contain the time when the file was created or last updated. The time is mapped in the bits as follows:       Ŀ                B Y T E    23                  B Y T E    22                Ĵ        F   E   D   C   B   A   9   8  7   6   5   4   3   2   1   0        Ĵ        H   H   H   H   H  M   M   M   M   M   M  D   D   D   D   D        Ĵ        binary # hrs 0-23  binary # minutes 0-59  bin. # 2-sec incr         
NOTE: The time is stored with the least significant byte first. *BYTES 24-25  This area contains the date when the file was created or last updated. The mm/dd/yy are mapped in the bits as follows: 
      Ŀ                B Y T E    25                  B Y T E    24                Ĵ        F   E   D   C   B   A   9   8  7   6   5   4   3   2   1   0        Ĵ        Y   Y   Y   Y   Y   Y   Y  M   M   M   M  D   D   D   D   D        Ĵ             0-119 (1980-2099)         1-12             1-31                
NOTE: The date is stored with the least significant byte first. *BYTES 26-27  This area contains the starting cluster number of the first cluster in the file. The first cluster for data space on all fixed disks and floppy disks is always cluster 002. The cluster number is stored with the least significant byte first. *BYTES 28-31 This area contains the file size in bytes. The first word contains the low order part of the size. Both words are stored with the least significant byte first. 
Offset Size Contents                Ŀ  +0      8  'F' 'I' 'L' 'E' 'N' 'A' 'M' 'E' left-justified, padded with blanks               +8      3  'E' 'X' 'T'                     left-justified, padded with blanks              +0bH     1  atr                              file attribute                Ŀ +0cH    0aH       reserved                        +16H     2   time             time created or last modified in filetime format             Ĵ +18H     2   date             date created or last modified in filetime format             Ĵ +1aH     2  ClstrNo      cluster number of start of file data (link into FAT )             Ŀ +1cH     4     file size                     file size in bytes              
 +0      8  'F' 'I' 'L' 'E' 'N' 'A' 'M' 'E' left-justified, padded with blanks               +8      3  'E' 'X' 'T'                     left-justified, padded with blanks              +0bH     1  atr                              file attribute                Ŀ +0cH    0aH       reserved                        +16H     2   time             time created or last modified in filetime format             Ĵ +18H     2   date             date created or last modified in filetime format             Ĵ +1aH     2  ClstrNo      cluster number of start of file data (link into FAT )             Ŀ +1cH     4     file size                     file size in bytes              +20H                                           directory entry size 
File Attribute 
 Several of the DOS services require a file attribute as a parameter.  The file  attribute is a 1-byte bit-flag associated with each file and found in the  directory entry of each file.  These bits are defined: 
76543210    advshr ҽ bit                                                mask value           > 0: 1=file is Read-only (can't be written/deleted)  (a & 01H)          > 1: 1=Hidden                                        (a & 02H)         > 2: 1=System                                        (a & 04H)        > 3: 1=Volume label entry                            (a = 08H)       > 4: 1=subDirectory entry                            (a & 10H)      > 5: Archive bit. 1=file has NOT been backed up      (a & 20H) 
DOS Fn 11H or 4eH directory searches are inclusive.  You can set one or more of the file attribute bits for Hidden, System, Directory, and Archive if you want to search for files with these attributes.  If you omit any bit, no files that have that attribute will be found. 
DOS Fn 11H or 4eH directory searches are inclusive.  You can set one or more of the file attribute bits for Hidden, System, Directory, and Archive if you want to search for files with these attributes.  If you omit any bit, no files that have that attribute will be found. 
For instance if you want to locate directory entries only, you can use an attribute of 10H to obtain a set of all files including directories.  You could then ignore all the entries that are not directories (they have bit 4=0). 
If you specify an attribute with the Volume bit, the search will be exclusive, returning only the entry of the volume label (if any). 
DOS Fn 43H (CHMOD) will let you set or clear the Read-only, Hidden, System, and Archive bits.  You cannot alter the Directory attribute bit, but you can add or remove other bits of the directory's attributejust use Fn 43H specifying an attribute having all the desired bits for the directory except bit 4. 
File Time/Date Format 
 1 1 1 1 1 1                         Load word at DIR_ENTRY+16H into a 5432109876543210    16-bit register and perform mask    hour    minute     sec/2      and shift operations to extract Ľ    components of the file time.  ͼ ͼ ͼ                          > 2-second increments (0-30 valid)   (t & 001fH)                > minute (0-59 valid)         ((t & 07e0H) >> 5)      > hour (0-23 valid)         ((t & 0f800H) >> 11) 
File Allocation Table 
offset size                  description    3       8 bytes system id (such as IBM 3.3)   11      2 bytes number of bytes per sector, ie 512 bytes is 200h   13      1 byte  sectors per cluster (1 or 2)   14      2 bytes number of reserved sectors at beginning, 1 for floppies   16      1 byte  number of copies of FAT, 2 for floppies   17      2 bytes number of root directory entries (64, 112, 256,etc)   19      2 bytes total sectors per disk   21      1 byte  format ID (F8, F9, FC, FF, etc)   22      2 bytes number of sectors per FAT (1 or 2)   24      2 bytes number of sectors per track (8 or 9, 17)   26      2 bytes number of sides, heads, or cylinders (1 or 2 for floppy)   28      2 bytes number of special reserved sectors 
THE DATA AREA 
Allocation of space for a file (in the data area) is done only when needed (it is not preallocated). The space is allocated one cluser (unit allocation) at a time. A cluster is always one or more consecutive sector numbers, and all of the clusters in a file are "chained" together in the FAT. 
The clusters are arranged on disk to minimize head movement for multisided media. All of the space on a track (or cylinder) is allocated before moving on to the next track. This is accomplished by using the sequential sector numbers on the lowest-numbered head, then all the sector numbers on the next head, and so on until all sectors of all heads of the track are used. Then the next sector used will be sector 1 of head 0 on the next track. 
An interesting innovation that was introduced in MS-DOS 3.0: disk space that is freed by erasing a file is not re-used immediately, unlike earlier versions of DOS. Instead, free space is obtained from the area not yet used during the current session, until all of it is used up. Only then will space that is freed during the current session be re-used. 
This feature minimizes fragmentation of files, since never-before-used space is always contiguous. However, once any space has been freed by deleting a file, that advantage vanishes at the next system boot. The feature also greatly simplifies un-erasing files, provided that the need to do an un-erase is found during the same session and also provided that the file occupies contiguous clusters. 
However, when one is using programs which make extensive use of temporary files, each of which may be created and erased many times during a session, the feature becomes a nuisance; it forces the permanent files to move farther and farther into the inner tracks of the disk, thus increasing rather than decreasing the amount of fragmentation which occurs. 
The feature is implemented in DOS by means of a single 16-bit "last cluster used" (LCU) pointer for each physical disk drive; this pointer is a part of the physical drive table maintained by DOS. At boot time, the LCU pointer is zeroed. Each time another cluster is obtained from the free-space pool (the FAT), its number is written into the LCU pointer. Each time a fresh cluster is required, the FAT is searched to locate a free one; in older versions of DOS this search always began at Cluster 0000, but in 3.x it begins at the cluster pointed to by the LCU pointer. 
For hard disks, the size of the file allocation table and directory are determined when FORMAT initializes it and are based on the size of the DOS partition. 
The following table gives the specifications for floppy disk formats: 
               # of   sectors  FAT size    DIR        DIR     sectors  total disk  DOS ver  sides  /track   (sectors) (sectors) (entries) /cluster sectors 
(5-1/4 inch) 160k (DOS 1.0)   1     8  (40)     1        4         64         1      320 320k (DOS 1.1)   2     8  (40)     1        7         112        2      360 180k (DOS 2.0)   1     9  (40)     2        4         64         1      640 360k (DOS 2.0)   2     9  (40)     2        7         112        2      720 1.2M (DOS 3.0)   2     15 (80)     7        14        224        1      2400 
(3-1/2 inch) 720k (DOS 3.2)   2     9  (80)     3        7         112        2      1440 1.44M(DOS 3.3)   2     18 (80)     9        14        224        1      2880 
Files in the data area are not nescessarily written sequentially on the first. The data area space is allocated one cluster at a time, skipping over clusters already allocated. The first free cluster found is the next cluster allocated, regardless of its physical location on the disk. This permits the most efficient utilization of disk space because clusters freed by erasing files can be allocated for new files. Refer back to the description of the DOS FAT in this chapter for more information. 
Hard Disk Layout 
 The DOS hard disk routines perform the following services: 
1) Allow multiple operating systems to utilize the hard disk without the need    to backup and restore files when changing operating systems. 
2) Allow a user-selected operating system to be started from the hard disk.    I) In order to share the hard disk among operating systems, the disk may be       logically divided into 1 to 4 partitions. The space within a given       partition is contiguous, and can be dedicated to a specific operating       system. Each operating system may "own" only one partition in DOS versions       2.0 through 3.2. PCDOS 3.3 introduced the "Extended DOS Partition" which       allows multiple DOS partitions on the same hard disk. The FDISK.COM (or       similar program from other DOS vendors) utility allows the user to select       the number, type, and size of each partition. The partition information is       kept in a partition table that is embedded in the master fixed disk boot       record on the first sector of the disk. The format of this table varies       from version to version of DOS. 
  II) An operating system must consider its partition to be the entire disk,       and must ensure that its functions and utilities do not access other       partitions on the disk. 
 III) Each partition may contain a boot record on its first sector, and any       other programs or data that you choose - including a copy of an operating       system. For example, the DOS FORMAT command may be used to format and       place a copy of DOS in the DOS partition in the same manner that a       diskette is formatted. With the FDISK utility, you may designate a       partition as "active" (bootable). The master hard disk boot record causes       that partition's boot record to receive control when the system is started       or reset. Additional disk partitions could be FORTH, UNIX, Pick, CP/M-86,       or the UCSD p-System. 
SYSTEM INITIALIZATION 
The boot sequence is as follows: 
1. System initialization first attempts to load an operating system from    diskette drive A. If the drive is not ready or a read error occurs, it then    attempts to read a master hard disk boot record on the first sector of the    first hard disk in the system. If unsuccessful, or if no hard disk is    present, it invokes ROM BASIC in an IBM PC or displays a disk error    message on most compatibles. 
2. If initialization is successful, the master hard disk boot record is given    control and it examines the partition table embedded within it. If one of    the entries indicates an active (bootable) partition, its boot record is    read from the partition's first sector and given control. 
3. If none of the partitions is bootable, ROM BASIC is invoked on an IBM PC or     a disk error on most compatibles. 
4. If any of the boot indicators are invalid, or if more than one indicator is    marked as bootable, the message INVALID PARTITION TABLE is displayed and the    system stops. 
5. If the partition's boot record cannot be successfully read within five    retries due to read errors, the message ERROR LOADING OPERATING SYSTEM    appears and the system stops. 
6. If the partition's boot record does not contain a valid "signature", the    message MISSING OPERATING SYSTEM appears, and the system stops. 
NOTE: When changing the size or location of any partition, you must ensure that       all existing data on the disk has been backed up. The partitioning program       will destroy the data on the disk. 
BOOT RECORD/PARTITION TABLE 
 A boot record must be written on the first sector of all hard disks, and must contain the following: 
1. Code to load and give control to the boot record for one of four possible    operating systems. 
2. A partition table at the end of the boot record. Each table entry is 16    bytes long, and contains the starting and ending cylinder, sector, and head    for each of four possible partitions, as well as the number of sectors    preceding the partition and the number of sectors occupied by the partition.    The "boot indicator" byte is used by the boot record to determine if one of    the partitions contains a loadable operating system. FDISK initialization    utilities mark a user-selected partition as "bootable" by placing a value    of 80h in the corresponding partition's boot indicator (setting all other    partitions' indicators to 0 at the same time). The presence of the 80h tells    the standard boot routine to load the sector whose location is contained in    the following three bytes. That sector is the actual boot record for the    selected operating system, and it is responsible for the remainder of the    system's loading process (as it is from the diskette). All boot records are    loaded at absolute address 0:7C00. 
The partition table with its offsets into the boot record is: (except for Wyse DOS 3.2 with 32 bit allocation table, and DOS 3.3-up) Ŀ  Offset   /    Purpose                         Head     Sector   Cylinder  Ĵ  1BEh partition 1 begin            boot ind     H         S        cyl     Ĵ  1C2h partition 1 end              syst ind     H         S        cyl     Ĵ  1C6h partition 1 relative sector       low word             high word       Ĵ  1CAh partition 1 # sectors             low word             high word       Ĵ  1CEh partition 2 begin            boot ind     H         S        cyl     Ĵ  1D2h partition 2 end              syst ind     H         S        cyl     Ĵ  1D6h partition 2 relative sector       low word             high word       Ĵ  1DAh partition 2 # sectors             low word             high word       Ĵ  1DEh partition 3 begin            boot ind     H         S        cyl     Ĵ  1E2h partition 3 end              syst ind     H         S        cyl     Ĵ  1E6h partition 3 relative sector       low word             high word       Ĵ  1EAh partition 3 # sectors             low word             high word       Ĵ  1EEh partition 4 begin            boot ind     H         S        cyl     Ĵ  1F2h partition 4 end              syst ind     H         S        cyl     Ĵ  1F6h partition 4 relative sector       low word             high word       Ĵ  1FAh partition 4 # sectors             low word             high word         1FEh signature                     hex 55    hex AA    
HARD DISK TECHNICAL INFORMATION 
Boot indicator (boot ind): The boot indicator byte must contain 0 for a non- bootable partition or 80h for a bootable partition. Only one partition can be marked as bootable at a time. 
System Indicator (sys ind): The sys ind field contains an indicator of the operating system that "owns" the partition. 
          The system indicators are:                        00h unknown (unspecified or non-DOS)                        01h DOS 12 bit FAT                        02h DOS 16 bit FAT 
Cylinder (CYL) and Sector (S): The 1 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 sector (S) field. This corresponds with the ROM BIOS interrupt 13h (disk I/O) requirements, to allow for a 10 bit cylinder number. 
The fields are ordered in such a manner that only two MOV instructions are required to properly set up the DX and CX registers for a ROM BIOS call to load the appropriate boot record (hard disk booting is only possible from the first hard disk in the system, where a BIOS drive number of 80h corresponds to the boot indicator byte). 
All partitions are allocated in cylinder multiples and begin on sector 1, head 0. 
 EXCEPTION: The partition that is allocated at the beginning of the disk starts at sector 2, to account for the hard disk's master boot record. 
 Relative Sector (rel sect): The number of sectors preceding each partition on the disk is kept in the 4 byte field labelled "rel sect". This value is obtained by counting the sectors beginning with cylinder 0, sector 1, head 0 of the disk, and incrementing the sector, head, and then track values up to the beginning of the partition. This, if the disk has 17 sectors per track and 4 heads, and the second partition begins at cylinder 1, sector 1, head 0,and the partition's starting relative sector is 68 (decimal) - there were 17 sectors on each of 4 heads on 1 track allocated ahead of it. The field is stored with the least significant word first. 
Number of sectors (#sects): The number of sectors allocated to the partition is kept in the "# of sects" field. This is a 4 byte field stored least significant word first. 
Signature: The last 2 bytes of the boot record (55AAh) are used as a signature to identify a valid boot record. Both this record and the partition boot record are required to contain the signature at offset 1FEh. 
The master disk boot record invokes ROM BASIC if no indicator byte reflects a bootable system. 
When a partition's boot record is given control. It is passed its partition table entry address in the DS:SI registers. 
DETERMINING FIXED DISK ALLOCATION 
DOS determines disk allocation using the following formula: 
                                         D * BPD                             TS - RS -                                              BPS                       SPF =                                          BPS * SPC                                  CF +                                             BPC where: 
     TS      total sectors on disk      RS      the number of sectrs at the beginning of the disk that are reserved              for the boot record. DOS reserves 1 sector.      D       The number of directory entries in the root directory.      BPD     the number of bytes per directory entry. This is always 32.      BPS     the number of bytes per logical sector. Typically 512, but you can              specify a different number with VDISK.      CF      The number of FATS per disk. Usually 2. VDISK is 1.      SPF     the number of sectors per FAT. Maximum 64.      SPC     The number of sectors per allocation unit.      BPC     the number of bytes per FAT entry. BPC is 1.5 for 12 bit FATs.              2 for 16 bit FATS. To calculate the minimum partition size that will force a 16-bit FAT: 
        CYL = (max clusters * 8)/(HEADS * SPT) 
where:      CYL     number of cylinders on the disk      max clusters  4092 (maximum number of clusters for a 12 bit FAT)      HEADS   number of heads on the hard disk      SPT     sectors per track  (normally 17 on MFM) note: DOS 2.0 uses a "first fit" algorithm when allocating file space on the hard disk. Each time an application requests disk space, it will scan from the beginning of the FAT until it finds a contiguous peice of storage large enough for the file.  DOS 3.0 keeps a pointer into the disk space, and begins its search from the point it last left off. This pointer is lost when the system is rebooted. This is called the "next fit" algorithm. It is faster than the first fit and helps minimize fragmentation.  In either case, if the FCB function calls are used instead of the handle function calls, the file will be broken into peices starting with the first availible space on the disk. Comment to 826. Better late than never... A partition table entry for the IBM AT is set up as follows: 
        DB      drive   ; 0 or 80H, 80H marks a bootable, active partition         DB      head1   ; starting heads         DW      trksec1 ; starting track/sector (CX value for INT 13)         DB      system  ; see below         DB      head2   ; ending head         DW      trksec2 ; ending track/sector         DD      sector1 ; absolute # of starting sector         DD      sector2 ; absolute # of last sector 
The system byte is different for different O/S entries: 
        1      DOS, 12-bit FAT entries         4      DOS, 16-bit FAT entries         DB     Concurrent DOS         F2     2nd partition for Sperry machines with large disks 
        And so on.  There are bytes for XENIX, Prologue and lots of other O/S. Many manufacturers diddle with these system bytes to implement more than 1 DOS partition per disk.  The only one I know about who violates the rule that only one DOS partition (1 or 4) per disk may exist is Tandon. 
MISCELANEOUS 
The CONFIG.SYS File 
When DOS boots, it loads IBMBIO.COM from the boot disk.  This program examines the root directory for a file named CONFIG.SYS and if it exists, it is read and interpretted as a series of configuration commands that can have an important effect on certain facets of the way DOS operates. 
This topic covers each of these configuration commands: 
Command   Function                      Command    Function      BREAK=    set Ctrl-Break testing level  LASTDRIVE= set SUBST drive ID limit BUFFERS=  set # of disk I/O buffers     FILES=     set max # of file handles COUNTRY=  set country-dependant info    SHELL=     install cmd interpreter DEVICE=   install a device driver       STACKS=    set hdwr int stack sizes DRIVPARM= I don't know, do you?         SWITCHAR=  select cmd-line switch char FCBS=     set max open FCBs (networks)   
CONFIG.SYS should be in standard ASCII format, with each line composed of text followed by a CRLF (ASCII 0dH,0aH).  Optionally, the end of the file may be marked with a Ctrl-Z (ASCII 1aH).  There is latitude in the way the config commands may be written.  Uppercase or lowercase is OK and the equal sign ('=') may be preceded and/or followed by white space.  Numeric parameters (when used) are in decimal (base-10) digits. 
Command    Function   BREAK=     Sets the level of DOS Ctrl-Break testing. 
           Usage: BREAK=ON                   BREAK=OFF 
           Use BREAK = ON to be able to abort some programs manually which            would otherwise need to be executed to completion.   BUFFERS=   Sets the number of disk sector-buffers DOS will allocate and use.            Makes certain disk-intensive operations perform faster. 
           Usage: BUFFERS=BuffCnt 
           BuffCnt is the number of buffers, from 2 to 99.  Default is 2. 
           By increasing the number of disk buffers, you increase the chance            that DOS will be able to avoid disk access, thus increasing the            overall speed of disk operations.  You should have at least enough            buffers to hold the entire FAT since this is read often.  Also, using            a lot of buffers is helpful with a large directory structure. 
           Too many buffers will actually DEGRADE the speed of disk access as            DOS has to spend more time checking the status of each buffer.            Serious slowdown occurs when you get up to about 50 buffers. 
           Here are some suggested settings for the BUFFERS= command:                AT with 20M or 30M hard disk: BUFFERS= 32                XT with 10M hard disk:        BUFFERS= 16                PC (floppy disks only):       BUFFERS= 4   COUNTRY=   Sets the "current country" as used in DOS Fn 38H   This affects the            the COMMAND.COM time/date display and input format 
           Usage: COUNTRY=CountryCode 
           A listing of Country Codes is found under DOS Fn 38H   The default            is the USA (001).   DEVICE=    Adds an installable device driver to the internal DOS device drivers. 
           Usage: DEVICE=[d:]filespec 
           The filespec is the filespec of the binary image of the driver.            These device drivers come with DOS:                        DEVICE=ANSI.SYS 
             DOS 2.0+  Installs extended console features.  See ANSI.SYS                        DEVICE=[d:][path]VDISK.SYS [KBytes] [SecSize] [DirSize] [/E[:MaxSec]] 
             DOS 3.x  Installs a RAM disk.  Options are: 
             KBytes    total size of the RAM disk in K-bytes (default=64)              SecSize   size of disk sectors: 128, 256, or 512 (default=128)              DirSize   max # of directory entries in the root (default=64)              /E        specifies to put the RAM disk 286 extended memory              :MaxSec   used with /E on DOS 3.2   Sets the maximum number of                        sectors which will be read/written at one time (1-8,                        default=8).  Hardware INTs are disabled while accessing                        extended memory.  This minimizes potential interrupt                        losses (as in concurrent serial I/O).  See INT 15H                        DEVICE=DRIVER.SYS /D:PhDrv [/T:Trks][/S:Sects][/H:Hds][/C][/N][/F:n] 
             DOS 3.2  Installs a 'phantom' (logical) disk.              See also:  IOCTL SubFns 0dH-0fH and Device Requests 13H-18H              Options are: 
             /D:PhDrv  physical drive number (required parameter)                          0-3  = diskette drive number                          128,129 = first, second hard disk drive              /T:Trks   number of tracks per side (default=80)              /S:Sects  number of sectors per track (default=9)              /H:Hds    number of heads on the drive (default=2)              /C        indicates that "Changeline" support is required              /N        specifies that the media is non-removable (fixed disk)              /F:n      specifies a drive Format type number:                          0 = 160/180K (1-sided) or 320/360K (2-sided)                          1 = 1.2M high-capacity drive                          2 = 720K (3-1/2 inch) format   DRIVPARM=  This is an UNDOCUMENTED config command.  It is handled in IBMBIO.COM,            but I can't figure out its parameters or its purpose.   FCBS=      Sets the number of File Control Blocks (FCBs) that may be opened at            the same time when file sharing is active. 
           Usage: FCBS=MaxCnt,KeepCnt 
           MaxCnt is the maximum number of concurrently opened files (1-255;            default=4) when SHARE has been installed. 
           KeepCnt specifies how many FCBs are to be protected from automatic            closure when MaxCnt has been reached.  This tells SHARE that, when            closing files, to keep the first KeepCnt files that were opened.   FILES=     Sets the number of file handles that may be opened at the same time. 
           Usage: FILES=MaxHandles 
           MaxHandles is the maximum number of file handles which DOS will            maintain (5 to 99, default=8).  Many applications require that            FILES= be set to 20.  See DOS error code 12H.   LASTDRIVE= Sets the limit for drive IDs usable by the DOS SUBST command.            DOS 3.0 (but only meaningful starting with DOS 3.1            Usage: LASTDRIVE=d            'd' is a single drive letter (A to Z; default=E)  DOS maintains            an 80-byte area for each drive.  For physical and logical drives, it            tracks the current default directory.  For SUBST drives, it tracks            the actual drive and directory pathname which is represented by the            drive letter. 
  SHELL=     Replaces command interpreter (COMMAND.COM) with a different program            Also used to set the size of the DOS environment for COMMAND.COM.            Usage: SHELL=[d:]filespec [parms]            To increase the size of the DOS environment, use:                   SHELL=COMMAND.COM /E:1000 /P            /E sets the number of bytes and /P forces execution of AUTOEXEC.BAT   SWITCHAR=  This is an UNDOCUMENTED config command that can be used in DOS 2.x            to select a DOS command-line 'switch' character.  See DOS Fn 37H            Usage: SWITCHAR=c            'c' is a single character (default='/')            The idea was to let DOS users select a different character for the            start of a command line option (eg, the dash '-') and to free up the            slash ('/') for use in pathnames.  This was never documented and many            utilities did not use it.  In DOS 3.2, SWITCHAR is not recognized as            a valid configuration command.  However, DOS Fn 37H still functions.   STACKS=    This solves a problem relating to reentrant and simultanoues            hardware interrupts.  See Interrupts and ROM-BIOS Services            slash ('/') for use in pathnames.  This was never documented and many            utilities did not use it.  In DOS 3.2, SWITCHAR is not recognized as            a valid configuration command.  However, DOS Fn 37H still functions.   STACKS=    This solves a problem relating to reentrant and simultanoues            hardware interrupts.  See Interrupts and ROM-BIOS Services            Usage: STACKS=FrmCnt,FrmSiz            FrmCnt  is the number of stack frames that are allocated by DOS                    (8 to 64; default=9)            FrmSiz  is the size in bytes of each stack frame (32 to 512;                    default=128) 
           Upon each hardware interrupt, DOS allocates a stack frame from the            pool and sets SS:SP for the interrupt handler.  Upon return from the            interrupt, the stack frame is returned to the pool. 
DOS Error Codes 
DOS 2.0+ Error Codes (returned in AX when Carry Flag is set) 
Error #                                  Error # Hex Dec  Meaning                         Hex Dec  Meaning           1    1  Invalid function number         0aH  10  Invalid environment  2    2  File not found                  0bH  11  Invalid format  3    3  Path not found                  0cH  12  Invalid access code  4    4  Too many open files             0dH  13  Invalid data  5    5  Access denied                   0eH  14  (not used)  6    6  Invalid handle                  0fH  15  Invalid drive specified  7    7  Memory ctrl blocks destroyed    10H  16  Can't remove current directory  8    8  Insufficient memory             11H  17  Not same device  9    9  Invalid memory block address    12H  18  No more matching files 
     DOS 3.x Fn 59H additions   0    0  No error occurred (don't expect 0 unless no error has EVER occurred) 13H  19  Attempted write on write-protected disk Ŀ 14H  20  Unknown unit ID                            15H  21  Disk drive not ready                       16H  22  Unknown command                            17H  23  Disk data error (CRC error)               > These correspond to 18H  24  Bad request structure length                 errors 0-0cH passed in 19H  25  Disk seek error                              the DI register to an 1aH  26  Unknown disk media type                      INT 24H critical error 1bH  27  Disk sector not found                        handler.  They also match 1cH  28  Printer out of paper                         the values in AL after 1dH  29  Write fault error                            errors in INT 25H/26H 1eH  30  Read fault error                           1fH  31  General failure   20H  32  File sharing violation 21H  33  File locking violation 22H  34  Invalid disk change 23H  35  FCB unavailable (too many FCBs) 24H-49H (reserved) 50H  80  File already exists 51H  81  (reserved) 52H  82  Cannot make (I have no idea what this means, either) 53H  83  INT 24H Critical Error interrupt failure 
Ŀ  Error Class  These codes are meant to provide additional information to help  you determine how to handle the error.  Fn 59H returns these informational codes in BH. Class # Hex Dec  Meaning (returned in BH by Fn 59H)      1    1  Out of resource: no more FCBs, memory, channels, file handles, etc.  2    2  Temporary situation: this will go away in a while (eg, locked file)  3    3  Authorization problem:  You need higher permission to do this  4    4  Internal error: DOS is at fault  5    5  Hardware failure  6    6  System failure: DOS is at fault  7    7  Application error: passed bad info to DOS, inconsistent request, etc.  8    8  Not found: requested file/item can't be found  9    9  Bad format: file/item in invalid format (EXE file bad, bad disk, etc.) 0aH  10  Locked: file/item locked 0bH  11  Media error: wrong disk, disk CRC error, etc. 0cH  12  Already exists: collision with existing file/item 0dH  13  Unknown error class: classification doesn't exist or is inappropriate 
Ŀ  Suggested Action  These codes indicate appropriate action to take when an  error occurs.  The idea is to limit your coding by NOT looking for specific error numbers in your application.  Instead maintain upward compatibility by taking the suggested actions listed below.  Fn 59H returns these codes in BL. 
Action# Hex Dec  Meaning (returned in BL by Fn 59H)      1    1  Retry: Retry the operation a few times.  If the error continues to          occur, ask the user if he wants to continue or quit. 
 1    1  Delay Retry: Delay a while and retry the operation a few times.  If the          error continues to occur, ask the user if he wants to continue or quit. 
 3    3  User Input: If data presented to DOS was entered by a user, ask the          user to re-enter input (eg, bad drive ID or pathname). 
 4    4  Abort: Abort the application, but it's OK to perform cleanup operations          such as closing files, updating indexes, releasing memory blocks, etc. 
 5    5  Immediate Exit: Abort immediately without attempting cleanup.  The          system is in an unhealthy state and immediate exit is best. 
 6    6  Ignore: the error doesn't make any difference 
 7    7  Retry after user action: the user needs to perform some action, such          as inserting a diskette.  Prompt the user and then retry. 
Ŀ  Error Locus  These codes are meant to help you figure out where the error  occurred.  Fn 59H returns these informational codes in CH. Locus # Hex Dec  Meaning (returned in CH by Fn 59H)      1    1  Unknown: No specific area to pin-point error source  2    2  Block device: error occurred on disk or tape drive  3    3  (reserved)  4    4  Character device  5    5  Memory Ŀ  DOS Versions  Error handling is upwardly-compatible for all DOS versions.  These general rules apply: 
   DOS 1.x: indicates some errors by placing 0ffH is AL upon return. 
   DOS 2.x: New 2.x calls indicate errors by setting the Carry Flag (CF=CY=1)             and putting an error code into AX. 
   DOS 3.x: 2.x and 3.x calls still return error codes in AX when CF=CY, but  2    2  Block device: error occurred on disk or tape drive  3    3  (reserved)  4    4  Character device  5    5  Memory 
Ŀ  DOS Versions  Error handling is upwardly-compatible for all DOS versions.  These general rules apply: 
   DOS 1.x: indicates some errors by placing 0ffH is AL upon return. 
   DOS 2.x: New 2.x calls indicate errors by setting the Carry Flag (CF=CY=1)             and putting an error code into AX. 
   DOS 3.x: 2.x and 3.x calls still return error codes in AX when CF=CY, but             there is no guarantee that future calls will do so.  You are             advised to use DOS Fn 59H to obtain error information.   INT 24H Critical Error Handling                                  DOS Functions  Several of the DOS services require a file attribute as a parameter.  The file  attribute is a 1-byte bit-flag associated with each file and found in the  directory entry of each file.  These bits are defined: 
76543210    advshr ҽ bit                                                mask value           > 0: 1=file is Read-only (can't be written/deleted)  (a & 01H)          > 1: 1=Hidden                                        (a & 02H)         > 2: 1=System                                        (a & 04H)        > 3: 1=Volume label entry                            (a = 08H)       > 4: 1=subDirectory entry                            (a & 10H)      > 5: Archive bit. 1=file has NOT been backed up      (a & 20H) 
DOS Fn 11H or 4eH directory searches are inclusive.  You can set one or more of the file attribute bits for Hidden, System, Directory, and Archive if you want to search for files with these attributes.  If you omit any bit, no files that have that attribute will be found. 
DOS Fn 11H or 4eH directory searches are inclusive.  You can set one or more of the file attribute bits for Hidden, System, Directory, and Archive if you want to search for files with these attributes.  If you omit any bit, no files that have that attribute will be found. 
For instance if you want to locate directory entries only, you can use an attribute of 10H to obtain a set of all files including directories.  You could then ignore all the entries that are not directories (they have bit 4=0). 
If you specify an attribute with the Volume bit, the search will be exclusive, returning only the entry of the volume label (if any). 
DOS Fn 43H (CHMOD) will let you set or clear the Read-only, Hidden, System, and Archive bits.  You cannot alter the Directory attribute bit, but you can add or remove other bits of the directory's attributejust use Fn 43H specifying an attribute having all the desired bits for the directory except bit 4. 
File Handle 
Starting with DOS version 2.0, a set of UNIX-like file functions were added to the DOS repertoire.  The idea is that when you open a file, DOS passes back a a 16-bit value called a "file handle."  Thereafter, when you read, write, seek a position, or close the file, you refer to it with its handle. 
One of the nicer features is that you can refer to certain devices as if they were disk files by using one of the reserved DOS handles: 
                              Pre-defined DOS handles  Handle  Name/Description       0     Standard Input Device  (usually the keyboard)    1     Standard Output Device (usually the screen)    2     Standard Error Device  (always CONthe screen.  Use for messages)    3     Standard AUX Device    (Asynchronous Adapter; 1st serial portCOM1)    4     Standard Printer       (first parallel printer portLPT1) 
DOS File Allocation Table (FAT) 
The FAT is a linked-list table that DOS uses to keep track of the physical position of data on a disk and for locating free space for storing new files. 
The word at offset 1aH in a directory entry is a cluster number of the first cluster in an allocation chain.  If you locate that cell in the FAT, it will either indicate the end of the chain or the next cell, etc.  Observe: 
                                    starting cluster number ͻ Directory vķ Entry     M Y F I L E   T X Ta                   timdat08  size             Ľ                                     ͼ     00  01  02  03  04  05  06  07  8  09  0a  0b  0c  0d  0e  0f    vĿ 00 IDff03>04>05>ff000009>0a>0b>1500000000                             ͼ    vĿ 10 000000000016>17>19f71a>1b>ff00000000    ^                                 ͼ This diagram illustrates the main concepts of reading the FAT.  In it: 
MYFILE.TXT is 10 clusters long.  The first byte is in cluster 08 and the last is in cluster 1bH.  The chain is 8,9,0a,0b,15,16,17,19,1a,1b.  Each entry indicates the next entry in the chain, with a special code in the last entry. Cluster 18H is marked bad and is not part of an allocation chain. Clusters 6,7, 0cH-14H, and 1cH-1fH are empty and available for allocation. Another chain starts at cluster 2 and ends at cluster 5.  You'd need to find a directory entry with starting cluster number of 02 to know the filename. 
Ŀ  FAT Facts  The FAT normally starts at logical sector 1 in the DOS partition  (eg, you can read it with INT 25H with DX=1).  The only way to be sure is to read the boot sector (DX=0), and examine offset 0eH.  This tells how many boot and reserved sectors come before the FAT.  Use that number (usually 1) in DX to read the FAT via INT 25H. 
There may be more than one copy of the FAT.  There are usually two complete copies.  If there are two or more, they will all be adjacent (the second FAT directly follows the first). 
You have the following services available to help you determine information about the FAT: 
     Use INT 25H to read the Boot Sector and examine the data fields therein      Use DOS Fn 36H or 1cH to determine total disk sectors and clusters      Use DOS Fn 44H (if the device driver supports Generic IOCTL)  DOS 3.2      Use DOS Fn 32H to get all kinds of useful information.   UNDOCUMENTED 
Note: The boot sector of non-booting disks (such as network block devices and older hard disks) may contain nothing but garbage. 
Ŀ  12-bit/16-bit  The FAT can be laid out in 12-bit or 16-bit entries.  12-bit  entries are very efficient for media less than 384K -- the entire FAT can fit in a single 512-byte disk sector.  For larger media, each FAT entry must map to a larger and larger cluster size -- to the point where a 20M hard disk would need to allocate in units of 16 sectors in order to use the 12-bit format (in other words, a 1-byte file would take up 8K of disk space). 
16-bit FAT entries were introduced with DOS 3.0 with the necessity of efficient handling the AT's 20-Megabyte hard disk.  However, floppy disks and 10M hard disks continue to use the 12-bit layout.  You can determine if the FAT is laid out with 12-bit or 16-bit elements: 
  DOS 3.0 says: If a disk has more than 4086 (0ff6H) clusters, it uses 16 bits                 (4096 is max value for a 12-bit number and >0ff6H is reserved)   DOS 3.2 says: If a disk has more than 20740 (5104H) SECTORS, it uses 16 bits                 (in other words, any disk over 10 Megabytes uses a 16-bit FAT) 
Note: It's a common misconception that the 16-bit FAT allows DOS to work with disks larger than 32 Megabytes.  In fact, the limiting factor is that INT 25H/26H (through which DOS performs its disk I/O) in unable to access a SECTOR higher than 65535.  Since sectors are normally 512 bytes (-K), that sets the 32M limit.  Nothing says you can't have sectors larger than 512 bytes, so DOS could theoretically handle any size disk. 
Ŀ  Reading the FAT  To read the value of any entry in a FAT (as when following a  FAT chain), first read the entire FAT into memory and obtain a starting cluster number from a directory.  Then, for 12-bit entries: 
  Multply the cluster number by 3 ͻ   Divide the result by 2  > each entry is 1.5 (3/2) bytes long   Read the WORD at the resulting address (as offset from the start of the FAT)   If the cluster number was even, mask the value by 0fffH (keep the low 12 bits)   If the cluster was odd, shift the value right by 4 bits (keep the hi 12 bits)   The result is the entry for the next cluster in the chain (0fffH=the end). 
  Note: A 12-bit entry can cross over two sectors, so beware of 1-sector         FAT buffering schemes. 
16-bit entries are simpler -- each entry contains the 16-bit offset (from the start of the FAT) of the next entry in the chain (ffffH indicates the end). 
Ŀ  FAT Content  The first byte of the FAT is called the  Media Descriptor  or  FAT ID byte.  The next 5 bytes (12-bit FATs) or 7 bytes (16-bit FATs) are 0ffH.  The rest of the FAT is composed of 12-bit or 16-bit cells that each represent one disk cluster.  These cells will contain one of the following values: 
      (0)000H .................. an available cluster       (f)ff0H through (f)ff7H .. a reserved cluster       (f)ff7H .................. a bad cluster       (f)ff8H through (f)fffH .. the end of an allocation chain       (0)002H through (f)fefH .. the cluster number of the next cell in a chain 
Note: the high nibble of the value is used only in 16-bit FATs; eg, a bad       cluster is marked with 0ff7H in 12-bit FATs, and fff7H with 16-bit FATs. 
Ŀ  Converting a Cluster Number to a Sector Number  After you obtain a file's  starting cluster number from a directory entry you will want to locate to actual disk sector that holds the file's (or subdirectory's) data. 
A diskette (or the DOS partition of a hard disk) is laid out like so: 
     Boot and reserved sector(s)      FAT #1      FAT #2 (optional -- not used on RAM disks)      root directory      data area (all file data reside here, including files for directories) 
Every section of this layout is variable and the sizes of each section must be known in order to perform a correct cluster-to-sector conversion.  The following formulae represent the only documented method of determining a DOS logical sector number from a cluster number: 
       RootDirSectors = SectorBytes / (RootDirEntries * 32)        FatSectors     = FatCount * SectorsPerFat        DataStart      = ReservedSectors + FatSectors + RootDirSectors 
       LogicalSector  = DataStart + ((StartCluster - 2) * SectorsPerCluster) 
Where the variables: SectorBytes      SectorsPerFat      FatCount                      RootDirEntries   ReservedSectors    SectorsPerCluster 
are obtained from the Boot Sector or from a BPB (if you can get access).  The resulting sector number can be used in DX for INT 25H/26H DOS absolute disk access. 
If you are a daring sort of person, you can save trouble by using the undocumented DOS Fn 32H (Get Disk Info) which provides a package of information that has already been pre-calculated, including the sector number of the start of data. 
Author's note:  The best use I've found for all this information on the FAT is to bypass the DOS file searching services and do my own directory scanning.  For a program that must obtain a list of all files and directories, direct access of directory sectors will work roughly twice as fast as the DOS services. 
The DOS Environment 
DOS maintains an area of memory that holds a set of ASCIIZ strings that can be used by applications to obtain certain system-level information and to pass data to other programs. 
   The DOS 'SET' command is a general purpose DOS interface to the environment.    The 'PATH' and 'PROMPT' commands also affect its contents.    UNDOCUMENTED  In batch files, any text surrounded by percent marks is    replaced with the environment 'value' that matches the 'name'.  Examples: 
    1 >   SET PATH=c:\my_dir;%PATH%     2 >   IF .%USER%. == .dan. GOTO dan_label     3 >   ECHO %CMPRS% > %CUR_LPT% 
   This opens up a variety of possibilities, but DOS still lacks all the tools    needed in a truly flexible batch processing language. 
The environment is limited to an arbitrary size, but a larger DOS environment can be created with the 'SHELL=' directive in the CONFIG.SYS file or the command 'COMMAND /e:NNNNN' which starts a secondary copy of the command interpreter, providing NNNNN bytes of environment space. 
   Layout:                         Example using ASM mnemonics:    name_1=value_1<0>               db  'COMSPEC=c:\command.com',0    name_2=value_2<0>               db  'PROMPT=$p$g',0         :                          db  'WP=c:\wordproc',0    name_N=value_N<0>               db  'PATH=d:\;c:\dos;c:\utils',0    <0>                             db  0  <xxxx> Ŀ   DOS     dw  1  Ŀ   EXEC_string_1<0>  > 3.0+ <͵  db  'C:\ACCTNG\AR001.EXE',0        :                  only    db  0     EXEC_string_NN<0>   <0>   
where <0> is the ASCII NUL character (00H) and <xxxx> is a 16-bit binary value. 
Ŀ  Using the Environment  The environment is less than 32K bytes and it starts  on a paragraph boundary.  Offset 2cH of the PSP of the current program contains the paragraph number of the environment. 
You can find a selected 'name' with a series of ASCIIZ string comparisons, until you come to a null string (zero length), indicating the end of the environment. Normally, the 'name' portion of each string in the environment is in uppercase, but this is not enforced. 
One typical operation with the environment is used by shell-type programs which execute a secondary copy of COMMAND.COM.  Shells typically search for the 'name' of "COMSPEC" and use the 'value' as the drive, path, and filespec of the DOS command interpreterthe program to EXEC via DOS Fn 4bH 
Some programs request the operator to store application-specific information in the environment via the SET command.  The application can use that information each time it is executed.  For instance, a wordprocessor may search the environment for a 'name' of "DICTIONARY" and use the text of the 'value' as the filespec for a dictionary data file. 
Ŀ  The "Root" Environment  Each program receives a static copy of the initial  environment.  Thus, any changes you make to an environment will be in effect for all your child processes (if any), but will be lost when control is returned to your parent process. 
There is no documented way to locate the "root" or "DOS master" environment. See INT 2eH for an UNDOCUMENTED technique.  You may benefit by running a copy of COMMAND.COM, passing it a tailored environment.  Then all of its spawns will receive a copy of that environment. 
Ŀ  Locating the Load Path  Starting with DOS version 3.0, DOS stores an  additional string after the end of the formal environment that can be used to locate the drive and directory from which a program was loaded.  A 'smart' application program can use this to help itself find program overlays and data files. 
This is most significant since DOS 3.0 began allowing an operator to invoke a environment that can be used to locate the drive and directory from which a program was loaded.  A 'smart' application program can use this to help itself find program overlays and data files. 
This is most significant since DOS 3.0 began allowing an operator to invoke a program by prefixing a pathname before the program filename. 
Following the final ASCIIZ string of the environment is a byte of 0, indicating the end of the formal environment.  The next two bytes are a 16-bit binary count of additional strings (this value is normally 0001H).  Following this binary value, you can expect to find an ASCIIZ string of the filespec which was used by DOS Fn 4bH (EXEC) to load and execute the program. 
Even if the program file was not in the default directory and DOS needed to use the command search path (ie, the PATH= string) to locate the program file, the correct full filespec (d:\path\filename.ext,0) will be stored after the end of the environment. 
Program Startup & Exit 
DOS is able to load and execute two types of program files -- COM and EXE. 
Because of the segmented address space of the 8088/86/286 CPU and the fact that JMPs and CALLs are address-relative, either type of program may be loaded and executed at any paragraph address in memory.  Thus, code can be made resident in "low" memory and other code can be loaded and executed above it in memory. Programs are NEVER written with the assumption that they'll be loaded at a certain address (except some self-booting, copy-protected games). 
  A COM-format file is a binary image of the code and data of the program.  The   file must be less than 64K, and no segment-address relocation takes place. 
  An EXE-format file contains a special header that directs the loader in   performing adjustments to segment references in a load module. 
Ŀ  All Programs  Before either a COM- or EXE-format program is loaded, DOS  selects a segment address, called the PSP (Program Segment Prefix) as the load base for the program.  DOS selects the lowest available address, but a control program (such as Microsoft Windows) may chose any part of memory.  Then DOS performs these steps: 
  It makes a duplicate of the current DOS Environment for the program.  DOS    Fn 4bH (EXEC) lets a parent program create a different environment.  For    instance, a program can run COMMAND.COM, setting the DOS prompt to include    the text "Use EXIT to return to UltraProg>". 
  It places the program's load path at the end of the environment  DOS 3.0+ 
  It fills the fields of the PSP with information useful to the program    (See Program Segment Prefix for a complete layout):      the amount of memory available to the program      the segment address of the DOS Environment      0-2 unopened File Control Blocks (FCBs) as parsed from the command line      (note: if you open the first FCB, it will overwite part of the second)      the command parameters: the exact characters entered in the command line      (parse this area to examine options and path\filename parameters)      the current vectors for INT 22H  INT 23H and INT 24H 
  It sets the default Disk Transfer Address (DTA) to PSP:0080 
  It sets the AX register to indicate the validity of the drive IDs (if any) of    the filepsec parameters entered on the command line: 
        if AL=0ffH, then the first drive ID was invalid         if AH=0ffH, then the second drive ID was invalid 
Ŀ  EXE Programs  EXE-format programs define multiple program segments, including  a code, data, and stack segment.  The EXE file is loaded starting at PSP:0100.  As it is loaded, a bunch of information is read from the the EXE Header at the start of file and segment address-relocation is performed. This means that references such as 
         mov     ax,data_seg          mov     ds,ax and          call    my_far_proc 
must be adjusted -- to allow for the fact that the program is being loaded into an arbitrarily-selected memory segment.  See EXE File Header for details of the header and the relocation process. 
After relocation, control is passed to the load module via a FAR jump to the CS:IP that was read from the EXE header. 
When the EXE-format program gets control: 
  DS and ES are set to the PSP   CS, IP, SS, and SP are set to values indicated in the EXE Header   the PSP MemTop field is set to a value in the EXE header.  Normally, all of    available memory is allocated to the program. 
Ŀ  COM Programs  COM-format programs define a single segment (or at least make  no explicit references to any other segment).  The bytes of the COM file are read from disk and stored into memory starting at PSP:0100.  Note that a COM program can use multiple segments, but it must calculate or derive segment addresses, using the Program Segment as a base. 
COM programs are preferred over EXE programs for short assembly language utilities.  They load faster since no segment relocation is needed, and they take less disk space since the bytes of the EXE header and the stack segment need not be present in the load module. 
After the binary image is loaded: 
  CS, DS, ES, and SS are set the same as the PSP   SP is set to the end of the PSP segment (usually 0fffeH, but it will be lower    if a full 64K is not available).   The word at offset 06H of the PSP is set    to indicate how much of the program segment is available.   All of system memory above the Program Segment is allocated to the program.   A word of 00H is pushed onto the stack.   The IP is set to 100H (the first byte of the load module) by a JMP to PSP:100 
Ŀ  Exiting a Program  At one time (back in the days of DOS 1.1), it took several  pages to explain the Rube Goldberg scheme DOS provided for exit from a program.  It got easier starting with DOS 2.0.  You can exit by: 
  using DOS Fn 4cH (EXIT) at any time, regardless of register values.   using DOS Fn 00H or INT 20H  when your CS is the same as the PSP 
Prior to DOS 2.0, you needed to save the PSP segment at startup.  Then to exit, you would PUSH it on the stack, PUSH a word of 00H, then do a FAR RETurn.  This sends control to PSP:0000 which contains the opcodes for INT 20H.  This ensures that CS is set as expected by DOS. 
DOS Fn 4cH eliminates this complication, and it lets you return an  exit code to the parent process (usually COMMAND.COM) which can be tested by the parent program or the COMMAND.COM "IF ERRORLEVEL" command. 
You may also terminate a program and make it permanently memory resident (TSR), by using either INT 27H or DOS Fn 31H (KEEP).  The latter has the advantages that you can make more than 64K resident and you can return an exit code that can be tested by the parent process. 
TSR program are handy for installing custom patches to various DOS and BIOS services.  It is the concept used by popup utilities such as SideKick and TECH Help! (to name two of the most important instances). 
The following topics are relevant: 
   Process Control Functions .... index of DOS Startup and Exit functions    Program Segment Prefix ....... detailed layout of the PSP    DOS Fn 26H ................... build a PSP    DOS Fn 4bH (EXEC)............. load and execute programs    DOS Fn 62H ................... obtain the PSP value for the current program    DOS Fn 2fH ................... obtain the current Disk Transfer Address    The DOS Environment .......... determine the drive, and directory from which                                   the current program was loaded 
Standard I/O 
Starting with version 2.0, DOS supports the UNIX-like concept of redirection of the Standard Input and Standard Output devices.  It is the basis of a technique which lets one program feed input into or capture output from another program. 
Unless redirected, Standard Input comes from the keyboard and Standard Output goes to screen; both are functions of the CON device.  A parent process (such as COMMAND.COM) can redirect either Standard Input or Output or both before passing control to a child process.  This can be a powerful way to pass information from process to process with a minimum of programming overhead. 
See File Handles for a list of pre-defined Standard I/O handles. 
Use DOS Character I/O functions or Fns 3fH / 40H to read/write the Standard I/O. Use file handle 02H (Standard Error device) with Fn 40H to make sure a message     is displayed. 
Use DOS Fn 46H (FORCDUP) to redirect the Standard I/O. Use DOS Fn 4bH (EXEC) to execute a child process. Use DOS Fn 44H (IOCTL) to determine if the Standard I/O has been redirected. 
The device attribute of an installable device driver indicates if the device is to be used as the default Standard Input and/or Standard Output device. 
Ŀ  COMMAND.COM & Standard I/O  The DOS command interpreter examines each  command line for I/O redirection symbols before it performs an internal command or EXECs a program: 
process < filespec   EXECs process; keyboard input will come from the file process > filespec   EXECs process; screen output will go to the file process >> filespec  EXECs process; screen output will be appended to the file process1 | process2  1. EXECs process1, screen output goes to a temporary file                      2. EXECs process2, keyboard input comes from the temp file                      3. deletes the temporary file Notes:     Output redirection with '>' creates the output file, truncating its length     to 0 before the first characters are written.  Use '>>' to append text to     the end of an existing file. 
    You can use the pipe ("|") symbol to chain several DOS commands and programs     together: 
         DIR | SORT | FIND /v "i" >myfile.txt 
    Each temporary pipe file will have a unique name formed from hex digits of     the current date and time.  They are always created in the current default     directory of the default drive. 
    Redirection of the ECHO command is handy for several uses: 
        ECHO ^L >PRN        (forces a formfeed on the printer)         ECHO y|DEL *.*      (answers "yes" to the "Are you sure?" prompt)         ECHO ATDT 1(213)555-1234 >AUX  (dials the phone) 
    Redirect output to the NUL device to get rid of some DOS messages:        COPY *.COM d: >NUL   (avoid the "1 File(s) copied" message)     Each temporary pipe file will have a unique name formed from hex digits of     the current date and time.  They are always created in the current default     directory of the default drive. 
    Redirection of the ECHO command is handy for several uses: 
        ECHO ^L >PRN        (forces a formfeed on the printer)         ECHO y|DEL *.*      (answers "yes" to the "Are you sure?" prompt)         ECHO ATDT 1(213)555-1234 >AUX  (dials the phone) 
    Redirect output to the NUL device to get rid of some DOS messages: 
       COPY *.COM d: >NUL   (avoid the "1 File(s) copied" message) 
    COMMAND.COM will ignore redirection symbols enclosed in quotes: 
         REM I am using the greater-than sign ">" in this remark 
DOS Versions 
TECH Help! indicates variations and incompatibilities between DOS versions by displaying a highlighted version number as a warning flag. 
Where a DOS Function or DOS Interrupt changed significantly between versions, these flags are used to let you see them at a glance: 
       2.0+ or (none) .......... applies to DOS version 2.0 and higher        2.x ..................... applies to DOS 2.0 or 2.1 
       3.0+ or 3.x ............. applies to DOS versions starting at DOS 3.0        3.0 or 3.1 or 3.2 ....... applies to this and later versions 
The fundamental DOS services were roughed out with DOS 1.0 and stabilized (read: debugged) with version 1.1.  If your program must be able to run under DOS 1.1, you must not use DOS Functions higher than 2eH. 
When IBM introduced a hard disk PC (the XT), it released DOS version 2.0 -- a significant upgrade, including: 
     Multiple directories to enhance access to large capacity media      Handle-Oriented File I/O  superceded the hard-to-use FCB File I/O to                                simplify file/device access.      Standard I/O  Redirection for generalized UNIX-like device independence.      Installable Device Drivers  to interface non-standard equipment & RAM disks                                  and included the ANSI.SYS console driver 
DOS 2.1 fixed a few bugs and added support for the PCjr diskette drives. 
DOS 3.0 came out with the AT and included support its 20M hard disk.  It added         support for 16-bit FAT entries to minimize slack space on hard disks.         Added extended error reporting for DOS functions.         Significant new DOS commands: ATTRIB, LABEL, VDISK.SYS RAM disk 
DOS 3.1 included some network services (file sharing, locking, redirecting).         Significant new DOS commands: JOIN, SUBST 
DOS 3.2 came out with the IBM Convertible PC.  It expanded on the device         driver IOCTL service to include DOS-blessed disk formatting, etc.         Significant new DOS commands: REPLACE, XCOPY, DRIVER.SYS logical disk 
Ŀ  Compatibility  In general, higher numbered versions are compatible with  lower numbered versions.  Most software is written to work with DOS 2.x since that is still the most common incarnation.  The added features of DOS 3.x are relatively insignificant, so there is little reason to develop software that relies on the 3.x-specific features (with the exception of networking applications). 
Perhaps the most common compatibility problem is seen on PCs with a limited amount of memory.  Higher numbered DOS version take up more RAM from the available pool and thus leave less room for application programs.          Version  On Disk  In Memory                        DOS 1.0  11,551   12,144    On Disk = size of COMMAND.COM          DOS 1.1  13,279   12,400                     +IBMBIOS.COM          DOS 2.0  39,424   24,800                     + IBMDOS.COM          DOS 2.1  39,551   24,800          DOS 3.0  58,926   37,024     In Memory = as reported by CHKDSK.COM          DOS 3.1  60,534   37,040                 more with SHARE, MODE, etc.          DOS 3.2  68,637   44,704                 and some CONFIG.SYS directives 
Another problem is seen with installed device drivers for non-IBM hard disks. Some work perfectly for DOS 2.x but won't work with 3.x (see below). 
Also beware of RAM-resident (TSR) software.  By necessity, it must perform a bunch of underhanded, if not specifically prohibited, operations to avoid the DOS re-entrancy problem.  The very FIRST thing to do when you suspect a DOS compatibility problem is to remove all TSR programs from your AUTOEXEC.BAT and reboot (and don't forget that the CONFIG.SYS file has a major affect on DOS). 
Ŀ  Traps and Pitfalls  Most DOS functions are upwardly-compatible, but there are  several places you can't take that for granted.  Most of the items in following list are relatively unimportant, but it might save you several hours of debugging time. 
  DOS Fn 1bH stopped returning a pointer to the actual FAT in DOS 2.0 and just   returns a pointer to a media descriptor byte.  The FAT need not be in memory. 
  DOS Fn 4fH (Find Next File) had a subtle change between DOS version 2.x and   3.x.  You are now required to keep DS:DX pointing to the information from a   4eH (Find First File) call.  DOS 2.x just assumed it was in the DTA. 
  DOS Fn 30H modifies BX and CX in DOS 3.0+ 
  DOS Fn 38H (Country Info) returns an incompatible Country Info Block 
  The three 16-bit words at the end of the BPB (used in device drivers) switched   from being "optional" to "mandatory" with DOS 3.0.  Also, be aware that some   non-IBM installed device drivers do NOT store the BPB in the boot sector of   the hard disk (this only applies to hard disks which are not installed with   ROM-Scan and thus need not have a partition table and are not self-booting). 
There are probably other upwardly-INcompatible features [I appreciate cards and   3.x.  You are now required to keep DS:DX pointing to the information from a   4eH (Find First File) call.  DOS 2.x just assumed it was in the DTA. 
  DOS Fn 30H modifies BX and CX in DOS 3.0+ 
  DOS Fn 38H (Country Info) returns an incompatible Country Info Block 
  The three 16-bit words at the end of the BPB (used in device drivers) switched   from being "optional" to "mandatory" with DOS 3.0.  Also, be aware that some   non-IBM installed device drivers do NOT store the BPB in the boot sector of   the hard disk (this only applies to hard disks which are not installed with   ROM-Scan and thus need not have a partition table and are not self-booting). There are probably other upwardly-INcompatible features [I appreciate cards and letters from programmers who find them -- DR].  If you use an undocumented DOS call, or (heaven forbid!) an undocumented address in DOS or ROM, be prepared to rewrite your program for later versions of DOS and BIOS. 
About DOS Functions 
The DOS functions are a haphazard set of file, device, memory, and process control services that are available to any program which is capable of setting registers and invoking software interrupts. 
To access DOS functions:            place a DOS Function number in the AH register            (if one or more sub-functions exist, it usually goes in AL)            load up the other registers as described in the function summary            prepare any buffers, ASCIIZ strings, and control blocks needed            be aware of (or set) the location of the DTA if necessary            invoke INT 21H            look for error indicators returned by DOS (examine the Carry Flag) 
DOS preserves register values except when information is returned in a register. 
As DOS evolved, later version have remained (generally) compatible with eariler versions.  See DOS Versions for a discussion of incompatibilities. 
Interrupts and ROM-BIOS Services 
Interrupts              Services                      Pointers     INT 00H Division by 0   INT 10H Video services        INT 1dH Video parms  INT 01H Single-step     INT 11H Equipment list        INT 1eH Diskette parms  INT 02H Non-Maskable    INT 12H Usable Memory Size    INT 1fH Graphics chars  INT 03H Breakpoint      INT 13H Disk I/O  INT 04H Overflow        INT 14H Serial Port I/O  INT 05H Print Screen    INT 15H AT Extended Services  INT 41H hard disk 0 parms  INT 06H (reserved)      INT 16H Keyboard I/O          INT 46H hard disk 1 parms  INT 07H (reserved)      INT 17H Printer I/O  INT 08H Timer           INT 18H ROM-BASIC             INT 44H EGA graphic chars  INT 09H Keyboard        INT 19H Bootstrap  INT 0aH-0dH (hdwr ints) INT 1aH Time I/O              INT 4aH user alarm addr  INT 0eH Diskette        INT 1bH Keyboard Break        INT 50H CMOS timer int  INT 0fH (hdwr int)      INT 1cH User timer Int                          INT 20H-2fH DOS Interrupts 
INSTALLABLE DEVICE DRIVERS 
DEVICE DRIVER FORMAT 
An installable device driver lets you create a standard interface between DOS and a non-standard piece of hardware.  These topics are covered: 
  Device Driver Basics ............ general introduction to device drivers 
  Device Header Layout ............ layout of the first part of a driver image   Device Attribute ................ bit flags that define a device 
  Device Requests ................. each command a device driver must perform   Device Request Header ........... layout of 1st 13-bytes of a request packet   Device Driver Errors ............ error codes a device driver returns to DOS   Device Status Word .............. device status bit flags returned to DOS 
  BIOS Parameter Block (BPB) ...... layout of a structure used by block devices 
  Expanded Memory Specification ... EMM Fns are installed as a device driver   CONFIG.SYS ...................... the DEVICE= directive installs devices 
 A device driver is a COM or EXE file that contains all of the code needed to control an add-in device. It has a special header to identify it as a device, define the strategy and interrupt entry points, and define its various attributes. 
NOTE: For device drivers the COM file must not use the ORG 100h. Since the       driver does not use the program segment prefix, it is simply loaded       without offset. Therefore the memory image file must have an origin of 0       (ORG 0 or no ORG statement). An installable device driver is a specially-formatted program that is loaded into memory when DOS boots. 
The device driver file is a binary image file.  After assembling the source code, use EXE2BIN to convert to a binary file.  Unlike a COM-format file, do not include an ORG 100H at the start of the code. 
The first part of the file must be an 18-byte structure called a Device Header The first four bytes are modified by DOS upon installation. When the CONFIG.SYS file contains a 'DEVICE=' directive for the driver file, the file will be installed into a chain of device drivers.  The action is such that an installed device takes precedence over a DOS driver for a device with the same name. 
TYPES OF DEVICES 
There are two types of devices: Character devices and Block devices. Their attributes are as follows: 
Character devices 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 with them. Because character devices have only one name, they can only support one device. 
Block devices are the fixed disk or diskette drives on a system. They can do random I/O in peices called blocks, which are usually the physical sector size of the disk. These devices are not named as character devices are, and cannot be opened directly. Instead they are mapped by using 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 drives. For example, the first block device driver can be responsible for drives A,B,C,and D. This means it has four units defined and therefore takes up four drive letters. The position of the driver in the chain of all drives determines the way in which the drive letters correspond. For example, if the device driver is the first block driver in the device chain, and it defines four units, then these devices are called A,B,C, and D. If the second device driver defines three units, then those units are E,F,and G. DOS 1.x allows 16 devices. DOS 2.x allows 63, and DOS 3.x allows 26. It is recommended that drivers limit themselves to 26 devices for compatibility with DOS 3.x. 
DOS doesn't care about the position of installed character devices versus block devices. The installed character devices get put into the chain ahead of resident character devices so that you can override the system's default driver for CON etc. 
Although it is sometimes beleived that installed block devices get linked into the chain BEHIND the resident block devices, if you look at the actual device chain, this is not true (though it is true in the sense that installed block devices get assigned drive letters in sequence, starting with the next letter after the last one assigned to a resident block device). 
DEVICE HEADER 
A device driver requires a device header at the beginning of the file. This is the format of the device header: 
                Field                           Length 
        Pointer to next device header field     dword         Attribute                               word         Pointer to device strategy routine      word         Pointer to device interrupt routine     word         Name/Unit field                         8 bytes 
      Device Header ͻ                     Ŀ <ͺNextDev         C O N           code and data of ANSI.SYS                                               Ŀ    NextDev         C O N           code and data of DOS CON device                                         Ŀ >NextDev         L P T 1         code and data of LPT1 device     <                    ķ >NextDev         C O M 1         <Ľ                    Ŀ >NextDev         C O M 2         code and data of COMn devices    <                 etc. 
POINTER TO NEXT DEVICE HEADER FIELD 
The device header field is a pointer to the device header of the next device driver. It is a doubleword field that is set by DOS at the time the device driver is loaded. The first word is an offset and the second word is the segment.  If you are loading only one device driver, set the device header field to -1 before loading the device. If you are loading more than one device driver, set the first word of the device driver header to the offset of the next device driver's header. Set the device driver header field of the last device driver to -1. 
Ŀ  Strategy and Interrupt  Two of the fields in the device header are 16-bit  pointers to within the device driver code segment. On any device request, DOS first calls the Strategy address, passing it the address of a Request Header in ES:BX.  The job of the Strategy routine is to record this ES:BX for later use (in a multi-tasking environment, it can make a FIFO queue of requests). 
The Interrupt routine is then called by DOS, with no parameters.  Its job is to fetch the address of the most recent request header and act on the command code in the request header.  The various device commands use different layouts for the data packet which is passed by DOS.  See Device Request Layouts for a list of commands and a description of each.  Typically, the driver will contain some sort of N-way branch to handle the requests. 
Upon completion of a request, the driver should set the Device Status Word to indicate completion and errors encountered, then return to DOS via a FAR return. 
Device Header Layout 
The binary image file of a device driver begins with this structure.  During installation, the Next_Device field is updated to fit in with device chain. 
Offset Size Contents            Ŀ Next_Device: FAR address of next device in chain  +0      4  offset  segment (offset=0ffffH if this the last driver)               +4      2  DevAttr         bit fields that make up the Device Attribute             Ĵ  +6      2  Stratgy         offset address of device STRATEGY routine             Ĵ  +8      2  Intrupt         offset address of device INTERRUPT routine             Ŀ +0aH     8  'L' 'P' 'T' '1' 20H 20H 20H 20H blank-padded Device_Name (or block              device sub-unit number) 
ATTRIBUTE FIELD 
 The attribute field is a word field that describes the attributes of the device driver to the system. The attributes are: 
        word    bits (decimal)                 15      1       character device                         0       block device                 14      1       supports IOCTL                         0       doesn't support IOCTL                 13      1       non-IBM format (block only)                         0       IBM format                 12      not documented - unknown                 11      1       supports removeable media                         0       doesn't support removeable media                 10      reserved for DOS              through                 4       reserved for DOS                 3       1       current block device                         0       not current block device                 2       1       current NUL device                         0       not current NUL device                 1       1       current standard output device                         0       not current standard output device 
BIT 15  is the device type bit. Use it to tell the system the that driver is a         block or character device. 
BIT 14  is the IOCTL bit. It is used for both character and block devices. Use         it to tell DOS whether the device driver can handle control strings         through the IOCTL function call 44h.          If a device driver cannot process control strings, it should set bit         14 to 0. This way DOS can return an error is an attempt is made through         the IOCTL function call to send or receive control strings to the         device. If a device can process control strings, it should set bit 14         to 1. This way, DOS makes calls to the IOCTL input and output device         function to send and receive IOCTL strings.          The IOCTL functions allow data to be sent to and from the device         without actually doing a normal read or write. In this way, the device         driver can use the data for its own use, (for example, setting a baud         rate or stop bits, changing form lengths, etc.) It is up to the device         to interpret the information that is passed to it, but the information         must not be treated as a normal I/O request. BIT 13  is the non-IBM format bit. It is used for block devices only. It affects         the operation of the Get BPB (BIOS parameter block) device call. 
BIT 11  is the open/close removeable media bit. Use it to tell DOS if the         device driver can handle removeable media. (DOS 3.x only) 
BIT 3   is the clock device bit. It is used for character devices only. Use it         to tell DOS if your character device driver is the new CLOCK$ device. 
BIT 2   is the NUL attribute bit. It is used for character devices only. Use it         to tell DOS if your character device driver is a NUL device. Although         there is a NUL device attribute bit, you cannot reassign the NUL device.         This is an attribute that exists for DOS so that DOS can tell if the NUL         device is being used. 
BIT 0   are the standard input and output bits. They are used for character   &     devices only. Use these bits to tell DOS if your character device BIT 1   driver is the new standard input device or standard output device. 
The DevAttr field of the Device Header indicates properties of a device.  1 1 1 1 1 1 5432109876543210    0 0 0 0 0 0 0     ҽ  bit#                              mask value                        >  0: 1=standard input device       (a & 0001H)                       >  1: 1=standard output device      (a & 0002H)                      >  2: 1=standard NUL device         (a & 0004H)                     >  3: 1=clock device                (a & 0008H)                >  6: 1=supports logical devices    (a & 0040H)       > 11: 1=supports open/close/RM      (a & 0800H)    > 13: 1=non-IBM block device        (a & 2000H)   > 14: 1=supports IOCTL              (a & 4000H)  > 15: 1=character device; 0=block   (a & 8000H) 
Notes:  set the standard I/O bits (0 and 1) when you replace the CON driver 
Device Request Layouts 
Cmd Name                     Usage     Cmd Name                   Usage  DOS            0  Initialize device         C,B      0aH Output Status          C  1  Media Check                 B      0bH Output Flush           C  2  Build BPB                   B      0cH IOCTL Output           C,B,I  3  IOCTL Input               C,B,I    0dH Device Open            C,B,R  3.0+  4  Input (read from device)  C,B      0eH Device Close           C,B,R  3.0+  5  Non-destructive Input     C        0fH Removable Media          B,R  3.0+  6  Input status              C        13H Generic IOCTL Request      I  3.2  7  Input Flush               C        17H Get Logical Device     C,B    3.2  8  Output (write to device)  C,B      18H Set Logical Device     C,B    3.2  9  Output with verify        C,B      Usage Key: C = character device drivers   Ŀ            B = block devices (mainly disk drives)       >See device attribute            I = must support IOCTL                                   R = must support Open/Close/Removable Media  
POINTER TO STRATEGY AND INTERRUPT ROUTINES 
 These two fields are pointers to the entry points of the strategy and input routines. They are word values, so they must be in the same segment as the device header. 
NAME/UNIT FIELD 
 This is an 8-byte field that contains the name of a character device or the unit of a block device. For the character names, the name is left-justified and the space is filled to 8 bytes. For block devices, the number of units can be placed in the first byte. This is optional because DOS fills in this location with the value returned by the driver's INIT code. 
CREATING A DEVICE DRIVER 
 To create a device driver that DOS can install, perform the following: 
1) Create a memory image file or an EXE file with a device header at the start    of the file. 2) Originate the code (including the device header) at 0, not 100h. 3) Set the next device header field. Refer to "Pointer to Next Device Header    Attribute Field" for more information. 4) Set the attribute field of the device header. Refer to "Attribute Field" for    more information. 5) Set the entry points for the interrupt and strategy routines. 6) Fill in the name/unit field with the name of the character device or the unit    number of the block device. 
 DOS always processes installable character device drivers before handling the default devices. So to install a new CON device, simply name the device CON. Be sure to set the standard input device and standard output device bits in the attribute field of a new CON device. The scan of the device list stops on the first match so the installable device driver takes precedence. 
NOTE: Because DOS can install the device driver anywhere in memory, care       must be taken in any FAR memory references. You should not expect that       your driver will be loaded in the same place every time. 
INSTALLING DEVICE DRIVERS 
 DOS installs new device drivers dynamically at boot time by reading and processing the DEVICE command in the config.sys file. For example, if you have written a device driver called DRIVER1, to install it put this command in the CONFIG.SYS file:                              DEVICE=DRIVER1 
 DOS calls a device driver at its strategy entry point first, passing in a request header the information describing what DOS wants the device driver to do.  This strategy routine does not perform the request but rather queues the request or saves a pointer to the request header. The second entry point is the interrupt routine and is called by DOS immediately after the strategy routine returns. The interrupt routine is called with no parameters. Its function is to perform the operation based on the queued request and set up any return infromation.  DOS passes the pointer to the request header in ES:BX. This structure consists of a fixed length header (Request Header) followed by data pertinent to the operation to be performed. 
NOTE: It is the responsibility of the device driver to preserve the machine       state. For example, save all registers on entry and restore them on exit. 
 The stack used by DOS has enough room on it to save all the registers. If more stack space is needed, it is the device driver's responsibility to allocate and maintain another stack.  All calls to execute device drivers are FAR calls. FAR returns should be executed to return to DOS. 
INSTALLING CHARACTER DEVICES 
 One of the functions defined for each device is INIT. This routine is called only once when the device is installed and never again. The INIT routine returns the following: 
A) A location to the first free byte of memory after the device driver, like a    TSR that is stored in the terminating address field. This way, the    initialization code can be used once and then thrown away to save space. B) After setting the address field, a character device driver can set the status    word and return. 
INSTALLING BLOCK DEVICES 
 Block devices are installed in the same way as character devices. The difference is that block devices return additional information. Block devices must also return: 
A) The number of units in the block device. This number determines the logical    names the devices will have. For example, if the current logical device    letter is F at the time of the install call, and the block device driver INIT    routine returns three logical units, the letters G, H, and I are assigned to    the units. The mapping is determined by the position of the driver in the    device list and the number of units in the device. The number of units    returned by INIT overrides the value in the name/unit field of the device    header. B) A pointer to a BPB (BIOS parameter block) pointer array. This is a pointer    to an array of *n* word pointers there *n* is the number of units defined.    These word pointers point to BPBs. This way, if all of the units are the    same, the entire array can point to the same BPB to save space.     The BPB contains information pertinent to the devices such as the sector    size, number of sectors per allocation unit, and so forth. The sector size of    the BPB cannot be greater than the maximum allotted size set at DOS    initialization time.    NOTE: This array must be protected below the free pointer set by the return. C) The media descriptor byte. This byte is passed to devices so that they know    what parameters DOS is currently using for a particular drive unit. 
 Block devices can take several approaches. They can be *dumb* or *smart*. A dumb device would define a unit (and therefore a BPB) for each possible media drive combination. Unit 0=drive 0;single side, unit 1=drive 0;double side, etc.  For this approach, the media descriptor bytes would mean nothing. A smart device would allow multiple media per unit. In this case, the BPB table returned at INIT must define space large enough to acommodate the largest possible medias supported (sector size in BPB must be as large as maximum sector size DOS is currently using). Smart drivers will use the media byte to pass information about what media is currently in a unit. 
REQUEST HEADER 
 The request header passes the information describing what DOS wants the device driver to do. 
Ŀ   Length                         F i e l d                                    Ĵ    BYTE    Length in bytes of the request header plus any data at end         Ĵ    BYTE    Unit code. The subunit the operation is for (minor device)                    Has no meaning for character devices.                              Ĵ    WORD    Command code                                                       Ĵ  8 BYTES   Deserved for DOS                                                   Ĵ (variable) Data appropriate for the operation                                  
Each request to a device driver is accompanied by a pointer to a request structure or packet.  Each request packet begins with this 13-byte header. Upon entry into a driver, ES:BX points to a packet in this layout. 
Offset Size Contents                Ŀ  +0      1  len         length of this request packet (header and data)             Ĵ  +1      1  unt         unit number (used for block devices only)             Ĵ  +2      1  cmd         Command Code (00-18H) specifies which action to take             Ŀ  +3      2  Status      Device Status Word is filled before exit from driver             Ŀ  +5H     8   (reserved)                                      +0dH     ?   variable-len data   data formatted according to command code                   See Device Requests for individual layouts. 
UNIT CODE FIELD 
 The unit code field identifies which unit in a block device driver the request is for. For example, if a block device driver has three units defined, then the possible values of the unit code field would be 0,1,and 2. 
COMMAND CODE FIELD 
 The command code field in the request header can have the following values: 
      CODE         FUNCTION 
        0       INIT         1       MEDIA CHECK      (block only,NOP for character)         2       BUILD BPB        (block only, NOP for character)         3       IOCTL input      (called only if IOCTL bit is 1)         4       INPUT            (read)         5       NONDESTRUCTIVE INPUT NO WAIT (character devices only)         6       INPUT STATUS     (character devices only)         7       INPUT FLUSH      (character devices only)         8       OUTPUT           (write)         9       OUTPUT           (write with verify)         10      OUTPUT STATUS    (character devices only)         11      OUTPUT FLUSH     (character devices only)         12      IOCTL OUTPUT     (called only if IOCTL bit is 1)         13      DEVICE OPEN      (called only if OPEN/CLOSE/RM bit is set)         14      DEVICE CLOSE     (called only if OPEN/CLOSE/RM bit is set)         15      REMOVEABLE MEDIA (called only if OPEN/CLOSE/RM bit is set and                                   device is block) 
NOTE: Command codes 13,14,and 15 are for use with DOS versions 3.x. 
STATUS FIELD 
The status field in the request header contains: 
Ŀ             D E V I C E    D R I V E R    S T A T U S    F I E L D             Ĵ    B    0                                                                            1                                                                       Y    2                                                                            3    Error message return code                                          T    4    (with bit 15=1)                                                         5                                                                       E    6                                                                            7                                                                    Ĵ   bit   8    DONE                                                            Ĵ   bit   9    BUSY                                                            Ĵ   bits  10 - 14    Reserved                                                  Ĵ   bit   15    Error                                                           
 The status word field is zero on entry and is set by the driver interrupt routine on return. 
BIT 15  is the error bit. If this bit is set, the low 8 bits of the status word         (7-0) indicate the error code. 
BITS 14-10 are reserved. 
BIT 9   is the busy bit. It is only set by status calls and the removable media         call. See "STATUS" and "REMOVABLE MEDIA" in this chapter for more         information about the calls. 
BIT 8   is the done bit. If it is set, it means the operation is complete. The         driver sets the bit to 1 when it exits. 
Device Driver Errors 
When a device driver receives an invalid request or encounters an error during operation, the Device Status Word error bit should be set (bit 15) and an error code should be placed into the low 8 bits (the byte at request header offset 3). These errors are: 
        00h  Write protect violation   01h  Unknown unit         02h  Device not ready          03h  Unknown command         04h  CRC error                 05h  Bad drive request structure length         06h  seek error                07h  unknown media         08h  sector not found          09h  printer out of paper         0Ah  write fault               0Bh  read fault         0Ch  general failure           0Dh  reserved         0Eh  reserved                  0Fh  invalid disk change 
 1 1 1 1 1 1 5432109876543210 ereserved bd  error code     s = 16-bit word at request header offset 3 Ľ  bit                               mask value               >  0-7: Device Error code           (s & 00ffH)              >  8: 1=Done (always set upon exit) (s & 0100H)             >  9: 1=Busy (only cmds 6 and 0fH)  (s & 0200H)  > 15: 1=error occurred              (s & 8000H) 
A device driver must always return a status word to DOS.  The status word is located at offset 3 from in the Device Request Header  Upon normal completion of a request, the driver must set the "done" bit and exit via a FAR RETurn. 
The "busy" bit is set by device request handlers when it determines that it can't satisfy a request because the physical device is in use by a previous request.  It is also used to return miscellaneous information, such as "keyboard queue in not empty" or "media is removable."  See Device Requests 
The "error" bit is set when a driver receives a request it can't handle or              >  8: 1=Done (always set upon exit) (s & 0100H)             >  9: 1=Busy (only cmds 6 and 0fH)  (s & 0200H)  > 15: 1=error occurred              (s & 8000H) 
A device driver must always return a status word to DOS.  The status word is located at offset 3 from in the Device Request Header  Upon normal completion of a request, the driver must set the "done" bit and exit via a FAR RETurn. 
The "busy" bit is set by device request handlers when it determines that it can't satisfy a request because the physical device is in use by a previous request.  It is also used to return miscellaneous information, such as "keyboard queue in not empty" or "media is removable."  See Device Requests 
The "error" bit is set when a driver receives a request it can't handle or encounters an error while attempting to satisfy a request.  When the "error" bit is set, bits 0-7 (the byte at request header offset 3) should be filled with an error code.  See Device Errors for a listing of defined error codes. 
DEVICE DRIVER FUNCTIONS 
 All strategy routines are called with ES:BX pointing to the request header. The interrupt routines get the pointers to the request header from the queue the strategy routines store them in. The command code in the request header tells the driver which function to perform. NOTE: all DWORD pointers are stored offset first, then segment. 
The following function call parameters are described: 
        INIT         MEDIA CHECK         BUILD BPB (BIOS PARAMETER BLOCK)         MEDIA DESCRIPTOR BYTE         INPUT OR OUTPUT         NONDESTRUCTIVE INPUT NO WAIT         STATUS         FLUSH         OPEN OR CLOSE         REMOVABLE MEDIA 
INIT 
Command code=0         ES:BX   pointer to request header. Format of header:                 length           field                 13 bytes  request header                  dword    number of units (not set by character devices)                  dword    Ending address of resident program code                  dword    Pointer to BPB array (not set by character devices)                           /pointer to remainder of arguments                   byte    Drive number (3x only) 
The driver must do the following: 
        A) set the number of units (block devices only)         B) set up the pointer to the BPB array (block devices only)         C) perform any initialization code (to modems, printers, etc)         D) Set the ending address of the resident program code         E) set the status word in the request header. 
 To obtain information obtained from CONFIG.SYS to a device driver at INIT time, the BPB pointer field points to a buffer containing the information passed from CONFIG.SYS following the =. The buffer that DOS passes to the driver at INIT after the file specification contains an ASCII string for the file OPEN. The ASCII string (ending in 0h) is terminated by a carriage return (0Dh) and linefeed (0Ah). If there is no parameter information after the file specification, the file specification is immediately followed by a linefeed (0Ah). This information is read-only and only system calls 01h-0Ch and 30h can be issued by the INIT code of the driver.  The last byte parameter contains the drive letter for the first unit of a block driver. For example, 0=A, 1=B etc.  If an INIT routine determines that it cannot set up the device and wants to abort without using any memory, follow this procedure: 
        A) set the number of units to 0         B) set the ending offset address at 0         C) set the ending offsret segment address to the code segment (CS) 
NOTE: If there are multiple device drivers in a single memory image file, the       ending address returned by the last INIT called is the one DOS uses. It is       recommended that all device drivers in a single memory image file return       the same ending address. 
MEDIA CHECK 
command code=1         ES:BX   pointer to request header. Format of header:                 length          field                 13 bytes  request header                 byte      media descriptor from DOS                 byte      return                 dword     returns a pointer to the previous volume ID (if bit                           11=1 and disk change is returned) (DOS 3.x) 
 When the command code field is 1, DOS calls MEDIA CHECK for a drive unit and passes its current media descriptor byte. See "Media Descriptor Byte" later in this chapter for more information about the byte. MEDIA CHECK returns one of the following: 
        A) media not changed             C) not sure         B) media changed                 D) error code 
The driver must perform the following:         A) set the status word in the request header         B) set the return byte                -1       media has been changed                 0       don't know if media has been changed                 1       media has not been changed 
 DOS 3.x: If the driver has set the removable media bit 11 of the device header attribute word to 1 and the driver returns -1 (media changed), the driver must set the DWORD pointer to the previous volume identification field. If DOS determines that the media changed is an error, DOS generates an error 0Fh (invalid disk change) on behalf of the device. If the driver does not implement volume identification support, but has bit 11 set to 1, the driver should set a pointer to the string "NO NAME",0. 
MEDIA DESCRIPTOR 
 Currently the media descriptor byte has been defined for a few media types. This byte should be idetnical to the media byte if the device has the non-IBM format bit off. These predetermined values are: 
media descriptor byte =>    1  1  1  1  1  0  0  0  (numerical order)          7  6  5  4  3  2  1  0 
       BIT                MEANING 
        0       1=2 sided       0=not 2 sided         1       1=8 sector      0=not 8 sector         2       1=removeable    0=nonremoveable        3-7      must be set to 1 Examples of current DOS media descriptor bytes: 
           media      sides   sectors  ID byte 
        hard disk       *       *       0F8h         5-1/4 floppy    2       15      0F9h         5-1/4 floppy    1       9       0FCh         5-1/4 floppy    2       9       0FDh         5-1/4 floppy    2       8       0FFh         5-1/4 floppy    1       8       0FEh         8" floppy       1       26      0FEh *         8" floppy       2       26      0FDh         8" floppy       2       8       0FEh * 
*NOTE: The two Media Descriptor Bytes that are the same for 8" diskettes (0FEh) are not a misprint. To determine whether you are using a single sided or double sided diskette, attempt to read the second side, and if an error occurs you can assume the diskette is single sided. 
BUILD BPB (BIOS Parameter Block) 
command code =2         ES:BX   pointer to request header. Format:                 length          field                 13 bytes  request header                 byte      media descriptor from DOS                 dword     transfer address (buffer address)                 dword     pointer to BPB table 
DOS calls BUILD BPB under the following two conditions: 
A) If "media changed" is returned B) If "not sure" is returned, there are no used buffers. Used buffers are    buffers with changed data that has not yet been written to the disk. 
The driver must do the following: 
A) set the pointer to the BPB B) set the status word in the request header. 
 The driver must determine the correct media type currently in the unit to return the pointer to the BPB table. The way the buffer is used (pointer passed by DOS) is determined by the non-IBM format bit in the attribute field of the device header. If bit 13=0 (device is IBM compatible), the buffer contains the first sector of the FAT (most importantly the FAT ID byte). The driver must not alter this buffer in this case. If bit 13=1 the buffer is a one sector scratch area which can be used for anything.  For drivers that support volume identification and disk change, the call should cause a new volume identification to be read off the disk. This call indicates that the disk has been legally changed.  If the device is IBM compatible, it must be true that the first sector of the first FAT is located at the same sector for all possible media. This is because the FAT sector is read before the media is actually determined.  The information relating to the BPB for a particular media is kept in the boot sector for the media. In particular, the format of the boot sector is: 
Ŀ  For DOS 2.x, 3 byte near jump (0E9h) For DOS 3.x, 2 byte near jump (0EBh)      followed by a NOP (90h)                                                       Ĵ  8 bytes    OEM name and version                                              Ĵ    BYTE          sectors per allocation unit (must be a power of 2)          Ĵ     Ĵ    WORD     B    reserved sectors (strarting at logical sector 0)            Ĵ     Ĵ    BYTE          number of FATs                                              Ĵ     Ĵ    WORD     P    max number of root directory entries                        Ĵ     Ĵ    WORD          number of sectors in logical image (total number of                          sectors in media, including boot sector directories, etc.)  Ĵ  B  Ĵ    BYTE          media descriptor                                            Ĵ     Ĵ    WORD          number of sectors occupied by a single FAT                  Ĵ    WORD     sectors per track                                                 Ĵ    WORD     number of heads                                                   Ĵ    WORD     number of hidden sectors                                           
 The three words at the end return information about the media. The number of heads is useful for supporting different multihead drives that have the same storage capacity but a different number of surfaces. The number of hidden sectors is useful for drive partitioning schemes. 
INPUT / OUTPUT 
command codes=3,4,8,9,and 12         ES:BX   pointer to request header. Format:                 length          field                 13 bytes  request header                 byte      media descriptor byte                 dword     transfer address (buffer address)                 word      byte/sector count                 dword     (DOS 3.x) pointer to the volume ID if error code 0Fh                           is returned 
The driver must perform the following:         A) set the status word in the request header         B) perform the requested function         C) set the actual number of sectors or bytes tranferred 
NOTE: No error checking is performed on an IOCTL I/O call. However the driver       must set the return sector or byte count to the actual number of bytes       transferred. The following applies to block device drivers:   
 Under certain circumstances the device driver may be asked to do a write operation of 64k bytes that seems to be a *wrap around* of the transfer address in the device driver request packet. This arises due to an optimization added to write code in DOS. It will only happen in writes that are within a sector size of 64k on files that are being exetended past the current end of file. It is allowable for the device driver to ignore the balance of the write that wraps around, if it so chooses. For example, a write of 10000h bytes worth of sectors with a transfer address of XXXX:1 ignores the last two bytes. 
Remember: A program that uses DOS function calls can never request an input or           output function of more than 0FFFFh bytes, therefore, a wrap around           in the transfer (buffer) segment can never occur. It is for this           reason you can ignore bytes that would have wrapped around in the           tranfer segment. 
 If the driver returns an error code of 0Fh (invalid disk change) it must put a DWORD pointer to an ASCIIZ string which is the correct volume ID to ask the user to reinsert the disk. 
DOS 3.x:  The reference count of open files on the field (maintained by the OPEN and CLOSE calls) allows the driver to determine when to return error 0Fh. If there are no open files (reference count=0) and the disk has been changed, the I/O is all right, and error 0Fh is not returned. If there are open files (reference count > 0) and the disk has been changed, an error 0Fh condition may exist. 
NONDESTRUCTIVE INPUT NO WAIT 
command code=5         ES:BX   pointer to request header. Format:                 length          field                 13 bytes  request header                 byte      read from device 
The driver must do the following:         A) return a byte from the device         B) set the status word in the request header. 
 If the character device returns busy bit=0 (characters in the buffer), then the next character that would be read is returned. This character is not removed form the buffer (hence the term nondestructive input). This call allows DOS to look ahead one character. 
STATUS 
command codes=8 and 10         ES:BX   pointer to a request header. Format:                 length          field                 13 bytes  request header 
This driver must perform the following:         A) perform the requested function         B) set the busy bit         C) set the status word in the request header. 
The busy bit is set as follows: 
 For input on character devices: if the busy bit is 1 on return, a write request would wait for completion of a current request. If the busy bit is 0, there is no current request. Therefore, a write request would start immediately. 
 For input on character devices with a buffer: if the busy bit is 1 on return, a read request does to the physical device. If the busy bit is 0, there are characters in the device buffer and a read returns quickly. It also indicates that a user has typed something. DOS assumes all character devices have a type- ahead input buffer. Devices that do not have this buffer should always return busy=0 so that DOS does not hang waiting for information to be put in a buffer that does not exist. 
FLUSH 
command codes=7 and 11         ES:BX   pointer                 length          field                 13 bytes  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 the status word in the request header upon return. 
OPEN or CLOSE (3.x) 
command codes=13 and 14         ES:BX   pointer                 length          field                 13 bytes  static request header 
 These calls are designed to give the device information about the current file activity on the device if bit 11 of the attribute word is set. On block devices, these calls can be used to manage local buffering. The device can keep a reference count. Every OPEN causes the device to increment the reference count. Every CLOSE causes the device to decrement the reference count. When the reference count is 0, if means there are no open files in the device. Therefore, the device should flush buffers inside the device it has written to because now the user can change the media on a removeable media drive. If the media had been changed, it is advisable to reset the reference count to 0 without flushing the buffers. This can be thought of as "last close causes flush". These calls are more useful on character devices. The OPEN call can be used to send a device initialization string. On a printer, this could cause a string to be sent to set the font, page size, etc. so that the printer would always be in a known state in the I/O stream. Similarly, a CLOSE call can be used to send a post string (like a form feed) at the end of an I/O stream. Using IOCTL to set these pre and post strings provides a flexible mechanism of serial I/O device stream control. 
NOTE: Since all processes have access to STDIN,STDOUT,STDERR,STDAUX, and STDPRN       (handles 0,1,2,3,and 4) the CON, AUX, and PRN devices are always open. 
REMOVABLE MEDIA (DOS 3.x) 
command code=15         ES:BX   pointer                 length          field                 13 bytes  status request header 
 To use this call, set bit 11 of the attribute field to 1. Block devices can only use this call through a subfunction of the IOCTL function call (44h). This call is useful because it allows a utility to know whether it is dealing with a nonremovable media drive or with a removable media drive. For example, the FORMAT utility needs to know whether a drive is removable or nonremovable because it prints different versions of some prompts. 
 The information is returned in the BUSY bit of the status word. If the busy bit is 1, the media is nonremovable. 
NOTE: No error checking is performed. It is assumed that this call always       succeeds. 
THE CLOCK$ DEVICE 
 To allow a clock board to be integrated into the system for TIME and DATE, the CLOCK$ device is used. This device defines and performs functions like any other character device (most functions will be reset done bit, reset error bit, and return). When a read or write to this device occurs, 6 bytes are transferred. The first 2 bytes are a word, which is the count of days since 01-01-80. The third byte is minutes, the fourth is hours, the fifth is hundredths of a second, and the sixth is seconds. Reading the CLOCK$ device gets the date and time, writing to it sets the date and time. 
LOTUS-INTEL-MICROSOFT EXPANDED MEMORY SPECIFICATION 
THE EXPANDED MEMORY MANAGER 
History 
 The Lotus/Intel/Microsoft Expanded Memory Manager was originally a Lotus and Intel project and was announced as version 3.0 in the second quarter of 1985 primarily as a means of running larger Lotus worksheets by transparently paging unused sections to bank-switched memory. Shortly afterward Microsoft announced support of the standard and version 3.2 was subsequently released with support for Microsoft Windows. LIM 3.2 supported up to 8 megabytes of paged memory. The LIM 4.0 supports up to 32 megabytes of paged memory. 
Expanded Memory Specification 
This topic describes the Lotus/Intel/Microsoft formal specification that is used to access "Expanded" memory on a PC-compatible system. 
            See  EMM Functions  for a description INT 67H services. 
Definitions: 
   "Extended" memory is found ONLY on ATs (PCs based on the 286 CPU).  It is     memory that occupies physical address space above 1 Megabyte.  In DOS 3.2     Extended memory is used only for RAM disks.  See INT 15H SubFns 87H-89H. 
   "Expanded" memory uses an EMS-compatible memory board and software driver in     order to add "pages" of memory which can be swapped into and out of physical     address space above the normal 640K limit (above a000:0000).  EMS boards     create four pages of 16K (64K total) of addressable memory, with up to     8 Megabytes total memory available to be swapped in and out. 
The EMS is an industry standard, making it possible for programs such as Lotus 1-2-3 to access it to hold data for large spreadsheets.  It is also used for RAM disks and print spoolers.  Some RAM-resident software uses EMS memory to hold data and pages of code (thus using a minimum amount of the 640K address space). 
Ŀ  Determining if EMS is Installed   EMS memory is managed by an installable   device driver with a device name of "EMSXXXX0" and referred to as the EMM (EMS Manager).  To determine if the driver has been installed you can use DOS Fn 3dH to attempt to open the device as a file.  Once opened, you can use DOS Fn 44H (IOCTL) SubFn 07H to get the status. If the returned status (in AL) is 0, then the EMM is NOT Installed and a disk file by the name "EMSXXXX0" exists for some reason. 
When the EMM driver is installed, it sets the INT 67H vector to point to its device header.  Thus, another way to test for EMS is to fetch the address in the vector for INT 67H (0:091c) and examine offset 0aH from that address.  It should contain the characters "EMSXXXX0".   See  Device Header Layout 
Ŀ  EMM Services  To access the EMS memory manager, use INT 67H with a SubFn code  in the AH register, as described in  EMM Functions 
AST/QUADRAM/ASHTON-TATE ENHANCED EXPANDED MEMORY SPECIFICATION 
 The AQA EEMS maintains upward compatibility with the LIM, but is a superset of functions. 
 The AQA EEMS permits its pages to be scattered throughout the unused portion of the machine's address space. 
On August 19, 1987, the new version of the Expanded Memory Specification (EMS) was announced by Lotus, Intel and Microsoft. This new version of the specification includes many features of the Enhanced Expanded Memory Specification (EEMS) originally developed by AST Reserach, Quadram and Ashton- Tate, although the three original sponsoring companies elected not to make the new specification upward compatible with EEMS. AST Research says that they will endorse EMS 4.0 without reservation. 
 The definitive document for the LIM-EMS is Intel part number 300275-004, August, 1987. 
                                                       32M Ŀ                                                           /                                                                                                                                              /                                                                                                                                              /                                                                                                                                              /                                                                                            Expanded                                          /                        Memory               1024K Ŀ                                                           / / / / / /    /                                                  960K Ĵ                                                            Page Frame                                                                                                                                     12 16K-Byte                                                               Physical                                                                 Pages                                                          768K Ĵ                            Divided into                   / / / / / /   \                            logical                640K Ĵ                               pages                                       \                                                                                                                                                 \                                                                                                                             24 16K-Byte         \                                                     Physical                                                                 Pages*             \                                                                                                                                                 \                                                                                                                                                 \                                       256K Ĵ                                                                                       \                                           / / / / / /                                                                                           \                                         / / / / / /                                                                                             \                                       / / / / / /                                                                                               \                                  0                                                                                                  \                                                                                                                                                     \                                                                         0   The page frame is located above the 640k system RAM area, anywhere from 0A000h to 0FFFFh. This area is used by the video adapters, network cards, and add-on ROMs (as in hard disk controllers). The page frames are mapped around areas that are in use. 
WRITING PROGRAMS THAT USE EXPANDED MEMORY 
 In order to use expanded memory, applications must perform these steps in the following order: 
1. Determine if EMM is installed. 2. Determine if enough expanded memory pages exist for your application.    (Function 3) 3. Allocate expanded memory pages. (Function 4 or 18) 4. Get the page frame base address. (Function 2) 5. Map in expanded memory pages. (Function 5 or 17) 6. Read/write/execute data in expanded memory, just as if it were conventional    memory. 7. Return expanded memory pages to expanded memory pool before exiting. Function    6 or 18) Programming Guidelines 
 The following section contains guidelines for programmers writing applications that use EMM. 
A) Do not put a program's stack in expanded memory. 
B) Do not replace interrupt 67h. This is the interrupt vector the EMM uses.    Replacing interrupt 67h could result in disabling the Expanded Memory    Manager. 
C) Do not map into conventional memory address space your application doesn't    own. Applications that use the EMM to swap into conventional memory space,    must first allocate this space from the operating system. If the operating    system is not aware that a region of memory it manages is in use, it will    think it is available. This could have disastrous results. EMM should not be    used to "allocate" conventional memory. DOS is the proper manager of    conventional memory space. EMM should only be used to swap data in    conventional memory space previously allocated from DOS. 
D) Applications that plan on using data aliasing in expanded memory must check    for the presence of expanded memory hardware. Data aliasing occurs when    mapping one logical page into two or more mappable segments. This makes one    16K-byte expanded memory page appear to be in more than one 16K-byte memory    address space. Data aliasing is legal and sometimes useful for applications.     Software-only expanded memory emulators cannot perform data aliasing. A    simple way to distinguish software emulators from actual expanded memory    hardware is to attempt data aliasing and check the results. For example, map    one logical page into four physical pages. Write to physical page 0. Read    physical pages 1-3 to see if the data is there as well. If the data appears    in all four physical pages, then expanded memory hardware is installed in the    system, and data aliasing is supported. 
E) Applications should always return expanded memory pages to the expanded    memory manager upon termination. These pages will be made available for other    applications. If unneeded pages are not returned to the expanded memory    manager, the system could run out of expanded memory pages or expanded    memory handles. F) Terminate and stay resident programs (TSRs) should always save the state of    the map registers before changing them. Since TSRs may interrupt other    programs which may be using expanded memory, they must not change the state    of the page mapping registers without first saving them. Before exiting, TSRs    must restore the state of the map registers.     The following sections describe the three ways to save and restore the state    of the map registers.    1) Save Page Map and Restore Page Map (Functions 8 and 9). This is the       simplest of the three methods. The EMM saves the map register contents in       its own data structures -- the application does not need to provide extra       storage locations for the mapping context. The last mapping context to be       saved, under a particular handle, will be restored when a call to Restore       Page Map is issued with the same handle. This method is limited to one       mapping context for each handle and saves the context for only LIM       standard 64K-byte page frames.    2) Get/Set Page Map (Function 15). This method requires the application to       allocate space for the storage array. The EMM saves the mapping context in       an array whose address is passed to the EMM. When restoring the mapping       context with this method, an application passes the address of an array       which contains a previously stored mapping context. This method is       preferable if an application needs to do more than one save before a       restore. It provides a mechanism for switching between more than one       mapping context.    3) Get/Set Partial Page Map (Function 16). This method provides a way for       saving a partial mapping context. It should be used when the application       does not need to save the context of all mappable memory. This function       also requires that the storage array be part of the application's data. 
G) All functions using pointers to data structures must have those data    structures in memory which will not be mapped out. Functions 22 and 23    (Alter Map & Call and Alter Map & Jump) are the only exceptions. 
EMS 4.0 SPECIFICATIONS 
Page Frames 
 The bank switched memory chunks are referred to as "page frames". These frame consist of four 16K memory blocks mapped into some of the normally unused system ROM address area, 0C0000-0EFFFF. Each 16K page is independent of the other and they can map to discrete or overlapping areas of the 8 megabyte expanded memory address area. Most cards allow selection of addresses to prevent conflict with other cards, such as hard disk controllers and other expanded memory boards. 
Calling the Manager 
Applications programs communicate with the EMM device driver directly via user interrupt 67h. All communication between the application program and the driver bypasses DOS completely. To call the driver, register AH is loaded with the number of the EMM service requested; DX is loaded with the file handle; and interrupt 67h is called. ES:DI is used to pass the address of a buffer or array if needed. On return AH contains 0 if the call was successful or an error code from 80h to 8Fh if unsuccessful. 
TESTING FOR THE PRESENCE OF THE EXPANDED MEMORY MANAGER 
Before an application program can use the Expanded Memory Manager, it must determine whether the manager is present. The two recommended methods are the "open handle" technique and the "get interrupt vector" technique. 
The majority of application programs can use either the "open handle" or the "get interrupt vector" method. However, if your program is a device driver or if it interrupts DOS during file system operations, you must use only the "get interrupt vector" method. 
Device drivers execute from within DOS and can't access the DOS file functions; programs that interrupt DOS during file operations have a similar restriction. During their interrupt processing procedures, they can't access the DOS file functions because another program may be using the system. Since the "get interrupt vector" method doesn't require the DOS file functions, you must use it for programs of this type.  The "Open Handle" Method 
Most application programs can use the DOS "Open Handle" method to test for the presence of the EMM. To use this method, follow these steps in order: 
1) Issue an "open handle" command (DOS function 3Dh) in "read only" access mode    (register AL = 0). This function requires your program to point to an ASCII    string which contains the path name of the file or device in which you're    interested (register set DS:DX contains the pointer). In this case the file    is actually the reserved name of the expanded memory manager. 
   you should format the ASCII string as follows: 
   ASCII_device_name  DB  'EMMXXXX0', 0 
   The ASCII codes for the capital letters EMMXXXX0 are terminated by a byte    containing a value of zero. 
2) If DOS returns no error code, skip Steps 3 and 4 and go to Step 5. If DOS    returns a "Too many open files" error code, go to Step 3. If DOS returns a    "File/Path not found" error code, skip Step 3 and go to Step 4. 
3) If DOS returns a "Too many open files" (not enough handles) status code, your    program should invoke the "open file" command before it opens any other    files. This will guarantee that at least one file handle will be available to    perform the function without causing this error.    After the program performs the "open file" command, it should perform the    test described in Step 6 and close the "file handle" (DOS function 3Eh).    Don't keep the manager "open" after this status test is performed since    "manager" functions are not available through DOS. Go to Step 6. 
4) If DOS returns a "File/Path not found," the memory manager is not installed.    If your application requires the memory manager, the user will have to reboot    the system with a disk containing the memory manager and the appropriate    CONFIG.SYS file before proceeding. 
5) If DOS doesn't return an error status code you can assume that either a    device with the name EMMXXXX0 is resident in the system, or a file with this    name is on disk in the current disk drive. Go to Step 6. 
6) Issue an "I/O Control for Devices" command (DOS function 44h) with a "get    device information" command (register AL = 0). DOS function 44h determines    whether EMMXXXX0 is a device or a file.     You must use the file handle (register BX) which you obtained in Step 1 to    access the "EMM" device.    This function returns the "device information" in a word (register DX).    Go to Step 7. 
7. If DOS returns any error code, you should assume that the memory manager    device driver is not installed. If your application requires the memory    manager, the user will have to reboot the system with a disk containing the    memory manager and the appropriate CONFIG.SYS file before proceeding. 
8) If DOS didn't return an error status, test the contents of bit 7 (counting    from 0) of the "device information" word (register DX) the function    returned. Go to Step 9. 
9) If bit 7 of the "device information" word contains a zero, then EMMXXXX0 is    a file, and the memory manager device driver is not present. If your    application requires the memory manager, the user will have to reboot the    system with a disk containing the memory manager and the appropriate    CONFIG.SYS file before proceeding.     If bit 7 contains a one, then EMMXXXX0 is a device. Go to Step 10. 
10) Issue an "I/O Control for Devices" command (DOS function 44h) with a "get     output status" command (register AL = 7). You must use the file handle you     obtained in Step 1 to access the "EMM" device (register BX). Go to Step 11. 
11) If the expanded memory device driver is ready, the memory manager passes     a status value of 0FFh in register AL. The status value is 00h if the device     driver is not ready.     If the memory manager device driver is "not ready" and your application     requires its presence, the user will have to reboot the system with a disk     containing the memory manager and the appropriate CONFIG.SYS file before     proceeding.      If the memory manager device driver is "ready," go to Step 12. 
12) Issue a "Close File Handle" command (DOS function 3Eh) to close the expanded     memory device driver. You must use the file handle you obtained in Step 1 to     close the "EMM" device (register BX). 
 The "Get Interrupt Vector" technique 
 Any type of program can use this method to test for the presence of the EMM. 
 Use this method (not the "Open Handle" method) if your program is a device driver or if it interrupts DOS during file system operations. 
 Follow these steps in order: 
1) Issue a "get vector" command (DOS function 35h) to obtain the contents of    interrupt vector array entry number 67h (addresses 0000:019Ch thru    0000:019Fh).    The memory manager uses this interrupt vector to perform all manager    functions. The offset portion of this interrupt service routine address is    stored in the word located at address 0000:019Ch; the segment portion is    stored in the word located at address 0000:019Eh. 2) Compare the "device name field" with the contents of the ASCII string which    starts at the address specified by the segment portion of the contents of    interrupt vector address 67h and a fixed offset of 000Ah. If DOS loaded the    memory manager at boot time this name field will have the name of the device    in it.    Since the memory manager is implemented as a character device driver, its    program origin is 0000h. Device drivers are required to have a "device    header" located at the program origin. Within the "device header" is an 8    byte "device name field." For a character mode device driver this name field    is always located at offset 000Ah within the device header. The device name    field contains the name of the device which DOS uses when it references the    device.     If the result of the "string compare" in this technique is positive, the    memory manager is present. 
 Terminate and Stay Resident (TSR) Program Cooperation:  In order for TSR's to cooperate with each other and with other applications, TSRs must follow this rule: a program may only remap the DOS partition it lives in. This rule applies at all times, even when no expanded memory is present. 
EXPANDED MEMORY SERVICES 
FUNCTIONS DEFINED IN EMS 3.2 SPECIFICATION 
Interrupt 67h 
Function 40h Get Manager Status 
LIM Function Call 1              Returns a status code indicating whether the memory manager is              present and the hardware is working correctly. entry   AH      40h return  AH      error status: 00h, 80h, 81h, 84h note 1) upward and downward compatible with both EMS and EEMS 3.2.         this call can be used only after establishing that the EMS driver is in         fact present      2) uses register AX 
Function 41h Get Page Frame Segment 
LIM Function Call 2              Obtain segment address of the page frame used by the EMM. entry   AH      41h return  AH      error status: 00h, 80h, 81h, 84h         BX      page frame segment address (error code 0) note 1) upward and downward compatible with both EMS and EEMS 3.2.      2) uses registers AX & BX 
Function 42h Get Unallocated Page Count 
LIM Function Call 3              Obtain total number of logical expanded memory pages present in              the system and the number of those pages not already allocated. entry   AH      42h return  AH      error status: 00h, 80h, 81h, 84h         BX      number of unallocated pages currently availible         DX      total number of pages note 1) upward and downward compatible with both EMS and EEMS 3.2. Note that EMS         and EEMS 3.2 had no mechanism to return the maximum number of handles         that can be allocated by programs. This is handled by the EMS 4.0 new         function 54h/02h.      2) uses registers AX, BX, DX 
Function 43h Get Handle and Allocate Memory 
LIM Function Call 4              Notifies the EMM that a program will be using extended memory,              obtains a handle, and allocates a certain number of logical pages              of extended memory to be controlled by that handle entry   AH      43h         BX      number of 16k logical pages requested (zero OK) return  AH      error status: 00h, 80h, 81h, 84h, 85h, 87h, 88h, 89h         DX      unique EMM handle (see note 2) note 1) upward compatible with both EMS and EEMS 3.2; EMS and EEMS 3.2 do not         allow the allocation of zero pages (returns error status 89h). EMS 4.0         does allow zero pages to be requested for a handle, allocating pages         later using function 51h      2) your program must use this EMM handle as a parameter in any function         that requires it. You can use up to 255 handles. The uppermost byte of         the handle will be zero and cannot be used by the application.      3) regs AX & DX are used 
Function 44h Map Memory 
LIM Function Call 5              Maps one of the logical pages of expanded memory assigned to a              handle onto one of the four physical pages within the EMM's page              frame. entry   AH      44h         AL      physical page to be mapped (0-3)         BX      the logical page to be mapped (zero through [number of pages                 allocated to the EMM handle - 1]). If the logical page number                 is 0FFFFh, the physical page specified in AL will be unmapped                 (made inaccessible for reading or writing).         DX      the EMM handle your program received from Function 4 (Allocate                 Pages). return  AH      error status: 00h, 80h, 81h, 83h, 84h, 8Ah, 8Bh note 1) downward compatible with both EMS and EEMS 3.2; EMS and EEMS 3.2 do not         support unmap (logical page 0FFFFh) capability. Also, EEMS 3.2         specified there were precisely four physical pages; EMS 4.0 uses the         subfunctions of function 58h to return the permitted number of physical         pages. This incorporates the functionality of function 69h ("function         42") of EEMS.      2) uses register AX 
Function 45h Release Handle and Memory 
LIM Function Call 6              Deallocates the logical pages of expanded memory currently              assigned to a handle and then releases the handle itself. entry   AH      45h         DX      handle return  AH      error status: 00h, 80h, 81h, 83h, 84h, 86h note 1) upward and downward compatible with both EMS and EEMS 3.2.      2) uses register AX      3) when a handle is deallocated, its name is set to all ASCII nulls         (binary zeros).      4) a program must perform this function before it exits to DOS or no other         programs can use these pages or the EMM handle. 
Function 46h Get EMM Version 
LIM Function Call 7              Returns the version number of the Expanded Memory Manager software. entry   AH      46h return  AH      error status: 00h, 80h, 81h, 84h         AL      version number byte (if AL=00h)                 binary coded decimal (BCD) format if version byte:                 high nibble: integer digit of the version number                 low nibble : fractional digit of version number                 i.e., version 4.0 is represented like this:                           0100 0000                             /   \                            4  .  0 note 1) upward and downward compatible with both EMS and EEMS 3.2. It appears         that the intended use for this function is to return the version of the         vendor implementation of the expanded memory manager instead of the         specification version.      2) uses register AX 
Function 47h Save Mapping Context 
LIM Function Call 8              Save the contents of the expanded memory page-mapping registers on              the expanded memory boards, associating those contents with a              specific EMM handle. entry   AH      47h         DX      caller's EMM handle (NOT current EMM handle) return  AH      error status:  00h, 80h, 81h, 83h, 84h, 8Ch, 8Dh note 1) upward and downward compatible with both EMS and EEMS 3.2.      2) This only saves the context saved in EMS 3.2 specification; if a driver,         interrupt routine or TSR needs to do more, functions 4Eh (Page Map         functions) or 4Fh (Partial Page Map functions) should be used.      3) no mention is made about the number of save contexts to provide. AST         recommends in their Rampage AT manual one save context for each handle         plus one per possible interrupt (5 + <handles>).      4) uses register AX      5) this function saves the state of the map registers for only the 64K page         frame defined in versions 3.x of the LIM. Since all applications written         to LIM versions 3.x require saving the map register state of only this         64K page frame, saving the entire mapping state for a large number of         mappable pages would be inefficient use of memory. Applications that use         a mappable memory region outside the LIM 3.x page frame should use         functions 15 or 16 to save and restore the state of the map registers. 
Function 48h Restore Page Map 
LIM Function Call 9              Restores the contents of all expanded memory hardwere page-mapping              registers to the values associated with the given handle by a              previous function 08h (Save Mapping Context). entry   AH      48h         DX      caller's EMM handle (NOT current EMM handle) return  AH      error status: 00h, 80h, 81h, 83h, 84h, 8Eh note 1) upward and downward compatible with both EMS and EEMS 3.2.      2) This only restores the context saved in EMS 3.2 specification; if a         driver, interrupt routine or TSR needs to do more, functions 4Eh (Page         Map functions) or 4Fh (Partial Page Map functions) should be used.      3) uses register AX      4) this function saves the state of the map registers for only the 64K page         frame defined in versions 3.x of the LIM. Since all applications written         to LIM versions 3.x require saving the map register state of only this         64K page frame, saving the entire mapping state for a large number of         mappable pages would be inefficient use of memory. Applications that use         a mappable memory region outside the LIM 3.x page frame should use         functions 15 or 16 to save and restore the state of the map registers. 
Function 49h Reserved 
LIM Function Call 10              This function was used in EMS 3.0, but was no longer documented in              EMS 3.2. It formerly returned the page mapping register I/O port              array. Use of this function is discouraged, and in EMS 4.0 may              conflict with the use of the new functions 16 through 30 (4Fh              through 5Dh) and functions 10 and 11. Functions 10 and 11 are              specific to the hardware on Intel expanded memory boards and may              not work correctly on all vendors' expanded memory boards. 
Function 4Ah Reserved 
LIM Function Call 11              This function was used in EMS 3.0, but was no longer documented in              EMS 3.2. It was formerly Get Page Translation Array. Use of this              function is discouraged, and in EMS 4.0 may conflict with the use              of the new functions (4Fh through 5Dh). 
Function 4Bh Get Number of EMM Handles 
LIM Function Call 12              The Get Handle Count function returns the number of open EMM              handles (including the operating system handle 0) in the system. entry   AH      4Bh return  AH      error status: 00h, 80h, 81h, 84h         BX      handle count (AH=00h) (including the operating system handle                 [0]). max 255. note 1) upward and downward compatible with EMS and EEMS 3.2.      2) uses registers AX and BX 
Function 4Ch Get Pages Owned by Handle 
LIM Function Call 13              Returns number of logical expanded memory pages allocated to a              specific EMM handle. entry   AH      4Ch         DX      handle return  AH      error status: 00h, 80h, 81h, 83h, 84h         BX      pages allocated to handle, max 2048 because the EMM allows a                 maximum of 2048 pages (32M bytes) of expanded memory. note 1) This function is upward compatible with EMS and EEMS 3.2.      2) programmers should compare the number returned in BX with the maximum         number of pages returned by function 42h register DX, total number of         EMM pages. This should be an UNSIGNED comparison, just in case the spec         writers decide to use 16 bit unsigned numbers (for a maximum space of         one gigabyte) instead of signed numbers (for a maximum space of 512         megabytes). Unsigned comparisons will work properly in either case      3) uses registers AX and BX 
Function 4Dh Get Pages for All Handles 
LIM Function Call 14              Returns an array containing all active handles and the number of              logical expanded memory pages associated with each handle. entry   AH      4Dh         ES:DI   pointer to 1020 byte array to receive information on an array of                 structures where a copy of all open EMM handles and the number                 of pages allocated to each will be stored. return  AH      error status: 00h, 80h, 81h, 84h         BX      number of active handles (1-255); array filled with 2-word                 entries, consisting of a handle and the number of pages                 allocated to that handle. (including the operating system handle                 [0]). BX cannot be zero because the operating system handle is                 always active and cannot be deallocated. note 1) NOT COMPATIBLE with EMS or EEMS 3.2, since the new special OS handle         0000h is returned as part of the array. Unless benign use of this         information is used (such as displaying the handle and count of pages         associated with the handle) code should be changed to only work with         handles between 01h and FFh and to specifically ignore handle 00h.      2) The array consists of an array of 255 elements. The first word of each         element is the handle number, the second word contains the number of         pages allocated.      3) There are two types of handles, "standard" and "raw". The specification         does not talk about how this function works when both raw and standard         handles exist in a given system. There is no currently known way to         differentiate between a standard handle and a raw handle in EMS 4.0.      4) uses registers AX and BX 
Function 4Eh Get or Set Page Map 
LIM Function Call 15              Gets or sets the contents of the EMS page-mapping registers on the              expanded memory boards.              This group of four subfunctions is provided for context switching              required by operating environments and systems. These functions are              upward and downward compatible with both EMS and EEMS 3.2; in              addition, these functions now include the functionality of EEMS              function 6Ah ("function 43") involving all pages.              The size and contents of the map register array will vary from              system to system based on hardware vendor, software vendor, number              of boards and the capacity of each board in the system. Note the              array size can be determined by function 4Eh/03h.              Use these functions (except for 03h) instead of Functions 8 and 9              if you need to save or restore the mapping context but don't want              (or have) to use a handle. 
        00h  Get Page Map              This call saves the mapping context for all mappable memory regions              (conventional and expanded) by copying the contents of the mapping              registers from each expanded memory board to a destination array.              The application must pass a pointer to the destination array. entry   AH      4Eh         AL      00h         ES:DI   pointer to target array return  AH      error status: 00h, 80h, 81h, 84h, 8Fh note 1) uses register AX      2) does not use an EMM handle 
         01h  Set Page Map              This call the mapping context for all mappable memory regions              (conventional and expanded) by copying the contents of a source              array into the mapping registers on each expanded memory board in              the system. The application must pass a pointer to the source array. entry   AH      4Eh         AL      01h         DS:SI   pointer to source array return  AH      error status: 00h, 80h, 81h, 84h, 8Fh, 0A3h note 1) uses register AX      2) does not use an EMM handle 
        02h  Get & Set Page Map              This call simultaneously saves the current mapping context and              restores a previous mapping context for all mappable memory regions              (both conventional and expanded). It first copies the contents of              the mapping registers from each expanded memory board in the system              into a destination array. Then the subfunction copies the contents              of a source array into the mapping registers on each of the              expanded memory boards. entry   AH      4Eh         AL      02h         DS:SI   pointer to source array         ES:DI   pointer to target array return  AH      error status: 00h, 80h, 81h, 84h, 8Fh, 0A3h note 1) uses register AX 
          03h  Get Size of Page Map Save Array entry   AH      4Eh         AL      03h return  AH      error status:  00h, 80h, 81h, 84h, 8Fh         AL      size in bytes of array note 1) this subfunction does not require an EMM handle      2) uses register AX 
FUNCTIONS NEW TO EMS 4.0 
Function 4Eh Get or Set Page Map 
LIM Function Call 16 entry   AH      4Eh         AL      00h     if getting mapping registers                 01h     if setting mapping registers                 02h     if getting and setting mapping registers at once                 03h     if getting size of page-mapping array         DS:SI   pointer to array holding information (AL=01/02)         ES:DI   pointer to array to receive information (AL=00/02) return  AH      error status: 00h, 80h, 81h, 84h, 8Fh, 0A3h note 1) this function was designed to be used by multitasking operating systems         and should not ordinarily be used by appplication software. 
Function 4Fh Get/Set Partial Page Map 
LIM Function Call 16              These four subfunctions are provided for context switching required              by interrupt routines, operating environments and systems. This set              of functions provides extended functionality over the EEMS function              6Ah (function 43) involving subsets of pages. In EEMS, a subset of              pages could be specified by starting position and number of pages;              in this function a list of pages is specified, which need not be              contiguous.               Interrupt routines can use this function in place of functions 47h              and 48h, especially if the interrupt routine wants to use more than              the standard four physical pages.         AH      4Fh         AL      subfunction                 00h     get partial page map                         DS:SI   pointer to structure containing list of                                 segments whose mapping contexts are to be saved                         ES:DI   pointer to array to receive page map                 01h     set partial page map                         DS:SI   pointer to structure containing saved partial                                 page map                 02h     get size of partial page map                         BX      number of mappable segments in the partial map                                 to be saved return  AH      error status (00h): 00h, 80h, 81h, 84h, 8Bh, 8Fh, 0A3h                 error status (01h): 00h, 80h, 81h, 84h, 8Fh, 0A3h                 error status (02h): 00h, 80h, 81h, 84h, 8Bh, 8Fh         AL      size of partial page map for subfunction 02h         DS:SI   (call 00h) pointer to array containing the partial mapping                 context and any additional information necessary to restore this                 context to its original state when the program invokes a Set                 subfunction. note    uses register AX 
Function 50h Map/Unmap Multiple Pages 
LIM Function Call 17 entry   AH      50h         AL      00h     (by physical page)                 01h     (by segment number)         CX      contains the number of entries in the array. For example, if the                 array contained four pages to map or unmap, then CX would                 contain 4.         DX      handle         DS:SI   pointer to an array of structures that contains the information                 necessary to map the desired pages. return  AH      error status: 00h, 80h, 81h, 83h, 84h, 8Ah, 8Bh, 8Fh note 1) New function permits multiple logical-to-physical assignments to be made         in a single call.(faster than mapping individual pages)      2) The source map array is an array of word pairs. The first word of a         pair contains the logical page to map (0FFFFh if the physical page is         to be totally unmapped) and the second word of a pair contains the         physical page number (subfunction 00h) or the segment selector         (subfunction 01h) of the physical page in which the logical page shall         be mapped.      3) A map of available physical pages (by physical page number and segment         selectors) can be obtained using function 58h/00h, Get Mappable         Physical Address Array.      4) uses register AX      5) Both mapping and unmapping pages can be done simultaneously.      6) If a request to map or unmap zero pages is made, nothing is done and no         error is returned.      7) Pages can be mapped or unmapped using one of two methods. Both methods         produce identical results.          A) A logical page and a physical page at which the logical page is to             be mapped. This method is an extension of Function 5 (Map Handle             Page).          B) Specifys both a logical page and a corresponding segment address at             which the logical page is to be mapped. While functionally the same             as the first method, it may be easier to use the actual segment             address of a physical page than to use a number which only             represents its location. The memory manager verifies whether the             specified segment address falls on the boundary of a mappable             physical page. The manager then translates the segment address             passed to it into the necessary internal representation to map the             pages. 
Function 51h Reallocate pages 
LIM Function Call 18              This function allows an application to change the number of logical              pages allocated to an EMM handle. entry   AH      51h         BX      number of pages desired at return         DX      handle return  AH      error status: 00h, 80h, 81h, 83h, 84h, 87h, 88h         BX      number of pages now associated with handle note 1) uses registers AX, BX      2) Logical pages which were originally allocated with Function 4 are called         pages and are 16K bytes long. Logical pages which were allocated with         Function 27 are called raw pages and might not be the same size as pages         allocated with Function 4.      3) If the status returned in BX is not zero, the value in BX is equal to         the number of pages allocated to the handle prior to calling this         function. This information can be used to verify that the request         generated the expected results. 
Function 52h Get/Set Handle Attributes 
LIM Function Call 19 entry   AH      52h         AL      subfunction                 00h     get handle attributes                 01h     set handle attributes                         BL      new attribute                                 00h     make handle volatile                                 01h     make handle non-volatile                 02h     get attribute capability         DX      handle return  AH      error status: (function 00h) 00h, 80h, 81h, 83h, 84h, 8Fh, 91h                 error status: (function 01h) 00h, 80h, 81h, 83h, 84h, 8Fh, 90h,                                              91h                 error status: (function 02h) 00h, 80h, 81h, 84h, 8Fh         AL      attribute (for subfunction 00h)                 00h     handle is volatile                 01h     handle is nonvolatile         AL      attribute capability (for subfunction 02h)                 00h     only volatile handles supported                 01h     both volatile and non-volatile supported note 1) uses register AX      2) A volatile handle attribute instructs the memory manager to deallocate         both the handle and the pages allocated to it after a warm boot. If all         handles have the volatile attribute (default) at warm boot the handle         directory will be empty and all expanded memory will be initialized to         zero immediately after a warm boot.      3) If the handle's attribute has been set to non-volatile, the handle, its         name (if it is assigned one), and the contents of the pages allocated to         the handle are all maintained after a warm boot.      4) Most PCs disable RAM refresh signals for a considerable period during a         warm boot. This can corrupt some of the data in memory boards. Non-         volatile handles should not be used unless it is definitely known that         the EMS board will retain proper function through a warm boot.      5) subfunction 02h can be used to determine whether the memory manager can         support the non-volatile attribute.      6) Currently the only attribute supported is non-volatile handles and         pages, indicated by the least significant bit. 
Function 53h Handle Name Functions 
LIM Function Call 20              EMS handles may be named. Each name may be any eight characters.              At installation, all handles have their name initialized to ASCII              nulls (binary zeros). There is no restriction on the characters              which may be used in the handle name (ASCII chars 00h through              0FFh). A name of eight nulls (zeroes) is special, and indicates a              handle has no name. Nulls have no special significance, and they              can appear in the middle of a name. The handle name is 64 bits of              binary information to the EMM.               Functions 53h and 54h provide a way of setting and reading the              names associated with a particular handle. Function 53h manipulates              names by number.               When a handle is assigned a name, at least one character in the              name must be a non-null character in order to distinguish it from              a handle without a name. 
        00h  Get Handle Name              This subfunction gets the eight character name currently              assigned to a handle.               The handle name is initialized to ASCII nulls (binary zeros)              three times:  when the memory manager is installed, when a handle              is allocated, and when a handle is deallocated. entry   AH      53h         AL      00h         DX      handle         ES:DI   pointer to 8-byte handle name array into which the name                 currently assigned to the handle will be copied. return  AH      error status: 00h, 80h, 81h, 83h, 84h, 8Fh note    uses register AX 
        01h  Set Handle Name              This subfunction assigns an eight character name to a handle.              A handle can be renamed at any time by setting the handle's              name to a new value. When a handle is deallocated, its name is              removed (set to ASCII nulls). entry   AH      53h         AL      01h         DX      handle         DS:SI   pointer to 8-byte handle name array that is to be assigned to                 the handle. The handle name must be padded with nulls if the                 name is less than eight characters long. return  AH      error status: 00h, 80h, 81h, 83h, 84h, 8Fh, 0A1h note    uses register AX 
Function 54h Handle Directory Functions 
LIM Function Call 21              Function 54h manipulates handles by name. 
        00h  Get Handle Directory              Returns an array which contains all active handles and the names              associated with each. entry   AH      54h         AL      00h         ES:DI   pointer to 2550 byte target array return  AH      error status: 00h, 80h, 81h, 84h, 8Fh         AL      number of active handles note 1) The name array consists of 10 byte entries; each entry has a word         containing the handle number, followed by the eight byte (64 bit) name.      2) uses register AX      3) The number of bytes required by the target array is:                 10 bytes * total number of handles      4) The maximum size of this array is:                 (10 bytes/entry) * 255 entries = 2550 bytes. 
        01h  Search for Named Handle              Searches the handle name directory for a handle with a particular              name. If the named handle is found, this subfunction returns the              handle number associated with the name. entry   AH      54h         AL      01h         DS:SI   pointer to an 8-byte string that contains the name of the                 handle being searched for return  AH      error status: 00h, 80h, 81h, 84h, 8Fh, A0h, 0A1h         DX      handle number note 1) uses registers AX and DX 
        02h  Get Total Handles              Returns the total number of handles the EMM supports, including              the operating system handle (handle value 0). entry   AH      54h         AL      02h return  AH      error status: 00h, 80h, 81h, 84h, 8Fh         BX      total number of handles availible note 1) This is NOT the current number of handles defined, but the maximum         number of handles that can be supported in the current environment.      2) uses registers AX and BX 
Function 55h Alter Page Map and Jump (cross page branch) 
LIM Function Call 22              Alters the memory mapping context and transfers control to the              specified address. Analogous to the FAR JUMP in the 8086 family              architecture. The memory mapping context which existed before              calling function is lost. entry   AH      55h         AL      00h     physical page numbers provided by caller                 01h     segment addresses provided by caller         DX      handle         DS:SI   pointer to structure containing map and jump address return  AH      error status: 00h, 80h, 81h, 83h, 84h, 8Ah, 8Bh, 8Fh note 1) Flags and all registers except AX are preserved across the jump.      2) uses register AX      3) Values in registers which don't contain required parameters maintain the         values across the jump. The values in registers (with the exception of         AX) and the flag state at the beginning of the function are still in the         registers and flags when the target address is reached.      4) Mapping no pages and jumping is not considered an error. If a request to         map zero pages and jump is made, control is transferred to the target         address, and this function performs a far jump. 
Function 56h Alter Page Map and Call (cross page call) 
LIM Function Call 23         00h and 01h                This subfunction saves the current memory mapping context,                alters the specified memory mapping context, and transfers                control to the specified address. entry   AH      56h         AL      00h physical page numbers provided by caller                 01h segment addresses provided by caller         DS:SI   pointer to structure containing page map and call address         DX      handle return  AH      error status: 00h, 80h, 81h, 83h, 84h, 8Ah, 8Bh, 8Fh note 1) Flags and all registers except AX are preserved to the called routine.         On return, flags and all registers except AX are preserved; AL is set to         zero and AX is undefined.      2) uses register AX      3) Values in registers which don't contain required parameters maintain         the values across the call. The values in registers (with the exception         of AX) and the flag state at the beginning of the function are still in         the registers and flags when the target address is reached.      4) Developers using this subfunction must make allowances for the         additional stack space this subfunction will use. 
        02h  Get Page Map Stack Space Size              Since the Alter Page Map & Call function pushes additional              information onto the stack, this subfunction returns the number of              bytes of stack space the function requires. entry   AH      56h         AL      02h return: BX      number of bytes of stack used per call         AH      error status: 00h, 80h, 81h, 84h, 8Fh note 1) if successful, the target address is called. Use a RETF to return and         restore mapping context      2) uses registers AX, BX 
Function 57h Move/Exchange Memory Region 
LIM Function Call 24         00h  Move Memory Region              Moves data between two memory areas. Includes moves between paged              and non-paged areas, or between two different paged areas. entry   AH      57h         AL      00h         SI      offset to request block         DS      segment selector to request block return  AH      error status: 00h, 80h, 81h, 83h, 84h, 8Ah, 8Fh, 92h, 93h, 94h,                 95h, 96h, 98h, 0A2h note 1) uses register AX 
        01h  Exchange Memory Region              Exchanges data between two memory areas. Includes exchanges between              paged and non-paged areas, or between two different paged areas. entry   AH      57h         AL      01h         DS:SI   pointer to the data structure which contains the source and                 destination information for the exchange. return  AH      error status: 00h, 80h, 81h, 83h, 84h, 8Ah, 8Fh, 93h, 94h, 95h,                 96h, 97h, 98h, 0A2h note 1) The request block is a structure with the following format:         dword   region length in bytes         byte    0=source in conventional memory                 1=source in expanded memory         word    source handle         word    source offset in page or selector         word    source logical page (expanded) or selector (conventional)         byte    0=target in conventional memory                 1=target in expanded memory         word    target handle         word    target offset in page or selector         word    target logical page (expanded) or selector (conventional)      2) Expanded memory allocated to a handle is considered to be a linear         array, starting from logical page 0 and progressing through logical page         1, 2, ... n, n+1, ... up to the last logical page in the handle.      3) uses register AX 
Function 58h Mappable Physical Address Array 
LIM Function Call 25              These functions let you obtain a complete map of the way physical              memory is laid out in a vendor independent manner. This is a              functional equivalent of EEMS function 68h ("function 41"). EEMS              function 60h ("function 33") is a subset call of 68h. 
        00h  Get Array              Returns an array containing the segment address and physical page              number for each mappable physical page in a system. This array              provides a cross reference between physical page numbers and the              actual segment addresses for each mappable page in the system. entry   AH      58h         AL      00h         ES:DI   pointer to target array return  AH      error status: 00h, 80h, 81h, 84h, 8Fh         CX      entries in target array note 1) The information returned is in an array composed of word pairs. The         first word is the physical page's segment selector, the second word the         physical page number. Note that values are not necessarily returned in a         particular order, either ascending/decending segment selector values or         as ascending/decending physical page number.      2) For compatibility with earlier EMS specifications, physical page zero         contains the segment selector value returned by function 41h, and         physical pages 1, 2 and 3 return segment selector values that corrospond         to the physical 16 KB blocks immediately following physical page zero.      3) uses registers AX and CX      4) The array is sorted in ascending segment order. This does not mean that         the physical page numbers associated with the segment addresses are         also in ascending order. 
        01h   Get Physical Page Address Array Entries.               Returns a word which represents the number of entries in the               array returned by the previous subfunction. This number also               indicates the number of mappable physical pages in a system. entry   AH      58h         AL      01h return  AH      error status: 00h, 80h, 81h, 84h, 8Fh         CX      number of entries returned by 58h/00h note 1) multiply CX by 4 for the byte count.      2) uses registers AX and CX 
Function 59h Get Expanded Memory Hardware Information 
LIM Function Call 26              These functions return information specific to a given hardware              implementation and to use of raw pages as opposed to standard              pages. The intent is that only operating system code ever need use              these functions.         00h  Get EMS Hardware Info              Returns an array containing expanded memory hardware configuration              information for use by an operating system. entry   AH      59h         AL      00h         ES:DI   pointer to 10 byte target array                 The target array has the following format:                 word: raw page size in paragraphs (multiples of 16 bytes)                 word: number of alternate register sets                 word: size of page maps (function 4Eh [15])                 word: number of alternate registers sets for DMA                 word: DMA operation -- see full specification return  AH      error status: 00h, 80h, 81h, 84h, 8Fh, 0A4h note 1) uses register AX      2) This function is for use by operating systems only.      3) This function can be disabled at any time by the operating system. 
        01h  Get Unallocated Raw Page Count              Returns the number of unallocated non-standard length mappable              pages as well as the total number of non-standard length mappable              pages of expanded memory entry   AH      59h         AL      01h return  AH      error status: 00h, 80h, 81h, 84h, 8Fh         BX      unallocated raw pages availible for use         DX      total raw 16k pages of expanded memory note 1) uses registers AX, BX, CX      2) An expanded memory page which is a sub-multiple of 16K is termed a raw         page. An operating system may deal with mappable physical page sizes         which are sub-multiples of 16K bytes.      3) If the expanded memory board supplies pages in exact multiples of 16K         bytes, the number of pages this function returns is identical to the         number Function 3 (Get Unallocated Page Count) returns. In this case,         there is no difference between a page and a raw page. 
Function 5Ah Allocate Raw Pages 
LIM Function Call 27              Allocates the number of nonstandard size pages that the operating              system requests and assigns a unique EMM handle to these pages. entry   AH      5Ah         AL      00h     allocate standard pages                 01h     allocate raw pages         BX      number of pages to allocate return  AH      error status: 00h, 80h, 81h, 84h, 85h, 87h, 88h         DX      unique raw EMM handle (1-255) note 1) it is intended this call be used only by operating systems      2) uses registers AX and DX      3) For all functions using the raw handle returned in DX, the length of         the physical and logical pages allocated to it are some nonstandard         length (that is, not 16K bytes).      4) this call is primarily for use by operating systems or EMM drivers         supporting hardware with a nonstandard EMS page size. 
Function 5Bh Alternate Map Register Set - DMA Registers 
LIM Function Call 28 entry   AH      00h     Get Alternate Map Register Set                 01h     Set Alternate Map Register Set                         BL      new alternate map register set number                         ES:DI   pointer to map register context save area if                                 BL=0                 02h     Get Alternate Map Save Array Size                 03h     Allocate Alternate Map Register Set                 04h     Deallocate Alternate Map Register Set                         BL      number of alternate map register set                 05h     Allocate DMA Register Set                 06h     Enable DMA on Alternate Map Register Set                         BL      DMA register set number                         DL      DMA channel number                 07h     Disable DMA on Alternate Map Register Set                         BL      DMA register set number                 08h     Deallocate DMA Register Set                         BL      DMA register set number return  AH      status: 00h, 02h   00h, 80h, 84h, 81h, 8Fh, 0A4h                         01h        00h, 80h, 81h, 84h, 8Fh, 9Ah, 9Ch, 9Dh,                                    0A3h, 0A4h                         03h, 05h   00h  80h  81h  84h, 8Fh, 9Bh, 0A4h                         04h        00h, 80h, 81h, 84h, 8Fh, 9Ch, 9Dh, 0A4h                         06h, 07h   00h, 80h, 81h, 84h, 8Fh, 9Ah, 9Ch, 9Dh, 9Eh,                                    9Fh, 0A4h         BL      current active alternate map register set number if nonzero                 (AL=0)         BL      number of alternate map register set; zero if not supported                 (AL=3)         DX      array size in bytes (subfunction 02h)         ES:DI   pointer to a map register context save area if BL=0 (AL=0) note 1) this call is for use by operating systems only, and can be enabled         or disabled at any time by the operating system      2) This set of functions performs the same functions at EEMS function 6Ah         subfunctions 04h and 05h ("function 43").      3) 00h uses registers AX, BX, ES:DI         01h uses register AX         02h uses registers AX and DX         03h uses registers AX and BX         04h uses register AX         05h uses registers AX, BX         06h uses register AX         07h uses register AX 
Function 5Ch Prepare EMS Hardware for Warm Boot 
LIM Function Call 29              Prepares the EMM hardware for a warm boot. entry   AH      5Ch return  AH      error status: 00h, 80h, 81h, 84h note 1) uses register AX      2) this function assumes that the next operation that the operating system         performs is a warm boot of the system.      3) in general, this function will affect the current mapping context, the         alternate register set in use, and any other expanded memory hardware         dependencies which need to be initialized at boot time.      4) if an application decides to map memory below 640K, the application must         trap all possible conditions leading to a warm boot and invoke this         function before performing the warm boot itself. 
Function 5Dh Enable/Disable OS Function Set Functions 
LIM Function Call 30              Lets the OS allow other programs or device drivers to use the OS              specific functions. This capability is provided only for an OS              which manages regions of mappable conventional memory and cannot              permit programs to use any of the functions which affect that              memory, but must be able to use these functions itself. entry   AH      5Dh         AL      00h     enable OS function set                 01h     disable OS function set                 02h     return access key (resets memory manager, returns access                         key at next invocation)         BX,CX   access key returned by first invocation return  BX,CX   access key, returned only on first invocation of function         AH      status  00h, 80h, 81h, 84h, 8Fh, 0A4h note 1) this function is for use by operating systems only. The operating system         can disable this function at any time.      2) 00h uses registers AX, BX, CX         01h uses registers AX, BX, CX         02h uses register AX      3) 00h, 01h: The OS/E (Operating System/Environment) functions these         subfunctions affect are:         Function 26. Get Expanded Memory Hardware Information.         Function 28. Alternate Map Register Sets.         Function 30. Enable/Disable Operating System Functions. 
Function 5Eh Unknown 
LIM Function call (not defined under LIM) 
Function 5Fh Unknown 
LIM Function call (not defined under LIM) 
Function 60h EEMS - Get Physical Window Array 
LIM Function call (not defined under LIM) entry   AH      60h         ES:DI   pointer to buffer return  AH      status         AL      number of entries         buffer at ES:DI filled 
Function 61h Generic Accelerator Card Support 
LIM Function Call 34              Contact AST Research for a copy of the Generic Accelerator Card              Driver (GACD) Specification note    Can be used by accelerator card manufacturer to flush RAM cache,         ensuring that the cache accurately reflects what the processor would         see without the cache. 
Function 68h EEMS - Get Addresses of All Page Frames in System 
LIM Function Call (not defined under LIM) entry   AH      68h         ES:DI   pointer to buffer return  AH      status         AL      number of entries         buffer at ES:DI filled note    Equivalent to LIM 4.0 function 58h 
Function 69h EEMS - Map Page Into Frame 
LIM Function Call (not defined under LIM) entry   AH      69h         AL      frame number         BX      page number         DX      handle return  AH      status note    Similar to EMS function 44h 
Function 6Ah EEMS - Page Mapping 
LIM Function Call (not defined under LIM) entry   AH      6Ah         AL      00h save partial page map                         CH      first page frame                         CL      number of frames                         ES:DI   pointer to buffer which is to be filled                 01h restore partial page map                         CH      first page frame                         CL      number of frames                         DI:SI   pointer to previously saved page map                 02h save and restore partial page map                         CH      first page frame                         CL      number of frames                         ES:DI   buffer for current page map                         DI:SI   new page map                 03h get size of save array                         CH      first page frame                         CL      number of frames                 return  AL      size of array in bytes                 04h switch to standard map register setting                 05h switch to alternate map register setting                 06h deallocate pages mapped to frames in conventional memory                         CH      first page frame                         CL      number of frames return  AH      status note    Similar to LIM function 4Eh, except that a subrange of pages can         be specified 
EXPANDED MEMORY MANAGER ERROR CODES 
 EMM error codes are returned in AH after a call to the EMM (int 67h). 
code    meaning 
00h     function successful 80h     internal error in EMM software (possibly corrupted driver) 81h     hardware malfunction 82h     EMM busy (dropped in EEMS 3.2) 83h     invalid EMM handle 84h     function requested not defined - unknown function code in AH. 85h     no more EMM handles availible 86h     error in save or restore of mapping context 87h     more pages requested than exist 88h     allocation request specified more logical pages than currently         availible in system (request does not exceed actual physical number of         pages, but some are already allocated to other handles); no pages         allocated 89h     zero pages; cannot be allocated (dropped in EMS 4.0) 8Ah     logical page requested to be mapped outside range of logical pages         assigned to handle 8Bh     illegal page number in mapping request (valid numbers are 0 to 3) 8Ch     page-mapping hardware state save area full 8Dh     save of mapping context failed; save area already contains context         associated with page handle 8Eh     retore of mapping context failed; save area does not contain context         for requested handle 8Fh     subfunction parameter not defined (unknown function) 
LIM 4.0 extended error codes: 
90h     attribute type undefined 91h     warm boot data save not implemented 92h     move overlaps memory 93h     move/exchange larger than allocated region 94h     conventional/expanded regions overlap 95h     logical page offset outside of logical page 96h     region larger than 1 MB 97h     exchange source/destination overlap 98h     source/destination undefined or not supported 99h     (no status assigned) 9Ah     alternate map register sets supported, specified set is not 9Bh     all alternate map & DMA register sets allocated 9Ch     alternate map & DMA register sets not supported 9Dh     alternate map register or DMA set not defined, allocated or is currently         defined set 9Eh     dedicated DMA channels not supported 9Fh     dedicated DMA channels supported; specifed channel is not 0A0h    named handle could not be found 0A1h    handle name already exists 0A2h    move/exchange wraps around 1 MB boundry 0A3h    data structure contains corrupted data 0A4h    access denied 
T A B L E S 
IBM PC KEYBOARD EXTENDED CODES 
 These scan codes are generated by pressing a key on the PC's keyboard. This is the 'make' code. A 'break' code is generated when the key is released. The break scancode is 128 higher than the make code, and is generated by setting bit 7 of the scan code byte to 1. 
        Normal          Shift          Control         Alt 
ESC     1 1       2                                               0;120 2       3                                               0;121 3       4                                               0;122 4       5                                               0;123 5       6                                               0;124 6       7                                               0;125 7       8                                               0;126 8       9                                               0;127 9       10                                              0;128 0       11                                              0;129 -       12                                              0;130 =       13                                              0;131 TAB     15              0;15(backtab) backtab none                                             0;15 RETURN  28 
         Normal      Shift     Control      Alt     NumLock 
Home      0;71                  0;119      none        7 UpArrow   0;72                  none       none        8 PgUp      0;73                  0;132      none        9 gray -    0;74                                         0;74 LArrow    0;75                  0;115      none        4 keypad 5  none                  none       none        5 RArrow    0;77                  0;116                  6 gray +    0;78                                         0;78 End       0;79                  0;117      none        1 DnArrow   0;80                                         2 PgDn      0;81                  0;118      none        3 Ins       0;82                             none        11 Del       0;83                  0;128      none        52 PrtSc     55                    0;114 L shift   42 R shift   54 alt key   56 capslock  58 spacebar  57 control key 29 numlock   69 scrollock 70 ;         39 [         26 ]         27 "         40 \         43 /         53 ,         51 .         52          Normal      Shift     Control      Alt 
a   =     30                               0;30 b   =     48                               0;48 c   =     46                               0;46 d   =     32                               0;32 e   =     18                               0;18 f   =     33                               0;33 g   =     34                               0;34 h   =     35                               0;35 i   =     23                               0;23 j   =     36                               0;36 k   =     37                               0;37 l   =     38                               0;38 m   =     50                               0;50 n   =     49                               0;49 o   =     24                               0;24 p   =     25                               0;25 q   =     16                               0;16 r   =     19                               0;19 s   =     31                               0;31 t   =     20                               0;20 u   =     22                               0;22 v   =     47                               0;47 w   =     17                               0;17 x   =     45                               0;45 y   =     21                               0;21 z   =     44                               0;44 
         Normal      Shift     Control      Alt 
F1  =     0;59       0;84       0;94       0;104 F2  =     0;60       0;85       0;95       0;105 F3  =     0;61       0;86       0;96       0;106 F4  =     0;62       0;87       0;97       0;107 F5  =     0;63       0;88       0;98       0;108 F6  =     0;64       0;89       0;99       0;109 F7  =     0;65       0;90       0;100      0;110 F8  =     0;66       0;91       0;101      0;111 F9  =     0;67       0;92       0;102      0;112 F10 =     0;68       0;93       0;103      0;113 
        "Enhanced" 101/102 key keyboard scancodes          Normal      Shift     Control      Alt F11 =     0;152      0;162      0;172      0;182  | F12 =     0;153      0;163      0;173      0;183  | Tandy? 
F11 =     0;133      0;135      0;137      0;139 F12 =     0;134      0;136      0;138      0;140 
alt-home                                    0;151 UpArr                           0;141       0;152 Ctrl -                          0;142 Ctrl 5                          0;143 Ctrl +                          0;144 DnArr                           0;145       0;160 Ins                             0;146       0;162 Del                             0;147       0;163 Tab                             0;148       0;165 /                               0;149       0;164 Ctrl-*                          0;150 alt-Enter                                   0;166 alt-PgUp                                    0;153 alt-LArr                                    0;154 alt-RArr                                    0;155 alt-End                                     0;156 alt-PgDn                                    0;161 
BIOS keystroke codes, hexadecimal
    Key      Normal         Shift          Control        Alt 
    Esc      011B           011B           011B            --     1!       0231 '1'       0221 '!'        --            7800     2@       0332 '2'       0340 '@'       0300           7900     3#       0433 '3'       0423 '#'        --            7A00     4$       0534 '4'       0524 '$'        --            7B00     5%       0635 '5'       0625 '%'        --            7C00     6^       0736 '6'       075E '^'       071E           7D00     7&       0837 '7'       0826 '&'        --            7E00     8*       0938 '8'       092A '*'        --            7F00     9(       0A39 '9'       0A28 '('        --            8000     0)       0B30 '0'       0B29 ')'        --            8100     -_       0C2D '-'       0C5F '_'       0C1F           8200     =+       0D3D '='       0D2B '+'        --            8300     BkSpc    0E08           0E08           0E7F            --     tab      0F09           0F00            --             --     q        1071 'q'       1051 'Q'       1011           1000     w        1177 'w'       1157 'W'       1117           1100     e        1265 'e'       1245 'E'       1205           1200     r        1372 'r'       1352 'R'       1312           1300     t        1474 't'       1454 'T'       1414           1400     y        1579 'y'       1559 'Y'       1519           1500     u        1675 'u'       1655 'U'       1615           1600     i        1769 'i'       1749 'I'       1709           1700     o        186F 'o'       184F 'O'       180F           1800     p        1970 'p'       1950 'P'       1910           1900     [{       1A5B '['       1A7B '{'       1A1B            --     ]}       1B5D ']'       1B7D '}'       1B1D            --     enter    1C0D           1C0D           1C0A            --     Ctrl      --             --             --             --     a        1E61 'a'       1E41 'A'       1E01           1E00     s        1F73 's'       1F53 'S'       1F13           1F00     d        2064 'd'       2044 'D'       2004           2000     f        2166 'f'       2146 'F'       2106           2100     g        2267 'g'       2247 'G'       2207           2200     h        2368 'h'       2348 'H'       2308           2300     j        246A 'j'       244A 'J'       240A           2400     k        256B 'k'       254B 'K'       250B           2500     l        266C 'l'       264C 'L'       260C           2600            273B '       273A ':'        --             --     '"       2827 '''       2822 '"'        --             --     `~       2960 '`'       297E '~'        --             --     l shift   --             --             --             --     \|       2B5C '\'       2B7C '|'       2B1C            --     z        2C7A 'z'       2C5A 'Z'       2C1A           2C00     x        2D78 'x'       2D58 'X'       2D18           2D00     c        2E63 'c'       2E43 'C'       2E03           2E00     v        2F76 'v'       2F56 'V'       2F16           2F00     b        3062 'b'       3042 'B'       3002           3000     n        316E 'n'       314E 'N'       310E           3100     m        326D 'm'       324D 'M'       320D           3200     ,<       332C ','       333C '<'        --             --     .>       342E '.'       343E '>'        --             --     /?       352F '/'       353F '?'        --             --     r shift   --             --             --             --     PrtSc    372A '*'        --            7200            --     Alt       --             --             --             --     spacebar 3920 ' '       3920 ' '       3920 ' '       3920 ' '     CapsLock  --             --             --             --     F1       3B00           5400           5E00           6800     F2       3C00           5500           5F00           6900     F3       3D00           5600           6000           6A00     F4       3E00           5700           6100           6B00     F5       3F00           5800           6200           6C00     F6       4000           5900           6300           6D00     F7       4100           5A00           6400           6E00     F8       4200           5B00           6500           6F00     F9       4300           5C00           6600           7000     F10      4400           5D00           6700           7100     NumLock   --             --             --             --     Scroll    --             --             --             --     7 Home   4700           4737 '7'       7700            --     8 up     4800           4838 '8'        --             --     9 PgUp   4900           4939 '9'       8400            --     grey -   4A2D '-'       4A2D '-'        --             --     4 left   4B00           4B34 '4'       7300            --     5         --            4C35 '5'        --             --     6 right  4D00           4D36 '6'       7400            --     grey +   4E2B '+'       4E2B '+'        --             --     1 End    4F00           4F31 '1'       7500            --     2 down   5000           5032 '2'        --             --     3 PgDn   5100           5133 '3'       7600            --     Ins      5200           5230 '0'        --             --     Del      5300           532E '.'        --             -- 
    A table entry of "--" means you can't get that combination out of BIOS. 
Instruction Set Matrix
                 * indicates 286 only (not available in 8088/8086).    ͸       x0      x1      x2      x3      x4      x5      x6      x7    ͵ 0x  ADD     ADD     ADD     ADD     ADD     ADD     PUSH    POP         r/m,r8 r/m,r16  r8,r/m r16,r/m  AL,im8 AX,im16  ES      ES      Ĵ 1x  ADC     ADC     ADC     ADC     ADC     ADC     PUSH    POP         r/m,r8 r/m,r16  r8,r/m r16,r/m  AL,im8 AX,im16  SS      SS      Ĵ 2x  AND     AND     AND     AND     AND     AND     SEG     DAA         r/m,r8 r/m,r16  r8,r/m r16,r/m  AL,im8 AX,im16  ES              Ĵ 3x  XOR     XOR     XOR     XOR     XOR     XOR     SEG     AAA         r/m,r8 r/m,r16  r8,r/m r16,r/m  AL,im8 AX,im16  SS              Ĵ 4x  INC     INC     INC     INC     INC     INC     INC     INC         AX      CX      DX      BX      SP      BP      SI      DI      Ĵ 5x  PUSH    PUSH    PUSH    PUSH    PUSH   PUSH     PUSH    PUSH        AX      CX      DX      BX      SP     BP       SI      DI      Ĵ 6x * PUSHA * POPA  * BOUND                                                                                                              Ĵ 7x  JO      JNO     JB/     JNB/    JE/     JNE/    JBE/    JNBE/                       JNAE    JAE     JZ      JNZ     JNA     JA      Ĵ 8x  ArOp1   ArOp1   ArOp2   ArOp2   TEST    TEST    XCHG    XCHG       r/m,im8 r/m,im16r/m8,im8rm16,im8r/m,r8  r/m,r16 r8,r/m  r16,r/m  Ĵ 9x  NOP     XCHG    XCHG    XCHG    XCHG    XCHG    XCHG    XCHG                AX,CX   AX,DX   AX,BX   AX,SP   AX,BP   AX,SI   AX,DI   Ĵ Ax  MOV     MOV     MOV     MOV     MOVSB   MOVSW   CMPSB   CMPSW      AL,mem8 AX,mem16mem8,AL mem16,AX                                 Ĵ Bx  MOV     MOV     MOV     MOV     MOV     MOV     MOV     MOV         AL,im8  CL,im8  DL,im8  BL,im8  AH,im8  CH,im8  DH,im8  BH,im8  Ĵ Cx * ShfOp * ShfOp RET nearRET near LES     LDS     MOV     MOV        r/m8,immr/m16,im im16          r16,mem r16,mem mem,im8 mem,im16 Ĵ Dx  ShftOp  ShftOp  ShftOp  ShftOp  AAM     AAD             XLAT       r/m8,1  r/m16,1 r/m8,CL r/m16,CL                                 Ĵ Ex  LOOPNE/ LOOPE/  LOOP    JCXZ    IN      IN      OUT     OUT         LOOPNZ  LOOPZ                  AL,port8AX,port8AL,port8AX,port8 Ĵ Fx  LOCK            REP/    REPZ/   HALT    CMC      Grp1    Grp1                       REPNE   REPE                   r/m8    r/m16    ͵       x0      x1      x2      x3      x4      x5      x6      x7       ; 
   ͸       x8      x9      xA      xB      xC      xD      xE      xF    ͵ 0x  OR      OR      OR      OR      OR      OR      PUSH   *Prtectd     r/m,r8 r/m,r16  r8,r/m r16,r/m  AL,im8 AX,im16  CS      Mode Op Ĵ 1x  SBB     SBB     SBB     SBB     SBB     SBB     PUSH    POP         r/m,r8 r/m,r16  r8,r/m r16,r/m  AL,im8 AX,im16  DS      DS      Ĵ 2x  SUB     SUB     SUB     SUB     SUB     SUB     SEG     DAS         r/m,r8 r/m,r16  r8,r/m r16,r/m  AL,im8 AX,im16  CS              Ĵ 3x  CMP     CMP     CMP     CMP     CMP     CMP     SEG     AAS         r/m,r8 r/m,r16  r8,r/m r16,r/m  AL,im8 AX,im16  DS              Ĵ 4x  DEC     DEC     DEC     DEC     DEC     DEC     DEC     DEC         AX      CX      DX      BX      SP      BP      SI      DI      Ĵ 5x  POP     POP     POP     POP     POP    POP      POP     POP         AX      CX      DX      BX      SP     BP       SI      DI      Ĵ 6x  * PUSH  * IMUL  *PUSH   * IMUL  * INSB  *INSW  * OUTSB * OUTSW      imm16  r/m,im16 imm8   r/m,im8                                  Ĵ 7x  JS      JNS     JP/     JNP/    JL/     JNL/    JLE/    JNLE/                       JPE     JPO     JNG     JGE     JNG     JG      Ĵ 8x  MOV     MOV     MOV     MOV     MOV     LEA     MOV     POP        r/m,r8  r/m,r16 r8,r/m  r16,r/m r/m,seg r16,mem seg,r/m  r/m     Ĵ 9x  CBW     CWD     CALL    WAIT    PUSHF   POPF    SAHF    LAHF                        far                                             Ĵ Ax  TEST    TEST    STOSB   STOSW   LODSB   LODSW   SCASB   SCASW      AL,mem8 AX,mem16                                                 Ĵ Bx  MOV     MOV     MOV     MOV     MOV     MOV     MOV     MOV        AX,im16 CX,im16 DX,im16 BX,im16 SP,im16 BP,im16 SI,im16 DI,im16  Ĵ Cx * ENTER * LEAVE RET far RET far  INT 3   INT     INTO    IRET       im16,im8         im16                   im8                     Ĵ Bx  MOV     MOV     MOV     MOV     MOV     MOV     MOV     MOV        AX,im16 CX,im16 DX,im16 BX,im16 SP,im16 BP,im16 SI,im16 DI,im16  Ĵ Cx * ENTER * LEAVE RET far RET far  INT 3   INT     INTO    IRET       im16,im8         im16                   im8                     Ĵ Dx  ESC 0   ESC 1   ESC 2   ESC 3   ESC 4   ESC 5   ESC 6   ESC 7                                                                       Ĵ Ex  CALL    JMP     JMP     JMP     IN      IN      OUT     OUT         near    near    far     short   AL,DX   AX,DX   AL,DX   AX,DX   Ĵ Fx  CLC     STC     CLI     STI     CLD     STD     Grp2    Grp3                                                        r/m8    r/m16   ͵       x8      x9      xA      xB      xC      xD      xE      xF       ; 
Secondary Opcode Space
This table identifies operations for the instruction groups which contain the opcode in bits 3-5 of the second byte (normally the addressing mode byte). 
       ͸        md000r/mmd001r/mmd010r/mmd011r/mmd100r/mmd101r/mmd110r/mmd111r/m ͵ ArOp1   ADD     OR      ADC     SBB     AND     SUB     XOR     CMP     Ĵ ArOp2   ADD             ADC     SBB             SUB             CMP     Ĵ ShftOp  ROL     ROR     RCL     RCR    SHL/SAL  SHR             RAR     Ĵ Grp1    TEST            NOT     NEG     MUL     IMUL    DIV     IDIV    Ĵ Grp2    INC      DEC   CALLnearCALL farJMP nearJMP far  PUSH            Ĵ Grp3    INC      DEC                                                    ; 
Arithmetic Instructions
ADD  dest,src         add two operands, placing result in dest                        dest<-(src + dest) ADC  dest,src         add two operands, using carry from previous ADD                        dest<-(src + dest + CF) INC  dest             add 1 to dest (reg or r/m)                        dest<-(dest+1) 
SUB  dest,src         subtract src from dest, leaving result in dest                        dest<-(dest - src) SBB  dest,src         subtract using borrow (carry flag) from previous SUB                        dest<-((dest - src) - CF) DEC  dest             subtract 1 from dest (reg or r/m)                        dest<-(dest - 1) 
CMP  dest,src         compare (non-destructive subtract)                        flags are set to indicate carry, overflow, etc. 
NEG  dest             change sign of an operand                        dest<-(0 - dest)
AAA                   adjust after ASCII addition                        AL<-(AL corrected for ASCII addition) AAS                   adjust for ASCII subtraction                        AL<-(AL corrected for ASCII subtraction) AAM                   adjust after ASCII multiply                        AH:AL<-(AH:AL corrected for ASCII multiplication) AAD                   adjust before ASCII division                        AH:AL<-(AH:AL prepared for division of ASCII codes) 
DAA                   adjust after BCD addition                        AL<-(AL corrected for BCD addition) DAS                   adjust for BCD subtraction                        AL<-(AL corrected for BCD subtraction) 
MUL src               multiply AL(AX) by unsigned value (reg/mem)                        AX<-(AL * src8)                        DX:AX<-(AX * src16) IMUL src              multiply AL(AX) by signed integer (reg/mem)                        AX<-(AL * immed8)                        DX:AX<-(AX * immed16) IMUL reg16,r/m,immed  multiply reg/mem by 16-bit immediate signed value  286                        reg16<-(r/m8 * immed)                        reg16<-(r/m16 * immed) 
DIV  src              divide accumulator by unsigned value (reg/mem)                       Division by 0 or result too large causes INT 0.                        AL<-(AX  src8)AH<-(AX MOD src8)                        AX<-(DX:AX  src16)DX<-(DX:AX MOD src16) IDIV src              divide accumulator by unsigned value (reg/mem) 
CBW                   convert byte to word (sign-extend AL into AH)                        AH<-(filled with bit-7 of AL) CWD                   convert word to dword (signed-extend AX int DX)                        DX<-(filled with bit-15 of AX) AND  dest,src         logical AND (maskreset dest bits which are 0s in src)                        dest<-(dest & src)                        AH<-(filled with bit-7 of AL) CWD                   convert word to dword (signed-extend AX int DX)                        DX<-(filled with bit-15 of AX) 
AND  dest,src         logical AND (maskreset dest bits which are 0s in src)                        dest<-(dest & src) TEST dest,src         non-destructive AND (bit testJZ will jump if no match)                        flags<-(set as for dest & src) 
OR   dest,src         inclusive OR (set dest bits which are 1s in src)                        dest<-(dest | src) 
XOR  dest,src         exclusive OR (toggle dest bits which are 1s in src)                        dest<-(dest ^ src) 
NOT  dest             form 1's complement (toggle every bit in dest)                        dest<-(~dest) 
Data Transfer Instructions
MOV  dest,src        transfer (copy) data to/from register, to/from memory                       dest<-src 
XCHG dest,src        exchange values of two registers or register and r/m                       dest <-> src 
IN   port8 (or DX)   input to AL(or AX) from I/O port                       byte: AL<-port                       word: AL<-[port]AH<-[port+1] OUT  port8 (or DX)   output from AL(or AX) to I/O port                       byte: [port]<-AL                       word: [port]<-AL [port+1]<-AH 
XLAT                 translate AL into a value in a translation table at BX                       AL<-ES:[BX+(AL)] 
LEA  reg16,addr      load address into a register                        reg16<-(result of EA calculation of addr offset) 
LDS  reg16,mem       load DS and reg16 from memory variable                       reg16<-[mem16]DS<-[mem16+2] LES  reg16,mem       load ES and reg16 from memory variable                       reg16<-[mem16]ES<-[mem16+2] 
LAHF                 load/convert flags into AH SAHF                 store/convert AH into flags 
PUSH src             transfer reg16 or r/m16 to stack                       SP-=2SS:[SP]<-src PUSH immed           transfer immed16 (or sign-extended immed8) to stack.                      SP-=2SS:[SP]<-immed16    286 only. 
PUSHA                PUSH ALL: copy general registers to stack.  286 only.                       SP-=10HAX,BX,CX,DX,SI,DI,BP,SP saved on stack 
PUSHF                PUSH Flags: transfer flags register to stack                       SP-=2SS:[SP]<-flags 
PUSH immed           transfer immed16 (or sign-extended immed8) to stack.                      SP-=2SS:[SP]<-immed16    286 only. 
PUSHA                PUSH ALL: copy general registers to stack.  286 only.                       SP-=10HAX,BX,CX,DX,SI,DI,BP,SP saved on stack 
PUSHF                PUSH Flags: transfer flags register to stack                       SP-=2SS:[SP]<-flags 
POP  dest            transfer from stack to reg16 or r/m16 or segreg                       dest<-SS:[SP]SP+=2 
POPA                 POP All: copy general registers from stack.  286 only.                       SP+=10HAX,BX,CX,DX,SI,DI,BP restored from stack 
POPF                 POP Flags: transfer from stack to flags register                       flags<-SS:[SP]SP+=2 
Execution Control Instructions
JMP     target       unconditionally transfer control to label                          short: IP<-(IP+(target displacement sign-extended))                           near: IP<-(IP+(target displacement))                       indirect: IP<-(register or value in memory)                            far: SS<-target_segIP<-target_offset 
JCXZ    short_label  jump if CX==0 
LOOP    short_label  CX<-(CX-1) jump if CX!=0 LOOPE/  short_label  CX<-(CX-1) jump if CX!=0 && ZF==ZR==1  LOOPZ LOOPNE/ short_label  CX<-(CX-1) jump if CX!=0 && ZF==NZ==0  LOOPNZ 
Jcond   short_label  jump when a condition is met                      IP<-(IP+(8-bit displacement sign-extended to 16 bits)) 
JA/JNBE short_label  jump if Above ((CF & ZF)==0 after unsigned math) JAE/JNB short_label  jump if Above or Equal (CF==NC==0 after unsigned math) JB/JC   short_label  jump if Below/Jump if Carry set (CF==CY==1) JE/JZ   short_label  jump if Equal (ZF==ZR==1) JG/JNGE short_label  jump if Greater (SF==(OF & ZF) after signed math) JGE/JNL short_label  jump if Greater or Equal (SF==OF after signed math) JL/JNGE short_label  jump if Less (ZF != OF after signed math) JLE/JNG short_label  jump if Less or Equal (SF!=OF || ZF==0 after signed math) JNC     short_label  jump if carry not set (CF==NC==0) (same as JAE/JNB) JNE/JNZ short_label  jump if Not Equal (ZF==NZ==0) JNO     short_label  jump if Not Overflow (OF==NO==0) JNP/JPO short_label  jump if Parity Odd (PF==PO==0: count of 1-bits is ODD) JNS     short_label  jump if Not Sign (SF==PL==0: same as high-bit of dest) JO      short_label  jump if Overflow (OF==OV==1) JP/JPE  short_label  jump if Parity Even (PF==PE==1 count of 1-bits is EVEN) JS      short_label  jump if Sign (SF==NG==1: same as high-bit of dest) 
BOUND   reg16,lmts   perform limit-check on reg16. 'lmts' is the address of a                      2-word table with desired min/max limits.  286 only.                      if (reg16<DS:[lmts]) or (reg16>DS:[lmts+2]) then INT 5 
ENTER   frmsiz,frms  set high-level language stack frame.  Use as the first                      operation in a CALLed procedure.  286 only.  Same as:                       PUSH BP     (repeated frms times)                       MOV BP,SP                      PUSH SP                      SUB SP,frmsize allocate dynamic space on stack) 
LEAVE                undo the effect of ENTER.  Use just before RET.                      Restores SP and BP to values at time of ENTER. 
INT type             perform a software interrupt (call a system function)                       PUSHF IF<-0; TF<-0;                       PUSH CS; PUSH IP                       IP<- 0000:[type * 4]; CS <- 0000:[(type * 4) + 2] 
INTO type            if OF==OV==1, then perform INT type IRET                 return from interrupt.  Effectively the same as:                       POP IP; POP CS; POPF                       PUSH BP;      (repeated frms times)                       MOV BP,SP;                       PUSH SP;                       SUB SP,frmsize ;(allocate dynamic space on stack) 
LEAVE                undo the effect of ENTER.  Use just before RET.                      Restores SP and BP to values at time of ENTER. 
INT type             perform a software interrupt (call a system function)                       PUSHF; IF<-0; TF<-0;                       PUSH CS; PUSH IP                       IP<- 0000:[type * 4]; CS <- 0000:[(type * 4) + 2] 
INTO type            if OF==OV==1, then perform INT type 
IRET                 return from interrupt.  Effectively the same as:                       POP IP; POP CS; POPF 
Processor Control Instructions 
CLC         clear the carry flag to NC                             (CF<-0) CMC         complement (reverse the value of) the carry flag       (CF<- ~CF) STC         set the carry flag to CY                               (CF<-1) CLD         clear direction flag to UP (string ops auto-increment) (DF<-0) STD         set direction flag to DN (string ops auto-decrement)   (DF<-1) CLI         disable maskable hardware interrupts                   (IF<-0) STI         enable maskable hardware interrupts                    (IF<-1) 
CTS         clear task switch flag.  286 only.                   (TF<-1) 
HLT         halt processing (perform NOPs until an interrupt occurs) 
WAIT/FWAIT  wait for TEST line active (synchronize with coprocessor) LOCK        (prefix) prevent coprocessor bus access for the next instruction 
SEG segreg  (prefix) override default segreg for next EA calculation 
Protection Control Instructions 
All Instructions on this page are 286 -specific (not available on 8088/86) 
LGDT src       load Global Descriptor Table from 6-byte table at src SGDT dest      store 6-byte Global Descriptor Table to memory at dest 
LIDT src       load Interrupt Descriptor Table from 6-byte table at src SIDT dest      store 6-byte Interrupt Descriptor Table to memory at dest 
LLDT src       load Local Descriptor Table (GDT selector) from reg/mem16 SLDT dest      store Local Descriptor Table register into dest (r/m16) 
LMSW src       load Machine Status Word (use to enter protected mode) SMSW src       store Machine Status Word to reg/mem16 
LTR  src       load Task Register (GDT selector) from reg/mem16 STR  dest      store Task Register to reg/mem16 
LAR  dest,src  load high-byte of dest with Access Rights of src descriptor 
SLDT dest      store Local Descriptor Table register into dest (r/m16) 
LMSW src       load Machine Status Word (use to enter protected mode) SMSW src       store Machine Status Word to reg/mem16 
LTR  src       load Task Register (GDT selector) from reg/mem16 STR  dest      store Task Register to reg/mem16 
LAR  dest,src  load high-byte of dest with Access Rights of src descriptor 
LSL  dest,src  load dest with Segment Limit of descriptor named by src 
ARPL lvl       Adjust Requested Privilege Level to higher of current or lvl 
VERR seg       Sets ZF to ZR if task has read privileges for segment seg 
VERR seg       Sets ZF to ZR if task has write privileges for segment seg 
String Operation Instructions 
CLD                  clear direction flag to UP (DF<-UP<-0)                       sets ^ (Delta) to positive. string ops auto-increment STD                  set direction flag to DN (DF<-DN<-1)                       sets ^ (Delta) to negative. string ops auto-decrement 
REP/REPE/REPZ        (prefix) repeat: perform string operation repeatedly                       CX<-(CX-1); string op repeats until CX==0 REPNE/REPNZ          (prefix) repeat: useful for string ops CMPS and SCAS                       ZF<-0; CX<-(CX-1); StrOp repeats while (CX!=0 and ZF==0) 
MOVSB                copy byte(word) string (byte:^=1, word:^=2) MOVSW                 ES:[DI]<-DS:[SI]; DI+=^; SI+=^ 
LODSB                copy string byte(word) into AL(AX)                       AL <- DS:[SI]; SI+=1; LODSW                 AX <- DS:[SI]; SI+=2; 
STOSB                store bytes(words) into string                       ES:[DI]<-AL; DI+=1;                       ES:[DI]<-AL; DI+=1; STOSW                 ES:[DI]<-AX; DI+=2; 
CMPSB                compare byte(word) strings (byte:^=1, word:^=2) CMPSW                 flags<-(result of CMP DS:[SI],ES:[DI]); DI+=^; SI+=^ 
SCASB                find byte(word) in string                       flags<-(result of CMP DS:[DI],AL); DI+=1 SCASW                 flags<-(result of CMP DS:[DI],AX); DI+=2 
INSB                 port input byte(word) into string (byte:^=1, word:^=2) INSW                 286 only.                       ES:[DI]<-(byte/word at port DX); DI+=^; 
OUTSB                port output byte(word) from string (byte:^=1, word:^=2) OUTSW                286 only.                       [port DX]<-DS:[SI]; SI+=^; 
Switch Settings 
                               PC Switch Settings  (includes PC-1 and PC-2)                                XT Switch Settings                                AT Switch Settings 
                               <EGA> Switch Settings 
DIP switches on the PC and XT tell the BIOS what equipment and how much memory is installed.  These switches are read during the POST and bit flags are set into the BIOS Equipment List variable and are made available to the programmer via INT 11H (Equipment Check). 
The menu items above show details of the DIP switch settings, as well as jumpers and other hardware configuration for the different standard IBM models. 
Clone PCs may not adhere to these settings.  Compaq Portable switches bear no resemblance to those of the standard PC and aren't documented in any manual available to Compaq owners.  Deskpro switches are labled inside the system unit. 
PC Switch Settings 
On the original PC (64K byte motherboard; sometimes called the PC-1), there are two DIP switch banks labeled SW1 and SW2.  This is a summary of switch meanings: 
           SW1                                   SW 2  (PC-1)  ON 12345678                      ON 12345678                                                ܳܳܳܺ     Ľ                         Ľ        ˼ ˼ > 7-8: diskette drives    ͼ > 5-8: always OFF            > 5-6: active display        > 1-4: total RAM         > 3-4: system board RAM       > 2: 8087 coprocessor      > 1: diskette drives 
A later version of the PC (sometimes             SW 2  (PC-2) called the PC-2) has a different BIOS      ON 12345678 which interprets the switches slightly                 ܳܳܺ differently.  SW1 is the same but SW2         Ľ differs as shown:                              ͼ > 6-8: always OFF                                                    > 1-5: total RAM 
On PCs and Xts, you can change the effect of the switch settings by changing the Equipment List bytes in BIOS Data Area 0:0410, then rebooting DOS.  Be sure to set address 0:0472 to 1234H first, then do an INT 19H 
Ŀ  PC and XT SW1: Diskette Drives  This indicates how many diskette drives are  attached to the system.           SW1  ON 12345678          ߳ߺ 1 diskette drive   (Note: position 1 is ON if 0 drives)     Ľ  ON 12345678          ܳߺ 2 diskette drives     Ľ  ON 12345678          ߳ܺ 3 diskette drives     Ľ  ON 12345678          ܳܺ 4 diskette drives     Ľ 
Ŀ  PC and XT SW1: Active Monitor  These switches tell the system which display  adapter is to be used when the system is turned on.  If the PC displays nothing after power-up, it may be because of an incorrect switch setting.            SW1  ON 12345678         ߳߳   None or <EGA>     Ľ  ON 12345678         ܳ߳   40x25 Color/Graphics Adapter (CGA)     Ľ  ON 12345678         ߳ܳ   80x25 Color/Graphics Adapter (CGA)     Ľ  ON 12345678         ܳܳ   Monochrome Adapter (MDA) or both MDA and CGA     Ľ 
Ŀ  PC and XT SW1: 8087  This switch enables the 8087 Coprocessor to interrupt  CPU (via INT 02H Non-Maskable Interrupt) when it encounters an exception condition (as in division by 0).  When OFF, software should be installed to trap INT 02H and determine if the interrupt was caused by a memory parity error or an 8087 exception condition. 
           SW1  ON 12345678             8087 is installed     Ľ  ON 12345678             8087 is NOT installed     Ľ 
Ŀ  PC SW1: System board RAM  These switches should both be OFF on systems that  have 64K of memory or more (ie, all systems able to read this). 
           SW1  ON 12345678       ܳ     64K or more on the system board     Ľ 
Ŀ  PC-1 SW2 (system board RAM)  These settings are for the original PC (64K  maximum on the system board) which does not have a later version of the ROM-BIOS; ie, it does not have ROM-Scan and does not connect to an expansion unit or have a self-booting hard disk.  The maximum settings for this system is 544K. 
       SW2  (PC-1)  ON 12345678      Note: on the PC-1, SW2 positions 5-8 are always OFF.     ߳߳߳     64K     Ľ  ON 12345678      Ŀ     ߳ܳ߳     128K  The settings reflect a binary number of 32K          Ľ       blocks where an OFF is a 1-bit.  To set the       ON 12345678       switches without using a chart, just remember:       ߳߳ܳ     192K                                                       Ľ           Position 4 = 256Ks  (ON=0, OFF=1)             ON 12345678           Position 3 = 128Ks                               ߳ܳܳ     256K      Position 2 =  64Ks                               Ľ           Position 1 =  32Ks                            ON 12345678                                                            ߳߳߳     320K  Add them up, then add 64K (system board RAM) to      Ľ       get the total system memory.                      ON 12345678           ߳ܳ߳     384K     Ľ  ON 12345678     ߳߳ܳ     448K     Ľ  ON 12345678     ߳ܳܳ     512K     Ľ  ON 12345678     ܳܳܳ     544K     Ľ 
Ŀ  PC-2 SW2 (system board RAM)  These settings are for a later version of the PC  (sometimes called the PC-2) which is capable of having 256K on the system board.  These setting also apply to the PC-1 (64K system board) when a later version of the ROM-BIOS has been installed.  If you have a self-booting hard disk or an IBM expansion chassis, you have PC-2 ROMS. The maximum memory for this model is 640K.        SW2  (PC-2)  ON 12345678      Note: on the PC-2, SW2 positions 6-8 are always OFF.     ߳߳߳߳߳    64K     Ľ  ON 12345678      Ŀ     ߳ܳ߳߳߳    128K  The settings reflect a binary number of 32K          Ľ       blocks where an OFF is a 1-bit.  To set the       ON 12345678       switches without using a chart, just remember:       ߳߳ܳ߳߳    192K                                                       Ľ           Position 5 = 512Ks  (ON=0, OFF=1)             ON 12345678           Position 4 = 256Ks                               ߳ܳܳ߳߳    256K      Position 3 = 128Ks                               Ľ           Position 2 =  64Ks                            ON 12345678           Position 1 =  32Ks                               ߳߳߳ܳ߳    320K                                                       Ľ       Add them up, then add 64K to get the total RAM.   ON 12345678           ߳ܳ߳ܳ߳    384K     Ľ  ON 12345678     ߳߳ܳܳ߳    448K     Ľ  ON 12345678     ߳ܳܳܳ߳    512K     Ľ  ON 12345678     ߳߳߳߳ܳ    576K     Ľ  ON 12345678     ߳ܳ߳߳ܳ    640K     Ľ 
Author's Note: Setting the memory switches has been a plague on users since the PC was created.  If you get one switch wrong, you get a hard memory error and must turn the computer off and start over.  This problem is compounded by the fact that most memory cards have their own set of switches that must be exactly right as well. 
One trick I've used is to set the switches to a low value, boot the computer and try CHKDSK to make sure it agrees with your setting.  Then try using higher and higher settings until the error occurs. 
By the way, if you set the switches above 640K, BIOS will be happy, but DOS will crap out (the transient part of COMMAND.COM gets loaded in highest RAM). 
XT Switch Settings 
The XT has a single bank of DIP switches.  They are summarized as follows: 
      SW1 (XT) ON 12345678    ܳ              Ľ       ˼ ˼ > 7-8: diskette drives           > 5-6: initial active display monitor        > 3-4: system board RAM      > 2: 8087     > 1: POST loop (always OFF) 
Positions 2, 5-6, and 7-8 are the same as on the PC.  See PC Switch Settings 
Ŀ  XT RAM  The XT POST determines the total system memory by scanning RAM  address space to locate 32K blocks (it displays numbers in the top left corner of the screen as it does this).  Therefore, you do not need to change switch settings when you add or remove memory option cards.  Furthermore, left corner of the screen as it does this).  Therefore, you do not need to change switch settings when you add or remove memory option cards.  Furthermore, you need not populate the system board fully (above 128K) to add additional memory option cards. 
Switches 3-4 indicate the memory on the XT system board as follows:                                                    SW1 (XT) ON 12345678      ܳ      128K    Ľ ON 12345678      ߳      192K    Ľ ON 12345678      ܳ      256K    Ľ 
AT Switch Settings 
The AT does not have any DIP switch banks.  The equipment configuration is set by the SETUP program which is incorporated into the DIAGNOSTICS diskette. See CMOS Memory for more information. 
The AT does have two system board options which are set by physical switches. 
A 3-pin Berg-strip connect is located on the front edge of the system board labeled J18 affects the usage of system board RAM. 
  J18 1 Ŀ  ENABLE second bank of 256K (512K on system board) 2 ٺ 3       ͼ   J18 1     2 Ŀ 3 ٺ  DISABLE second bank of 256K RAM (256K on system board)   ͼ 
A single slide switch near the back of the system board, labeled SW1, determines the initial display adapter.  This is used by the POST but has meaning only when the CMOS Memory (which contains the full equipment list) has lost power or has become invalid for some other reasons.  In other words, this switch indicates the primary display adapter that will be used by the SETUP program. 
 SW1  ݺ ON     ON (toward the rear) Color/Graphics Adapter (CGA) is primary      OFF  ͼ  SW1      ON  ݺ OFF    OFF (toward the front) Monochrome Display Adapter (MDA) is primary  ͼ 
Note: The <EGA> reference contradicts this, saying to use OFF for a CGA alone       and ON for any other display adapter or combination of adapters.  You       figure it out! the initial display adapter.  This is used by the POST but has meaning only when the CMOS Memory (which contains the full equipment list) has lost power or has become invalid for some other reasons.  In other words, this switch indicates the primary display adapter that will be used by the SETUP program. 
 SW1  ݺ ON     ON (toward the rear) Color/Graphics Adapter (CGA) is primary      OFF  ͼ  SW1      ON  ݺ OFF    OFF (toward the front) Monochrome Display Adapter (MDA) is primary  ͼ 
Note: The <EGA> reference contradicts this, saying to use OFF for a CGA alone       and ON for any other display adapter or combination of adapters.  You       figure it out! 
<EGA> Switch Settingse 
The DIP switches on the rear of the <EGA> indicate which display monitor is connected to the card and which (if any) other adapters are in the system at the same time.  The switches are mirrored in memory.  See <EGA> Data Areas 
There is one VERY CRITICAL thing to watch for:  never plug an IBM (TTL-type) Monochrome monitor into the EGA adapter unless the switches are set to accept it.  A wrong setting will actually do physical damage to the monitor! 
In the following table, "Primary" indicates the adapter/monitor which is first enabled when the computer is turned on.  "Secondary" indicates an optional second adapter/monitor which may be connected. 
ON 4321 Primary EGA connected to 40x25 color monitor    ߳ܳܳߺ Secondary MDA    Ľ ON 4321 Primary EGA connected to 80x25 color monitor    ߳ܳܳܺ Secondary MDA    Ľ ON 4321 Primary EGA connected to Enhanced color monitor (CGA emulation)    ܳ߳߳ߺ Secondary MDA    Ľ ON 4321 Primary EGA connected to Enhanced color monitor (best resolution)    ܳ߳߳ܺ Secondary MDA    Ľ ON 4321 Primary EGA connected to Monochrome monitor    ܳ߳ܳߺ Secondary CGA connected to 40x25 color monitor    Ľ ON 4321 Primary EGA connected to Monochrome monitor    ܳ߳ܳܺ Secondary CGA connected to 80x25 color monitor    Ľ 
ON 4321 Primary MDA    ߳߳߳ߺ Secondary EGA connected to 40x25 color monitor    Ľ ON 4321 Primary MDA    ߳߳߳ܺ Secondary EGA connected to 80x25 color monitor    Ľ ON 4321 Primary MDA    ߳߳ܳߺ Secondary EGA connected to Enhanced color monitor (CGA emulation)    Ľ ON 4321 Primary MDA    ߳߳ܳܺ Secondary EGA connected to Enhanced color monitor (best resolution)    Ľ ON 4321 Primary CGA connected to 40x25 color monitor    ߳ܳ߳ߺ Secondary EGA connected to Monochrome monitor    Ľ ON 4321 Primary CGA connected to 80x25 color monitor    ߳ܳ߳ܺ Secondary EGA connected to Monochrome monitor    Ľ 
Ŀ  EGA Jumpers   The three jumpers on the <EGA> control various features of the   card.  The jumper/connectors are used as follows:     P1ͻ   1 Ŀ Supports Enhanced Color Monitor (640x350 and 64 color capability)   2 ٺ   3         ͼ     P1ͻ   1       2 Ŀ   3 ٺ Supports color monitor only (640x200 and 16 color capability)     ͼ 
    P2 is a connector for a light pen. 
    P3ͻ   1 Ŀ Sets EGA I/O ports to 3xxH   (normal setting)   2 ٺ   3         ͼ     P3ͻ   1       2 Ŀ   3 ٺ Sets EGA I/O ports to 2xxH    NOT supported by  <EGA> BIOS     ͼ   1       2 Ŀ   3 ٺ Supports color monitor only (640x200 and 16 color capability)     ͼ 
    P2 is a connector for a light pen. 
    P3ͻ   1 Ŀ Sets EGA I/O ports to 3xxH   (normal setting)   2 ٺ   3         ͼ     P3ͻ   1       2 Ŀ   3 ٺ Sets EGA I/O ports to 2xxH    NOT supported by  <EGA> BIOS     ͼ 
ASCIIDecimalHexBinary Cross Reference
ASC Dec Hex Binary  ASC Dec Hex Binary  ASC Dec Hex Binary  ASC Dec Hex Binary        0  00 00000000   16  10 00010000   32  20 00100000 0 48  30 00110000    1  01 00000001   17  11 00010001 ! 33  21 00100001 1 49  31 00110001    2  02 00000010   18  12 00010010 " 34  22 00100010 2 50  32 00110010    3  03 00000011   19  13 00010011 # 35  23 00100011 3 51  33 00110011    4  04 00000100   20  14 00010100 $ 36  24 00100100 4 52  34 00110100    5  05 00000101   21  15 00010101 % 37  25 00100101 5 53  35 00110101    6  06 00000110   22  16 00010110 & 38  26 00100110 6 54  36 00110110    7  07 00000111   23  17 00010111 ' 39  27 00100111 7 55  37 00110111    8  08 00001000   24  18 00011000 ( 40  28 00101000 8 56  38 00111000    9  09 00001001   25  19 00011001 ) 41  29 00101001 9 57  39 00110010   10  0A 00001010   26  1A 00011010 * 42  2A 00101010 : 58  3A 00111010   11  0B 00001011   27  1B 00011011 + 43  2B 00101011 ; 59  3B 00111011   12  0C 00001100   28  1C 00011100 , 44  2C 00101100 < 60  3C 00111100   13  0D 00001101   29  1D 00011101 - 45  2D 00101101 = 61  3D 00111101   14  0E 00001110   30  1E 00011110 . 46  2E 00101110 > 62  3E 00111110   15  0F 00001111   31  1F 00011111 / 47  2F 00101111 ? 63  3F 00111111 
ASC Dec Hex Binary  ASC Dec Hex Binary  ASC Dec Hex Binary  ASC Dec Hex Binary     @ 64  40 01000000 P 80  50 00010000 ` 96  60 00100000 p112  70 00110000 A 65  41 01000001 Q 81  51 01010001 a 97  61 01100001 q113  71 01110001 B 66  42 01000010 R 82  52 01010010 b 98  62 01100010 r114  72 01110010 C 67  43 01000011 S 83  53 01010011 c 99  63 01100011 s115  73 01110011 D 68  44 01000100 T 84  54 01010100 d100  64 01100100 t116  74 01110100 E 69  45 01000101 U 85  55 01010101 e101  65 01100101 u117  75 01110101 F 70  46 01000110 V 86  56 01010110 f102  66 01100110 v118  76 01110110 G 71  47 01000111 W 87  57 01010111 g103  67 01100111 w119  77 01110111 H 72  48 01001000 X 88  58 01011000 h104  68 01101000 x120  78 01111000 I 73  49 01001001 Y 89  59 01011001 i105  69 01101001 y121  79 01110010 J 74  4A 01001010 Z 90  5A 01011010 j106  6A 01101010 z122  7A 01111010 K 75  4B 01001011 [ 91  5B 01011011 k107  6B 01101011 {123  7B 01111011 L 76  4C 01001100 \ 92  5C 01011100 l108  6C 01101100 |124  7C 01111100 M 77  4D 01001101 ] 93  5D 01011101 m109  6D 01101101 }125  7D 01111101 N 78  4E 01001110 ^ 94  5E 01011110 n110  6E 01101110 ~126  7E 01111110 O 79  4F 01001111 _ 95  5F 01011111 o111  6F 01101111 127  7F 01111111 
܀         v       q E  E  l E  g d[ f[ b ] ] ] [^ ]^ X "_          @"_ $_ v ;` >` q H` T` l Lc Nc g xc zc b c c ] 1q 3q X 0?        0? 2? v   q ; < l ln nn g   b E G ]   X           v { } q   l   g 0) 2) b 
+ + ] +. -. X @        @ @ v } } q 
" " l '  g 0) 2) b 
+ + ] +. -. X @              i       g    g   g   e 8  c |  c                                                 ?             |    y   y   y   y   w -  u ;  u g  s   s                                                             	    y   y   y 1  y T  y s  y   y   y   y   y                                                             
    y \  y   y   y   y :  y O  w   u   u                                                                	    y   y \  y |  y   y   y   y   y   y 8  y                                                             
8  V  y   y   y   y <  w N  u r  u   u   u                                                                	    y   y   y 	  y 5	  y H	  w \	  w ~	  w 	  w                                                                		  	  y 	  y 	  y 
  y 6
  y W
  w u
  w 
  w 
  w                                                                	
  
  y 
  y 
  y   y )  y E  y   y   y   y   y                                                             
    y `  y t  y   y   y   y   y 
  y A
  y f
  y                                                             
f
  
  y 
  y 
  y 
  y *  y g  y   y   y   y   y                                                             
  1  y b  y   y   y   y   y +  y b  y   y   y                                                             
    y   y   y   y :  y d  y   y   y   y   y                                                             
    y    y >  y \  y   y   y   y 	  y /  y R  y                                                             
R  r  y   y   y   y   y %  y N  y p  y   y   y                                                             
    y   y 5  y U  y   y   y   y   y 3  y a  y                                                             
a  s  y   y   y   y   y   y   y =  y c  y   y                                                             
    y   y   y   y T  y r  y   y   y   y   y                                                             
  1  y g  y   y   y   y   y )  y F  y r  y   y                                                             
    y   w   w   w &  w @  w Z  w t  w   w                                                                  	    y   y   y   y   y $  y >  y S  y m  y   y                                                             
    y   y   y (  y I  w o  u   u   u   u                                                                	    y E  y w  y   y   y   y N  y   y   y   y                                                             
     y 2   y N   y    y    y !  y b!  y !  y !  y C"  y                                                             
C"  "  y "  y $#  y o#  y #  y #  y  $  y I$  y $  y $  y                                                             
$   %  y V%  y %  y %  y /&  y {&  y &  y &  y %'  y ['  y                                                             
['  '  y '  y '  y 3(  y i(  y (  y (  y )  y U)  y )  y                                                             
)  )  y )  y (*  y t*  y *  y *  y "+  y Q+  y +  y +  y                                                             
+  +  y -,  y u,  y ,  y ,  y %-  y c-  y -  y -  y /.  y                                                             
/.  L.  y i.  y .  y .  y .  y /  y `/  y /  y /  y /  y                                                             
/  '0  y }0  y 0  y 0  y 0  y %1  y s1  y 1  y 1  w                                                                  	1  2  y &2  y H2  y j2  y 2  y 2  y 2  y 2  w 2  u                                                                	2  3  y $3  y ?3  y [3  y 3  y 3  y 3  y 3  y 4  y ,4  y                                                             
,4  L4  y f4  y 4  y 4  y 4  w 4  u 4  u 5  s E5  q                                                            	E5  s5  y 5  y 5  y 5  y 5  y 6  y 6  y 36  y J6  y f6  y                                                             
f6  6  y 6  y 6  y 6  w 7  u 7  u +7  u Q7  u k7  u                                                                	k7  7  y 7  y 7  y 7  y 7  y 8  w +8  u B8  u V8  u                                                                	V8  8  y 8  y 8  y 8  y 8  y 9  y 49  y T9  y w9  y 9  y                                                             
9  9  y 9  y 9  y 9  y :  y &:  y 1:  y C:  y Z:  y :  y                                                             
:  :  y :  y :  y :  y :  y ;  y $;  y ^;  w ;  u                                                                	;  ;  y ;  y <  y 6<  y t<  y <  y <  y <  w =  w                                                                	=  B=  y t=  y =  y =  y =  y 
>  y .>  y J>  y f>  y >  y                                                             
>  >  y >  y ?  y 3?  w Z?  u ?  u ?  u ?  u @  u                                                                	@  ,@  y Z@  y @  y @  y A  y 8A  y tA  y A  y A  y B  y                                                             
B  JB  y eB  y B  y B  y B  y -C  y [C  y C  y C  w                                                                  	C  C  y C  w D  u .D  u JD  u fD  u D  u D  u D  u                                                                	D  D  y E  y 6E  y LE  y eE  y ~E  y E  y E  y E  y                                                                	E  E  v F  "F  q G  l hH  l I  l -K  l K  l L  l                                                       =  = 	L  N  v P  v Q  v Q  v Q  q S  l -U  l V  l ^V  l                                                       =  = 	^V  nV  v V  v V  v UW  v W  v X  v aX  v X  v Y  v                                                       =  = 	Y  Y  v Z  v pZ  v Z  v Z  v [  v g[  v [  v .\  v                                                       =  = 	.\  \  v \  v ]  v ^]  v ]  v ]  v 8^  v ^  v ^  v                                                       =  = 	^  !_  v _  v _  v [`  v `  v `  v a  v a  v *a  v                                                       =  = 	*a  <a  v Pa  v ga  v wa  v a  v a  v a  v a  v b  v                                                       =  = 	b  2b  v gb  v b  v b  v Sc  v c  v c  q c  l                                                               = c  c  v Id  q d  q  p  q "p  q q  q r  q t  q 5u  q                                                        =  	5u  ~w  v x  v x  v x  q y  l y  g y  b zz  b                                                   =  =  = zz  z  v z  q e}  q }  q !  q ~  q   q    q   q                                                       = =  	    v {  v   v y  v   q   l 3  l ݓ  l 2  l                                                       =  = 	2    v   v   v \  v   v 7  v   v $  v   v                                                       =  = 	    v   v   v   v   v   v ;  v    v   v                                                       =  = 	    v   v   v *  v   v g  v z  v   v   v                                                       =  = 	    v !  v d  v   q   l y  l ڹ  l p  l x  l                                                       =  = 	x  w  v   v   v   v   v   v   v   v #  v                                                       =  = 	#  M  v m  q B q J# q ' q ' l ( g Y) g                                                        =  =  Y) w) v H* v + v Q, v - v s0 v I2 v 5 v 9 v                                                        = = 	9 ; v X; v ; v < v = v > v ? v ? v }F v                                                        = = 	}F F v F v F q G l H l HI l K l L l LM l                                                       =  = 	LM xN v N q P l GZ l f[ l [ g [ g b\ b                                                   =  =  = b\ ~\ v ] q ] l ]^ g x^ b $_ ] D_ X                                                =  =  =  D_ !` v >` q a l Nc l nc g zc b c ]                                                 =  =  = c c v c q Wd l e l e g hf b n b                                                 =  =  = n o v ?o q o l 8p g {p b 1q ] 3q ]                                                =  =  =  3q bq v q q +r l Vr g vr b r ] r X                                                =  =  =  r s v {u q  q b q  q  q > q  q A q                                                        =  	A  v  v  v X v  v վ v  v  v  v                                                        = = 	 W v H v | v  v ] v  v : v  v ^ v                                                        = = 	^  v  v d v  v $ v  v  v  v h v                                                        = = 	h  v  v  v d v K v  v  v < v  v                                                        = = 	   v  v [ v  v X v 5 v 7 v W q ;' l                                                       =  = 	;' W' v A( q ( l ( g ) g / g k3 g 6 g                                                        =  =  6 7 v p: v < v ? v A v nE v G v I v 	K v                                                        = = 		K K v -N v qP v Q v Q v R v ~S v T v ]V v                                                        = = 	]V bW v wY v [ v d\ v _ v B_ q u_ l ` l ,b l                                                       =  = 	,b b v h v m v m v q v r v u v w v x q                                                       =  = 	x Nx v 6y v z v  } v ~ v  v  v Z v  v                                                       =  = 	  v C v  v  v  v  v | v P v = v                                                       =  = 	=  v y v Y v z v  v  v  v h v j v                                                       =  = 	j  v  v  v  v  v  q  l  l " l                                                       =  = 	" A v  v I v M v ; v  v F v  v  q                                                       =  = 	 } v d v  v t v  q  l 	 g k
 b                                                   =  =  = k
 
 v 
 q  q 
 q  q  q  q  q 
 q                                                       = =  	
 T v  v  v W v  v  v  v  q  l                                                       =  = 	  v  q  l  g 0# b K& b & ]                                                     =  =  = & Z, v , q j- l . l . g / b [3 ]                                                    =   =  = [3 5 v 7 v b9 v 9 v < v v> v 2? v S? q B l                                                       =  = 	B B v C q C q E q F q  G q :I q VI q I q                                                       = =  	I I v WK v L v M v cN v O v O v Q v WR v                                                       = = = 	WR R v `S v uS q W l X l BY l tY l  [ l D\ l                                                       =  = 	D\ \ v \ q ] q l] l ^` l ` l za l b l 5c l                                                       =  = 	5c Bc v d q e l h g  i g tj g j b                                                          =  =  j nk v n v  v  q ł l  l * g } b                                                   =  =  = } 5 v T q  l n l  l ܌ l  l  g                                                   =  =  =  ݍ v | v / v  v 5 v P q  l P l  l                                                       =  = 	 - v i v  q  l Γ l  l e l  l                                                             =  =  $ v  q ؖ q  q Y q  q  l ! g                                                        =  =  ! Q v  v  v F v  v ՙ q Y l w g                                                         =  = w  v  q u l  l T l  l k l p l _ l                                                       =  = 	_ ߦ v  q  l  l Ч g  b  ]                                                     =  =  =   v  q 5 l K g  b ʱ ] ʳ X                                               =  =  =  = ʳ ߳ v $ q = l  g E b  ]  X                                                =  =  =   λ v  q ' l E g  b , ]  X                                               =  =  =  =   v K q \ l  g  b y ]  X                                                =  =  =    v  q  l  g  b 	 ]   X                                               =  =  =  =   & v  q  l  g  b  ] 0 X                                                =  =  =  0 ! v 7 q n l  g T b  ] 7 X                                               =  =  =  = 7 q v  q 
 l # g E b } ]  X                                                =  =  =    v   q   l   g : b g ] j X                                               =  =  =  = j  v ~	 q 	 l  g  b  ]  X                                                =  =  =   5 v c q I l | g e b  ] " X                                               =  =  =  = " " v X, q g, l 10 g @0 b 1 ] 1 X                                                =  =  =  1 
3 v 3 q 4 l 4 g G6 b m6 ] 7 X                                               =  =  =  = 7 7 v 9 q 9 l M< g g< b D ] E X                                                =  =  =  E F v G q N l N g iO b O ] V X                                               =  =  =  = V V v w` q ` l ` g c g d b Qd ]                                               = =  =  =  Qd s v 4s q 1u l Su g w b (w ] x X                                               =  =  =  = x x v >z q Zz l } g } b  ]  X                                                =  =  =    v ; q h l  g b b  ] ɏ X                                               =  =  =  = ɏ  v ! q ͒ q  l  g  b  ]                                               = =  =  =   2 v V q  l ܮ g  b հ ] U X                                               =  =  =  = U k v  q  l v g  b r ]  X                                                =  =  =    v  q + l X g  b D ] j X                                               =  =  =  = j  v  q 	 l 4 g U b  ] + X                                                =  =  =  + D v X q = l V g  b  ]  X                                               =  =  =  =   v  q  l  g ( b 2 ] Z X                                                =  =  =  Z  v 
 v % v  v 9	 v [ v # v # q 
% l                                                       =  = 	
% *& v B& q ]' l ' l  ( g I) b ) b                                                         =  =  = )  * v 6. q p. l 4 g  5 b < ] = X                                                =  =  =  = @ v A q A l A g 4B b aB ] D X                                               =  =  =  = D D v D q E l _H g H b J ] K X                                                =  =  =  K K v L q $M l JM g O b O ] O ]                                                 =  =  = O O v V q V l X g 7X b Y ] 0Y X                                                =  =  =  0Y Y v Z q "Z q ?Z l UZ g kZ g Z g 3[ b                                                 =  =  = 3[ I[ v _[ v >\ q O\ l \ g \ b \ b                                                        =  =  \ \ v ] q a] l w] g ] g ] b ] ]                                                     =  =  = ] ^ v ^ q ^ l ^ l ^ l _ g _ b                                                      =  =  _ _ v #` q \` l ` g c b c ] c X                                                 =  =  = c g v 9g q pl l l g o b mo b p b "q b                                                 =  =  = "q q v t v u v } v } v & v 5 v  v t v                                                       =  = 	t  v  v  v L v ڋ v  q ! q  l ? l                                                       =  = 	? \ v  v  q Ԗ l ɛ l  g  b  b                                                   =  =  =  ў v  v  v ` v  q  l ^ l v l                                                   =  =  = v  v  q ̫ q  l 6 g d b  ]                                                    =  =  =   ά v 
 q 6 l s g Ԯ g m g  g T g                                                  =  =  T  v  q k l Y l 8 l  l  l v l  l                                                       =  = 	 . v  v  v  v  v  v V v  v  v                                                       =  = 	  v  v   v K	 v )
 v  v D v ~ q                                                        =  = 	  v  q  l & l G g  g : g  g                                                        =  =    v 1 v  v  v ^ v  v  v   v ! v                                                        = = 	! % v /& v & v y' v ( v ) v * v + v c, v                                                        = = 	c, , v ~- v . v K. v y. v . v . v / v M/ v                                                        = = 	M/ / v 1 v 1 v 93 v 4 v 5 q N5 l 5 g                                                         =  = 5 5 v 6 q H6 l 6 g 6 b 7 ] B7 X                                               =  =  =  = B7 7 v 7 q 8 l <8 g 8 b 8 ]  9 X                                                =  =  =   9 M9 v 9 q 9 l $: g c: g : g ; b                                                = =  =  = ; ; v ; o@ q @ l /A g wA b 1B ]                                                =  =  =  1B vB v <C q C q C l (D l D g D b ,E b                                                  =  =  ,E F v \F q cH l H g I b BI ] tI ]                                                     =  =  = tI I v I v 
J v <J v iJ q J l J l M g                                                 = =  =  M 6M v hM v M v M q 
N l :N l O g P b                                                  =  =  P EP v wP v P v Q v Q q Q l Q l R l .R l                                                        =  	.R yR v R v R v S v QS v S q S l S l /T l                                                        =  	/T |T v T v T v U v !U v PU v mU v U v U q                                                        =  	U V v TV v |V v V v W q HW l W g W b                                                    =  =  W Z v oZ q Z l Z g Z g [ g <[ g [ g                                                     =  = [ [ v [ q !] l T_ l <` l ` l b l d l e l                                                       =   	e h v i v i v j q Sk l m l nn l n g                                                         =  = n }o v ;p v q v q v gs v {s v s v Dy v t{ v                                                       =  = 	t{ ]| v M} v } v ~ v c v  v  v v v ̂ v                                                       =  = 	̂ c v  v ! v  v  v ) v z v  v  v                                                       =  = 	 ѕ v  v ϖ v b v  v  v ј v  v  v                                                       =  = 	 u v  v  q  l  l  l 	 g  b                                                   =  =  =  î v  v  v  q  l  g ) b } b                                                   =  =  = }  v  v ! v j v $ v  v , v  v  v                                                       =  = 	  v  v G v _ q  l X l  l M l ! l                                                       =  = 	! \ v  v  q  l  g  g L g  g                                                        =   =   v : v E v  v  q { l Z l r l  l                                                       =  = 	  v ` v x q  l  l ' l [ l ! l  l                                                       =  = 	  v  v  v  q X l p l  l  l } l                                                       =  = 	}  v T q  q  q : l v g } g  g                                                        =  =   ? v z q  q f q  l  g / b                                                          =  =  /  v E v & v p v  v ; q u l  g                                                     =  =  	 v  v , q  l H l o l  l  g                                                     =  =   v  v  v m v  v  v  q ! l =" l                                                       =  = 	=" " v 0% v & v \& v ' v 2) v c) q + l                                                             =  = + #+ v 2+ q + l , l , l - g -. b                                                         =  =   -. J. v . q 4 q 74 l 5 g S5 g 6 g 7 g                                                   = =  =  7 i8 v 8 v ;; v ; v G< v < v < v = v > v                                                        = = 	> @ v 0@ q t@ l @ l PC l C l uD l D g                                                         =  = D E v zF v G v G q G l G g wH b I b                                                   =  =  = I I v K v L v DL v L v M v 0N v O v ^O v                                                       =  = 	^O O v kP v P v Q v UT v U v W v Y v x] v                                                       =  = 	x] ` v a q a l Ed l Xe l kf l Qg l g l i l                                                       =  = 	i 'i v Xk q pk l ]n g mn b o ] Rq ]                                                    =  =  =  Rq r v Dt v u v w v x v x v ly v z v { v                                                        = = 	{ } v } q } l ~ l  l Ȃ l Y l q g                                                         =  = q  v 1 v Z v ҈ v  v ? v ъ v  v  q                                                       =  = 	 & v  v  v  v 
 q ŝ l > l  l + l                                                       =  = 	+ z v Ρ v ` v  v  v t v զ v O v s q                                                       =  = 	s  v % v T v  v  v 2 v l v  v J v                                                       =  = 	J Y v o q  l ʵ l ^ l  l  l ߺ l O l                                                       =   	O s v  v E v ) v  v ' v 9 v a v L v                                                       =  = 	L ; v v v  v n v 4 v \ v  v p v  v                                                       =  = 	  v ' v  v  q Y l  l  l H l  l                                                       =  = 	  v g v  v  v / v h v  v y v  v                                                       =  = 	 @ v 
 v  v  v b v  v  v ) v < v                                                       =  = 	< " v  v  v  q  l  l  l  g                                                         =  =  W v 9 v % v 2	 v 
 v b v  v  v r
 v                                                       =  = 	r
 b v t v  v d v f v  v  v   v } v                                                       =  = 	}  v H v  v  v  v  v b v  v A v                                                       =  = 	A  v   v " v %" q " l $ l |$ l % l $& l                                                       =  = 	$& ( v ( v ) v * v , v n- v . v / v 61 v                                                       =  = 	61 G2 v 2 v H4 v I5 v b5 q 5 l x7 l 8 l 8 l                                                       =  = 	8 : v 6; v ; v = v > v > v ? v @ v @ v                                                       =  = 	@ A v ,B v XB v AC v D v E v F v G v H v                                                       =  = 	H zI v J v fK v {L v OM v tM v O v O q P l                                                       =  = 	P R v ZR v S v S v eT v UU v W v 9X v iX v                                                       =  = 	iX /Y v pY v 6Z v [ v [ v \ v \ v ] v c] v                                                       =  = 	c] ] v ] q A^ l ^ l M_ l _ l ` l 'a l b l                                                       =  = 	b ,c v Rd v d v e v ng v rj v k v l v m v                                                       =  = 	m an v Ho v vo v o v Pq v 9r v gr v r v mu v                                                       =  = 	mu u v Mv q 3x q x q y q ?y l h} g } b                                                    =  =  } } v .~ q {~ q  q M q  q : q . q  q                                                        =  	 t v  v  q y l  l  l  l o l                                                             =  = o  v  q * q = q  q  l ۖ g  g                                                        =  =   V v  v  q  l L l ^ g ܞ b  b                                                   =  =  =   v   v  v / v  v x v J v  v  q                                                       =  = 	  v  q Y l k g ݶ b  ] B X                                               =  =  =  = B } v  v ջ v  q  l  l  l  l                                                 =  =  =   v  q  q  l  g  g  g  b                                                  =  =    v  v g v z v  q k l  g  b                                                 =  =  =   v  v ( v 7 q j l  l 4 l  l  l                                                       =  = 	  v  v % q , l   l : l % l U l  l                                                       =  = 	  v  v  v  q [ l  l  l  g                                                         =  =   v  v  v v v  v - v ; q  l  l                                                       =  = 	 5 v V v T	 v g	 q 6	 l 	 l 	 l 	 l 	 l                                                       =  = 		 {	 v 	 v 	 q 	 l +	 l 	 l 		 l V		 l 
	 l                                                       =  = 	
	 G	 v c	 v t	 q *	 l 	 l 	 l F	 l 	 l V	 l                                                       =  = 	V	  	 v 
!	 q !	 l Q"	 l ]#	 l f#	 g $	 b $	 b                                                   =  =  = $	 $	 v %	 v '	 v '	 q ;(	 l *)	 l @)	 g )	 b                                                   =  =  = )	 .	 v j/	 v /	 q 	0	 l 1	 l =2	 l 2	 l 2	 g                                                   =  =  = 2	 5	 v ;5	 q Y5	 l c5	 g y7	 g 7	 b $8	 ]                                                    =  =   = $8	 j8	 v y8	 v h9	 v :	 v ,<	 v _>	 v ?	 v <@	 v }@	 q                                                         = 	}@	 @	 v LA	 v @C	 v C	 v $R	 v PR	 q R	 l T	 l U	 l                                                       =  = 	U	 :U	 v U	 v 9X	 v [	 v d	 v e	 v e	 q e	 l g	 l                                                       =  = 	g	 g	 v i	 v i	 q j	 l k	 l m	 l ,n	 l o	 l o	 l                                                       =  = 	o	 p	 v {p	 v ]q	 v s	 v t	 v u	 v 7w	 v kx	 v y	 v                                                       =  = 	y	 z	 v {	 v }	 v |~	 v ~	 v ~	 v 	 v 	 v 	 v                                                       =  = 		 &	 v A	 q n	 q ~	 l 	 g L	 b r	 ]                                                     =  =  = r	 	 v 	 q o	 l 	 g q	 b 	 ] $	 X                                               =  =  =  = $	 M	 v 	 q Ǘ	 l >	 g b	 b 	 ] :	 X                                                =  =  =  :	 0	 v H	 q |	 l 	 g ѩ	 b 	 ] 	 X                                               =  =  =  = 	 	 v 	 q ϯ	 l 	 g ϶	 b Ϻ	 ] 	 ]                                               = =  =  =  	 	 v 	 v 	 v :	 q ]	 l 	 g 	 b                                               = =  =   = 	 	 v 	 q Q	 l q	 g +	 b T	 ] 	 X                                               =  =  =  = 	 	 v 	 q 	 q ,	 q V	 l 	 g 	 g 	 g                                                 = =  =  	 	 v 	 q 	 l 	 g 	 b  
 b  
 ]                                                     =  =  =  
 
 v ;
 v j
 q 	
 l I
 l N
 l 
 g 
 b                                                 =  =  = 
 
 v 
 q 
 l 
 g '
 b 6'
 ] !*
 X                                               =  =  =  = !*
 Y*
 v /
 q /
 l /
 g 
0
 b 60
 ] f0
 X                                                =  =  =  f0
 %1
 v U1
 q 2
 l 2
 g 3
 b 3
 ] 4
 X                                               =  =  =  = 4
 4
 v J:
 q p:
 l :
 g :
 g ?
 g ?
 b                                               =   =  =  ?
 C
 v C
 q C
 l D
 g )E
 g H
 g H
 g M
 g                                                  =   = M
 	R
 v ;R
 v 0T
 v U
 v kU
 v X
 v X
 q Y
 l m
 l                                                       =  = 	m
 m
 v n
 q u~
 l p
 l 
 g $
 b 
 b                                                         =  =  = 
 
 v H
 q 
 q 
 q w
 q [
 q :
 q 
 q h
 q                                                       = =  	h
 
 v 
 v  
 v w
 v 
 v  
 q n
 l ޤ
 l 
 l                                                       =  = 	
 {
 v 
 v ٧
 v =
 v $
 v 
 v '
 v 
 v B
 v                                                       =  = 	B
 
 v "
 v 
 v ,
 v L
 q 
 l Į
 l }
 l 
 l                                                       =  = 	
 @
 v *
 v 
 v 
 v 
 v m
 v 
 v 
 v 
 v                                                       =  = 	
 
 v 
 q ˽
 l 
 l _
 l 
 l ;
 l ]
 g                                                         =  = ]
 
 v :
 v 
 v a
 v 
 v S
 v 
 v 
 v h
 v                                                       =  = 	h
 
 v (
 v q
 v 
 v 

 v V
 v v
 q 
 l 
 l                                                       =  = 	
 *
 v 
 v u
 v 
 v 
 v h
 v 
 v 
 q 
 l                                                       =  = 	
 
 v 
 v 
 v 
 v 
 q [
 l 
 l ,
 l 
 l                                                       =  = 	
 H
 v 
 v 
 v e
 v 3
 v 
 v '
 v 
 v 
 v                                                       =  = 	
 
 v 
 v {
 v 
 q 
 l 
 l e
 l 
 l 
 l                                                       =  = 	
 (
 v 
 q =
 q 
 q 
 q 
 q 
 q 
 q 
 q                                                       = =  	
 V
 v o
 q W
 l <
 l 	  l  l  l , l U l                                                       =  = 	U  v  v 	 v 	 q t l & l ' l (                                                             =  = 	              3
     9	  7  #  '  3  :  D  yE  mQ  Z  e_  d  o  y    ]               n          + 1 C< H lP Z c n t J s   ص     w      O( 2 T< G P X Db 1m Mu o~  L Ş  (    &     t N H [ % 2 > J X qd Kn Mz  А o  	   j + o 
  d    O" + 4 ; iF N 0V c r y  I w a '   O  {   Z     b' - f4 r@ G $O vY (^ f Rq ~ Z T ޢ    > 	     & P% - 6 @ I Q 
W 5b o }  O  k    r     e $ _. 18 D 8O Y e s     ʳ        + [) 6 B P X\ f t   +  ]     c 	  
	 	 0'	 2	 ?	 C	 3R	 N[	 .i	 v	 ~	 	 (	 	 A	 ,	 	 3	 	 	 +	 ,	 /	
 
 

 )
 H3
 K:
 D
 L
 T
 X
 oh
 om
 }
 
 
 
 
 N
 
 
 )
 `
 _
 
 P 	             ,            6             :                 	     
 X      v          
       a      +     U                                `
          '     '     
                     V            B    ! [	    "      # |    $ C     % x    & x    ' o    (     ) _    * S    +     , 4    -     . Z    /      0 m    1     2 [    3     4 
    5 -    6     7     8 (    9      : 9    ;     <      = +    >     ? %    @ %    A I    B     C      D P    E     F s
    G r    H     I     J W    K      L <    M      N U    O     P     Q     R 8    S     T     U     V     W      X 4     Y W     Z      [     \ ?     ]     ^ 	    _ 	    `     a k    b     c V     d -    e     f 	    g     h     i     j     k G    l 	    m     n %    o M    p      q %     r     s Q    t     u ~    v ^    w ^    x R    y 9    z '    {     | %     }      ~ "     "     @     g                                           _                G                a     T      _     	     (     (     	     K                _      .      G                                     !                                                            '                2          d                      f           &           /     F          %      7     e     V           A           
                ~     E                                 d     e      L           i     0          i           U           k                               4     (                         #           	                    )               z	                     r          4                              N           Z                 B     ~        7                           ;                (       09.12.9006.06.90 