MSDOS
MSDOS
MSDOS
It is unlikely that you will ever be called upon to configure the MS-DOS software for
a new model of computer. Still, an acquaintance with the general structure of MS-
DOS can often be very helpful in understanding the behavior of the system as a
whole. In this chapter, we will discuss how MS-DOS is organized and how it is loaded
into memory when the computer is turned on.
The Structure of MS-DOS
MS-DOS is partitioned into several layers that serve to isolate the kernel logic of the
operating system, and the user's perception of the system, from the hardware it is
running on. These layers are:
1. The BIOS (Basic Input/Output System)
2. The DOS kernel
3. The command processor (shell)
COMMAND.COM
The default MS-DOS shell, COMMAND.COM, is divided into three parts:
1. A resident portion
2. An initialization section
3. A transient module
The resident portion is loaded in lower memory, above the DOS kernel and its
buffers and tables. It contains the routines to process Ctrl-C and Ctrl-Break, critical
errors, and the termination (final exit) of other transient programs. This part of
COMMAND.COM issues error messages and is responsible for the familiar prompt
The resident portion also contains the code required to reload the transient portion
of COMMAND.COM when necessary.
The transient portion of COMMAND.COM is loaded at the high end of memory, and
its memory can also be used for other purposes by application programs. The
transient module issues the user prompt, reads the commands from the keyboard or
batch file, and causes them to be executed. When an application program
terminates, the resident portion of COMMAND.COM does a checksum of the
transient module to determine whether it has been destroyed and fetches a fresh
copy from the disk if necessary.
The user commands that are accepted by COMMAND.COM fall into three categories:
1. Internal commands
2.External commands
3. Batch files
Internal commands, sometimes called intrinsic commands, are those carried out by
code embedded in COMMAND.COM itself. Commands in this category include COPY,
REN(AME), DIR(ECTORY), and DEL(ETE). The routines for the internal commands are
included in the transient part of COMMAND.COM.
Batch files are text files that contain lists of other intrinsic, extrinsic, or batch
commands. These files are processed by a special interpreter that is built into the
transient portion of COMMAND.COM. The interpreter reads the batch file one line at
a time and carries out each of the specified operations in order.
In order to interpret a user's command, COMMAND.COM first looks to see if the user
typed the name of a built-in (intrinsic) command that it can carry out directly. If not,
it searches for an external command
(executable program file) or batch file by the same name. The search is carried out
first in the current directory of the current disk drive and then in each of the
directories specified in the most recent PATH command. In each directory inspected,
COMMAND.COM first tries to find a file with the extension .COM, then .EXE, and
finally .BAT. If the search fails for all three file types in all of the possible locations,
COMMAND.COM displays the familiar message.
INTERRUPT SERVICES:====>
AH = 07
AL = number of lines to scroll, previous lines are
blanked, if 0 or AL > screen size, window is blanked
BH = attribute to be used on blank line
CH = row of upper left corner of scroll window
CL = column of upper left corner of scroll window
DH = row of lower right corner of scroll window
DL = column of lower right corner of scroll window
returns nothing
- in video mode 4 (300x200 4 color) on the EGA, MCGA and VGA
this function scrolls page 0 regardless of the current page
- can be used to scroll graphics screens, using character coords
- on CGA's this function disables video adapter, causing flitter
INT 21,41 - DELETE FILE
AH = 41h
DS:DX = pointer to an ASCIIZ filename
on return:
AX = error code if CF set (see DOS ERROR CODES)
- marks first byte of file directory entry with E5 to indicate
the file has been deleted. The rest of the directory entry
stays intact until reused. ~FAT~ pointers are returned to DOS
- documented as not accepting wildcards in filename but actually
does in several DOS versions
INT 21,56 - RENAME FILE
AH = 56h
DS:DX = pointer to old ASCIIZ path/filename
ES:DI = pointer to new ASCIIZ path/filename
on return:
AX = error code if CF set (see ~DOS ERROR CODES~)
- supports full pathnames and allows renaming files across
directories and in DOS 3.x allows renaming subdirectories
- does not support use of wildcards unless invoked from via
~INT 21,5D~ in which case error code 12h is returned
- unpredictable result may occur if an opened file is renamed