** Programmer's Technical Reference for MSDOS and the IBM PC ** USA copyright TXG 392-616 ALL RIGHTS RESERVED ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ DOSREF (tm) ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ISBN 1-878830-02-3 (disk-based text) Copyright (c) 1987, 1994 Dave Williams ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Shareware Version, 01/20/94 ³ ³ Please Register Your Copy ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The rest of the chapters aren't included in this shareware demonstration package. Since the complete manual takes about 2000 Kb even compressed in LHarc format, something had to give somewhere. Here's a sample of what you're missing: Appendices Mouse API Networking EMS XMS VCPI Video chip-level stuff 386 Multiware API MS TSR Specification Alloy NTNX API Concurrent DOS/386 API MultiDOS Plus API PC-MOS/386 API Sound Blaster programming NDIS network spec X-DOS 3.3 info VMiX/386 API working TSR samples VESA APIs MORE! TABLE OF CONTENTS INTRO Introduction, credits, copyrights CHAPTER 1 DOS and the PC Some History ..................................................... 1**1 What is DOS? ..................................................... 1**2 Other Operating Systems .......................................... 1**3 Specific Versions of MS/PC-DOS ................................... 1**4 The Operating System Heirarchy ................................... 1**5 DOS Structure .................................................... 1**6 DOS Initialization ............................................... 1**7 CHAPTER 2 Low Memory and Absolute Addresses Introduction ..................................................... 2**1 System Memory Map ................................................ 2**2 A Brief Guide to Current Memory Terminology ...................... 2**3 PC Port Assignment ............................................... 2**4 Reserved Memory Locations ........................................ 2**5 Absolute Addresses ............................................... 2**6 The IBM PC System Interrupts (Overview) .......................... 2**7 Quick Chart of Interrupts 00h-0FFh ............................... 2**8 IRQ Usage Chart .................................................. 2**9 The IBM-PC System Interrupts 00h-0Fh (in detail) ................. 2**10 CHAPTER 3 ROM BIOS and Serice Interrupts Calling the ROM BIOS ............................................. 3**1 Interrupt 10h Video Services .................................... 3**2 Interrupt 11h Equipment Check ................................... 3**3 Interrupt 12h Memory Size ....................................... 3**4 Interrupt 13h Disk Functions .................................... 3**5 Interrupt 14h Initialize and Access Serial Port ................. 3**6 FOSSIL Drivers ................................................... 3**7 Interrupt 15h Cassette I/O ...................................... 3**8 Interrupt 16h Keyboard I/O ...................................... 3**9 Interrupt 17h Printer ........................................... 3**10 Interrupt 18h ROM BASIC ......................................... 3**11 Interrupt 19h Bootstrap Loader .................................. 3**12 Interrupt 1Ah Time of Day ....................................... 3**13 Interrupt 1Bh Control-Break ..................................... 3**14 Interrupt 1Ch Timer Tick ........................................ 3**15 Interrupt 1Dh Vector of Video Initialization Parameters ......... 3**16 Interrupt 1Eh Vector of Diskette Controller Parameters .......... 3**17 Interrupt 1Fh Ptr to Graphics Char Extensions (Graphics Set 2) .. 3**18 CHAPTER 4 DOS Function Requests General Programming Guides ....................................... 4**1 DOS Registers .................................................... 4**2 DOS Stacks ....................................................... 4**3 DOS Interrupts ................................................... 4**4 Interrupt 20h (Terminate) ........................................ 4**5 DOS Services (quick list) ........................................ 4**6 Calling the DOS Services ......................................... 4**7 Version Specific Information ..................................... 4**8 Compatibility Problems With DOS 4.0+ ............................. 4**9 PCjr Cartridge Support ........................................... 4**10 eDOS 4.0 ......................................................... 4**11 DOS Services in Detail ........................................... 4**12 CHAPTER 5 Interrupts 22h through 0FFh Interrupt 22h Terminate Address ................................ 5**1 Interrupt 23h Ctrl-Break Exit Address .......................... 5**2 Interrupt 24h Critical Error Handler ........................... 5**3 Interrupt 25h Absolute Disk Read ............................... 5**4 Interrupt 26h Absolute Disk Write .............................. 5**5 Interrupt 27h Terminate And Stay Resident ...................... 5**6 Interrupt 28h (not documented by Microsoft) .................... 5**7 Interrupt 29h (not documented by Microsoft) .................... 5**8 Interrupt 2Ah Microsoft Networks - Session Layer Interrupt ..... 5**9 Interrupt 2Bh Unknown .......................................... 5**10 Interrupt 2Ch Unknown .......................................... 5**11 Interrupt 2Dh Unknown .......................................... 5**12 Interrupt 2Eh Alternate EXEC (DOS 2.0+) ........................ 5**13 Interrupt 2Fh Multiplex Interrupt .............................. 5**14 Interrupt 30h FAR jump instruction for CP/M-style calls ........ 5**15 Interrupt 31h Unknown .......................................... 5**16 Interrupt 32h Unknown .......................................... 5**17 Interrupt 33h Used by Microsoft Mouse Driver Function Calls .... 5**18 Interrupt 34h Turbo C/Microsoft languages - Floating Point .... 5**19 Interrupt 35h Turbo C/Microsoft languages - Floating Point .... 5**20 Interrupt 36h Turbo C/Microsoft languages - Floating Point .... 5**21 Interrupt 37h Turbo C/Microsoft languages - Floating Point .... 5**22 Interrupt 38h Turbo C/Microsoft languages - Floating Point .... 5**23 Interrupt 39h Turbo C/Microsoft languages - Floating Point .... 5**24 Interrupt 3Ah Turbo C/Microsoft languages - Floating Point .... 5**25 Interrupt 3Bh Turbo C/Microsoft languages - Floating Point .... 5**26 Interrupt 3Ch Turbo C/Microsoft languages - Floating Point .... 5**27 Interrupt 3Dh Turbo C/Microsoft languages - Floating Point .... 5**28 Interrupt 3Eh Turbo C/Microsoft languages - Floating Point ..... 5**29 Interrupt 3Fh Overlay Manager Interrupt (Microsoft LINK.EXE) ... 5**30 Interrupt 40h Hard Disk BIOS ................................... 5**31 Interrupt 41h Hard Disk Parameters ............................. 5**32 Interrupt 42h Pointer to screen BIOS entry ..................... 5**33 Interrupt 43h Pointer to EGA Graphics Character Table .......... 5**34 Interrupt 44h Pointer to graphics character table .............. 5**35 Interrupt 45h Reserved by IBM (not initialized) ............... 5**36 Interrupt 46h Pointer to second hard disk parameter block ...... 5**37 Interrupt 47h Reserved by IBM (not initialized) ............... 5**38 Interrupt 48h Cordless Keyboard Translation .................... 5**39 Interrupt 49h Non-kbd Scan Code Translation Table Addr (PCjr) .. 5**40 Interrupt 4Ah Real-Time Clock Alarm (Convertible, PS/2) ........ 5**41 Interrupt 4Bh Reserved by IBM (not initialized) ............... 5**42 Interrupt 4Ch Reserved by IBM (not initialized) ............... 5**43 Interrupt 4Dh Reserved by IBM (not initialized) ............... 5**44 Interrupt 4Eh Reserved by IBM (not initialized) ............... 5**45 Interrupt 4Fh Reserved by IBM (not initialized) ............... 5**46 Interrupt 50-57 IRQ0-IRQ7 Relocation ............................. 5**47 Interrupt 58h Reserved by IBM (not initialized) ............... 5**48 Interrupt 59h Reserved by IBM (not initialized) ............... 5**49 Interrupt 5Ah Reserved by IBM (not initialized) .............. 5**50 Interrupt 5Bh Reserved by IBM (not initialized) ............... 5**51 Interrupt 5Ah Cluster Adapter BIOS entry address ............... 5**52 Interrupt 5Bh Reserved by IBM (not initialized) ............... 5**53 Interrupt 5Ch NETBIOS interface entry port, TOPS ............... 5**54 Interrupt 5Dh Reserved by IBM (not initialized) ............... 5**55 Interrupt 5Eh Reserved by IBM (not initialized) ............... 5**56 Interrupt 5Fh Reserved by IBM (not initialized) ............... 5**57 Interrupt 60h-67h User Program Interrupts ....................... 5**58 Interrupt 60h Network OS Interface ............................. 5**59 Interrupt 67h Expanded Memory Board Driver Interrupt ........... 5**60 Interrupt 68h Not Used (not initialized) ...................... 5**61 Interrupt 69h Not Used (not initialized) ...................... 5**62 Interrupt 6Ah Not Used (not initialized) ...................... 5**63 Interrupt 6Bh Not Used (not initialized) ...................... 5**64 Interrupt 6Ch System Resume Vector (Convertible) ............... 5**65 Interrupt 6Dh Not Used (not initialized) ...................... 5**66 Interrupt 6Eh Not Used (not initialized) ...................... 5**67 Interrupt 6Fh 10-Net API........................................ 5**68 Interrupt 70h IRQ 8, Real Time Clock Int (AT, XT/286, PS/2) .... 5**69 Interrupt 71h IRQ 9, Redirected to IRQ 8 (AT, XT/286, PS/2) .... 5**70 Interrupt 72h IRQ 10 (AT, XT/286, PS/2) Reserved ............. 5**71 Interrupt 73h IRQ 11 (AT, XT/286, PS/2) Reserved ............. 5**72 Interrupt 74h IRQ 12 Mouse Interrupt (PS/2) ................... 5**73 Interrupt 75h IRQ 13, Coprocessor Error (AT) ................... 5**74 Interrupt 76h IRQ 14, Hard Disk Controller (AT, XT/286, PS/2) .. 5**75 Interrupt 77h IRQ 15 (AT, XT/286, PS/2) Reserved .............. 5**76 Interrupt 78h Not Used ......................................... 5**77 Interrupt 79h Not Used ......................................... 5**78 Interrupt 7Ah Reserved ......................................... 5**79 Interrupt 7Bh-7Eh Not Used by IBM ............................... 5**80 Interrupt 7Ch REXX-PC API ...................................... 5**81 Interrupt 7Fh IBM 8514/A Graphics Adapter API .................. 5**82 Interrupt 80h-85h Reserved by BASIC ............................. 5**83 Interrupt 86h Int 18 when relocated by NETBIOS ................. 5**84 Interrupt 86h-0F0h Used by BASICA ............................... 5**85 Interrupt 0A4h Right Hand Man API ............................... 5**86 Interrupt 0D4h PC-MOS/386 API ................................... 5**87 Interrupt 0E0h Digital Research CP/M-86 function calls .......... 5**88 Interrupt 0E1h PC Cluster Disk Server Information ............... 5**89 Interrupt 0E2h PC Cluster Program ............................... 5**90 Interrupt 0E4h Logitech Modula-2 v2.0 Monitor Entry ........... 5**91 Interrupt 0E5h Not Used ......................................... 5**92 Interrupt 0E6h Not Used ......................................... 5**93 Interrupt 0E7h Not Used ......................................... 5**94 Interrupt 0E8h Not Used ......................................... 5**95 Interrupt 0E9h Not Used ......................................... 5**96 Interrupt 0EAh Not Used ......................................... 5**97 Interrupt 0EBh Not Used ......................................... 5**98 Interrupt 0ECh Not Used ......................................... 5**99 Interrupt 0EDh Not Used ......................................... 5**100 Interrupt 0EEh Not Used ......................................... 5**101 Interrupt 0EFh GEM interface (Digital Research) ................. 5**102 Interrupt 0F0h unknown .......................................... 5**103 Interrupts 0F1h-0FFh (absolute addresses 3C4h-3FFh) ............. 5**104 Interrupt 0F4h Not Used ............ ............................ 5**105 Interrupt 0F5h Not Used ............ ............................ 5**106 Interrupt 0F8h Set Shell Interrupt (OEM) ........................ 5**107 Interrupt 0F9h Reserved ......................................... 5**108 Interrupt 0FAh USART ready (RS-232C) ............................ 5**109 Interrupt 0FBh USART RS ready (keyboard) ........................ 5**110 Interrupt 0FCh Unknown ...........................................5**111 Interrupt 0FDh reserved for user interrupt ...................... 5**112 Interrupt 0FEh reserved by IBM .................................. 5**113 Interrupt 0FFh reserved by IBM .................................. 5**114 CHAPTER 6 DOS Control Blocks and Work Areas DOS Address Space ................................................ 6**1 Storage Blocks ................................................... 6**2 Disk Transfer Area (DTA) ......................................... 6**3 Program Segment Prefix ........................................... 6**4 Memory Control Blocks ............................................ 6**5 DOS Program Segment .............................................. 6**6 CHAPTER 7 DOS File Information File Management Functions ........................................ 7**1 FCB Function Calls ............................................... 7**2 Handle Function Calls ............................................ 7**3 Special File Handles ............................................. 7**4 Raw and Cooked File I/O .......................................... 7**5 Number of Open Files Allowed .................................... 7**6 Restrictions on FCB Usage ........................................ 7**7 Restrictions on Handle usage ..................................... 7**8 Allocating Space to a File ....................................... 7**9 MSDOS / PCDOS Differences ........................................ 7**10 .COM File Structure .............................................. 7**11 .EXE File Structure .............................................. 7**12 The Relocation Table ............................................. 7**13 "NEW" .EXE Format (Microsoft Windows and OS/2) ................... 7**14 Standard File Control Block ...................................... 7**15 Extended File Control Block ...................................... 7**16 Disk Transfer Area ............................................... 7**17 CHAPTER 8 DOS Disk Information The DOS Area ..................................................... 8**1 The Boot Record .................................................. 8**2 DOS File Allocation Table (FAT) .................................. 8**3 Media Descriptor Byte .................................... 8**4 12 Bit FATs .............................................. 8**5 16 Bit FATs .............................................. 8**6 Cluster Size Information ......................................... 8**7 DOS Disk Directory ............................................... 8**8 The Data Area .................................................... 8**9 Floppy Disk Types ................................................ 8**10 Hard Disk Layout ................................................. 8**11 System Initialization ............................................ 8**12 Boot Record/Partition Table ...................................... 8**13 Hard Disk Technical Information .................................. 8**14 Determining Hard Disk File Allocation ............................ 8**15 BIOS Disk Functions .............................................. 8**16 CHAPTER 9 DOS Device Drivers CHAPTER 10 EMS, EEMS, and VCPI Memory Specifications History .......................................................... 10**1 Uses of Expanded Memory .......................................... 10**2 DOS and Expanded Memory .......................................... 10**3 Different Memory Types ........................................... 10**4 AST/Quadram/Ashton-Tate Enhanced EMM ............................. 10**5 EMS Address Space Map ............................................ 10**6 Writing Programs That Use Expanded Memory ........................ 10**7 Page Frames ...................................................... 10**8 Calling the Manager .............................................. 10**9 Detecting EMS .................................................... 10**10 Terminate and Stay Resident (TSR) Program Cooperation ............ 10**11 Expanded Memory Services Quick List .............................. 10**12 Expanded Memory Services ......................................... 10**13 LIM 3.2 Specification .................................... 10**14 LIM 4.0 Specification .................................... 10**15 AQA EEMS 3.2 Specification ............................... 10**16 VCPI API 1.0 ............................................. 10**17 Expanded Memory Manager Error Codes .............................. 10**18 CHAPTER 11 Microsoft Extended Memory (XMS) Specification CHAPTER 12 TSR Programming CHAPTER 13 PC-MOS/386 Application Program Interface Introduction ..................................................... 13**1 Programming For PC-MOS ........................................... 13**2 Extended Services Interrupt ...................................... 13**3 MOS Extended Services in Detail .................................. 13**4 ESI Error Codes .................................................. 13**5 PC-MOS Data Structures ........................................... 13**6 Terminal Device Interface ........................................ 13**7 Serial Device Interface .......................................... 13**8 NETBIOS Interface ................................................ 13**9 Memory Manager Interface ......................................... 13**10 INT 6 Handler .................................................... 13**11 User's Overview .................................................. 13**12 CHAPTER 14 Concurrent DOS/386 Application Program Interface Introduction ..................................................... 14**1 General Programming Guides ....................................... 14**2 Quick Function List .............................................. 14**3 AUX Functions .................................................... 14**4 CONSOLE Functions ................................................ 14**5 DEVICE Functions ................................................. 14**6 DRIVE Functions .................................................. 14**7 FILE Functions ................................................... 14**8 LST Functions .................................................... 14**9 MEMORY Functions ................................................. 14**10 PROCESS Functions ................................................ 14**11 QUEUE Functions .................................................. 14**12 SYSTEM Functions ................................................. 14**13 TIME Functions ................................................... 14**14 CHAPTER 15 Register-Level Programming 8255 Peripheral Interface ........................................ 15**1 8259 Interrupt Controller ........................................ 15**2 AT CMOS RAM Configuration ........................................ 15**3 8250 Serial UART ................................................. 15**4 8327 DMA Controller .............................................. 15**5 8253 Triple Timer ................................................ 15**6 NEC 765 Diskette Controller....................................... 15**7 CHAPTER 16 Video Programming Quick List of BIOS Interrupt 10h Functions ....................... 16**1 PC Video Subsystems .............................................. 16**2 BIOS Interrupt 10h Functions in Detail ........................... 16**3 CHAPTER 17 Multitasking Shells Introduction ..................................................... 17**1 Programming Practices ............................................ 17**2 TopView/DESQview API (interrupt 15h, "System Services" interface) 17**3 TopView/DESQview API (interrupt 16h, "BIOS Video" interface) ..... 17**4 CHAPTER 18 Viruses and Trojan Horses CHAPTER 19 Tips and Tricks CHAPTER 20 Conversion Between Operating Systems Overview ......................................................... 20**1 Special Considerations ........................................... 20**2 Example Operating Systems ........................................ 20**3 Atari ST ......................................................... 20**4 CP/M ............................................................. 20**5 MacOS ............................................................ 20**6 AmigaDOS ......................................................... 20**7 OS/2 ............................................................. 20**8 UNIX ............................................................. 20**9 CHAPTER 21 Microsoft Virtual DMA Specification 1.0 Introduction ..................................................... 21**1 VDS Function List ................................................ 21**2 VDS Functions .................................................... 21**3 DMA Descriptor Structure ......................................... 21**4 DX Flag Bits ..................................................... 21**5 VDS Error Codes .................................................. 21**6 CHAPTER 22 Mouse Programming General Information .............................................. 22**1 Register Usage ................................................... 22**2 Interrupt 33h Function Requests .................................. 22**3 Interrupt 10h Function Requests .................................. 22**4 CHAPTER 23 Network APIs FTP Driver - PC/TCP Packet Driver Specification .................. 23**1 10-Net Network ................................................... 23**2 LANtastic LANOS API .............................................. 23**3 Novell NetWare 2.11 API .......................................... 23**4 APPC/PC .......................................................... 23**5 CHAPTER 24 MultiDos Plus API CHAPTER 25 VMiX 2.6x API What is VMiX? .................................................... 25**1 Assembler Interface .............................................. 25**2 CHAPTER 26 X-DOS 3.3 MISCSTUF Miscellaneous Stuff AFTERWRD Afterword CREDITS Credits and Bibliography A P P E N D I C E S APPENDIX 1 Keyboard scan code chart APPENDIX 2 ASCII character chart APPENDIX 3 IBM PC character set APPENDIX 4 IBM PC error code listing APPENDIX 5 Addresses of various manufacturers APPENDIX 6 Hard disk information APPENDIX 7 Floppy and Tape Devices APPENDIX 8 Pinouts of various connectors on the IBM PC APPENDIX 9 Sizes of various drivers installed in CONFIG.SYS APPENDIX 10 Common modem instruction sets APPENDIX 11 Glossary of computer terminology APPENDIX 12 Various busses used in MSDOS machines APPENDIX 13 Common filename extensions APPENDIX 14 Clock speeds of various expansion cards APPENDIX 15 Header formats used by various archive utilities APPENDIX 16 Miscellaneous Hardware Information APPENDIX 17 HP LaserJet Setup Codes APPENDIX 18 ANSI.SYS Escape Sequences APPENDIX 19 DEC VT100 Escape Sequences APPENDIX 20 Various Paint Program Formats APPENDIX 21 Some Commonly Used Hot-Keys APPENDIX 22 Sound Blaster API APPENDIX 23 French-Canadian accented character chart APPENDIX 24 Compuserve Graphic Image Format '89a APPENDIX 25 Hex Chart APPENDIX 26 Microsoft TSR Specification 1.0 APPENDIX 27 Baud vs BPS Explained APPENDIX 28 Borland BGI Stroked Font .CHR File Format APPENDIX 29 Differences From DOS 4.0 In The OS/2 1.3 DOS Box APPENDIX 30 IBM Interrupt Sharing Protocol APPENDIX 31 CCITT v.XX Protocol Overview APPENDIX 32 CCITT x.XX Protocol Overview APPENDIX 33 Miscellaneous Switch Settings APPENDIX 34 DOS BACKUP Format APPENDIX 35 .WAV File Format