`REFEREN‘aon
`MS - DOS, IBM PC:& COMPATIBLES
`
`L 20
`
`=
`t. handle attributes:
`|.
`handle-‘attributes
`ew‘attribute 4
`: ‘makehandle
`
`is: volatile
`8 nonvolatile «
`bility (for subfunct
`volatile handles suppo
`latile and non-volat
`ndle attribute instructs the a
`he. pages allocated,to
`le
`the fvola&ileattribute. (defaul
`24
`p and all. ex anded me
`
`ile Name Functions
`
`OLYMPUS EX.1015 - 1/393
`
`OLYMPUS EX. 1015 - 1/393
`
`
`
`THE PROGRAMMER’S
`TECHNICAL
`REFERENCE:
`MS-DOS, IBM PC & Compatibles
`
`Dave W:illiams :
`
`SIGMA PRESS - Wilmslow, United Kingdom _
`
`|
`
`OLYMPUS EX.1015 - 2/393
`
`OLYMPUS EX. 1015 - 2/393
`
`
`
`Copyright ©, D. Williams, 1990
`
`All Rights Reserved. No part of this publication may be reproduced, stored in a
`retrieval system, or transmitted in any form or by any means, electronic, mechanical,
`photocopying, recording or otherwise, without prior written permission.
`
`First published in 1990 by
`
`Sigma Press, 1 South Oak Lane, Wilmslow, Cheshire SK9 6AR, England.
`Reprinted, 1992.
`
`British Library Cataloguing in Publication Data
`
`A CIP catalogue record for this book is available from the British Library.
`
`ISBN:1-85058-199-1
`
`Typesetting and design by
`
`Sigma Hi-Tech Services Ltd
`Printed in Malta by
`Interprint Lid.
`
`_ Distributed by
`
`John Wiley & Sons Ltd., Baffins Lane, Chichester, West Sussex, England.
`
`Acknowledgement of copyright names
`
`Within this book, various proprietary trade names and names, as listed below, are
`protected by copyright and are mentioned for descriptive purposes:
`
`UNIX, AT&T, Allied Telephone and Telegraph; AST, RAMpage! AST Corporation;
`Atari, ST, Atari Computer; Borland, Turbo C, Turbo Pascal, Turbo Lightning,
`Borland; Amiga 2000, Commodore Business Machines; Compag, Deskpro, Compaq
`Computer Corporation; Corona, Cordata, Cordata Computer; 10-Net, Fox Research,
`Inc.; Smartmodem, Hayes; IBM, PC, PCjr, PCIXT, PCIAT, XT/286, PS/2, TopView,
`DOS, PC-DOS, Micro Channel 3270 PC, RT PC, Token Ring, IBM Corporation;
`Intel,
`iAPX286, iAPX386, LIM EMS, Communicating Applications Standard,
`Intel.
`Corporation; Logitech, Logimouse, Logitech, Inc.; Microsoft, MS, MS-DOS, OS/2,
`Xenix, Windows, Windows/286, Windows/386, Microsoft Networks, LIM EMS, XMA,
`Microsoft Corp.; Mouse Systems, Mouse Systems Corp.; Novell, NetWare,
`Novell Corp.; DesQview, Quarterdeck Office Systems; ARC, SEAware,
`Inc.;
`DoubleDOS, Softlogic; TaskView, Sunny Hill Software; Tandy, Tandy Corp.; Zenith,
`Z-100, Zenith Radio Corporation; ShowPartner, Paintbrush, ZSoft Corporation;
`‘LIM 4.0’ and ‘Expanded Memory Specification’ are copyright Lotus Development
`Corp,Intel Corp, and Microsoft Corp;
`‘EEMS’,
`‘AQA 3.1’ and ‘Enhanced Expanded
`Memory Specification’ are copyright by Ashton-Tate, Quadram, and AST.Various
`other names are trademarks of their respective companiesFull acknowledgmentis
`hereby madeofall such protection.
`
`
`
`|
`
`|
`
`|
`
`-
`
`OLYMPUS EX.1015 - 3/393
`
`OLYMPUS EX. 1015 - 3/393
`
`
`
`Preface
`
`
`
`This bookis a technical reference. It is NOT a tutorial. It is intended to replace the various (ex-
`pensive) references needed to program for the DOSenvironment, that stack of magazines
`threatening to take over your work area, and those odd tables and charts you can neverfind
`whenyou need them.
`
`The various Microsoft and IBM publications and references don’t always have the sameinfor-
`mation. This has caused someconsternation aboutthe ‘undocumented’ features to be found in
`DOS.In general,if a call doesn’t appear in the IBM DOSTechnical Referenceit is considered
`‘undocumented’ although it may be in commonuse.
`
`Microsoft’s offical policy toward DOShas beento put the burden of documenting and suppor-
`ting their productto their vendors. Microsoft will not answer any questions concerning DOSdi-
`rectly since they don’t officially supportit. 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 aroundinsideit.
`
`Now that Microsoft is selling MSDOS3.3 and 4.0 over the counter they seem to be dragging
`their feet over whetherthey will have to support the generic version since it doesn’t have an .
`OEM nameonit anymore.In view oftheir push to OS/2 (OS/2! Just Say No!) further support of
`DOSseemsunlikely.
`
`A project this size takes a LOT of time and effort. I’ve tried to verify as much of the information
`I’ve received as I could, but there’s just too muchfor absolutecertainty.
`
`OLYMPUS EX.1015 - 4/393
`
`OLYMPUS EX. 1015 - 4/393
`
`
`
`
`
`OLYMPUS EX.1015 - 5/393
`
`OLYMPUS EX. 1015 - 5/393
`
`
`
`Contents
`
`Chapter 1: DOSand the IBM PC
`
`Chapter 2: CPU Port Assignments, System Memory Map, BIOS Data Area,
`Interrupts 00h to09h
`
`Chapter 3: The PC ROM BIOS
`
`Chapter 4; DOSInterrupts and Function Calls
`
`Chapter5: Interrupts 22h Through 86h
`
`Chapter 6: DOS Control Blocks and Work Areas
`
`Chapter 7: DOSFile Structure
`
`Chapter 8: DOSDisk Information
`
`Chapter 9:Installable Device Drivers
`
`Chapter 10: Expanded and Enhanced Expanded Memory Specifications
`Chapter 11: Conversion Between MSDOSand Foreign Operating Systems
`Chapter 12: Microsoft WindowsA.PI.
`
`Chapter 13: Network Interfacing
`
`Chapter 14: Mouse Programming —
`
`Chapter15: Register-Level Hardware Access
`
`Chapter 16: Video Subsystems and Programming
`
`Appendix 1: Keyboard Scan Codes
`Appendix 2: Standard ASCII Character Codes
`
`.
`
`Appendix 3; ASCII Control Codes
`
`Appendix 4: IBM PC Interrupt Usage
`
`Appendixs: List of IBM PC-XT-AT-PS/2 Diagnostic Error Codes
`
`Appendix 6: Pinouts For VariousInterfaces
`
`Appendix 7: ANSLSYS
`Bibliography
`
`Index
`
`.
`
`‘
`
`1
`
`10
`
`25
`
`34
`
`98
`
`130
`
`140
`
`151
`
`171
`
`185
`208
`210
`
`269
`
`300
`
`310
`
`- 315
`
`328
`342
`
`345
`
`347
`
`349
`
`358
`
`370
`374
`
`380
`
`OLYMPUS EX.1015 - 6/393
`
`OLYMPUS EX. 1015 - 6/393
`
`
`
`OLYMPUS EX.1015 - 7/393
`
`OLYMPUS EX. 1015 - 7/393
`
`
`
`DOSand the IBM PC
`
`
`
`Some History
`Development of MS-DOS/PCDOSbeganin October 1980, when IBM began searching the mar-
`ket for an operating system for the yet-to-be-introduced IBM PC. Microsoft hadnoreal opera-
`ting system to sell, but after some research licensed Seattle Computer Products’ 86-DOSopera-
`ting system, which had been written by a man named Tim Patersonearlier in 1980for use on that
`company’s line of 8086, S100 bus micros. 86-DOS(also called QDOS, for Quick and Dirty
`Operating System) had beenwritten as moreorless a 16-bit version of CP/M,since Digital Re-
`search was showing no hurry in introducing CP/M-86.
`This code was hurriedly polished up andpresented to IBM for evaluation. IBM had originally in-
`tended 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 founditself left with Microsoft’s offering of
`"Microsoft Disk Operating System 1.0". An agreementwas reached between the two, and IBM
`- agreed to accept 86-DOSas the main operating system for their new PC. Microsoft purchased
`all rights to 86-DOSin July 1981, and "IBM PC-DOS1.0" was ready for the introduction of the
`IBM PC in October1981. IBM subjectedthe operating system to an extensive quality-assurance
`program,reportedly found well over 300 bugs, and decided to rewrite the programs. Thisis why
`PC-DOSis copyrighted by both IBM and Microsoft.
`It is sometimes amusingto reflect on the fact that the IBM PC was not originally intended to run
`MS-DOS.Thetarget operating system at the end of the developmentwasfor a (notyetin exist-
`ence) 8086 version of CP/M. Onthe other hand, when DOS was originally written the IBM PC
`did notyet exist! Although PC-DOSwas bundled with the computer, Digital Research’s CP/M-
`86 would probably have been the main operating system for the PC exceptfor two things - Digi-
`tal Research wanted $495 for CP/M-86 (considering PC-DOS was essentially free) and many
`software developers foundit easier to port existing CP/M software to DOSthanto the new ver-
`sion of CP/M. Several computer magazines claimed that Digital Research aided IBM in writing
`DOS4.0, which was subsequently licensed back to Microsoft, which has droppedfurther devel-
`opmentof the operating system totilt at the windmills of OS/2. OS/2? Notyet! After using DR-
`DOS3.4 andnoting its behaviour, I now tendto seriously doubt Digital had any dealings with
`PC-DOS4.0.
`MS-DOSand PC-DOShave been run on more than just the IBM-PC and clones. Some of the
`following have been done:
`
`OLYMPUS EX.1015 - 8/393
`
`OLYMPUS EX. 1015 - 8/393
`
`
`
`2
`Hardware PC Emulation:
`Commodore Amiga 2000
`IBM PC/AT
`Atari 400/800
`Apple Macintosh
`Atari ST
`AppleII
`
`Software PC Emulation:
`AtariST
`Apple Macintosh
`
`DOS Emulation:
`Os/2
`QONX
`SunOS
`Xenix
`
`/
`
`The Programmer's Technical Reference
`
`8088 or A2286D 80286 Bridge Board
`80286 AT adapter
`Co-Power88 board
`AST 80286 board
`PC-Ditto II cartridge
`TransPC8088 board, QuadRam QuadLink
`
`PC-Ditto I
`SoftPC
`
`;
`
`DOSemulationin "Compatibility Box"
`DOSwindow
`DOSwindow
`DOS emulation with DOSMerge
`
`What is DOS?
`DOSexists as a high-level interface between an application program and the computer. DOS
`stands for "Disk Operating System", which reflects the fact that its main original purpose wasto
`provide aninterface between the computerandits disk drives.
`
`DOSnowlets your programs do simple memory management,I/O from the system console, and
`assorted system tasks (time and date, etc) as well as managingdisk operations. Versions 3.1 and
`up also incorporate basic networking functions.
`With the introduction of installable device drivers and TSR (terminate butstay resident) pro-
`grams in DOS2.0,the basic DOSfunctions may be expandedto covervirtually anyscale of oper-
`ations required.
`
`i
`
`Other Operating Systems
`There are a number of compatible replacements for Microsoft’s MS-DOS. Someare:
`
`Consortium Technologies MultiDOS
`(multitasking, multiuser)
`(multitasking)
`Digital Research Concurrent DOS
`Digital Research Concurrent DOS386—_(for 80386 computers) .
`
`Digital Research ConcurrentDOSXM_(multitasking, multiuser)
`Digital Research DR-DOS 3.31and4.0
`(PC-DOS clones)
`PC-MOS/386
`(multitasking, multiuser)
`Wendin-DOS
`(multitasking, multiuser)
`VM/386
`(multitasking)
`-
`
`Various other operating systemsare available for the IBM PC. Theseinclude:
`Digital Research CP/M-86
`Digital Research Concurrent CP/M-86 (multitasking)
`Minix (multitasking UNIX workalike)
`Pick (database-operating system)
`
`OLYMPUS EX.1015 - 9/393
`
`OLYMPUS EX. 1015 - 9/393
`
`
`
`DOSand the IBM PC
`
`3
`
`QNX(multitasking, multiuser)
`UNIX (various systems from IBMitself, Microsoft-SCO,Bell, and various UNIX clones, Single
`and multi user) (AIX, Xenix, AT&T System V, etc.)
`"Shell" programs exist which use DOS only for disk managementwhile they moreor less com-
`prise a new operating system. These include:
`
`DesQview
`Windows
`OmniView
`GEM
`TopView
`-TaskView
`
`Specific Versions of MS/PC-DOS
`DOS1.xis essentially 86-DOS. DOS 2.x kept the multiplefile layout (the two hiddenfiles and
`COMMAND.COM)butforail practical purposesis an entirely different operating system with
`backwards compatibility with 1.x. I seriously doubt there has been much code from 1.x retained
`in 2.x. DOS 3.x is merely an enhancementof 2.x; there seemslittle justification for jumping a
`whole version number. DOS4.0,originating as it did from outside Microsoft, can justify a ver-
`sion jump. Unfortunately, 4.x seemsto have very little reasontojustify its existence- Virtually all
`ofits core features can be foundin oneversion or another of DOS 3.x.
`
`DOSversion nomenclature: major.minor.minor. Thedigit to the left of the decimal point indi-
`cates a major DOSversion change. 1.0 wasthefirst version. 2.0 added support for subdirec-
`tories, 3.0 added support for networking, 4.0 added some minimal support for Lotus-Intel-
`Microsoft EMS.
`
`Thefirst minor version indicates customization for a major application. For example, 2.1 for the
`PCjr, 3.3 for the PS/2s. The second minorversion does not seem to have any particular meaning.
`- The main versions of DOSare:
`
`original release
`August 1981
`PC-DOS1.0
`bugfix, double sided drive support
`May 1982
`PC-DOS 1.1
`for early compatibles
`June 1982
`MS-DOS1.25
`for PC/XT, Unix-type subdirectory support
`March 1983
`PC-DOS 2.0
`for PCjr, bugfixes for 2.0
`October 1983
`PC-DOS 2.1
`compatible equivalent to PC-DOS2.1
`MS-DOS2.11 October 1983
`1.2 meg drive for PC/AT, some new system calls
`PC-DOS3.0
`August 1984
`bugfix for 3.0, implemented network support
`PC-DOS3.1
`November 1984
`compatible; extended foreign language support
`MS-DOS 2.25 October 1985
`720k 3.5 inch drive support for Convertible
`PC-DOS3.2
`December 1985
`for PS/2 series, 1.44 meg, multiple DOSpartitions
`PC-DOS3.3
`April 1987
`over-32 meg DOSpartitions, new functioncalls
`MS-DOS 3.31 November 1987
`minor EMSsupport, some new functioncalls
`PC-DOS 4.0
`August 1988
`Microsoft version with somebugfixes
`MS-DOS 4.01
`January 1989
`_ IBM’s PC-DOSis consideredto be the "standard" version of DOS; Microsoft has sold MS-DOS
`over the counter only since version 3.2 (previously, Microsoft sold its versions only to OEMs).
`
`OLYMPUS EX.1015 - 10/393
`
`OLYMPUS EX. 1015 - 10/393
`
`
`
`4
`
`The Programmer's Technical Reference
`
`Mostversions of DOSfunctionally duplicate the external DOS commands such as DISKCOPY,
`etc. Although Microsoft announced that they would sell MS-DOS 4.0 only to OEMs,they ap-
`parently changed the policy and are nowselling it over the counter.
`
`Some versions of MS-DOSvaried from PC-DOSin the available external commands. Some
`OEMsonly licensed the basic operating system code (the xDOS and xBIO programs, and
`COMMAND.COM)from Microsoft, and either wrote the rest themselves or contracted them
`from outside software houses like Phoenix. Mostof the external programsfor DOS 3.x and 4.x
`are written in "C" while the 1.x and 2.x utilities were written in assembly language. Other OEMs
`required customized versions of DOSfor their specific hardware configurations, such as Sanyo
`55x and early Tandy computers, which were unable to exchange their DOSwith the IBM version.
`
`At least two versions of DOS have been modified to be run entirely out of ROM. The Sharp
`PCS5000 had MS-DOS1.25 in ROM,and the Toshiba 1000 and some Tandy 1000 models have
`MS-DOS 2.11 in ROM.Digital Research has also announcedits DR-DOSis available ina ROM
`version and Award Software is marketing DOScards to OEMs asa plug-in.
`
`PC-DOS3.0 was extremely buggy on release. It does not handle the DOS environmentcorrectly
`and there are numerous documented problemswith the batch file parser. The network support
`codeis also nonfunctional in this DOSversion.It is recommendedthat users upgradeto at least
`version 3.1.
`
`DEC MS-DOSversions 2.11 for the Rainbow had the ANSISYSdevice driver built into the
`main code. The Rainbow also used a unique quad density, single-sided floppy drive and its DOS
`had special supportforit.
`
`IBM hada version 1.85 of PC-DOSin April 1983, after the introduction of DOS2.0. It was evi-
`dently for internal use only, supported multiple drive file searches (a primitive form of PATH),
`built in MODE commandsfor screen support, a /P parameter for TYPE for pausedscreens, an
`editable commandstack like the public domain DOSEDIT:COMutility, and could be set up to
`remain completely resident in RAM instead of a resident/transientpart like normal DOS. Itisa
`pity some of the neat enhancements didn’t makeit into DOS2.0. IBM also had an "internal use
`only"version 3.4, evidently used while developing DOS4.0.
`
`Someversions of DOS used in compatibles do not maintain the 1.x, 2.x, ... numbering system.
`Columbia Data Products computers labelled DOS 1.25 as DOS 2.0. Early Compagslabelled
`DOS 2.0 as DOS 1.x. Other versions incorporated special features - Compaq DOS 3.31 and
`Wyse DOS3.21 both support 32-bitfile allocation tables in the same fashion as DOS4.x.
`
`According to PC’'Week Magazine,July 4, 1988, Arabic versions of MS-DOSare shipping with a
`hardware copy-protection system from Rainbow Technologies. This is similar to the short-lived
`system used by AutoCAD 2.52 and a very few other MS-DOSprograms, where an adapter block
`is plugged into the parallel port and software makesuse of coded bytes within the block. This
`type of copy protection has been common on Commodoreproductsfor several years, whereit is
`called a "dongle".
`
`The AutoCAD dongle was defeated by a small programwritten within weeks of version 2.52’s
`debut. Version 2.62 was released 3 months later, without the dongle. The DOS dongle will, how-
`ever, prevent the system from booting at all unlessit is found.
`
`This makes the Arabic version of MS-DOSthefirst copy-protected operating system, a dubious
`distinction at best. The modifications to the operating system to. support the dongle are not
`knownat this time. Frankly, it would seem that burning the operating system into ROMs would
`be cheaper and simpler.
`
`;
`
`OLYMPUS EX.1015 - 11/393
`
`OLYMPUS EX. 1015 - 11/393
`
`
`
`DOS and the IBMPC
`
`.
`
`5
`
`Versions of DOSsold in Great Britain are either newer than those sold in the US oruse a differ-
`ent numbering system. DOS3.4,4.0, 4.1, 4.2, and 4.3 had been released here between the USre-
`leases of 3.3 and 4.0.
`
`Microsoft changed their OEM licensing agreements between DOSversions 2.x and 3.x. OEM
`versions Of DOS 3.x must maintain certain data areas and undocumentedfunctionsin order to
`provide compatibility with the networking features of the operating system. For this reason,
`resident programswill be much morereliable when operating under DOS 3.x.
`
`IBM’s release of DOS4.0 (and the immediate subsequentreleaseof a bugfix) is a dubious step
`"forward". DOS4.0is the first version of DOS to come with a warranty; the catch is that IBM
`warrants it only for avery slim list of IBM-packagedsoftware. 4.0 has some minor EMSsupport,
`‘Supportfor large hard disks, and not muchelse. With its voracious RAM requirementsand lack
`of compatibility with previous versions of DOS (many major software packages crash under
`DOS4.0), plus the increasein price to a cool $150, there has been no greatrushto go to the ne-
`west DOS
`
`The Operating System Hierarchy
`The Disk Operating System (DOS) and the ROM BIOSserve as an insulating layer between the
`application program andthe machine, and as asource of services to the application program.
`As the term ‘system’ might imply, DOSis not one program but a collection of programsde-
`signed to work together to allow the user access to programs and data. Thus, DOSconsists of
`several layers of "control" programs anda set of “utility” programs.
`
`The system hierarchy may be thought of as a tree, with the lowest level being the actual hard-
`ware. 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,andpartsare notas-
`signed. There are also various "ports" that the processor canuseto control devices.
`
`The hardware is normally addressed by the ROM BIOS, which will always know where every-
`thing is in its particular system. The chips may usually also be written to directly, by telling the
`processorto write to a specific addressor port. This sometimes does not work as the chips may
`notalwaysbe at the same addresses or have the samefunctions from machine to machine.
`
`DOS Structure
`
`DOSconsists of four components:
`The boot record
`The ROM BIOSinterface IBMBIO.COM or IO.SYS)
`The DOSprogram file (IBMDOS.COM or MS-DOS.SYS)
`The command processor (COMMAND.COMoraftermarket replacement)
`
`The Boot Record
`
`The boot record begins on track 0, sector 1, side 0 of every disketie formatted by the DOS FOR-
`MAT command. The boot record is placed on diskettes to produce an error messageif you try to
`Start up the system with a non-system diskette in drive A. For hard disks, the boot record resides
`
`OLYMPUS EX.1015 - 12/393
`
`OLYMPUS EX. 1015 - 12/393
`
`
`
`6
`
`The Programmer's Technical Reference
`
`onthe first sector of the DOSpartition. All media supported by DOSuse onesectorfor the boot
`record,
`.
`
`Read Only Memory (ROM) BIOSInterface and Extensions
`ThefileIBMBIO.COMorIO.SYSis the interface module to the ROM BIOS. Thisfile provides
`a low-level interface to the ROM BIOSdevice routines and may contain extensions or changes
`to the system board ROMs. Some compatibles do not havea ROM BIOSto extend,and load the
`entire BIOS from disk (Sanyo 55x, Viasyn machines). Some versions of MS-DOS,such as those
`supplied to Tandy, are named IBMBIO.COMbutare not IBMfiles.
`
`These low-level interface routines include the instructions for performing operations such as
`displaying information on the screen, reading the keyboard, sending data outto theprinter,
`operating the disk drives, and so on.It is the operating system’s meansof controlling the hard-
`ware. IBMBIO.COMcontains any modifications or updates to the ROM BIOSthat are needed
`to correct any bugs or add supportfor other types of hardware such as new diskdrives. By using
`IBMBIO.COMto update the ROM BIOSonthe fly whenthe user turns on their computer,
`IBM doesnotneed to replace the ROM BIOSchipitself, but makes any corrections through the
`cheaper and easier method of modifying the I]BMBIO.COMfile instead.
`
`IBMBIO.COMalso keepstrack of hardware operations on an internal stack or "scratch pad"
`area for the operating system to save information such as addressesit will need, etc. An example
`of the use for this stack can be seen when running a program such as a word processor.If you
`have told the word processorto save yourletter, it will write the data to your disk. During this
`time, if you start typing some moreinformation, the keyboard generates a hardwareinterrupt.
`Since you don’t wantthe process of writing the informationto the disk to be interrupted, DOS
`allocates a slot in the stack for the keyboard’s hardware interrupt and whenit gets a chance,
`(probably after the data has been written to the disk), it can process that interrupt andpick up
`the characters you may have been typing. The STACKS= command in DOS 3.2+’s
`CONFIG.SYSfile controls the numberof stack framesavailable for this purpose.
`IBMBJO.COM also reads your CONFIG.SYSfile and installs any device drivers (ie.
`DEVICE=ANSLSYS)or configuration commandsit mayfind there.
`
`The DOS Program
`
`The actual DOSprogram is the file IBMDOS.COM or MS-DOS.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.
`
`\
`
`_
`
`Whena user program calls these function routines, they accept high-level information by way of
`register and control block contents. When a user program calls DOSto perform an operation,
`these functions translate the requirement
`into one or more calls to IBMBIO.COM,
`MS-DOS.SYSorsystem hardware to completethe request.
`
`The CommandInterpreter
`
`The commandinterpreter, COMMAND.COM,is the part you interact with on the command
`line. COMMAND.COMhasthreeparts. IBM calls them the "residentportion", the "initializa-
`tion portion" and the "transient portion".
`
`OLYMPUS EX.1015 - 13/393
`
`OLYMPUS EX. 1015 - 13/393
`
`
`
`DOSand the IBM PC
`
`7
`
`IBM’s original documentation spokeofinstalling alternate commandinterpreters (programs
`other than COMMAND.COM)with the SHELL= statement in CONFIG.SYS. Unfortunately,
`IBM chose not to document much of the interaction between IBMDOS.COM and IBM-
`BIO.COM.Bythe time muchofthe interaction was widely understood, many commercial soft-
`ware programs had been written to use peculiarities of COMMAND.COMitself.
`‘wo programsexist that perform as actual "shells" by completely replacing COMMAND.COM
`and substituting their own commandinterpreter to use with the hidden DOSfiles. These are
`CommandPlus, a commercial package, and the very interesting shareware 4DOSpackage. Both
`supply greatly enhanced batchlanguage andediting capabilities.
`
`Note: DOS3.3 + checks for the presenceof a harddisk, and will default to COMSPEC=C\\,Pre-
`- vious versions default to COMSPEC=A:\. Under some DOSversions, if COMMAND.COMis
`not immediately available for reloading (i.e., swapping to a floppy with COMMAND.COM on
`it) DOS may crash.
`
`Resident Portion
`
`The resident portion resides in memory immediately following IBMDOS.COMandits data
`area. This portion contains routines to processinterrupts 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 DOS3.x, this portion also contains a routine to load and executé external
`commands, such asfiles with extensions of COM or EXE.
`
`Whena program terminates, a checksum is used to determineif the application program over-
`laid the transient portion of COMMAND.COM.Ifso,the residentportionwill reload the tran-
`sient portion from the area designated by COMSPEC= in the DOSenvironment. If COM-
`MAND.COMcannotbefound, thesystem will halt.
`
`All standard DOSerror handling is done within the resident portion of COMMAND.COM.
`This includes displaying error messages and interpreting the replies to the "Abort, Retry, Ig-
`nore, Fail?" message.
`
`Since the transient portion of COMMAND.COMis so large (containing the internal com-
`mands and all those error messages), andit is not needed whentheuseris running an applica-
`tion it can be overlaid that programif that application needs the room. Whenthe applicationis
`through, the resident portion of COMMAND.COM brings the transient portion back into
`memory to show the prompt. This is why you will sometimes see the message "Insert disk with
`COMMAND.COM".It needsto getthe transient portion off the disk since it was overlaid with
`the application program.
`
`Theinitialization portion of COMMAND.COMfollowsthe resident portion and is given con-
`trol during the boot-up procedure. This section actually processes the AUTOEXEC.BATfile.It
`also decides whereto loadthe user’s programs when they are executed. Since this code is only
`needed during start-up,it is overlaid by the first program which COMMAND.COMloads.
`The transient portion is loaded at the high end of memory and it is the command processorit-
`self. It interprets whatever the user types in at the keyboard, hence messages such as ‘Bad com-
`mandorfile name’ for when the user misspells acommand.This portion contains all the internal
`commands(i.e. COPY, DIR, RENAME, ERASE), the batch file processor (to run .BATfiles)
`and a routine to load and execute external commands which are either .COM or .EXE files.
`Thetransient portion of COMMAND.COM produces the system prompt, (C), and reads what
`
`OLYMPUS EX.1015 - 14/393
`
`OLYMPUS EX. 1015 - 14/393
`
`
`
`8
`
`The Programmer’s Technical Reference
`
`the user types in from the keyboard andtries to do something with it. For any .COM or .EXE
`files, it builds a commandline and issues an EXEC function call to load the program and trans-
`fer controltoit.
`
`DOS Initialization
`
`The system is initialized by a software reset (Ctrl-Alt-Del), a hardware reset(reset button), or by
`turning the computeron. TheIntel 80x8x series processors always lookfortheirfirst instruction
`at the end of their address space (OFFFFOh) when powered up orreset. This address contains a
`jumpto thefirst instruction for the ROM BIOS.
`
`Built-in ROM programs (Power-OnSelf-Test, or POST, in the IBM) check machinestatus and
`run inspection programsof various sorts. Some machinesset up a reserved RAM area with bytes
`indicating installed equipment(AT and PCjr).
`
`When the ROM BIOSfinds a ROM on an adapter card,it lets that ROM takecontrol of the sys-
`tem so that it may perform any set up necessary to use the hardware or software controlled by
`that ROM. The ROM BIOSsearches absolute addresses OC8000h through OE0000h in 2Kin-
`crements in search of a valid ROM.A valid ROM is determined by thefirst few bytes in the
`ROM.The ROM will have the bytes 55h, OAAh,a length indicator and then the assembly lan-
`guage instruction to CALL FAR (to bring ina ‘FAR’routine). A checksum is done on the ROM
`to verify its integrity, then the BIOS performs the CALL FAR to bring in the executable code.
`The adapter’s ROM thenperformsits initialization tasks and hopefully returns controlof the
`computerback to the ROM BIOSsoit can continuewith the bootingprocess.
`
`The ROM BIOSroutinesthen look fora disk drive at A: or an option ROM (usually a hard disk)
`at absolute address C:800h.If no floppy drive or option ROMis found, the BIOScalls int 19h
`(ROM BASICifit is an IBM)ordisplays an error message.
`
`Ifa bootable disk is found, the ROM BIOSloadsthefirst sector of data from the disk and then
`- jumpsinto the RAM location holding that code. This code normallyis a routine to loadthe rest
`of the codeoff the disk,or to ‘boot’ the system.
`The following actionsoccur after a system initialization:
`The bootrecordis read into memory andgiven control.
`2. The boot record then checks the rootdirectory to assure thatthe first twofiles are
`IBMBIO.COMand IBMDOS.COM.Thesetwofiles must bethefirst twofiles, and they
`mustbe in that order (IBMBIO.COMfirst, with its sectors in contiguous order).
`Note: IBMDOS.COMneednotbe contiguous in version 3.x+.
`
`The boot record loads IBMBIO.COMinto memory.
`The initialization code in ]BMBIO.COMloads IBMDOS.COM,determines equipment
`status,resets the disk system,initializes the attached devices, sets the system parameters
`and loads anyinstallable device drivers according to the CONFIG.SYSfile in the root
`directory (if present), sets the low-numbered interrupt vectors, relocatesBMDOS.COM
`downward, andcalls the firstbyte of DOS.
`Note: CONFIG.SYSmaybe a hiddenfile.
`5. _DOSinitializes its internal working tables,initializes the interrupt vectors for interrupts
`20h through 27h, and builds a Program SegmentPrefix for COMMAND.COMatthelowest
`available segment. For DOSversions 3.10 up, DOSalsoinitializes the vectors for interrupts
`
`OLYMPUS EX.1015 - 15/393
`
`OLYMPUS EX. 1015 - 15/393
`
`
`
`DOSandthe IBM PC
`
`.
`
`.
`
`9
`
`6.
`
`OFh through 3Fh. An initialization routineis includedin the resident portion and assumes
`control duringstart-up. This routine contains the AUTOEXEC.BATfile handler and
`determines the segment address where user application programs may be loaded. The
`initialization routineis then no longer needed andis overlaid by thefirst program
`COMMAND.COMloads.
`Note: AUTOEXEC.BATmaybe a hiddenfile.
`IBMBIO.COMuses the EXECfunctioncall to load andstart the top-level command
`processor. The default commandprocessor is COMMAND.COMintherootdirectory of
`the boot drive. If COMMAND.COMisin a subdirectory or another commandprocessoris
`to be used, it must be specified by a SHELL= statement in the CONFIG.SYSfile. A
`transient portionis loaded at the high end of memory.This is the commandprocessoritself,
`containing ail of the internal commandprocessorsandthe batchfile processor. For
`DOS2.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.COMalso produces
`the DOS prompt (such as ‘A), reads the commandfrom the standard input device (usually
`the keyboard or a batchfile), and executes the command.For external commands,it builds a
`commandline and issues an EXECfunction call to load andtransfer control to the
`program.
`
`Note 1.
`
`COMMAND.COM maybea hiddenfile.
`
`2.
`
`3.
`
`ForIBMDOS2.x,the transientportion ofthe commandprocessor contains the
`EXEC routine that loads and executes external commands. For MS-DOS 2.x+ and
`IBM DOS3.x+, the resident portion of the commandprocessorcontains the
`EXEC routine.
`
`IBMBIO only checksfor a file named COMMAND.COM.It will loadanyfile of
`that name ifno SHELL= command is used.
`
`That pretty much covers the boot-up process. After COMMAND.COMis loaded,it runs the
`AUTOEXEC.BATfile and thenthe user gets a promptto begin working.
`
`OLYMPUSEX.1015 - 16/393
`
`OLYMPUS EX. 1015 - 16/393
`
`
`
`CPU Port Assignments, System
`Memory Map, BIOS Data Area,
`Interrupts 00h to 09h
`
`Introduction
`
`For consistency in this reference, all locations and offsets are in hexadecimal unless otherwise
`specified. All hex numbersare prefaced with a leading zeroif they begin with an alphabetic char-
`acter, and are terminated with a lowercase H (h). The formats vary according to commonusage.
`
`System Memory Map
`
`The IBM PChandlesits address space in 64k segments,divided into 16k fractions and then fur-
`then as necessary.
`start
`start
`end
`addr. addr.
`addr
`(dec)
`(hex)
`
`usage
`
`start of RAM, first K is interrupt vector table
`PC-0 system board RAM ends
`
`PC-1 system board RAM ends
`
`*640k RAM Area*
`
`0k
`16k
`32k
`48k
`64k
`80k
`96k
`112k
`128k
`144k
`160k
`176k
`
`192k
`208k
`224k
`240k
`
`00000-03FFF
`04000-0O7FFF
`08000-OBFFF
`10000-13FFF
`14000-l17FFF
`18000-1BFFF
`1C000~1FFFF
`20000-23FFF
`24000-27FFF
`28000-2BFFF
`2C000-2FFFF
`
`30000-33FFF
`34000-37FFF
`38000-3BFFF
`3C000-3FFFF
`
`OLYMPUS EX.1015 - 17/393
`
`OLYMPUS EX. 1015 - 17/393
`
`
`
`CPUPorts Assignments, System Memory Data, BIOS Data Area
`40000-43FFF
`board R