MSDOS [version] [program [arguments]]
Runs program (any command, including a BAT file, which it runs as DOS does; see Batch Files, since MSDOS runs it as COMMAND /C program [arguments]), or without one, a command shell (until EXIT), with DOS services that some real-mode programs need but BASIC-DOS doesn’t provide itself. So far, there’s one: Load Overlay (DOS function 4B03h), which programs built with Borland C use to replace themselves with another program (the C runtime’s exec functions). For example, the VIEW program on the Simtel CD-ROMs unzips a file by replacing itself with UNZIP, so on a Simtel disc, run MSDOS GO instead of GO, or run MSDOS and then GO. Without MSDOS, such a program fails when it tries to run the other one, usually after it has released its own memory, so it just ends (VIEW displays a few garbage characters first).
A version (a number, optionally followed by a decimal point and one or two digits, eg, 5, 3.3, or 3.30, where 3.3 is 3.30) is the DOS version that programs get when they ask for it (DOS function 30h), for programs that refuse to run on the version that BASIC-DOS reports, as MS-DOS’s SETVER provided (eg, MSDOS 3.30 OLDPROG, or MSDOS 5 for a shell whose programs all get version 5.00). A major version over 255, or more than two digits after the decimal point, is a usage error; an argument that isn’t just a number (eg, 3DMAZE) is the program. Without a version, programs get BASIC-DOS’s own version.
Programs that MSDOS (or a program run under it) runs also get their full names (eg, D:\SETUP.EXE) after the strings in their environments, as DOS 3.0 and up provide, since a C program uses that name as argv[0] on DOS 3.0 or up (eg, the SETUP program on the Microsoft Programmer’s Library disc requires a drive in it, and otherwise says that it needs DOS 3.0, so run MSDOS 3.0 SETUP).
Under MSDOS, a BAT file is a DOS batch file: COMMAND gives each BAT file that it’s asked to run (at the prompt, or with COMMAND /C, but not one that a BAS or BAT program runs) to MSDOS, which runs it the way DOS’s COMMAND does, giving COMMAND its commands one at a time, which COMMAND runs as if they’d been typed (and displays first, with the prompt, while ECHO is on). In a batch file’s lines, %0 through %9 are its name (as typed) and arguments, after any SHIFTs, %name% is a variable that SET set, and %% is a %; a line that starts with @ isn’t displayed, and a line that starts with : is a label. MSDOS runs DOS’s batch commands itself:
ECHO displays whether ECHO is on, ECHO ON and ECHO OFF turn it on and off, ECHO. displays a blank line, and ECHO text displays the text (as PRINT "text", so redirecting it works too, eg, ECHO text >> LOG.TXT)SET displays the variables, and SET name=value sets one (an empty value removes it); PATH [path] does the same for PATH (PATH ; for none), and setting PATH sets PATH$, tooIF [NOT] ERRORLEVEL n |
EXIST filespec |
string1==string2 command runs command if ERRORLEVEL is n or more, a file matches filespec, or the strings are the same (in the same case), or with NOT, if not |
GOTO label continues after the line :label (the first 8 characters count, in any case), SHIFT makes %1 the next argument (and so on), and CALL file runs another batch file and then continues (without CALL, the other batch file replaces the one that runs it, as in DOS)FOR %%v IN (set) DO command runs command once for each item of set, with %v replaced by the item, where an item with * or ? is each file it matchesPAUSE displays Press any key to continue . . . and waits for a key, REM does nothing, and so do BREAK, CTTY, PROMPT, and VERIFYCHDIR, MKDIR, RMDIR, RENAME, and ERASE are COMMAND’s CD, MD, RD, REN, and DELThe variables that SET sets are in a master environment that MSDOS keeps (starting with a copy of its own environment), which every program that runs under MSDOS gets, along with the COMSPEC and PATH that COMMAND gives every program. If CTRL-C ends a command, MSDOS asks Terminate batch job (Y/N)?. Lines that are BASIC statements still run (as they would at the prompt), but a line number in a batch file isn’t a label (a line that starts with a number is added to the loaded program, as at the prompt), so run BASIC-DOS’s own BAT files without MSDOS.
If there’s a CD-ROM drive, programs also get the MSCDEX functions (INT 2Fh, AH = 15h) that CD-ROM programs use to find the drive (1500h, 150Bh, and 150Dh), check MSCDEX’s version (150Ch, which reports 2.10), and send device requests to the drive (1510h), although BASIC-DOS reads the disc itself: the drive answers as one with a data disc and no audio, so its audio status is always stopped (no audio plays), and a raw read (READ LONG) is an unknown command. Some programs need them even without audio (eg, The Manhole, which otherwise says CD-ROM Extensions not installed and then waits forever for its audio to stop); on an 80386 in protected mode, such a program runs under MSDOS automatically (see V86).
MSDOS provides these services by hooking INT 21h (and INT 2Fh, for a CD-ROM drive) for as long as it runs (in real mode, programs in other sessions get them, too, including any version), and the hook is removed when MSDOS ends, however it ends (eg, CTRL-ALT-DEL or KILL). Protected mode can’t load real-mode programs, so in protected mode on an 80386, MSDOS runs START V86 MSDOS [program [arguments]], which runs MSDOS again, in a V86 machine on a console of its own that gets the focus, where it hooks the machine’s INT 21h and runs the command; the machine, and its console, close when the command (or the shell) ends, after Press any key to return to your original prompt. COMMAND does the same when it can’t load a real-mode program in protected mode (eg, WOLF3D at the prompt; see V86), so such a program gets these services, too. As with START, MSDOS doesn’t wait for the machine: it ends as soon as the machine has started (so a BAS or BAT file goes on with its next command), and the command’s input and output are its new console (to keep them redirected, run V86 MSDOS [program [arguments]] instead, which runs the machine on the current console). In protected mode on an 80286, which has no V86 mode, MSDOS displays Real mode required (see CPU for how to start BASIC-DOS in real mode). Any switch before program is a usage error.
ERRORLEVEL is set to the command’s exit code (COMMAND’s, which is the program’s; in protected mode, START’s), or 1 if MSDOS couldn’t run COMMAND.COM (from the root of the system drive) or needs real mode.
Source: msdos.asm
Copyright (c) 2020-2026 Jeff Parsons Released under MIT License