** 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 ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ C H A P T E R O N E DOS AND THE IBM PC C O N T E N T S 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 Some History ................................................... 1**1 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. IBM had originally intended to use Digital Research's (actually, they had the somewhat pretentious name of "Intergalactic Digital Research" at the time) CP/M was then the industry standard operating system - you either ran a BASIC with disk functions, someone's proprietary OS, or CP/M. Folklore reports various stories about the rift between DRI and IBM. The most popular story claims Gary Kildall or DRI snubbed the IBM executives by flying his airplane when the meeting was scheduled. Another story claims Kildall didn't want to release the source for CP/M to IBM, which would be odd, since they released it to other companies. One noted industry pundit claims Kildall's wife killed the deal by insisting on various contract changes. I suspect the deal was killed by the good ol' boy network. It's hard to imagine a couple of junior IBM executives giving up when ordered to a task as simple as licensing an operating system from a vendor. It wouldn't look good on their performance reports. It would be interesting to hear IBM's story... IBM then talked to a small company called Microsoft. Microsoft was a language vendor. Bill Gates and Paul Allen had written Microsoft BASIC and were selling it on punched tape or disk to early PC hobbyists, which was probably a step up from the company's original name and goal - they were Traf-O-Data before, making car counters for highway departments. Microsoft had no 8086 real operating system to sell, but quickly made a deal to license Seattle Computer Products' 86-DOS operating system, which had been written by Tim Paterson earlier in 1980 for use on that company's line of 8086, S100 bus micros. 86-DOS (also called QDOS, for Quick and Dirty Operating System) had been written as more or less a 16-bit version of CP/M, since Digital Research was showing no hurry in introducing CP/M-86. Paterson's DOS 1.0 was approximately 4000 lines of assembler source. This code was quickly polished up and presented to IBM for evaluation. IBM found itself left with Microsoft's offering of "Microsoft Disk Operating System 1.0". An agreement was reached between the two, and IBM agreed to accept 86-DOS as the main operating system for their new PC. Microsoft purchased all rights to 86-DOS in July 1981, and "IBM Personal Computer 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, reportedly found well over 300 bugs, and decided to rewrite the programs. This is why PC-DOS is copyrighted by both IBM and Microsoft. Some early OEM versions of DOS had different names, such as Compaq- DOS, Z-DOS, Software Bus 86, etc. By version 2 Microsoft managed to persuade everyone but IBM to refer to the product as "MS-DOS." It is sometimes amusing to reflect on the fact that the IBM PC was not originally intended to run MS-DOS. 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. The IBM PC shipped without an operating system. IBM didn't start bundling DOS until the second generation AT/339 came out. You could order one of three operating systems for your PC, assuming you popped for the optional disk drive and 64k RAM upgrade (base models had 16k and a cassette player port). These operating systems were IBM Personal Computer DOS 1.0, a version of the UCSD p-System, which was an integrated Pascal operating system something like the souped-up BASIC operating systems used by the Commodore 64 and others, or Digital Research's CP/M-86, which was officially an option although you couldn't buy it until later. Since IBM's $39.95 DOS was far cheaper than anyone else's alternative, darned near everyone bought DOS. The upgrade from DOS 3.3 to 4.0 was done in-house by IBM. DOS 4.0 was a completely IBM product, later licensed back to Microsoft. In early 1990 IBM announced that it was ceasing development of DOS and all further work would be done solely by Microsoft. Microsoft Press' "MSDOS Encyclopedia" shows a reproduction of a late DOS 1.25 OEM brochure. Microsoft was touting future enhancements to 1.25 including Xenix-compatible pipes, process forks, and multitasking, as well as "graphics and cursor positioning, kanji support, multi-user and hard disk support, and networking." Microsoft certainly thought big, but, alas, the forks, multitasking, and multiuser support never came about, at least in US versions of DOS. Oddly, the flyer claims: "MS-DOS has no practical limit on disk size. MS-DOS uses 4-byte XENIX OS compatible pointers for file and disk capacity up to 4 gigabytes." Umm... yeah. One sort of gets the idea nobody at Microsoft had a hard disk larger than 32 megabytes... For the record they actually delivered: Xenix-compatible pipes: DOS 2.0 ("|" operator) process forks, and multitasking: eDOS 4.0 (not delivered in the US) multi-user: never delivered graphics and cursor positioning: DOS 2.0 (ANSI.SYS) kanji support: DOS 2.01, 2.25 (double-byte character set) hard disk support: DOS 2.0 (subdirectories) networking: DOS 3.1 (file locking support MS Networks) DOS 6.0 (bundled Interlink in with DOS) Early Microsoft ads pumped DOS' Xenix-like features and promised Xenix functionality in future releases. We'll probably never know what the real story was behind eDOS/DOS 4/ DOS 5/286DOS/OS2. Microsoft had announced their intent to build a multitasking, multiuser version of MSDOS as early as 1982. They shipped betas of "DOS 4.0" in '86 and early '87, before 3.3 was even announced. Microsoft UK announced they had licensed 4.0 to Apricot Computer, and the French Postal Service was supposed to be running it. I've never been able to find out if Apricot ever shipped any 4.0 to end users. Despite Gordon Letwin's acid comments about problems with the 80286 processor, I doubt the '286 was the barrier between users and a multitasking MS-DOS. I also doubt there was any shortage of programming talent at Microsoft - Digital Research's Concurrent DOS and Software Link's PC-MOS/386 were developed without undue trouble. MSDOS and PC-DOS have been run on more than just the IBM-PC and clones. Some of the following have been done: Hardware PC Emulation: Apple II -> TransPC 8088 board Apple MacIntosh -> AST 80286 board Atari 400/800 -> Co-Power 88 board Atari ST -> PC-Ditto II cartridge Amiga 2000 -> 8088 or A2286D 80286 Bridge Board IBM PC/RT -> 80286 AT adapter Kaypro 2 -> Co-Power Plus board Software PC Emulation: Apple MacIntosh -> SoftPC Atari ST -> PC-Ditto I IBM RS/6000 -> DOS emulation DOS Emulation: AIX (IBM RS/6000) -> DOS emulation with "PCSIMulator" OS/2 1.x -> DOS emulation in "Compatibility Box" OS/2 2.x -> executes Virtual DOS Machine QNX -> DOS window SunOS -> DOS window Xenix -> DOS emulation with DOSMerge What Is DOS?.................................................... 1**2 DOS exists 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 was to provide an interface between the computer and its disk drives. DOS now lets your programs do simple memory management, I/O from the system console, and assorted system tasks (time and date, etc) as well as managing disk operations. Versions 3.1 and up also incorporate basic networking functions. With the introduction of installable device drivers and TSR (terminate but stay resident) programs in DOS 2.0, the basic DOS functions may be expanded to cover virtually any scale of operations required. Other Operating Systems ........................................ 1**3 There are a number of compatible replacements for Microsoft's MSDOS. Some are: Alloy 386 Multiware (multitasking control prog, licensed DOS) Consortium Technologies MultiDOS (multitasking, multiuser) Digital Research Concurrent DOS (multitasking) Digital Research Concurrent DOS 386 (for 80386 computers) Digital Research Concurrent DOS XM (multitasking, multiuser) Digital Research DR-DOS (PC-DOS clones) Digital Research Multiuser DOS (multitasking, multiuser) PC-MOS/386 (multitasking, multiuser) Wendin-DOS (multitasking, multiuser) VM/386 (multitasking) X-DOS (DOS 3.31 compatible) Various other operating systems are available for the IBM PC. These include: Digital Research CP/M-86 Digital Research Concurrent CP/M-86 (multitasking) Minix (multitasking UNIX workalike) Pick (database-operating system) QNX (multitasking, multiuser) UCSD p-System (Pascal interpreter and operating system) UNIX (various systems from IBM itself, Microsoft-SCO, Bell, and various UNIX clones, single and multi user, such as AIX, Xenix, AT&T System V, etc.) "Shell" programs exist which use DOS only for disk management while they more or less comprise a new operating system. These include: DESQview Windows OmniView GEM TopView TaskView GeoWorks TopView and TaskView (later called OmniView) and Omniview are no longer sold. Systems using the NEC V-series CPUs can execute Intel 8080/8085 8-bit instructions as well as the 16-bit 8088-up instructions. They can run standard Digital Research 8-bit CP/M and MP/M directly, as well as other operating systems developed for that processor. Specific Versions of MS/PC-DOS ................................. 1**4 DOS 1.x is essentially 86-DOS. DOS 2.x kept the multiple file layout (the two hidden files and COMMAND.COM) but for all practical purposes is 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 enhancement of 2.x; there seems little justification for jumping a whole version number. The disk handling routines were considerably extended in 3.1, allowing disk access in a "virtual" fashion, independent of whether the drive was a local or network device. DOS 4.0, originating as it did from outside Microsoft, can justify a version jump. Unfortunately, 4.0 seemed to have very little reason to justify its existence - virtually all of its core features could be found in one version or another of DOS 3.x. According to Microsoft's Gordon Letwin, DOS 5.0 was a complete rewrite with the kernel done in hand optimized assembly language. 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 support for subdirectories, 3.0 added support for networking, 4.0 added some minimal support for Lotus- Intel-Microsoft EMS. 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: 86-DOS February 1981 Paterson's Quick'n'Dirty DOS first runs on IBM's wirewrapped PC prototype PC-DOS 1.0 August 1981 original IBM release PC-DOS 1.05 -------- ---- fixes to BASIC interpreter PC-DOS 1.1 June 1982 bugfix, double sided drive support MS-DOS 1.25 July 1982 for early compatibles. This is the first non-IBM OEM version PC-DOS 2.0 March 1983 for PC/XT, Unix-type subdirectory support, installable device drivers, I/O redirection, subdirectories, hard disk support, handle calls PC-DOS 1.85 April 1983 internal IBM - extended 1.1 - not released I found a copy of this one on an old diskette. It added a whole host of features, including an enhanced COMMAND.COM with command line editing. Too bad none of the goodies made it into DOS 2.0! MS-DOS 2.01 -------- 1983 first support for individual country formats, Kanji PC-DOS 2.1 October 1983 for IBM PCjr, bugfixes for 2.0. No country support MS-DOS 2.11 December 1983 basically a cross of PC-DOS 2.1 and MS-DOS 2.01 MS-DOS 2.12 -------- ---- special version for TI Professional (nonstandard video and keyboard) PC-DOS 3.0 August 1984 1.2 meg drive for PC/AT, some new system calls, new external programs, 16-bit FAT, specific support for IBM network MS-DOS 3.05 November 1984 first OEM version of 3.x PC-DOS 3.1 November 1984 bugfix for 3.0, implemented generic network support MS-DOS 2.25 October 1985 extended foreign language support PC-DOS 3.2 January 1986 720k 3.5 inch drive support, special support for laptops (IBM PC Convertible), XCOPY MS-DOS 4.0 April 1986 multitasking (Europe only) - withdrawn from market after a very short run PC-DOS 3.3 April 1987 for PS/2 series, 1.44 meg support, multiple DOS partition support, code page switching, improved foreign language support, some new function calls, support for the AT's CMOS clock. MS-DOS 3.31 November 1987 over-32 meg DOS partitions. Different versions from different OEMs (not Microsoft). Compaq and Wyse are most common. PC-DOS 3.4 -------- ---- internal IBM - not released (4.0 development) MS-DOS 2.11R -------- 1988 bootable ROM DOS for Tandy machines PC-DOS 4.0 August 1988 32mb disk limit officially broken, minor EMS support, more new function calls, enhanced network support for external commands. PCjr support dropped. MS-DOS 4.01 January? 1989 Microsoft version with some bugfixes MS-DOS 3.21R September1989 DOS in ROM, Flash File System for laptops MS-DOS 3.3R -------- 1990 DOS in ROM, introduced for TI laptops MS-DOS 5.0 June 1991 high memory support, uses up to 8 hard disks, command line editor and aliasing, 2.88 floppies, ROMable OEM kit available MS-DOS V February 1993 Japanese-market version of 5, with double byte Kanji character support MS-DOS 6.0 March 1993 disk compression (Doublespace), multiple configurations in CONFIG.SYS IBM's PC-DOS was long considered to be the "standard" version of DOS. Now that MS 5.0 is a commercial product most developers will probably write to it. Microsoft's policy was once to sell DOS only to OEMs. Despite this, they sold small quantities of DOS 3.2, 3.3, and 4.0 without insurmountable difficulties. DOS 5.0 was conceived from the beginning as an over-the-counter retail product. Incidentally, IBM refers to its DOS as "The IBM Personal Computer DOS." The term "PC-DOS" is a trademark of IBM's rival DEC. Some versions of MS-DOS varied from PC-DOS in the available 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 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 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. PC-DOS 3.0 was extremely buggy on release. It did not handle the DOS environment correctly and there were numerous documented problems with the batch file parser. The network support code was also nonfunctional in that DOS version. It is recommended that users upgrade to at least version 3.1. DEC MS-DOS versions 2.11 for the Rainbow had the ANSI.SYS device driver built into the main code. The Rainbow also used a unique quad density, single-sided floppy drive and its DOS had special support for it. IBM had a version 1.85 of PC-DOS in April 1983, after the introduction of DOS 2.0. It was evidently for internal use only, supported multiple drive file searches (a primitive form of PATH), built in MODE sommands for screen support, a /P parameter for TYPE for paused screens, an editable command stack like the public domain DOSEDIT.COM utility, and could be set up to remain completely resident in RAM instead of a resident/transient part like normal DOS. It is a pity some of the neat enhancements didn't make it into DOS 2.0. IBM also had an "internal use only" version 3.4, evidently used while developing DOS 4.0. Digital Research's DR-DOS is the first widely available DOS clone. Version 3.4, released in June 1988, was the one first available to the American public. It was somewhat buggy and its use is not recommended. DR 3.41 is extremely compatible and its use should pose no problems on any machine. DR-DOS 5.0 (released May, 1990) is functionally equivalent to MS-DOS 5.0. For all practical purposes, MS 5.0 is a clone of DR 5.0, since DR beat MS to market by over a year. According to Greg Ewald, DRI's DR-DOS product manager, DR-DOS was developed from Concurrent DOS 386 with the multiuser and multitasking code stripped out. DR-DOS 6.0 was introduced in December 1991, and added disk compression via bundling the third-party SuperStor program. Novell DOS 7.0 (DRI sold out to Novell) in March 1993, at the same time as MS-DOS 6.0. Novell one-upped Microsoft by tossing in their Netware Lite with their DOS. Some versions of DOS used in compatibles do not maintain the 1.x, 2.x, ... numbering system. Columbia Data Products computers labeled DOS 1.25 as DOS 2.0. Early Compaqs labeled DOS 2.0 as DOS 1.x. Other versions incorporated special features - Compaq DOS 3.31 and Wyse DOS 3.21 both support >32mb disk partitions in the same fashion as DOS 4.x. AT&T DOS 3.1 differs from generic MS-DOS 3.10 in its use of cluster- size and file allocation table structures. AT&T DOS appears to use rules not from version 3, but rather those from version 2. Epson Equity III and ComputerLand 3.10 DOS's appear to use cluster techniques that are a cross between versions 2 and 3. On type DOS partitions, these DOS's use 3.x rules if the partition is larger than 32,680 sectors in total size. This implies 16 bit FAT entries as well. On partitions below this size, they will use 2.x rules, including the 12 bit FAT entries. Zenith DOS 3.x and Wyse DOS 3.2 have a builtin internal device driver to handle up to 4 32Mb DOS partitions on a single hard disk. Wyse DOS 3.31 will handle single partitions up to 512Mb with a 32-bit FAT. According to PC Week Magazine, July 4, 1988, Arabic versions of MS- DOS are 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-DOS programs, where an adapter block is plugged into the parallel port and software makes use of coded bytes within the block. This type of copy protection has been common on Commodore products for several years, where it is called a "dongle." The AutoCAD dongle was defeated by a small program written within weeks of version 2.52's debut. Version 2.62 was released 3 months later, without the dongle. The DOS dongle will, however, prevent the system from booting at all unless it is found. This makes the Arabic version of MSDOS the first copy-protected operating system, a dubious distinction at best. The modifications to the operating system to support the dongle are not known at this time. Frankly, it would seem that burning the operating system into ROMs would be cheaper and simpler. Versions of DOS sold in Great Britain are either newer than those sold in the US or use a different numbering system. DOS 3.4, 4.0, 4.1, 4.2, and 4.3 had been released there between the US releases of 3.3 and 4.0. MSDOS 4.0 (eDOS) was introduced in mid-1987 in Europe (at SICOB in Paris and sometime earlier by Apricot Computer in the UK). It offered multitasking provided applications were specially written for it. David Fraser (Microsoft UK Managing Director) is on record saying that "DOS 4.0 is unlikely to set the world alight and is of interest only to specific OEMs who want its features for networking and communications." Standard DOS applications will run under DOS 4.x as a foreground task according to uncertain information. It differs from earlier versions only in allowing background tasks to run. For further information, see Chapter 4. Microsoft changed their OEM licensing agreements between DOS versions 2.x and 3.x. OEM versions of DOS 3.x must maintain certain data areas and undocumented functions in order to provide compatibility with the networking features of the operating system. For this reason, TSR programs will be much more reliable when operating under DOS 3.x. Several versions of DOS have been modified to be run out of ROM. The Sharp PC5000 had MSDOS 1.25 in ROM, and the Toshiba 1000 and some Tandy 1000 models have MSDOS 2.11 in ROM. In mid-September 1989 Microsoft introduced 3.21R ROMs for laptops, and in early '90 Texas Instruments laptops were the first to get the 3.3R ROMs. All versions of Digital Research's DR-DOS are available in ROM version and Award Software is marketing DR-DOS cards to OEMs as a plug-in to ISA-bus machines. IBM's release of DOS 4.0 (and the immediate subsequent release of a bugfix) was a dubious step "forward." DOS 4.0 was the first version of DOS to come with a warranty; the catch is that IBM warranted it only for a very slim list of IBM-packaged software. 4.0 had some minor EMS support, support for large hard disks, and not much else. With its voracious RAM requirements and lack of compatibility with previous versions of DOS (many major software packages crashed under DOS 4.0), plus the increase in price to a cool $150, there was no great rush to go to that version of DOS. Microsoft undertook development of MSDOS 5.0 in early 1990, soliciting input from Usenet, BIX, and Compuserve among others. This was quite a surprise after Bill Gates had announced "DOS is dead" at every opportunity, trying to build support for OS/2. Alas, most of Microsoft's revenue came from DOS, not OS/2's few sales (at $325 per copy) or applications. Apparently Microsoft realized they were shooting themselves in the foot and that there was still plenty of life left in DOS. They dropped OS/2 development shortly after starting on DOS 5.0. 5.0 is a functional clone of Digital Research's DR-DOS 5.0. 5.0's compatibility was assured by what has been claimed as the largest beta-test program in history -in his address to the Boston Computer Society, Bill Gates announced over 7,500 testers were involved. There are many versions of MS-DOS 5.0. Microsoft's original revision reported "Revision A" when you used the at-first-undocumented VER/R command. There was a Revision B and C, which I have personally seen right out of the shrinkwrap. Microsoft has denied (at least up to late 1992) there ever was a B or C revision, and shortly afterward new copies started reporting "Revision A" no matter what the datestamps on the files were. IBM DOS 5.0 went through a number of CSDs, all of which were available for free download from their BBS in Atlanta (see Appendix 5) but most of the revisions related to IBM specific hardware problems. MS-DOS 6.0 was introduced in March 1993. It bundles some third party utilities and disk compression (developed from licensed code), but other than boot control via new CONFIG.SYS options, it doesn't add any new features. If it weren't for marketing reasons, it would probably have been called DOS 5.1. The Operating System Hierarchy ................................. 1**5 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. As the term 'system' might imply, DOS is not one program but a collection of programs designed to work together to allow the user access to programs and data. Thus, DOS consists of several layers of "control" programs and a set of "utility" programs. The system hierarchy 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 one byte wide and one million bytes long. Parts of this ladder are in ROM, parts in RAM, and parts are not assigned. There are also 65,536 "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 .................................................. 1**6 DOS consists of four components: * The boot record * The ROM BIOS interface (IBMBIO.COM, DRBIOS.SYS, or IO.SYS) * The DOS program file (IBMDOS.COM, DRBDOS.SYS, 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 prepared 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 and Extensions 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 machines). Some versions of MSDOS, such as those from Compaq's MS-DOS and Digital Research's DRDOS 5.0, are named IBMBIO.COM but are not IBM files. These low-level interface routines include the instructions for performing operations such as displaying information on the screen, reading the keyboard, sending data out to the printer, operating the disk drives, and so on. It is the operating system's means of controlling the hardware. IBMBIO.COM contains any modifications or updates to the ROM BIOS that are needed to correct any bugs or add support for other types of hardware such as new disk drives. By using IBMBIO.COM to update the ROM BIOS on the fly when the user turns on their computer, IBM does not need to replace the ROM BIOS chip itself, but makes any corrections through the cheaper and easier method of modifying the IBMBIO.COM file instead. IBMBIO.COM also keeps track of hardware operations on an internal stack or "scratch pad" area for the operating system to save information such as addresses it 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 processor to save your letter, it will write the data to your disk. During this time, if you start typing some more information, the keyboard generates a hardware interrupt. Since you don't want the process of writing the information to the disk to be interrupted, DOS allocates a slot in the stack for the keyboard's hardware interrupt and when it gets a chance, (probably after the data has been written to the disk), it can process that interrupt and pick up the characters you may have been typing. The STACKS= command in DOS 3.2+'s CONFIG.SYS file controls the number of stack frames available for this purpose. IBMBIO.COM also reads your CONFIG.SYS file and installs any device drivers (i.e. DEVICE=ANSI.SYS) or configuration commands it may find there. * The DOS Program The actual DOS program is the 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. When a user program calls DOS to perform an operation, these functions translate the requirement into one or more calls to IBMBIO.COM, MSDOS.SYS or system hardware to complete the request. This section is often referred to as the "kernel" by systems programmers. * The Command Interpreter The command interpreter, COMMAND.COM, is the part you interact with on the command line. COMMAND.COM has three parts. IBM calls them the "resident portion", the "initialization portion" and the "transient portion". IBM's original documentation spoke of installing alternate command interpreters (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 IBMBIO.COM. By the time much of the interaction was widely understood, many commercial software programs had been written to use peculiarities of COMMAND.COM itself. Several programs exist that perform as actual "shells" by completely replacing COMMAND.COM and substituting their own command interpreter to use with the hidden DOS files. Examples are Command Plus, a commercial package, and the shareware 4DOS and FlexShell packages. Both supply greatly enhanced batch language and editing capabilities. 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 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.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. All standard DOS error handling is done within the resident portion of COMMAND.COM. This includes displaying error messages and interpreting the replies to the "Abort, Retry, Ignore, Fail?" message. Since the transient portion of COMMAND.COM is so large (containing the internal commands and all those error messages), and it is not needed when the user is running an application it can be overlaid that program if that application needs the room. When the application is 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 needs to get the transient portion off the disk since it was overlaid with the application program. The initialization portion of COMMAND.COM follows the resident portion and is given control during the bootup procedure. This section actually processes the AUTOEXEC.BAT file. It also decides where to load the user's programs when they are executed. Since this code is only needed during startup, it is overlaid by the first program which COMMAND.COM loads. The transient portion is loaded at the high end of memory and it is the command processor itself. It interprets whatever the user types in at the keyboard, hence messages such as "Bad command or file name" for when the user misspells a command. This portion contains all the internal commands (i.e. COPY, DIR, RENAME, ERASE), the batch file processor (to run .BAT files) and a routine to load and execute external commands which are either .COM or .EXE files. The transient portion of COMMAND.COM produces the system prompt, (C>), and reads what the user types in from the keyboard and tries to do something with it. For any .COM or .EXE files, it builds a command line and issues an EXEC function call to load the program and transfer control to it. DOS Initialization ............................................. 1**7 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). When the ROM BIOS finds a ROM on an adapter card, it lets that ROM take control of the system so that it may perform any set up necessary to use the hardware or software controlled by that ROM. The ROM BIOS searches absolute addresses C8000h through E0000h in 2K increments in search of a valid ROM. A valid ROM is determined by the first few bytes in the ROM. The ROM will have the bytes 55h, AAh, a length indicator and then the assembly language instruction to CALL FAR (to bring in a "FAR" routine). A checksum is done on the ROM to verify its integrity, then the BIOS performs the CALL FAR to bring in the executible code. The adapter's ROM then performs its initialization tasks and hopefully returns control of the computer back to the ROM BIOS so it can continue with the booting process. The ROM BIOS routines then look 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 an 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 or their OEM equivalents. These files must be in that order, with IBMBIO.COM first, with its sectors in contiguous order. note 1) IBMDOS.COM need not be contiguous in version 3.x+. 2) DR-DOS versions 3.40 through 6.0 may have DRBIOS.SYS and DRDOS.SYS anywhere on the hard disk. 3) PC-MOS/386' $$MOS.SYS file may be anywhere on the hard disk. 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 1) 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 also initializes the vectors for interrupts 0Fh through 3Fh. 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 1) AUTOEXEC.BAT may be a hidden file. 6. IBMDOS.COM uses the EXEC function call to load and start the top- level command processor. The default command processor is COMMAND.COM in the root directory of the boot drive. If COMMAND.COM is in a subdirectory or another command processor is to be used, it must be specified by a SHELL= statement in the CONFIG.SYS 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 1) COMMAND.COM may be a hidden file. 2) For IBM DOS 2.x, the transient portion of the command processor contains the EXEC routine that loads and executes external commands. For MSDOS 2.x+ and IBM DOS 3.x+, the resident portion of the command processor contains the EXEC routine. 3) IBMDOS only checks for a file named "COMMAND.COM". It will load any file of that name if no SHELL= command is used. That pretty much covers the bootup process. After the command processor is loaded, it runs the AUTOEXEC.BAT file and then the user gets their prompt to begin working.