DOS Technical Reference
Total Page:16
File Type:pdf, Size:1020Kb
-------- - ---- Personal Computer - ---- - --- ------ - . - Programming Family DOS Technical Reference 6138536 Preliminary First Edition (February 1985) The following paragraph does not apply to the United Kingdom or any country where such provisions are inconsistent ~ith local law: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES TIllS PUBLICATION "AS IS" wrrnom WARRANTY OF ANY KIND, EmlER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 1HE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you. lbis publication could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and!or changes in the product(s) and/or the program(s) described in this pUblication at any time. It is possible that this publication may contain reference to, or information about, IBM products (machines and programs), programming, or services that are not announced in your country. Such references or information must not be construed to mean that IBM intends to announce such IBM products, programming, or services in your country. Products are not stocked at the address below. Requests for copies of this publication and for technical information about IBM Personal Computer products should be made to your authorized IBM Personal Computer dealer, IBM Product Center, or your IBM Marketing Representative. The following paragraph applies only to the United States and Puerto Rico: A Reader's Comment Form is provided at the back of this publication. If the form has been removed. address comments to: IBM Corporation, Personal Computer, P.O. Box 1328-C, Boca Raton, Florida 33432. IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligations whatever. © Copyright International Business Machines Corporation 1984, 1985 rreununary About This Book Read This First This book contains technical information pertaining to DOS versions 2.10, 3.00, and 3.10. Some information is specific to a version of DOS and does not apply to all versions. This book covers topics for the experienced DOS user, system programmer, and application developer. It is assumed that you are familiar with the 8088 architecture. Version Specific Information Chapters that contain information that is specific to a version of DOS, contain a section called "Version Specific Information." This section identifies the information in the chapter that is for use with a particular version of DOS. Chapters that do not contain this section contain information that applies to DOS versions 2.10, 3.00, and 3.10. iii Preliminary How This Book is Organized This book has 11 chapters. Chapter 1 contains general technical information about DOS. Chapter 2 contains detailed information about device drivers. Chapter 3 contains detailed information about using extended screen and keyboard functions to control cursor positioning and to redefine keyboard keys. Chapter 4 contains notes and considerations for proper file management. Chapter 5 describes allocation of space on a disk. Chapter 6 describes the system interrupts and function calls. Chapter 7 describes control blocks and work areas, including a memory map, program segment prefix, and file control block. Chapter 8 explains how to execute commands from within an application. Chapter 9 contains technical information about DOS support of fixed disks. Chapter 10 contains detailed information about .EXE file structure. Chapter 11 contains information about DOS memory management. iv rreununary Contents Chapter 1. DOS Technical Information •••••.•.• 1-1 Introduction ......................... 1-3 Version Specific Information ............ 1-3 DOS Structure ..................... '.. 1-4 The Boot Record ................. 1-4 Read Only Memory (ROM) BIOS Interface ....................... 1-4 The DOS Program File ............. 1-5 The Command Processor ........... 1-5 DOS Initialization ..................... 1-7 Available DOS Functions ............... 1-8 The Disk Transfer Area (DTA) .......... 1-9 Error Trapping ...................... 1-10 Chapter 2. Installable Device Drivers •••••••..•• 2-1 Introduction ......................... 2-3 Version Specific Information ............ 2-3 Device Driver Format .................. 2-4 Types of Devices ...................... 2-5 Character Devices ................. 2-5 Block Devices .................... 2-5 Device Header ....................... 2-6 Pointer to Next Device Header Field .. 2-6 Attribute Field ................... 2-7 Pointer to Strategy and Interrupt Routines ....................... 2-9 Name/Unit Field ................. 2-9 Creating a Device Driver .............. 2-10 Installing Device Drivers ............... 2-11 Installing Character Devices ........ 2-12 Installing Block Devices ........... 2-12 Request Header ..................... 2-14 Unit Code Field ................. 2-14 Command Code Field ............. 2-15 Status Field ..................... 2-16 Device Driver Functions ............... 2-18 !NIT .......................... 2-19 v Preliminary MEDIA CHECK ................ 2-21 Media Descriptor Byte ............ 2-23 BUlLD BPB (BIOS Parameter Block) 2-26 INPUf or OUfPUf .............. 2-29 NONDESTRUCTIVE INPUT NO WAIT ........................ 2-31 STAJUS ....................... 2-32 Fl.USH ........................ 2-33 OPEN or CLOSE (DOS 3.00 and 3.10) 2-34 REMOVABLE :MEDIA (nOS 3.00 and 3.10) ......................... 2-35 The CLOCKS Device ................. 2-36 Sample Device Driver ........... ~ . .. 2-36 Chapter 3. Using Extended Screen and Keyboard Control .• 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ••• 0 •• 0 e 0 0 0 3-1 Introduction ......................... 3-3 Control Sequences .................... 3-3 Control Sequence Syntax ............... 3-4 Cursor Control Sequences .............. 3-6 Cursor Position ................... 3-6 Cursor Up ....................... 3-7 Cursor Down .................... 3-7 Cursor Forward .................. 3-8 Cursor Backward ................. 3-8 Horizontal and Vertical Position ...... 3-9 Cursor Position Report ............ 3-10 Device Status Report ............. 3-10 Save Cursor Position ..... .. 3-12 Restore Cursor Position ........... 3-12 Erasing ............................ 3-13 Erase in Display ................. 3-13 Erase in Line .................... 3-13 Mode of Operation ................... 3-14 Keyboard Key Reassignment ........... 3-17 Chapter 4. File Management Notes •••••••••••. 4-1 Introduction ......................... 4-3 Version Specific Information ............ 4-3 File Management Functions ............. 4-3 FCB Function Calls ................... 4-5 Handle Function Calls ................. 4-6 Special File Handles ................... 4-8 vi Preliminary ASCn and Binary Mooe ................ 4-9 File IIO in Binary Mooe ........... 4-10 File IIO in ASCn Mooe ........... 4-11 Number of Open Files Allowed ......... 4-12 Restrictions on FCB Usage ............. 4-12 Restrictions on Handle Usage ........... 4-13 Allocating Space to a File .............. 4-14 Chapter 5. DOS Disk Allocation •••.....•••... 5-1 Introduction ......................... 5-3 Version Specific Information ............ 5-3 The DOS Area ........................ 5-4 The Boot Record ..................... 5-4 DOS File Allocation Table (FAT) ........ 5-5 How to Use the File Allocation Table for 12-Bit FAT Entries .............. 5-8 How to Use the File Allocation Table for 16-Bit FAT Entries .............. 5-9 DOS Disk Directory .................. 5-10 Directory Entries ................ 5-10 The Data Area ...................... 5-14 Chapter 6. DOS Interrupts and Function Calls •••. 6-1 Introduction ......................... 6-7 Version Specific Information ............ 6-7 DOS Registers ....................... 6-9 Extended ASCn Codes ............... 6-11 Interrupts .......................... 6-12 20H Program Terminate ........... 6-12 21H Function Request ............ 6-13 22H Tenninate Address ........... 6-13 23H Ctrl-Break Exit Address ....... 6-13 24H Critical Error Handler Vector ... 6-14 25H Absolute Disk Read .......... 6-22 26H Absolute Disk Write .......... 6-23 27H Tenninate but Stay Resident .... 6-24 28H-2EH Reserved for DOS ....... 6-25 2FH Multiplex Interrupt ........... 6-26 30H-3FH Reserved for DOS ....... 6-31 Function Calls ...................... 6-32 Listing of Function Calls .......... 6-33 DOS Internal Stack ............... 6-36 Error Return Information .......... 6-36 vii Preliminary ASCnz Strings .................. 6-44 Network Paths .................. 6-45 Network Access Rights ............ 6-45 File Handles .................... 6-46 Using DOS Functions ............. 6-47 OOH Program Terminate ............... 6-49 01H Keyboard Input .................. 6-50 02H Display Output .................. 6-51 03H Auxiliary Input .................. 6-52 04H Auxiliary Output ................. 6-53 05H Printer Output ............. .. 6-54 06H Direct ConsoleI/O ............... 6-55 07H Direct Console Input Without Echo .. 6-56 08H Console Input Without Echo ....... 6-57 09H Print String ..................... 6-58 OAH Buffered Keyboard Input .......... 6-59 OBH Check Standard Input Status ....... 6-60 OCH Clear Keyboard Buffer and Invoke a Keyboard Function ................... 6-61 ODH Disk Reset ..................... 6-62