Chapter 6 (a2) - MS-DOS Command Referance ; Debug - EGA.SYS
  
Debug

Starts the Debug program, which you can use to test and debug executable files. 

Syntax

debug [[drive:][path]filename [testfile-parameters]] 
  
Parameters

[drive:][path]filename
Specifies the location and name of the executable file you want to test. 

testfile-parameters
Specifies any command-line information required by the executable file you want to test. 

Notes

Using the debug command without specifying a file to be tested

If you use the debug command without a location and filename, you then type all Debug commands in 
response to the Debug prompt, a hyphen (-). 

Debug commands

The following is a list of Debug commands: 
  
Command	Description

?	Displays a list of the Debug commands. 
a	Assembles 8086/8087/8088 mnemonics. 
c	Compares two portions of memory. 
d	Displays the contents of a portion of memory. 
e	Enters data into memory starting at a specified address. 
f	Fills a range of memory with specified values. 
g	Runs the executable file that is in memory. 
h	Performs hexadecimal arithmetic. 
i	Displays one byte value from a specified port. 
l	Loads the contents of a file or disk sectors into memory. 
m	Copies the contents of a block of memory. 
n	Specifies a file for an l or w command, or specifies the parameters for the file you are testing. 
o	Sends one byte value to an output port. 
p	Executes a loop, a repeated string instruction, a software interrupt, or a subroutine.
q	Stops the Debug session. 
r	Displays or alters the contents of one or more registers. 
s	Searches a portion of memory for a specified pattern of one or more byte values. 
t	Executes one instruction and then displays the contents of all registers, the status of all flags, 
	and the decoded form of the instruction that Debug will execute next. 
u	Disassembles bytes and displays the corresponding source statements. 
w	Writes the file being tested to a disk. 
xa	Allocates expanded memory. 
xd	Deallocates expanded memory. 
xm	Maps expanded memory pages. 
xs	Displays the status of expanded memory. 

Separating command parameters

All Debug commands accept parameters, except the q command. You can separate parameters with 
commas or spaces, but these separators are required only between two hexadecimal values. Therefore, 
the following commands are equivalent: 
  
dcs:100 110 
d cs:100 110 
d,cs:100,110 
  
Specifying valid address entries

An address parameter in a Debug command specifies a location in memory. Address is a two-part 
designation containing either an alphabetic segment register or a 4-digit segment address, plus an 
offset value. You can omit the segment register or segment address. The default segment for the a, g, l, 
t, u, and w commands is CS. The default segment for all other commands is DS. All numeric values are 
in hexadecimal format. 

The following are valid addresses: 
  
CS:0100 
04BA:0100 
  
The colon between the segment name and the offset value is required. 

Specifying valid range entries 

A range parameter in a Debug command specifies a range of memory. You can choose from two 
formats for range: a starting address and an ending address, or a starting address and the length 
(denoted by l) of the range. 

For example, both of the following syntaxes specify a 16-byte range beginning at CS:100: 
  
cs:100 10f 
cs:100 l 10 
  
Related Commands

The following commands are Debug commands: 
  
a (Assemble)	p (Proceed)
c (Compare)	q (Quit)
d (Dump)	r (Register)
e (Enter)	s (Search)
f (Fill)		t (Trace)
g (Go)		u (Unassemble)
h (Hex)		w (Write)
i (Input)		xa (Allocate Expanded Memory)
l (Load)		xd (Deallocate Expanded Memory)
m (Move)	xm (Map Extended Memory Pages)
n (Name)	xs (Display Expanded Memory Status)
o (Output)
	
Debug: A (Assemble)

Assembles 8086/8087/8088 mnemonics directly into memory. 

This command creates executable machine code from assembly-language statements. All numeric 
values are in hexadecimal format, and you must type them as 1 to 4 characters. You specify a prefix 
mnemonic in front of the operation code (opcode) to which it refers. 

Syntax
a [address] 

Parameters

address
Specifies the location where you type assembly-language mnemonics. You use hexadecimal values for 
address and type each value without the trailing “h” character. If you do not specify an address, a starts 
assembling where it last stopped. 

Notes

Using mnemonics

The segment-override mnemonics are cs:, ds:, es:, and ss:. The mnemonic for the far return is retf. 
String-manipulation mnemonics must explicitly state the string size. For example, use movsw to move 
word strings (16 bits), and use movsb to move byte strings (8 bits). 

Assembling jumps and calls

The assembler automatically assembles a short, near, or far jump or call, depending on byte 
displacement, to the destination address. You can override such a jump or call by using a near or far 
prefix, as the following example shows: 

–a0100:0500
0100:0500 jmp 502       ; a 2-byte short jump
0100:0502 jmp near 505  ;a 3-byte near jump
0100:0505 jmp far 50a   ; a 5-byte far jump

You can abbreviate the near prefix to ne. 

Distinguishing word and byte memory locations

When an operand can refer to either a word memory location or a byte memory location, you must 
specify the data type with the prefix word ptr or the prefix byte ptr. Acceptable abbreviations are wo and 
by, respectively. The following example shows the two formats: 
  
dec 	wo [si] 
neg 	byte ptr [128] 
  
Specifying operands

Debug uses the common convention that an operand enclosed in brackets ([ ]) refers to a memory 
location. This is because Debug cannot otherwise differentiate between an immediate operand and an 
operand that is a memory location. The following example shows the two formats: 
  
mov 	ax,21       ; load AX with 21h
mov 	ax,[21]     ; load AX with the
               	 	; contents of
                	; memory location 21h
  
Using pseudoinstructions

Two popular pseudoinstructions are available with the a command: the db opcode, which assembles 
byte values directly into memory, and the dw opcode, which assembles word values directly into 
memory. Following are examples of both pseudoinstructions: 
  
db 1,2,3,4,“THIS IS AN EXAMPLE”
db ‘THIS IS A QUOTATION MARK: “’
db ”THIS IS A QUOTATION MARK: ‘“

dw 1000,2000,3000,”BACH“
  
Examples

The a command supports all forms of register-indirect commands, as the following example shows: 
  
add bx,34[bp+2].[si-1]
pop [bp+di]
push [si]
  
All opcode synonyms are also supported, as the following example shows: 
  
loopz 100
loope 100

ja      200
jnbe    200
  
For 8087 opcodes, you must specify the wait or fwait prefix, as the following example shows: 
  
fwait fadd st,st(3)       ; this line assembles
                          ; an fwait prefix
  
Related Commands

For information about entering data into specific bytes, see the Debug e (Enter) command. 
For information about disassembling bytes, see the Debug u (Unassemble) command. 

Debug: C (Compare)

Compares two portions of memory. 

Syntax

c range address 

Parameters

range
Specifies the starting and ending addresses, or the starting address and length, of the first area of 
memory you want to compare. For information about valid range values, see the debug command. 

address 
Specifies the starting address of the second area of memory you want to compare. For information 
about valid address values, see the debug command. 

Note

If the range and address memory areas are identical, Debug displays nothing and returns directly to the 
Debug prompt. If there are differences, Debug displays them in the following format: 

address1 byte1 byte2 address2 
  
Example

The following commands have the same effect: 
  
c100,10f 300 
c100l10 300 
  
Each command compares the block of memory from 100h through 10Fh with the block of memory from 
300h through 30Fh. 

Debug responds to either of the previous commands with a display similar to the following 
(assuming DS = 197F): 
  
197F:0100 4D E4 197F:0300
197F:0101 67 99 197F:0301
197F:0102 A3 27 197F:0302
197F:0103 35 F3 197F:0303
197F:0104 97 BD 197F:0304
197F:0105 04 35 197F:0305
197F:0107 76 71 197F:0307
197F:0108 E6 11 197F:0308
197F:0109 19 2C 197F:0309
197F:010A 80 0A 197F:030A
197F:010B 36 7F 197F:030B
197F:010C BE 22 197F:030C
197F:010D 83 93 197F:030D
197F:010E 49 77 197F:030E
197F:010F 4F 8A 197F:030F
  
Notice that the addresses 197F:0106 and 197F:0306 are missing from the list. This means that the 
values in those addresses are identical. 

Debug: D (Dump)

Displays the contents of a range of memory addresses. 

Syntax

d [range] 

Parameter

range
Specifies the starting and ending addresses, or the starting address and length, of the memory area 
whose contents you want to display. For information about valid range values, see the debug command. 
If you do not specify range, Debug displays the contents of 128 bytes, starting at the end of the address 
range specified in the previous d command. 

Note

When you use the d command, Debug displays memory contents in two portions: a hexadecimal 
portion (each byte value is shown in hexadecimal format) and an ASCII portion (each byte value is 
shown as an ASCII character). Each nonprinting character is denoted by a period (.) in the ASCII portion 
of the display. Each display line shows the contents of 16 bytes, with a hyphen between the eighth and 
ninth bytes. Each display line begins on a 16-byte boundary. 

Examples

Suppose you type the following command: 
  
dcs:100 10f 
  
Debug displays the the contents of the range in the following format: 
  
04BA:0100 54 4F 4D 00 53 41 57 59-45 52 00 00 00 00 00 00 TOM.SAWYER......
  
If you type the d command without parameters, Debug formats the display as described in the previous 
example. Each line of the display begins with an address that is 16 bytes greater than the address on 
the previous line (or 8 bytes if you have a 40-column screen). 

For each subsequent d command you type without parameters, Debug displays the bytes immediately
 following those last displayed. 

If you type the following command, Debug displays the contents of 20h bytes, starting at CS:100: 
  
dcs:100 l 20 
  
If you type the following command, Debug displays the contents of all bytes in the range of lines from 
100h through 115h in the CS segment: 
  
dcs:100 115 
  
Related Commands

For information about displaying the contents of registers, see the Debug r (Register) command. 

For information about disassembling bytes, see the Debag u (Unassemble) command. 

Debug: E (Enter)

Enters data into memory at the address you specify. 

You can type data in either hexadecimal or ASCII format. Any data previously stored at the specified 
address is lost. 

Syntax

e address [list] 

Parameters

address
Specifies the first memory location where you want to enter data. 

list
Specifies the data you want to enter into successive bytes of memory. 

Notes

Using the address parameter

If you specify a value for address without specifying a value for the optional list parameter, Debug 
displays the address and its contents, repeats the address on the next line, and waits for your input. At 
this point, you can perform one of the following actions: 

·	Replace the byte value. To do this, you type a new value after the current value. If the value you 
	type is not a valid hexadecimal value or if it contains more than two digits, Debug does not echo
	 the invalid or extra character. 
·	Advance to the next byte. To do this, you press the SPACEBAR. To change the value in that 
	byte, type a new value after the current value. If you move beyond an 8-byte boundary when you 
	press the SPACEBAR, Debug starts a new display line and displays the new address at the 
	beginning of the line. 
·	Return to the preceding byte. To do this, you press the HYPHEN key. You can press the 
	HYPHEN key repeatedly to move back more than 1 byte. When you press HYPHEN, Debug 
	starts a new line and displays the current address and byte value. 
·	Stop the e command. To do this, you press the ENTER key. You can press ENTER at any 
	byte position. 
  
Using the list parameter

If you specify values for the list parameter, the e command sequentially replaces the existing byte
 values with the values from the list. If an error occurs, no byte values are changed. 

List values can be either hexadecimal byte values or strings. You separate values by using a space, a 
comma, or a tab character. You must enclose strings within single or double quotation marks. 

Examples

Suppose you type the following command: 
  
ecs:100 
  
Debug displays the contents of the first byte in the following format: 
  
04BA:0100 EB._
  
To change this value to 41, type 41 at the cursor, as follows: 
  
04BA:0100 EB.41_ 
  
You can type consecutive byte values with one e command. Instead of pressing ENTER after typing the 
new value, press the SPACEBAR. Debug displays the next value. In this example, if you press the 
SPACEBAR three times, Debug displays the following values: 
  
04BA:0100 EB.41  10. 00. BC._
  
To change the hexadecimal value BC to 42, type 42 at the cursor, as follows: 
  
04BA:0100 EB.41  10. 00. BC.42_ 
  
Now suppose that you decide the value 10 should be 6F. To correct this value, press the HYPHEN key 
twice to return to address 0101 (value 10). Debug displays the following: 
  
04BA:0100 EB.41  10. 00. BC.42-
04BA:0102  00.-
04BA:0101  10._
  
Type 6f at the cursor to change the value, as follows: 
  
04BA:0101  10.6f_ 
  
Press ENTER to stop the e command and return to the Debug prompt. 
The following is an example of a string entry: 
  
eds:100 “This is the text example” 
  
This string will fill 24 bytes, starting at DS:100. 

Related Commands

For information about assembling mnemonics, see the Debug a (Assemble) command. 
For information about displaying the contents of a portion of memory, see the Debug d (Dump) 
command. 

Debug: F (Fill)

Fills addresses in the specified memory area with values you specify. 
You can specify data in either hexadecimal or ASCII format. Any data you previously stored at the 
specified address is lost.
 
Syntax

f range list 

Parameters

range
Specifies the starting and ending addresses, or the starting address and length, of the memory area 
you want to fill. For information about valid range values, see the debug command. 

list
Specifies the data you want to enter. List can consist of hexadecimal numbers or a string enclosed in 
quotation marks. 

Notes

Using the range parameter

If range contains more bytes than the number of values in list, Debug assigns the values in list 
repeatedly until all bytes in range are filled. 

If any of the memory in range is bad or doesn’t exist, Debug displays an error message and stops the 
f command.
 
Using the list parameter

If list contains more values than the number of bytes in range, Debug ignores the extra values in list. 

Example

Suppose you type the following command: 
  
f04ba:100l100 42 45 52 54 41 
  
In response, Debug fills memory locations 04BA:100 through 04BA:1FF with the values specified. 
Debug repeats the five values until all the 100h bytes are filled. 

Debug: G (Go)

Runs the program currently in memory. 

Syntax

g [=address] [breakpoints] 

Parameters

=address
Specifies the address in the program currently in memory at which you want execution to begin. If you 
do not specify address, MS-DOS begins program execution at the current address in the CS:IP 
registers. 

breakpoints
Specifies 1 to 10 temporary breakpoints that you can set as part of the g command. 

Notes

Using the address parameter

You must precede the address parameter with an equal sign (=) to distinguish the starting address 
(address) from the breakpoint addresses (breakpoints). 

Specifying breakpoints

The program stops at the first breakpoint it encounters, regardless of where you typed that breakpoint in
 the breakpoints list. Debug replaces the original instruction at each breakpoint with an interrupt code. 

When the program reaches a breakpoint, Debug restores all breakpoint addresses to their original 
instructions and displays the contents of all registers, the status of all flags, and the decoded form of 
the last instruction executed. Debug displays the same information as it would display if you used the 
Debug r (register) command and specified the breakpoint address. 

If you do not stop the program at one of the breakpoints, Debug does not replace the interrupt codes 
with the original instructions. 

Limitations on setting breakpoints

You can set breakpoints only at addresses containing the first byte of an 8086 operation code (opcode)
If you set more than 10 breakpoints, Debug displays the following message: 
  
bp Error
  
Requirements for the user stack pointer

The user stack pointer must be valid and must have 6 bytes available for the g command. This command
 uses an iret instruction to jump to the program being tested. Debug sets the user stack pointer and 
pushes the user flags, the code segment register, and the instruction pointer onto the user stack. 
(If the user stack is not valid or is too small, the operating system might fail.) Debug places an interrupt
code (0CCh) at the specified breakpoint address(es). 

Restarting a program

Do not attempt to restart a program after MS-DOS displays the following message: 
  
Program terminated normally
  
To run the program properly, you must reload it by using the Debug n (name) and l (load) commands. 

Examples

Suppose you type the following command: 
  
gcs:7550 
  
MS-DOS runs the program currently in memory up to the breakpoint address 7550 in the CS segment. 
Debug then displays the contents of the registers and the status of the flags and stops the g command. 

The following command sets two breakpoints: 
  
gcs:7550, cs:8000 
  
If you type the g command again after Debug encounters a breakpoint, execution begins at the 
instruction after the breakpoint, rather than at the usual starting address. 

Related Commands

For information about executing a loop, a repeated string instruction, a software interrupt, or a 
subroutine, see the Debug p (Proceed) command. 

For information about executing one instruction, see the Debug t (Trace) command. 

Debug: H (Hex)

Performs hexadecimal arithmetic on two parameters you specify. 

Syntax

h value1 value2
 
Parameters

value1
Represents any hexadecimal number in the range 0 through FFFFh.
 
value2
Represents a second hexadecimal number in the range 0 through FFFFh. 

Note

Debug first adds the two parameters you specify and then subtracts the second parameter from the first.
The results of these calculations are displayed on one line  —  first the sum, then the difference. 

Example

Suppose you type the following command: 
  
h19f 10a 
  
Debug performs the calculations and displays the following result: 
  
02A9 0095
  
Debug: I (Input)

Reads and displays one byte value from the port you specify. 

Syntax

i port 

Parameter

port
Specifies the input port by address. The address can be a 16-bit value. 

Example

Suppose you type the following command: 
  
i2f8 
  
Suppose also that the byte value at the port is 42h. Debug reads the byte and then displays the value, 
as follows: 
  
42
  
Related Command

For information about sending the value of a byte to an output port, see the Debug o (Output) command.
 
Debug: L (Load)

Loads a file or contents of specific disk sectors into memory. 

To load the contents of the number of bytes specified in the BX:CX registers from a disk file, use the 
following syntax: 

Syntax

l [address] 
  
To bypass the MS-DOS file system and directly load specific sectors, use the following syntax: 

l address drive start number 
  
Parameters

address
Specifies the memory location where you want to load the file or the sector contents. If you do not 
specify address, Debug uses the current address in the CS register. 

drive
Specifies the drive that contains the disk from which specific sectors are to be read. This value is 
numeric: 0 = A, 1 = B, 2 = C, and so on. You use the drive, start, and number parameters only if you 
want to load the contents of specific sectors rather than load the file specified on the debug command 
line or in the most recent Debug n (name) command. 

start
Specifies the hexadecimal number of the first sector whose contents you want to load. 

number
Specifies the hexadecimal number of consecutive sectors whose contents you want to load. 

Notes

Using the l command without parameters

When you use the l command without parameters, the file you specified on the debug command line is 
loaded into memory, beginning at address CS:100. Debug also sets the BX and CX registers to the 
number of bytes loaded. If you did not specify a file on the debug command line, the file loaded is the 
one you most recently specified by using the n command. 

Using the l command with the address parameter

If you use the l command with the address parameter, Debug begins loading the file or the contents of 
the specified sectors at the memory location address.
 
Using the l command with all parameters

If you use the l command with all parameters, Debug loads the contents of specific disk sectors instead 
of loading a file. 

Loading the contents of specific sectors

Each sector in the range you specify is read from drive. Debug begins loading with start and continues 
until the contents of the number of sectors specified in number have been loaded. 

Loading an .EXE file

Debug ignores the address parameter for .EXE files. If you specify an .EXE file, Debug relocates the file 
to the loading address specified in the header of the .EXE file. The header itself is stripped off the .EXE 
file before the file is loaded into memory, so the size of an .EXE file on disk differs from its size in 
memory. If you want to examine a complete .EXE file, rename the file with a different extension. 

Opening a hex file

A hex file is a file that uses the Intel hexadecimal format, as described in The MS-DOS Encyclopedia. 
Debug assumes that files with the .HEX extension are hexadecimal-format files. You can type the l 
command with no parameters to load a hex file beginning at the address specified in the hex file. If the l 
command you type includes the address parameter, Debug adds the specified address to the address 
found in the hex file to determine the starting address. 

Examples

Suppose you start Debug and type the following command: 
  
nfile.com 
  
You can now type the l command to load FILE.COM. Debug loads the file and displays the Debug 
prompt. 

Suppose that you want to load the contents of 109 (6Dh) sectors from drive C, beginning with logical 
sector 15 (0Fh), into memory beginning at address 04BA:0100. To do this, type the following command: 
  
l04ba:100 2 0f 6d 
  
Related Commands

For information about specifying a file for the l command, see the Debug n (Name) command. 
For information about writing the file being debugged to a disk, see the Debug w (Write) command. 

Debug: M (Move)

Copies the contents of a block of memory to another block of memory. 

Syntax

m range address 

Parameters

range
Specifies the starting and ending addresses, or the starting address and the length, of the memory area 
whose contents you want to copy. 

address
Specifies the starting address of the location to which you want to copy the contents of range. 

Notes

Effects of the copy operation on existing data

If the addresses in the block being copied do not have new data written to them, the original data
remains intact. However, if the destination block already contains data (as it might in an overlapping 
copy operation), that data is overwritten. (Overlapping copy operations are those in which part of the 
destination block overlaps part of the source block.) 

Performing overlapping copy operations

The m command performs overlapping copy operations without losing data at the destination addresses.
The contents of addresses that will be overwritten are copied first. Thus, if data is to be copied from 
higher addresses to lower addresses, the copy operation begins at the source block’s lowest address 
and progresses toward the highest address. Conversely, if data is to be copied from lower addresses to
 higher addresses, the copy operation begins at the source block’s highest address and progresses 
toward the lowest address. 

Example

Suppose you type the following command: 
  
mcs:100 110 cs:500 
  
Debug first copies the contents of address CS:110 to CS:510, then copies the contents of CS:10F to 
CS:50F, and so on until it has copied the contents of CS:100 to CS:500. To view the results, you can 
use the Debug d (dump) command, specifying the destination address you used with the m command.
 
Debug: N (Name)

Specifies the name of an executable file for a Debug l (load) or w (write) command, or specifies 
parameters for the executable file being debugged.
 
Syntax

n [drive:][path]filename 

To specify parameters for the executable file you are testing, use the following syntax: 

n file-parameters 

To clear the current specifications, use the following syntax:
 
n 

Parameters

[drive:][path]filename
Specifies the location and name of the executable file you want to test.
 
file-parameters
Specifies parameters and switches for the executable file you are testing. 

Notes

The two uses of the n command

You can use the n command in two ways. First, you can use it to specify a file to be used by a later l or 
w command. If you start Debug without naming a file to be debugged, you must use the command 
nfilename before you can use the l command to load the file. The filename is correctly formatted for a file
control block at CS:5C. Second, you can use the n command to specify command-line parameters and 
switches for the file being debugged. 

Memory areas

The following four areas of memory can be affected by the n command: 
  
Memory location	Contents

CS:5C			File control block (FCB) for file 1 
CS:6C			File control block (FCB) for file 2 
CS:80			Length of n command line (in characters) 
CS:81			Beginning of n command-line characters 

The first filename you specify for the n command is placed in a file control block (FCB) at CS:5C. If you 
specify a second filename, this name is placed in an FCB at CS:6C. The number of characters typed on 
the n command line (exclusive of the first character, n) is stored at location CS:80. The actual 
characters on the n command line (again, exclusive of the letter n) are stored beginning at CS:81. 
Note that these characters can be any switches and delimiters that would be legal in a command typed 
at the MS-DOS prompt. 

Examples

Suppose you’ve started Debug and loaded the program PROG.COM for debugging. You subsequently 
decide to specify two parameters for PROG.COM and run the program. 
Following is the sequence of  commands for this example: 
  
    debug prog.com
    nparam1 param2
    g
  
In this case, the Debug g (go) command runs the program as if you had typed the following command 
at the MS-DOS prompt: 
  
prog param1 param2 
  
Testing and debugging therefore reflect a typical run-time environment for PROG.COM. 

In the following sequence of commands, the first n command specifies FILE1.EXE as the file for the 
subsequent l command, which loads FILE1.EXE into memory. The second n command specifies the 
parameters to be used by FILE1.EXE. Finally, the g command runs FILE1.EXE as if you had typed file1 
file2.dat file3.dat at the MS-DOS prompt. 
  
nfile1.exe
l
nfile2.dat file3.dat
g
  
Note that you do not use the l command after the second form of the n command. Also note that if you 
now use the w command, MS-DOS saves FILE1.EXE, the file being debugged, with the name 
FILE2.DAT. To avoid this result, you should always use the first form of the n command immediately 
before either an l or a w command. 

Related Commands

For information about loading the contents of a file or of specific disk sectors into memory, see the 
Debug l (Load) command. 
For information about writing the file being debugged to a disk, see the Debug w (Write) command. 

Debug: O (Output)

Sends the value of a byte to an output port. 

Syntax

o port byte-value 

Parameters

port
Specifies the output port by address. The port address can be a 16-bit value. 

byte-value
Specifies the byte value you want to direct to port. 

Example

To send the byte value 4Fh to the output port at address 2F8h, type the following command: 
  
o2f8 4f 
  
Related Command

For information about reading the value of a byte from an input port, see the Debug i (Input) command. 

Debug: P (Proceed)


Executes a loop, a repeated string instruction, a software interrupt, or a subroutine; or traces through 
any other instruction. 

Syntax

p [=address] [number] 

Parameters

=address
Specifies the location of the first instruction to execute. If you do not specify an address, the default 
address is the current address specified in the CS:IP registers. 

number
Specifies the number of instructions to execute before returning control to Debug. The default value is 1.
 
Notes

Transferring control to the program being tested

When the p command transfers control from Debug to the program being tested, that program runs 
without interruption until the loop, repeated string instruction, software interrupt, or subroutine at the 
specified address is completed, or until the specified number of machine instructions have been 
executed. Control then returns to Debug. 

Limitations on the address parameter

If the address parameter does not specify a segment, Debug uses the CS register of the program being 
tested. If you omit address, the program is executed beginning at the address specified by its CS:IP 
registers. You must precede the address parameter with an equal sign (=) to distinguish it from the 
number parameter. If the instruction at the specified address is not a loop, a repeated string instruction, 
a software interrupt, or a subroutine, the p command works the same way as the Debug t (trace) 
command. 

Messages displayed with the p command

After p executes an instruction, Debug displays the contents of the program’s registers, the status of 
its flags, and the decoded form of the next instruction to be executed. 
  

Caution   You cannot use the p command to trace through read-only memory (ROM). 

  
Example
Suppose that the program you’re testing contains a call instruction at address CS:143F. To run the 
subroutine that is the destination of call and then return control to Debug, type the following command: 
  
p=143f 
  
Debug displays the results in the following format: 
  
AX=0000  BX=0000  CX=0000  DX=0000  SP=FFEE  BP=0000  SI=0000  DI=0000
DS=2246  ES=2246  SS=2246  CS=2246  IP=1443   NV UP EI PL NZ AC PO NC
2246:1442 7505          JNZ     144A
  
Related Commands

For information about running the program currently in memory, see the Debug g (Go) command. 

For information about executing one instruction, see the Debug t (Trace) command. 

Debug: Q (Quit)

Stops the Debug session without saving the file currently being tested. 

After you type q, control returns to MS-DOS. 

Syntax

q 
  
Example

To stop the debugging session, type the following command: 

q 
  
MS-DOS displays the MS-DOS prompt. 

Related Command

For information about saving a file, see the Debug w (Write) command. 

Debug: R (Register)

Displays or alters the contents of one or more central-processing-unit (CPU) registers.

Syntax

r [register-name] 
  
To display the contents of all registers and flags in the register storage area, use the following syntax: 

r 
  
Parameter

register-name
Specifies the name of the register whose contents you want to display. 

Notes

Using the r command

If you specify a register name, MS-DOS displays the 16-bit value of that register in hexadecimal 
notation and displays a colon as the prompt. If you want to change the value contained in the register, 
type a new value and press ENTER; otherwise, just press ENTER to return to the Debug prompt. 

Valid register names

The following are valid values for register-name: ax, bx, cx, dx, sp, bp, si, di, ds, es, ss, cs, ip, pc, and 
f. Both ip and pc refer to the instruction pointer. 

If you specify a register name other than one from the preceding list, MS-DOS displays the following 
message: 
  
br error
  
Using the f character instead of a register name

If you type the f character instead of a register name, Debug displays the current setting of each flag as 
a two-letter code and then displays the Debug prompt. To change the setting of a flag, type the 
appropriate two-letter code from the following table: 
  
Flag name		Set			Clear

Overflow		ov			nv 
Direction		dn (decrement)		up (increment) 
Interrupt		ei (enabled)		di (disabled) 
Sign			ng (negative)		pl (positive) 
Zero			zr			nz 
Auxiliary Carry		ac			na 
Parity			pe (even)		po (odd) 
Carry			cy			nc 

You can type new flag values in any order. You need not leave spaces between these values. To stop 
the r command, press ENTER. Any flags for which you did not specify new values remain unchanged.
 
Messages displayed with the r command

If you specify more than one value for a flag, Debug displays the following message: 
  
df error
  
If you specify a flag code not listed in the preceding table, Debug displays the following message: 
  
bf error
  
In both cases, Debug ignores all settings specified after the invalid entry. 

Default settings for Debug

When you start Debug, the segment registers are set to the bottom of free memory, the instruction 
pointer is set to 0100h, all flags are cleared, and the remaining registers are set to zero, except for sp, 
which is set to FFEEh. 

Examples

To view the contents of all registers, the status of all flags, and the decoded form of the instruction at 
the current location, type the following command: 
  
r 
  
If the current location is CS:11A, the display will look similar to the following: 
  
AX=0E00 BX=00FF CX=0007 DX=01FF SP=039D BP=0000 SI=005C DI=0000
DS=04BA ES=04BA SS=04BA CS=O4BA IP=011A  NV UP DI NG NZ AC PE NC
04BA:011A  CD21          INT     21
  
To view only the status of the flags, type the following command: 
  
rf 
  
Debug displays the information in the following format: 
  
NV UP DI NG NZ AC PE NC - _
  
Now you can type one or more valid flag values, in any order, with or without spaces, as in the following 
command: 
  
nv up di ng nz ac pe nc – pleicy 
  
Debug stops the r command and displays the Debug prompt. To see the changes, type either the r or rf 
command. Debug then displays the following: 
  
NV UP EI PL NZ AC PE CY - _
  
Press ENTER to return to the Debug prompt.
 
Related Commands

For information about displaying the contents of a portion of memory, see the Debug d (Dump) 
command. 

For information about disassembling bytes, see the Debug u (Unassemble) command. 

Debug: S (Search)

Searches a range of addresses for a pattern of one or more byte values. 

Syntax

s range list
 
Parameters

range
Specifies the beginning and ending addresses of the range you want to search. For information about 
valid values for the range parameter, see the debug command. 

list
Specifies the pattern of one or more byte values or a string you want to search for. Separate each byte 
value from the next with a space or a comma. Enclose string values in quotation marks. 

Note

If the list parameter contains more than one byte value, Debug displays only the first address where the 
byte value occurs. If list contains only one byte value, Debug displays all addresses where the value 
occurs in the specified range. 

Examples

Suppose you want to find all addresses in the range CS:100 through CS:110 that contain the value 41. 
To do this, type the following command: 
  
scs:100 110 41 
  
Debug displays the results in the following format: 
  
04BA:0104
04BA:010D
-
  
The following command searches for the string “Ph” in the range CS:100 through CS:1A0: 
  
scs:100 1a0 “Ph” 
  
Debug: T (Trace)

Executes one instruction and displays the contents of all registers, the status of all flags, and the 
decoded form of the instruction executed.
 
Syntax

t [=address] [number] 
  
Parameters

=address
Specifies the address at which Debug is to start tracing instructions. If you omit the address parameter, 
tracing begins at the address specified by your program’s CS:IP registers. For information about valid 
values for the address parameter, see the debug command. 

number
Specifies the number of instructions to be traced. This value must be a hexadecimal number. The 
default value is 1. 

Notes

Tracing instructions in read-only memory

The t command uses the hardware trace mode of the 8086 or 8088 microprocessor. Therefore, you can 
also trace instructions stored in read-only memory (ROM). 

Using the address parameter

You must precede the address parameter with an equal sign (=) to distinguish it from the number 
parameter. 

Example

To execute one instruction (pointed to by CS:IP), and then display the contents of the registers, the 
status of the flags, and the decoded form of the instruction, type the following command: 
  
t 
  
If the position of the instruction in the program were 04BA:011A, Debug might display the following 
information: 
  
AX=0E00 BX=00FF CX=0007 DX=01FF SP=039D BP=0000 SI=005C DI=0000
DS=04BA ES=04BA SS=04BA CS=O4BA IP=011A  NV UP DI NG NZ AC PE NC
04BA:011A  CD21          INT     21
  
Related Commands

For information about executing a loop, a repeated string instruction, a software interrupt, or a 
subroutine, see the Debug p (Proceed) command. 
For information about executing the program currently in memory, see the Debug g (Go) command. 

Debug: U (Unassemble)

Disassembles bytes and displays their corresponding source statements, including addresses and 
byte values. The disassembled code looks like a listing for an assembled file. 

Syntax

u [range] 
  
To disassemble 20h bytes (the default number), beginning at the first address after the address 
displayed by the previous u command, use the following syntax: 

u 
  
Parameter

range
Specifies the starting and ending addresses, or the starting address and length, of the code you want 
to disassemble. For information about valid values for the range parameter, see the debug command.
 
Examples

To disassemble 16 (10h) bytes, beginning at address 04BA:0100, type the following command: 
  
u04ba:100l10 
  
Debug displays the results in the following format: 
  
04BA:0100  206472    AND  [SI+72],AH
04BA:0103  69        DB   69
04BA:0104  7665      JBE  016B
04BA:0106  207370    AND  [BP+DI+70],DH
04BA:0109  65        DB   65
04BA:010A  63        DB   63
04BA:010B  69        DB   69
04BA:010C  66        DB   66
04BA:010D  69        DB   69
04BA:010E  63        DB   63
04BA:010F  61        DB   61
  
To display only the information for the specific addresses 04BA:0100 through 04BA:0108, type the 
following command: 
  
u04ba:0100 0108 
  
Debug displays the following: 
  
04BA:0100  206472    AND  [SI+72],AH
04BA:0103  69        DB   69
04BA:0104  7665      JBE  016B
04BA:0106  207370    AND  [BP+DI+70],DH
  
Related Commands

For information about assembling mnemonics, see the Debug a (Assemble) command. 
For information about displaying the contents of a portion of memory, see the Debug d (Dump) 
command. 

Debug: W (Write)

Writes a file or specific sectors to disk. 

You must have specified the name of the disk file when you started Debug or in the most recent Debug 
n (name) command. Both of these methods properly format a filename for a file control block at address 
CS:5C. 

To write the contents of the number of bytes specified in the BX:CX registers to a disk file, use the 
following syntax: 

Syntax

w [address] 
  
To bypass the MS-DOS file system and directly write specific sectors, use the following syntax: 

w address drive start number   

Caution   Writing specific sectors is extremely risky because it bypasses the MS-DOS file handler. 
The disk’s file structure can easily be damaged if the wrong values are typed.

Parameters

address
Specifies the beginning memory address of the file, or portion of the file, you want to write to a disk file. 
If you do not specify address, Debug starts from CS:100. For information about valid values for the 
address parameter, see the debug command. 

drive
Specifies the drive that contains the destination disk. This value is numeric: 0 = A, 1 = B, 2 = C, 
and so on.
 
start
Specifies the hexadecimal number of the first sector to which you want to write. 

number
Specifies the number of sectors to which you want to write. 

Notes

Resetting BX:CX before using the w command without parameters

If you have used a Debug g (go), t (trace), p (proceed), or r (register) command, you must reset the 
BX:CX registers before using the w command without parameters. 

Writing a modified file to a disk

If you modify the file but do not change the name, length, or starting address, Debug can still correctly write the file to the original disk location.
 
Limitation on the w command

You cannot write an .EXE or .HEX file with this command. 

Example

Suppose you want to write the contents of memory, beginning at the address CS:100, to the disk in 
drive B. You want the data to begin in the disk’s logical sector number 37h and continue for 2Bh sectors.
 To do this, type the following command: 
  
wcs:100 1 37 2b 
  
When the write operation is complete, Debug displays the Debug prompt again. 

Related Commands

For information about specifying a file for the w command, see the Debug n (Name) command. 
For information about loading the contents of a file or file sectors into memory, see the Debug l (Load) 
command. 

Debug: XA (Allocate Expanded Memory)

Allocates a specified number of pages of expanded memory.

To use expanded memory, you must have installed an expanded-memory device driver that conforms to
 version 4.0 of the Lotus/Intel/Microsoft Expanded Memory Specification (LIM EMS).
 
Syntax

xa [count] 

Parameter

count
Specifies the number of 16-kilobyte pages of expanded memory to allocate.

Example

To deallocate handle 0003, type the following command: 
  
xd 0003 
  
If the command is successful, Debug displays the following message: 
  
Handle 0003 deallocated
  
Related Commands

For information about other Debug commands that work with expanded memory, see the Debug 
commands xd (Deallocate Expanded Memory), xm (Map Expanded-Memory Pages), and xs 
(Display Expanded-Memory Status). 

Debug: XD (Deallocate Expanded Memory)

Deallocates a handle to expanded memory. 

To use expanded memory, you must have installed an expanded-memory device driver that conforms to
 version 4.0 of the Lotus/Intel/Microsoft Expanded Memory Specification (LIM EMS).

Syntax

xd [handle]

Parameters

handle
Specifies the handle you want to deallocate. 

Example

To deallocate handle 0003, type the following command: 
  
xd 0003
  
If the command is successful, Debug displays the following message: 
  
Handle 0003 deallocated
  
Related Commands

For information about other Debug commands that work with expanded memory, see the Debug 
commands xa (allocate expanded memory), xm (map expanded-memory pages), and xs (display 
expanded-memory status). 

Debug: XM (Map Expanded Memory Pages)

Maps a logical page of expanded memory, belonging to the specified handle, to a physical page of 
expanded memory. 

To use expanded memory, you must have installed an expanded-memory device driver that conforms to 
version 4.0 of the Lotus/Intel/Microsoft Expanded Memory Specification (LIM EMS).
 
Syntax

xm [lpage] [ppage] [handle]
 
Parameters

lpage
Specifies the number of the logical page of expanded memory that you want to map to physical page 
ppage. 

ppage
Specifies the number of the physical page to which lpage is to be mapped. 

handle
Specifies the handle. 

Example

To map logical page 5 of handle 0003 to physical page 2, type the following command: 
  
xm 5 2 0003 
  
If the command is successful, Debug displays the following message: 
  
Logical page 05 mapped to physical page 02
  
Related Commands

For information about other Debug commands that work with expanded memory, see the Debug 
commands xa (Allocate Expanded Memory), xd (Deallocate Expanded Memory), and xs (Display 
Expanded-Memory Status). 

Debug: XS (Display Expanded-Memory Status)

Displays information about the status of expanded memory. 

To use expanded memory, you must have installed an expanded-memory device driver that conforms to 
version 4.0 of the Lotus/Intel/Microsoft Expanded Memory Specification (LIM EMS). 

Syntax

xs 

Note

The information that Debug displays has the following format: 
  
Handle xx has xx pages allocated
Physical page xx = Frame segment xx 
	xx of a total xx EMS pages have been allocated
	xx of a total xx EMS handles have been allocated
  
Example

To display expanded-memory information, type the following command: 
  
xs 

Debug displays information similar to the following: 

Handle 0000 has 0000 pages allocated
Handle 0001 has 0002 pages allocated
Physical page 00 = Frame segment C000
Physical page 01 = Frame segment C400
Physical page 02 = Frame segment C800
Physical page 03 = Frame segment CC00
	2 of a total 80 EMS pages have been allocated
	2 of a total FF EMS handles have been allocated
  
Related Commands

For information about other Debug commands that work with expanded memory, see the Debug 
commands xa (Allocate Expanded Memory), xd (Deallocate Expanded Memory), and xm 
(Map Expanded-Memory Pages). 

Defrag
Reorganizes the files on a disk to optimize disk performance. 

Do not use this command when you are running Windows. 

Syntax

defrag [drive:] [/f] [/s[:]order] [/b] [/skiphigh] [/lcd | /bw | /g0] [/h] 
defrag [drive:] [/u] [/b] [/skiphigh] [/lcd | /bw | /g0] [/h] 

Parameter

drive:
Specifies the drive that contains the disk you want to optimize. 

Switches

/f
Defragments files and ensures that the disk contains no empty spaces between files. 

/u
Defragments files and leaves empty spaces, if any, between files. 

/s
Controls how the files are sorted in their directories. If you omit this switch, defrag uses the current 
order on the disk. The colon (:) is optional. The following list describes each of the values you can use 
to sort files. Use any combination of the values, and do not separate these values with spaces. 

n	In alphabetic order by name
n-	In reverse alphabetic order by name (Z through A) 
e	In alphabetic order by extension 
e-	In reverse alphabetic order by extension (Z through A)
d	By date and time, earliest first 
d-	By date and time, latest first 
s	By size, smallest first 
s-	By size, largest first 
/b

Restarts your computer after files have been reorganized. 

/skiphigh
Loads defrag into conventional memory. By default, defrag is loaded into upper memory, if upper 
memory is available. 

/lcd
Starts defrag using an LCD color scheme. 

/bw
Starts defrag using a black and white color scheme.
 
/g0
Disables the graphic mouse and graphic character set. 

/h
Moves hidden files. 

Notes

Network and INTERLNK drives

You cannot use defrag to optimize network drives or drives created with INTERLNK. 

Disk information reported by defrag and chkdsk

Disk information that defrag reports differs from information that chkdsk reports. Defrag reports hidden 
and user files as one number; chkdsk reports numbers for each type. Defrag counts the root as a 
directory; chkdsk does not. Defrag does not count the volume label as a file; chkdsk does. 

Start defrag only from MS-DOS

If you start defrag from a program such as Microsoft Windows, you may lose data. 

Defrag exit codes

The following list briefly describes the meaning of each defrag exit code (errorlevel parameter): 

0	The defragmentation was successful. 
1	An internal error occurred. 
2	The disk contained no free clusters. To operate, defrag needs 1 free cluster. 
3	The user pressed CTRL+C to stop the process. 
4	A general error occurred. 
5	Defrag encountered an error while reading a cluster. 
6	Defrag encountered an error while writing a cluster. 
7	An allocation error occurred. To correct the error, use the chkdsk command with the /f switch. 
8	A memory error occurred. 
9	There was insufficient memory to defragment the disk. 

You can use the errorlevel parameter on the if command line in a batch program to process exit codes 
returned by defrag. For an example of a batch program that processes exit codes, see the diskcomp 
command. 

Example

To load defrag into conventional memory and specify that defrag sort files according to the date they 
were created, from latest created to earliest created, type the following command: 
  
defrag c: /f /sd- /skiphigh 
  
This example fully optimizes drive C, but slows defrag. 

Del (Erase)

Deletes the files you specify. 

Syntax

del [drive:][path]filename [/p] 
erase [drive:][path]filename [/p]
 
Parameter

[drive:][path]filename
Specifies the location and name of the file or set of files you want to delete. 

Switch

/p
Prompts you for confirmation before deleting the specified file. 

Notes

Using the /p switch

If you use the /p switch, del displays the name of a file and prompts you with a message in the 
following format: 
  
filename, Delete (Y/N)?
  
Press Y to confirm the deletion, N to cancel the deletion and display the next filename (if you specified 
a group of files), or CRTL+C to stop the del command. 

Deleting more than one file at a time

You can delete all the files in a directory by typing the del command followed by [drive:]path. You can 
also use wildcards (* and ?) to delete more than one file at a time. However, you should use wildcards 
cautiously with the del command to avoid deleting files unintentionally. Suppose you type the following 
command: 
  
del *.* 
  
Del displays the following prompt: 
  
All files in directory will be deleted!
Are you sure (Y/N)?
  
Press Y and then ENTER to delete all files in the current directory, or press N and then ENTER to 
cancel the deletion.
 
Before you use wildcards with the del command to delete a group of files, you can use the same 
wildcards with the dir command to see a list of the names of all the files included in the group. 
  

Caution   Once you delete a file from your disk, you may not be able to retrieve it. Although the undelete 
command can retrieve deleted files, it can do so with certainty only if no other files have been created or 
changed on the disk. If you accidentally delete a file that you want to keep, stop what you are doing and 
immediately use the undelete command to retrieve the file. 

  
For more information on undeleting files, see the chapter “Managing Your System” in the MS-DOS 6 
User’s Guide. 

Examples

To delete the CAT.TMP file from the TEST directory on drive C, you can use either of the following 
commands: 
  
del c:\test\cat.tmp 
erase c:\test\cat.tmp 
  
To delete all the files in a directory named TEST on drive C, you can use either of the following commands: 
  
del c:\test 
del c:\test\*.* 
  
Related Commands

For information about retrieving a deleted file, see the undelete command. 
For information about removing a directory, see the rmdir command. 
For information about deleting a directory, its files, and all subdirectories and files subordinate to it, 
see the deltree command. 

Deltree

Deletes a directory and all the files and subdirectories that are in it. 

Syntax

deltree [/y] [drive:]path 

Parameter

drive:path
Specifies the name of the directory you want to delete. The deltree command will delete all the files 
contained in the directory you specify, as well as all subdirectories and files in the subdirectories 
subordinate to this directory. 

Switch

/y
Carries out the deltree command without first prompting you to confirm the deletion.
 
Notes

Deltree and Hidden, System, and Read-Only Attributes

The deltree command deletes all files contained in a directory or subdirectory, regardless of attributes. 

Errorlevel parameters

If deltree successfully deleted the directory, it returns an errorlevel value of 0. 

Using wildcards with deltree

You can use wildcards with the deltree command, but use them with extreme caution. If you specify a 
wildcard that matches both directory names and filenames, both the directories and files will be deleted. Before specifying wildcards with the deltree command, use the dir command to view the files and directories 
you will delete. 

Example

To delete the TEMP directory on drive C, including all files and subdirectories of the TEMP directory, 
type the following at the command prompt: 
  
deltree c:\temp 
  
Related Commands

For information about removing a directory, see the rmdir command. 
For information about deleting files, see the del command. 

Device

Loads the device driver you specify into memory. You can use this command only in your 
CONFIG.SYS file.
 
Syntax

device=[drive:][path]filename [dd-parameters] 

Parameters

[drive:][path]filename
Specifies the location and name of the device driver you want to load. 

[dd-parameters]
Specifies any command-line information required by the device driver. 

Notes

Using standard device drivers

The standard installable device drivers provided with MS-DOS 6 are ANSI.SYS, DISPLAY.SYS, 
DRIVER.SYS, DBLSPACE.SYS, EGA.SYS, EMM386.EXE, HIMEM.SYS, INTERLNK.EXE, 
POWER.EXE, RAMDRIVE.SYS, SETVER.EXE, and SMARTDRV.EXE.
 
The files COUNTRY.SYS and KEYBOARD.SYS are not device drivers. They are data files for the 
country and keyb commands, respectively. Do not try to load either of these files with the device 
command. If you do, your system halts, and you cannot restart MS-DOS. For information about loading 
COUNTRY.SYS, see the country command. For information about loading KEYBOARD.SYS, see the 
keyb command. 

Installing device drivers for other products

When you purchase a mouse, a scanner, or a similar product, the manufacturer usually includes 
device-driver software. To install a device driver, specify its location and name on a device command line.
 
Installing a third-party console driver

If you install both DISPLAY.SYS and a third-party console driver, such as VT52.SYS, the third-party 
device driver must be installed first. Otherwise, the third-party device driver may disable DISPLAY.SYS. 

Installing multiple device drivers

Sometimes one installable device driver will require that it be loaded before or after another in your 
CONFIG.SYS file. For example, EMM386.EXE requires HIMEM.SYS to be loaded first. If the device 
driver requires that another device driver be loaded before it, make sure the commands are listed in the 
correct order in your CONFIG.SYS file. 

Example

If you plan to use an ANSI escape sequence to control the screen and keyboard, you should add the 
following command to your CONFIG.SYS file (assuming MS-DOS files are in the DOS directory on drive 
C): 
  
device=c:\dos\ansi.sys 
  
Related Command

For information about loading device drivers into the upper memory area, see the devicehigh command. 

Devicehigh

Loads device driver you specify into the upper memory area. Loading a device driver into the upper 
memory area frees more bytes of conventional memory for other programs. If upper memory is not 
available, the devicehigh command functions just like the device command. 

You can use this command only in your CONFIG.SYS file. 

Syntax

devicehigh [drive:][path]filename [dd-parameters] 

To specify the region(s) of memory into which to load the device driver, use the following syntax: 

devicehigh [[/l:region1[,minsize1][;region2[,minsize2] [/s]]= [drive:][path]filename [dd-parameters] 

Parameters

[drive:][path]filename
Specifies the location and name of the device driver you want to load into the upper memory area.

dd-parameters
Specifies any command-line information required by the device driver.

Switches

/l:region1[,minsize1][;region2[,minsize2]...
Specifies one or more regions of memory into which to load the device driver. By default, MS-DOS loads 
the driver into the largest free upper-memory block (UMB) and makes all other UMBs available for the 
driver’s use. You can use the /l switch to load the device driver into a specific region of memory or to 
specify which region(s) the driver can use. 

To load the driver into the largest block in a specific region of upper memory, specify the region number 
after the /l switch. For example, to load the driver into the largest free block in region 4, you would type 
/l:4. (To list the free areas of memory, type mem /f at the command prompt.) 

When loaded with the /l switch, a device driver can use only the specified memory region. Some device 
drivers use more than one area of memory; for those drivers, you can specify more than one region. (To 
find out how a particular device driver uses memory, issue the mem /m command and specify the 
device-driver name as an argument.) To specify two or more regions, separate the block numbers with a
 semicolon (;). For example, to use blocks 2 and 3, you would type /l:2;3. 

Normally, MS-DOS loads a driver into a UMB in the specified region only if that region contains a UMB 
larger than the driver’s load size (usually equal to the size of the executable program file). If the driver 
requires more memory while running than it does when loaded, you can use the minsize parameter to 
ensure that the driver will not be loaded into a UMB that is too small for it. If you specify a value for 
minsize, MS-DOS loads the driver into that region only if it contains a UMB that is larger than both the 
driver’s load size and the minsize value. 

/s
Shrinks the UMB to its minimum size while the driver is loading. Using this switch makes the most 
efficient use of memory. This switch is normally used only by the MemMaker program, which can 
analyze a device driver’s memory use to determine whether the /s switch can safely be used when 
loading that driver. This switch can be used only in conjunction with the /l switch and affects only UMBs
 for which a minimum size was specified. 

Notes

Using the DOS=umb command

To use the devicehigh command, you must also include the DOS=umb command in your CONFIG.SYS 
file. If you do not specify this command, all device drivers are loaded into conventional memory, as if you
 had used the device command. For more information, see the DOS command. 

Using MemMaker to optimize upper memory area automatically

The MemMaker program, included with MS-DOS 6, automatically optimizes your system’s memory. 
MemMaker surveys the upper memory area, analyzes the memory use of your drivers and programs, 
and determines which drivers and programs fit best into the available UMBs. MemMaker then changes 
selected device commands in your CONFIG.SYS file to devicehigh commands and adds /l and /s 
switches as necessary. For more information about using MemMaker to optimize your computer’s 
memory, see “Making More Memory Available” in the MS-DOS 6 User’s Guide. 

Using MS-DOS 5 devicehigh syntax

The version of devicehigh provided with MS-DOS 5 used the following syntax: 
  
devicehigh size=hexsize [drive:][path] filename [dd-parameters] 
  
Although the MS-DOS 5 devicehigh syntax will still work with MS-DOS 6, it is strongly recommended 
that you use the current devicehigh syntax whenever possible.
 
Installing HIMEM.SYS and a UMB provider

To load a device driver into the upper memory area, your computer must have extended memory. You 
must use the device command once to install the HIMEM.SYS device driver and then again to install an 
upper-memory-block (UMB) provider. These commands must appear before the devicehigh command in 
your CONFIG.SYS file. If your computer has an 80386 or 80486 processor, you can use EMM386.EXE 
as the UMB provider. If your computer has a different processor, you must supply a different UMB 
provider. 

If no upper memory area is available

If there is not enough upper memory area available to load the device driver you specified with the 
devicehigh command, MS-DOS will load it into conventional memory (as if you had used the device 
command).
 
Examples

The following CONFIG.SYS commands make the upper memory area available for running device drivers 
and programs: 
  
device=c:\\dos\\himem.sys
device=c:\\dos\\emm386.exe ram
dos=umb
  
The following command directs MS-DOS to load a device driver named MYDRIV.SYS into the upper 
memory area of an 80386 computer: 
  
devicehigh=mydriv.sys 
  
The following CONFIG.SYS command directs MS-DOS to run the MOUSE.SYS driver in the upper 
memory area and load the driver into upper memory block 2: 
  
devicehigh=/l:2 C:\drivers\mouse.sys 
  
The following command loads the MYDRIV.SYS driver into region 1 of upper memory, and also allows 
the driver to use region 3 if it needs to: 
  
devicehigh=/l:1;3 C:\util\mydriv.sys 
  
The following command loads the same driver into upper memory regions 1 and 3, but only if each 
region is at least 30 bytes in size: 
  
devicehigh=/l:1,30;3,30 C:\util\mydriv.sys 
  
Related Commands

For information about loading programs into the upper memory area, see the loadhigh command. 
For information about loading device drivers into conventional memory, see the device command. 
For information about using the MemMaker program to move programs to the upper memory area, see 
the memmaker command. 

Dir

Displays a list of the files and subdirectories that are in the directory you specify. 

When you use dir without parameters or switches, it displays the disk’s volume label and serial number; 
one directory or filename per line, including the filename extension, the file size in bytes, and the date 
and time the file was last modified; and the total number of files listed, their cumulative size, and the 
free space (in bytes) remaining on the disk. 

Syntax

dir [drive:][path][filename] [/p] [/w] [/a[[:]attributes]][/o[[:]sortorder]] [/s] [/b] [/l] [/c] 

Parameters

[drive:][path]
Specifies the drive and directory for which you want to see a listing. 

[filename]
Specifies a particular file or group of files for which you want to see a listing. 

Switches

/p
Displays one screen of the listing at a time. To see the next screen, press any key. 

/w
Displays the listing in wide format, with as many as five filenames or directory names on each line.
 
/a[[:] attributes]
Displays only the names of those directories and files with the attributes you specify. If you omit this 
switch, dir displays the names of all files except hidden and system files. If you use this switch without 
specifying attributes, dir displays the names of all files, including hidden and system files. The following 
list describes each of the values you can use for attributes. The colon (:) is optional. Use any 
combination of these values, and do not separate the values with spaces. 

h  	Hidden files
–h 	Files that are not hidden
s  	System files
–s 	Files other than system files
d  	Directories
–d	Files only (not directories)
a  	Files ready for archiving (backup)
–a	Files that have not changed since the last backup
r  	Read-only files
–r 	Files that are not read-only

/o[[:] sortorder]
Controls the order in which dir sorts and displays directory names and filenames. If you omit this switch,
dir displays the names in the order in which they occur in the directory. If you use this switch without 
specifying sortorder, dir displays the names of the directories, sorted in alphabetic order, and then 
displays the names of files, sorted in alphabetic order. The colon (:) is optional. The following list 
describes each of the values you can use for sortorder. Use any combination of the values, and do not 
separate these values with spaces. 
  
	In alphabetic order by name

–n 	In reverse alphabetic order by name (Z through A)
e  	In alphabetic order by extension
–e 	In reverse alphabetic order by extension (Z through A)
d  	By date and time, earliest first
–d 	By date and time, latest first
s  	By size, smallest first
–s 	By size, largest first
g  	With directories grouped before files
–g 	With directories grouped after files
c  	By compression ratio, lowest first.
–c 	By compression ratio, highest first.

/s
Lists every occurrence, in the specified directory and all subdirectories, of the specified filename. 

/b
Lists each directory name or filename, one per line (including the filename extension). This switch 
displays no heading information and no summary. The /b switch overrides the /w switch. 

/l
Displays unsorted directory names and filenames in lowercase. This switch does not convert extended 
characters to lowercase. 

/c[h]
Displays the compression ratio of files compressed using Doublespace, based on an 8K cluster size. 
The optional h switch displays the compression ratio of files compressed using Doublespace, based on 
the cluster size of the host drive. The /c[h] switch is ignored when used with the /w or /b switch. 

Notes

Using wildcards with dir

You can use wildcards (* and ?) to display a listing of a subset of files and subdirectories. For an 
example illustrating the use of a wildcard, see the “Examples” section. 

Specifying file display attributes

If you specify the /a switch with more than one value in attributes, dir displays the names of only those 
files with all the specified attributes. For example, if you specify the /a switch with the r and –h values f
or attributes by using either /a:r-h or /ar-h, dir displays only the names of Read-Only files that are not 
hidden.
 
Specifying filename sorting

If you specify more than one sortorder value, dir sorts the filenames by the first criterion first, then by the
second criterion, and so on. For example, if you specify the /o switch with the e and –s values for 
sortorder by using either /o:e-s or /oe-s, dir sorts the names of directories and files by extension, with 
the largest first, and displays the final result. The alphabetic sorting by extension causes filenames with 
no extensions to appear first, then directory names, then filenames with extensions. 

Setting date and time formats

The date and time formats used by dir depend on the country setting you use in your CONFIG.SYS file. 
If you don’t use the country command, the formats are those for the United States. 

Using redirection symbols and pipes

When you use a redirection symbol (>) to send dir output to a file or a pipe (|) to send dir output to 
another command, use the /a:-d and /b switches to list only the filenames. You can use the filename 
parameter with the /b and /s switches to specify that dir is to search the current directory and its 
subdirectories for all filenames that match filename. Dir lists only the drive letter, directory name, f
ilename, and filename extension, one path per line, for each filename it finds. 

Before using a pipe for redirection, you should set the TEMP environment variable in your 
AUTOEXEC.BAT file. Otherwise, the temporary file will appear in the directory listing. 

Presetting dir parameters and switches

You can preset dir parameters and switches by including the set command with the DIRCMD 
environment variable in your AUTOEXEC.BAT file. You can use any valid combination of dir parameters 
and switches with the set DIRCMD command, including the location and name of a file. 

For example, to use the DIRCMD environment variable to set the wide display format (/w) as the default 
format, include the following command in your AUTOEXEC.BAT file: 
  
set dircmd=/w 
  
For a single use of the dir command, you can override a switch set by using the DIRCMD environment 
variable. To do so, you use the same switch on the dir command line, but you must also precede the 
switch letter with a minus sign, as the following example shows: 
  
dir /-w 
  
You can change the DIRCMD default settings by typing the set command at the command prompt with 
a new parameter or switch after the equal sign (=). The new default settings are effective for all 
subsequent dir commands until you use set DIRCMD again on the command line or until you restart 
MS-DOS. 

To clear all default settings, type the following command: 
  
set dircmd= 
  
You can view the current settings of the DIRCMD environment variable by typing the following command:
  
set 
  
MS-DOS displays a list of environment variables and their settings. For more information about setting 
environment variables, see the set command. 

Examples

Suppose you want to display all files and directories in a directory, including hidden or system files. To 
specify this display, type the following command: 
  
dir /a 
  
Suppose you want dir to display one directory listing after another, until it has displayed the listing for 
every directory on the disk in the current drive. Suppose also that you want dir to alphabetize each 
directory listing, display it in wide format, and pause after each screen. To specify such a display, be 
sure the root directory is the current directory and then type the following command: 
  
dir /s/w/o/p 
  
Dir lists the name of the root directory, the names of the subdirectories of the root directory, and the 
names of the files in the root directory (including extensions). Then dir lists the subdirectory names and 
filenames in each subdirectory in the directory tree. 

To alter the preceding example so that dir displays the filenames and extensions but omits the 
directory names, type the following command: 
  
dir /s/w/o/p/a:-d 
  
To print a directory listing, type the redirection symbol and prn after any form of the dir command, as 
the following example shows: 
  
dir > prn 
  
When you specify prn on the dir command line, the directory listing is sent to the printer attached to the
LPT1 port. If your printer is attached to a different port, you must replace prn with the name of the 
correct port. 

You can also redirect output of the dir command to a file by replacing prn with a filename. A path is also 
accepted on the command line. For example, to direct dir output to the file DIR.DOC in the RECORDS 
directory, type the following command: 
  
dir > \records\dir.doc 
  
If DIR.DOC does not exist, MS-DOS creates it, unless the directory RECORDS also does not exist. In 
that case, MS-DOS displays the following message: 
  
File creation error
  
To display a list of all the filenames with the .TXT extension in all directories on drive C, type the 
following command: 
  
dir c:\*.txt /w/o/s/p 
  
Dir displays, in wide format, an alphabetized list of the matching filenames in each directory and 
pauses each time the screen fills, until you press a key to continue. 

Related Commands

For information about displaying the directory structure of a path or disk, see the tree command. 
For information about compressing disks, see the dblspace command.
 
Diskcomp
Compares the contents of two floppy disks. 

This command performs a track-by-track comparison. Diskcomp determines the number of sides and 
sectors per track to compare based on the format of the first disk you specify. 

Syntax

diskcomp [drive1: [drive2:]] [/1] [/8] 

Parameters

drive1:
Specifies the drive containing one of the floppy disks. 

drive2:
Specifies the drive containing the other floppy disk. 

Switches

/1
Compares only the first sides of the disks, even if the disks are double-sided and the drives can read 
double-sided disks. 

/8
Compares only the first 8 sectors per track, even if the disks contain 9 or 15 sectors per track. 
Notes
Invalid drive for diskcomp
The diskcomp command works only with floppy disks. You cannot use diskcomp with a hard disk. If 
you specify a hard disk drive for drive1 or drive2, diskcomp displays the following error message: 
  
  
Diskcomp messages

If all tracks on the two disks being compared are the same, diskcomp displays the following message: 
  
Compare OK
  
If the tracks are not the same, diskcomp displays a message similar to the following: 
  
Compare error on
side 1, track 2
  
When diskcomp completes the comparison, it displays the following message: 
  
Compare another diskette (Y/N)?
  
If you press Y, diskcomp prompts you to insert disks for the next comparison. If you press N, diskcomp
stops the comparison. 

Diskcomp ignores a disk’s volume number when it makes the comparison. 

Omitting drive parameters

If you omit the drive2 parameter, diskcomp uses the current drive for drive2. If you omit both drive 
parameters, diskcomp uses the current drive for both. If the current drive is the same as drive1, 
diskcomp prompts you to swap disks as necessary. 

Using one drive for the comparison

If you specify the same floppy disk drive for drive1 and drive2, diskcomp does a comparison by using 
one drive and prompts you to insert the disks as necessary. You might have to swap the disks more 
than once, depending on the capacity of the disks and the amount of available memory.
 
Comparing different types of disks

Diskcomp cannot compare a single-sided disk with a double-sided disk or a high-density disk with a 
double-density disk. If the disk in drive1 is not of the same type as the disk in drive2, diskcomp 
displays the following message: 
  
Drive types or diskette types not compatible
  
Using diskcomp with networks and redirected drives

Diskcomp does not work on a network drive or on a drive created or affected by a subst command. If 
you attempt to use diskcomp with a network drive or a drive created by the subst command, diskcomp 
displays an error message. 

Comparing an original disk with a copy

When you use diskcomp with a disk that you made with the copy command, diskcomp may display a 
message similar to the following: 
  
    Compare error on
    side 0, track 0
  
This type of error can occur even if the files on the disks are identical. Although the copy command 
duplicates information, it doesn’t necessarily place it in the same location on the destination disk. For 
more information about comparing individual files on two disks, see the fc command. 

Diskcomp exit codes

The following list shows each exit code and gives a brief description of its meaning: 

0	The disks are the same. 
1	Differences were found. 
2	The user pressed CTRL+C to stop the process. 
3	A critical error occurred. 
4	An initialization error occurred. 

You can use the errorlevel parameter on the if command line in a batch program to process exit codes 
returned by diskcomp. 

Example

If your system has only one floppy disk drive, drive A, and you want to compare two disks, type the 
following command: 
  
diskcomp a: a: 
  
Diskcomp prompts you to insert each disk, as required. 

Related Command

For information about comparing two files, see the fc command. 

Diskcopy

Copies the entire contents of one floppy disk to another floppy disk. Diskcopy writes over the existing 
contents of the destination disk as it copies the new information to it. 

This command determines the number of sides to copy based on the source drive and disk. 

Syntax

diskcopy [drive1: [drive2:]] [/1] [/v] 

Parameters

drive1:
Specifies the drive containing the source disk. 

drive2:
Specifies the drive containing the destination disk. 

Switches

/1
Copies only the first side of a disk. 

/v
Verifies that the information is copied correctly. Use of this switch slows the copying process. 

Notes

Invalid drive for diskcopy

The diskcopy command works only with removable disks, such as floppy disks. You cannot use 
diskcopy with a hard disk. If you specify a hard disk drive for drive1 or drive2, diskcopy displays the 
following error message: 
  
Invalid drive specification
Specified drive does not exist
or is non-removable
  
Diskcopy messages

The diskcopy command prompts you to insert the source and destination disks and waits for you to 
press any key before continuing. 

After copying, diskcopy displays the following message: 
  
Copy another diskette (Y/N)?
  
If you press Y, diskcopy prompts you to insert source and destination disks for the next copy operation.
To stop the diskcopy process, press N. 

If you are copying to an unformatted floppy disk in drive2, diskcopy formats the disk with the same 
number of sides and sectors per track as are on the disk in drive1. Diskcopy displays the following 
message while it formats the disk and copies the files: 
  
Formatting while copying
  
If the capacity of the source disk is greater than that of the destination disk and your computer can 
detect this difference, diskcopy displays the following message: 
  
Drive types or diskette types not compatible
  
Disk serial numbers

If the source disk has a volume serial number, diskcopy creates a new volume serial number for the 
destination disk and displays the number when the copy operation is complete. 

Omitting drive parameters

If you omit the drive2 parameter, diskcopy uses the current drive as the destination drive. If you omit 
both drive parameters, diskcopy uses the current drive for both. If the current drive is the same as drive1,
diskcopy prompts you to swap disks as necessary. 

Using one drive for copying

If drive1 and drive2 are the same, diskcopy prompts you whenever you should switch disks. If you omit 
both drive parameters and the current disk drive is a floppy disk drive, diskcopy prompts you each time 
you should insert a disk in the drive. If the disks contain more information than available memory can 
hold, diskcopy cannot read all of the information at once. Diskcopy reads from the source disk, writes to
 the destination disk, and prompts you to insert the source disk again. This process continues until the
 entire disk has been copied. 

Avoiding disk fragmentation

Because diskcopy makes an exact copy of the source disk on the destination disk, any fragmentation 
on the source disk is transferred to the destination disk. Fragmentation is the presence of small areas 
of unused disk space between existing files on a disk. 

A fragmented source disk can slow down the finding, reading, or writing of files. To avoid transferring
 fragmentation from one disk to another, use either the copy command or the xcopy command to copy 
your disk. Because copy and xcopy copy files sequentially, the new disk is not fragmented. 

Copying Startup disks

If you use the diskcopy command to copy a startup disk, the copy will also be a startup disk. If you use
copy or xcopy to copy a startup disk, the copy usually will not be a startup disk. 

Diskcopy exit codes

The following list shows each exit code (errorlevel parameter) and gives a brief description of its meaning: 
  
0	The copy operation was successful. 
1	A nonfatal read/write error occurred. 
2	The user pressed CTRL+C to stop the process. 
3	A critical error occurred. 
4	An initialization error occurred.
 
You can use the errorlevel parameter on the if command line in a batch program to process exit codes 
returned by diskcopy. For an example of a batch program that processes exit codes, see the diskcomp 
command. 

Related Commands

For information about copying one or more files, see the copy command. 
For information about copying directories and subdirectories, see the xcopy command. 
For information about comparing two disks to see if they are identical, see the diskcomp command. 

DISPLAY.SYS

Enables you to display international character sets on EGA, VGA, and LCD monitors. This device driver 
must be loaded by a device or devicehigh command in your CONFIG.SYS file. 

For an introduction to preparing your screen and keyboard for character sets, see the chapter
 “Customizing for International Use” in the MS-DOS 6 User’s Guide. 

Syntax

device=[drive:][path]display.sys con[:]=(type[,[hwcp][,n]]) 
device=[drive:][path]display.sys con[:]=(type[,[hwcp][,(n,m)]]) 

Parameters

[drive:][path]
Specifies the location of the DISPLAY.SYS file. 

type
Specifies the display adapter in use. Valid values include EGA and LCD. The EGA value supports both 
EGA and VGA display adapters. If you omit the type parameter, DISPLAY.SYS checks the hardware to 
determine which display adapter is in use. You can also specify CGA and MONO as values for type, but 
they have no effect because character set switching is not enabled for these devices. 

hwcp
Specifies the number of the character set that your hardware supports. The following list shows the 
character sets that MS-DOS supports and the country or language for each: 

437	United States 
850	Multilingual (Latin I) 
852	Slavic (Latin II) 
860	Portuguese 
863	Canadian-French 
865	Nordic 

For more information about character sets, see the appendix “Keyboard Layouts and Character Sets” 
in the MS-DOS 6 User’s Guide. 

n
Specifies the number of character sets the hardware can support in addition to the primary character set 
specified for the hwcp parameter. Valid values for n are in the range 0 through 6. This value depends on 
your hardware. For EGA display adapters, the maximum value for n is 6; for LCD display adapters, the 
maximum value for n is 1. 

m
Specifies the number of subfonts the hardware supports for each code page. The default value is 2 if 
type is EGA, and 1 if type is LCD. 

Notes

Using DISPLAY.SYS with monochrome or CGA display adapters 

Because monochrome and CGA display adapters do not support character set switching, using 
DISPLAY.SYS with either type of adapter has no effect. 

Installing a third-party console driver 

If you install both DISPLAY.SYS and a third-party console driver, such as VT52.SYS, the third-party 
device driver must be installed first. Otherwise, the third-party device driver may disable DISPLAY.SYS. 

Example

Suppose you want DISPLAY.SYS to support an EGA display adapter with the United States hardware 
character set (437) and the potential for two additional MS-DOS character sets. To do this and to 
specify that DISPLAY.SYS is in the DOS directory on drive C, add the following line to your 
CONFIG.SYS file: 
  
device=c:\dos\display.sys con=(ega,437,2) 
  
Dos 

Specifies that MS-DOS should maintain a link to the upper memory area, load part of itself into the 
high memory area (HMA), or both. You can use this command only in your CONFIG.SYS file. 

Syntax

dos=high|low[,umb|,noumb] 
dos=[high,|low,]umb|noumb 

Parameters

umb|noumb
Specifies whether MS-DOS should manage upper memory blocks (UMBs) created by a UMB provider 
such as EMM386.EXE. The umb parameter specifies that MS-DOS should manage UMBs, if they exist. 
The noumb parameter specifies that MS-DOS should not manage UMBs. The default setting is noumb.
 
high|low
Specifies whether MS-DOS should attempt to load a part of itself into the HMA (high) or keep all of 
MS-DOS in conventional memory (low). The default setting is low. 

Notes

Must install HIMEM.SYS for dos=umb or dos=high

You must install the HIMEM.SYS device driver or another extended memory manager before you 
specify either dos=umb or dos=high. 

Using the umb parameter

You must specify the dos=umb command in order to load programs and device drivers into the upper 
memory area. Using the upper memory area frees more space in conventional memory for programs. In 
addition to using this command, you must install an upper-memory-block (UMB) provider. If your 
computer has an 80386 or 80486 processor, you can use EMM386.EXE for your UMB provider. 

If you specify dos=umb and no UMB provider is installed, MS-DOS will not display an error message.
 
Using the high parameter

If you specify the high parameter, MS-DOS attempts to load part of itself into the HMA. Loading part of 
MS-DOS into the HMA frees conventional memory for programs. If you specify dos=high and MS-DOS 
is unable to use the HMA, the following message will appear: 
  
HMA not available
Loading DOS low
  
Combining parameters

You can include more than one parameter on a single DOS command line, using commas to separate
 them. For example, the following command lines are valid: 
  
dos=umb,low 
dos=high,umb 
  
You can place the dos command anywhere in your CONFIG.SYS file. 

Related Commands

For information about loading a device driver into the upper memory area, see the devicehigh command. 
For information about loading a program into the upper memory area, see the loadhigh command. 

Doskey

Loads the Doskey program into memory. The Doskey program recalls MS-DOS commands and enables 
you to edit command lines and create and run macros. 

Doskey is a memory-resident program. When installed, Doskey occupies about 3 kilobytes of resident 
memory. 

Syntax

doskey [/reinstall] [/bufsize=size] [/macros] [/history][/insert|/overstrike] [macroname=[text]] 

To start the Doskey program and use the default settings, use the following syntax: 

doskey 
Parameter

macroname=[text]
Creates a macro that carries out one or more MS-DOS commands (a Doskey macro). Macroname 
specifies the name you want to assign to the macro. Text specifies the commands you want to record. 

Switches

/reinstall
Installs a new copy of the Doskey program, even if one is already installed. In the latter case, the 
/reinstall switch also clears the buffer.
 
/bufsize=size
Specifies the size of the buffer in which Doskey stores commands and Doskey macros. The default size
 is 512 bytes. The minimum buffer size is 256 bytes.
 
/macros
Displays a list of all Doskey macros. You can use a redirection symbol (>) with the /macros switch to
 redirect the list to a file. You can abbreviate the /macros switch as /m. 

/history
Displays a list of all commands stored in memory. You can use a redirection symbol (>) with the
 /history switch to redirect the list to a file. You can abbreviate the /history switch as /h. 

/insert|/overstrike
Specifies whether new text you type is to replace old text. If you use the /insert switch, new text that 
you type on a line is inserted into old text (as if you had pressed the INSERT key). If you use the 
/overstrike switch, new text replaces old text. The default setting is /overstrike. 

Notes

Recalling a command

To recall a command, you can use any of the following keys after loading Doskey into memory: 

UP ARROW
Recalls the MS-DOS command you used before the one displayed. 

DOWN ARROW
Recalls the MS-DOS command you used after the one displayed. 

PAGE UP 
Recalls the oldest MS-DOS command you used in the current session. 

PAGE DOWN 
Recalls the most recent MS-DOS command you used. 

Editing the command line

With the Doskey program, you can edit the current command line. The following list describes the 
Doskey editing keys and their functions: 

LEFT ARROW
Moves the cursor back one character. 

RIGHT ARROW 
Moves the cursor forward one character. 

CTRL+LEFT ARROW 
Moves the cursor back one word. 

CTRL+RIGHT ARROW 
Moves the cursor forward one word. 

HOME 
Moves the cursor to the beginning of the line. 

END
Moves the cursor to the end of the line. 

ESC 
Clears the command from the display.
 
F1 
Copies one character from the template to the MS-DOS command line. (The template is a memory 
buffer that holds the last command you typed.) 

F2
Searches forward in the template for the next key you type after pressing F2. Doskey inserts the text
 from the template up to but not including the character you specify. 

F3 
Copies the remainder of the template to the command line. Doskey begins copying characters from the
 position in the template that corresponds to the position indicated by the cursor on the command line. 

F4 
Deletes characters, beginning with the current character position, up to a character you specify. To use 
this editing key, press F4 and type a character. Doskey deletes up to, but not including, that character.
 
F5 
Copies the current command into the template and clears the command line. 

F6 
Places an end-of-file character (CTRL+Z) at the current position on the command line.
 
F7 
Displays all commands stored in memory, with their associated numbers. Doskey assigns these 
numbers sequentially, beginning with 1 for the first (oldest) command stored in memory. 

ALT+F7
Deletes all commands stored in memory.

F8
Searches memory for a command that you want Doskey to display. To use this editing key, type the 
first character, or the first few characters, of the command you want Doskey to search for and then 
press F8. Doskey displays the most recent command that begins with the text you typed. Press F8 
repeatedly to cycle through all the commands that start with the characters you specified. 

F9 
Prompts you for a command number and displays the command associated with the number you 
specify. To display all the numbers and their associated commands, press F7. 

ALT+F10
Deletes all macro definitions. 

Specifying a default insert mode

If you press the INSERT key, you can type text on the Doskey command line in the middle of old text 
without replacing the old text. However, once you press ENTER, Doskey returns your keyboard to 
replace mode. You must press INSERT again to return to insert mode. 

The /insert switch puts your keyboard in insert mode each time you press ENTER. Your keyboard 
effectively remains in insert mode until you use the /overstrike switch. You can temporarily return to 
replace mode by pressing the INSERT key; but once you press ENTER, Doskey returns your keyboard 
to insert mode. 

The cursor changes shape when you use the INSERT key to change from one mode to the other. 

Creating a macro

You can use the Doskey program to create macros that carry out one or more MS-DOS commands. 

You can use the following special characters to control command operations when defining a macro: 

$G or $g
Redirects output. Use either of these special characters to send output to a device or a file instead of to the screen. This character is equivalent to the redirection symbol for output (>). 

$G$G or $g$g
Appends output to the end of a file. Use either of these special double characters to append output to 
an existing file rather than replace the data in the file. These double characters are equivalent to the “append” redirection symbol for output (>>). 

$L or $l
Redirects input. Use either of these special characters to read input from a device or a file instead of 
from the keyboard. This character is equivalent to the redirection symbol for input (<). 

$B or $b
Sends macro output to a command. Using one of these special characters is equivalent to using the 
pipe (|) on a command line. 

$T or $t
Separates commands. Use either of these special characters to separate commands when you are 
creating macros or typing commands on the Doskey command line. 

$$
Specifies the dollar-sign character ($). 

$1 through $9
Represents any command-line information you want to specify when you run the macro. The special 
characters $1 through $9 are batch parameters, which make it possible for you to use different data on 
the command line each time you run the macro. The $1 character in a doskey command is similar to
 the %1 character in a batch program. 

$*
Represents all the command-line information you want to specify when you type the macro name. The 
special character $* is a replaceable parameter that is similar to the batch parameters $1 through $9, 
with one important difference. Here, everything you type on the command line after the macro name is 
substituted for the $* in the macro.
 
For example, to create a macro that performs a quick and unconditional format of a disk, 
type the following command: 
  
doskey qf=format $1 /q /u 
  
For information about quick and unconditional formatting, see the format command. 

You can use the doskey command in a batch program to create a macro.
 
Running a macro

To run a macro, type the macro name starting at the first position on the command line. If the macro 
was defined with $* or any of the batch parameters $1 through $9, use a space to separate parameters. 
You could run the qf macro created in the previous example to format a disk in drive A quickly and 
unconditionally. To do so, you would type the following command: 
  
qf a: 
  
You cannot run a macro from a batch program. 

Creating a macro with the same name as an MS-DOS command

You might want to create a macro that has the same name as an MS-DOS command. This can be 
useful, for example, if you always use a certain command with specific switches. To specify whether 
you want to run the macro or the MS-DOS command, follow these guidelines: 

·	To run the macro, begin typing the macro name immediately after the command prompt, with 
	no space between the prompt and the command name. 
·	To carry out the command, insert one or more spaces between the command prompt and the 
	command name. 
  
To delete a macro, type the following command: 
  
doskey macroname= 
  
Examples

The /macros and /history switches are useful for creating batch programs to save macros and 
commands. For example, to create a batch program named MACINIT.BAT that includes all Doskey 
macros, type the following command: 
  
doskey /macros > macinit.bat 
  
To use the MACINIT.BAT file, edit it to include the doskey command at the beginning of each macro
line. 

To create a batch program named TMP.BAT that contains recently used commands, type the following 
command: 
  
doskey /history >  tmp.bat 
  
To define a macro with multiple commands, use $t to separate commands, as follows: 
  
doskey tx=cd\temp$tdir/w $* 
  
In the preceding example, the tx macro changes the current directory to TEMP and then displays a 
directory listing, using the wide display format. You can use $* at the end of the macro to append other 
switches to the dir command when you run tx. 

The following macro uses a batch parameter for a new directory name. The macro first creates a new 
directory and then changes to it from the current directory. 
  
doskey mc=md $1$tcd $1 
  
To use the preceding macro to create and change to a directory named BOOKS, type the following: 
  
mc books 
  
To create a macro that uses batch parameters for moving a file or group of files, type the following 
command: 
  
doskey mv=copy $1 $2 $t del $1 
  
To create a macro that causes the mem command to pause after each screen, type the following 
command: 
  
doskey mem=mem $* /p 
  
Dosshell

Starts MS-DOS Shell, a graphical interface to MS-DOS. 

Syntax

To start MS-DOS Shell in text mode, use the following syntax: 

dosshell [/t[:res[n]]] [/b] 

To start MS-DOS Shell in graphics mode, use the following syntax: 

dosshell [/g[:res[n]]] [/b] 

Parameters

res
Specifies a screen-resolution category. Valid values are l, m, and h to specify low, medium, and high 
resolution, respectively. The default value of res depends on your hardware. 

n
Specifies a screen resolution when there is more than one choice within a category. For information 
about the valid values for this parameter, see the “Notes” section. The default value of n depends on 
your hardware. 

Switches

/t
Starts MS-DOS Shell in text mode. 

/b
Starts MS-DOS Shell using a black-and-white color scheme. 

/g
Starts MS-DOS Shell in graphics mode. 

Notes

Running MS-DOS Shell with Microsoft Windows

Do not start Microsoft Windows from within MS-DOS Shell. If you want to use both Microsoft Windows 
and MS-DOS Shell, start Windows, and then start MS-DOS Shell from within Windows.
 
Memory requirement

To run MS-DOS Shell, you should ensure that your computer has at least 384K of available conventional 
memory. 

Adjusting screen resolution

Once you have started MS-DOS Shell, you can adjust the screen resolution by using the Display 
command on the Options menu. A dialog box displays the mode (text or graphics), the number of lines, 
the resolution category, and the specific number within each category for all possible screen-resolution
 modes available for your hardware. 

The DOSSHELL.INI file

Your current MS-DOS Shell settings for program items and groups, options, screen resolution, colors, 
and so on, are stored in a file called DOSSHELL.INI. The DOSSHELL.INI file will be updated whenever 
you make a change or start a program item, so it must be located on a drive that is not write-protected. 
You can specify the location of the DOSSHELL.INI file by setting a dosshell environment variable in your AUTOEXEC.BAT file. 

For example, if the DOSSHELL.INI file is located in the DOS directory on drive C, type the following 
command in your AUTOEXEC.BAT file: 
  
dosshell=c:\dos 
  
If you customize MS-DOS Shell to suit your own needs, you should back up this file regularly. If the 
DOSSHELL.INI file is deleted or corrupted, a new file will be created the next time you start MS-DOS 
Shell. 

Setting the location to store temporary files

When you run a program from MS-DOS Shell, temporary files are created in the directory where the 
DOSSHELL.EXE file is located. You can specify that temporary files should be placed elsewhere by 
setting the TEMP environment variable in your AUTOEXEC.BAT file. 

Example

To start MS-DOS Shell in graphics mode, type the following command: 
  
dosshell /g 
  
DRIVER.SYS

Creates a logical drive that you can use to refer to a physical floppy disk drive. This device driver must 
be loaded by a device or devicehigh command in your CONFIG.SYS file.
 
A logical drive is a pointer to a physical disk drive in your system. The logical drive is associated with a 
drive letter (for example, A or B). You can specify parameters to describe the disk drive to MS-DOS.
 
Syntax

device=[drive:][path]driver.sys /d:number [/c] [/f:factor] [/h:heads] [/s:sectors] [/t:tracks] 

Parameter

[drive:][path]
Specifies the location of the DRIVER.SYS file. 

Switches

/d:number
Specifies the number of the physical floppy disk drive. Valid values for number are in the range 0 through
 127. The first physical floppy disk drive (drive A) is drive 0; a second physical floppy disk drive is drive 1;
 a third physical floppy disk drive, which must be external, is drive 2. For a computer with one floppy 
disk drive, drives A and B are both numbered 0; for a computer with multiple floppy disk drives, drive B
 is numbered 1. 

/c
Specifies that the physical disk drive can detect whether the drive door is closed (change-line support). 

/f:factor
Specifies the type of disk drive. Valid values for factor are as follows: 

0	160K/180K or 320K/360K 
1	1.2 megabyte (MB) 
2	720K (3.5-inch disk) or other 
7	1.44 MB (3.5-inch disk) 
9	2.88 MB (3.5-inch disk) 

The default value for factor is 2. 

Generally, if you use the /f switch, you can omit the /h, /s, and /t switches. Check the default values for 
these switches to make sure they are correct for the type of disk drive you are using. To determine the 
appropriate values for the disk drive, see the disk-drive manufacturer’s documentation. 

If you specify the /h, /s, and /t switches, you can omit the /f switch. 

/h:heads
Specifies the number of heads in the disk drive. Valid values for heads are in the range 1 through 99. 
The default value is 2. To determine the correct value for your disk drive, see the disk-drive 
manufacturer’s documentation. 

/s:sectors
Specifies the number of sectors per track. Valid values for sectors are in the range 1 through 99. The default value depends on the value of /f:factor, as follows: 

/f:0    /s:9 
/f:1    /s:15 
/f:2    /s:9 
/f:7    /s:18 
/f:9    /s:36 

To determine the correct value for your disk drive, see the disk-drive manufacturer’s documentation. 

/t:tracks
Specifies the number of tracks per side on the block device. Valid values for tracks are in the range 1 
through 999. The default value is 80, unless /f:factor is 0, in which case the default value is 40. To 
determine the correct value for your disk drive, see the disk-drive manufacturer’s documentation. 

Notes

Disk-drive change-line support

The term “change-line support” means that a physical disk drive can detect when the drive door is 
opened and closed. Change-line support allows faster MS-DOS operation with floppy disks. The /c 
switch indicates to MS-DOS that the physical disk drive can support change-line error detection. To 
determine whether your disk drive has change-line support, see the disk-drive manufacturer’s 
documentation. 

Modifying or redefining a supported physical disk drive

For information about modifying the parameters of a physical disk drive that is supported by your 
hardware, see the drivparm command. You can also use DRIVER.SYS to redefine a physical floppy 
disk drive.
 
Limitations on DRIVER.SYS

You cannot use DRIVER.SYS with hard disk drives. For information about substituting a logical drive 
letter for a hard disk drive, see the subst command. 

Creating a duplicate logical drive

Suppose you want to use one physical floppy disk drive to copy files from one floppy disk to another. 
Because you cannot copy from and to the same logical drive by using the copy or xcopy command, 
you must assign a second drive letter to that physical drive.
 
If your system has just one physical floppy disk drive, you do not need to install DRIVER.SYS for this 
purpose. MS-DOS already assigns both logical drive A and logical drive B to that drive. Just copy files 
from drive A to drive B and switch disks when MS-DOS prompts you. 

If your system has more than one floppy disk drive, then you need to use DRIVER.SYS to assign a 
second drive letter to the physical floppy disk drive. 

Creating a new logical drive with different parameters

If you use DRIVER.SYS to assign a logical drive that has parameters different from those of the 
previously assigned logical drive, then the parameters of the previous logical drive will be invalid. 
Therefore, you should no longer use the drive letter corresponding to the previous logical drive.
 
Examples

To add an external 720K drive to your system, add the following line to your CONFIG.SYS file: 
  
device=driver.sys /d:2 
  
Since no location is specified, MS-DOS searches for DRIVER.SYS in the root directory of your startup 
drive. 

Suppose you want to use a single 1.44-megabyte external disk drive to copy files from one floppy disk 
to another. To do this, you must add two identical device commands for DRIVER.SYS in your 
CONFIG.SYS file. This procedure assigns two logical drive letters to the same physical drive. You can 
then swap disks in the same drive during the copying process. The following example shows how to do
 this: 
  
device=driver.sys /d:2 /f:7 
device=driver.sys /d:2 /f:7 
  
Drivparm

Defines parameters for devices such as disk and tape drives when you start MS-DOS. You can use this
 command only in your CONFIG.SYS file.
 
The drivparm command modifies the parameters of an existing physical drive. It does not create a new 
logical drive. The settings specified in the drivparm command override the driver definitions for any 
previous block device. 

Syntax

drivparm=/d:number [/c] [/f:factor] [/h:heads] [/i] [/n] [/s:sectors] [/t:tracks] 

Switches

/d:number
Specifies the physical drive number. Values for number must be in the range 0 through 255 
(for example, drive number 0 = drive A, 1 = drive B, 2 = drive C, and so on). 

/c
Specifies that the drive can detect whether the drive door is closed. 

/f:factor
Specifies the drive type. The following list shows the valid values for factor and a brief description of 
each. The default value is 2. 

0 	160K/180K or 320K/360K 
1	1.2 megabyte (MB) 
2	720K (3.5-inch disk) 
5	 Hard disk 
6	Tape 
7	1.44 MB (3.5-inch disk) 
8	Read/write optical disk 
9	2.88 MB (3.5-inch disk) 

/h:heads
Specifies the maximum number of heads. Values for heads must be in the range 1 through 99. The 
default value depends upon the value you specify for /f:factor. 

/i
Specifies an electronically compatible 3.5-inch floppy disk drive. (Electronically compatible drives are 
installed on your computer and use your existing floppy-disk-drive controller.) Use the /i switch if your 
computer’s ROM BIOS does not support 3.5-inch floppy disk drives.
 
/n
Specifies a non-removable block device. 

/s:sectors
Specifies the number of sectors per track that the block device supports. Values for sectors must be in 
the range 1 through 99. The default value depends upon the value you specify for /f:factor. 

/t:tracks
Specifies the number of tracks per side that the block device supports. The default value depends upon 
the value you specify for /f:factor. 

Notes

Using the /i switch

Use the /i switch if your system does not support 3.5-inch floppy disk drives. (Some IBM PC/AT
-compatible systems do not have a ROM BIOS that supports 3.5-inch floppy disk drives.) 

Disk drive change-line support

Change-line support means that a physical disk drive can detect whether the drive door is opened and 
closed. Change-line support improves performance by letting MS-DOS know when one floppy disk has 
been replaced by another. The /c switch allows MS-DOS to make use of change-line support. To find 
out whether your disk drive has change-line support, see your disk-drive documentation. 

Creating a logical drive

Drivparm modifies the parameters of an existing physical drive and does not create a new logical drive. 

Example

Suppose your system has an internal tape drive with one head on drive D that is configured at startup to
 write 20 tracks of 40 sectors per track. To reconfigure this tape drive to write 10 tracks of 99 sectors 
each, add the following command to your CONFIG.SYS file: 
  
drivparm=/d:3 /f:6 /h:1 /s:99 /t:10 
  
Echo

Displays or hides the text in batch programs when the program is running. Also indicates whether the 
command-echoing feature is on or off. 

When you run a batch program, MS-DOS typically displays (echoes) the batch program’s commands 
on the screen. You can turn this feature on or off by using the echo command. 

Syntax

echo [on|off] 

To use the echo command to display a message, use the following syntax: 

echo [message] 

Parameters

on|off
Specifies whether to turn the command-echoing feature on or off. To display the current echo setting, 
use the echo command without a parameter.
 
message
Specifies text you want MS-DOS to display on the screen. 

Notes

Using a message with the echo command

The echo message command is useful when echo is off. To display a message that is several lines 
long without displaying other commands, you can include several echo message commands after the 
echo off command in your batch program.
 
Hiding the command prompt

If you use the echo off command on the command line, the command prompt does not appear on your 
screen. To redisplay the command prompt, type echo on. 

Preventing MS-DOS from echoing a line

You can insert an at sign (@) in front of a command in a batch program to prevent MS-DOS from 
echoing that line. 

Echoing a blank line

To echo a blank line on the screen, you can type echo and then a period (echo.). There must be no 
intervening space. 

Displaying pipes and redirection characters

You cannot display a pipe (|) or redirection character (< or >) by using the echo command. 

Examples

The following example shows a batch program that includes a three-line message preceded and 
followed by a blank line: 
  
echo off
echo.
echo This batch program
echo formats and checks
echo new disks
echo.
  
If you want to turn echo off and you do not want to echo the echo command itself, include an at sign 
(@) before the command, as follows: 
  
@echo off 
  
You can use the if and echo commands on the same command line, as follows: 
  
if exist *.rpt echo The report has arrived. 
  
Related Command

For information about suspending the execution of a batch program, see the pause command. 

Edit

Starts MS-DOS Editor, a text editor you can use to create and edit ASCII text files. 

MS-DOS Editor is a full-screen editor that allows you to create, edit, save, and print ASCII text files. 
Using MS-DOS Editor, you can choose commands from menus and specify information and 
preferences in dialog boxes. MS-DOS Editor includes extensive online Help about MS-DOS Editor t
echniques and commands. 

Syntax

edit [[drive:][path]filename] [/b] [/g] [/h] [/nohi] 

Parameter

[drive:][path]filename
Specifies the location and name of an ASCII text file. If the file does not exist, MS-DOS Editor creates it.
 If the file exists, MS-DOS Editor opens it and displays its contents on the screen. 

Switches

/b
Displays MS-DOS Editor in black and white. Use this option if MS-DOS Editor isn’t displayed correctly 
on a monochrome monitor. 

/g
Uses the fastest screen updating for a CGA monitor. 

/h
Displays the maximum number of lines possible for the monitor you are using. 

/nohi
Enables you to use 8-color monitors with MS-DOS Editor. Usually, MS-DOS uses 16 colors. 
  

Caution   MS-DOS Editor does not work if the file QBASIC.EXE is not in the current directory or in the 
search path or in the same directory as the file EDIT.COM. If you delete QBASIC.EXE to save space 
on your hard disk, you cannot use MS-DOS Editor.
  
Note
  
Note   Some monitors may not support the display of shortcut keys by default. If your monitor does not
display shortcut keys, use the /b switch (for CGA monitors) and the /nohi switch (for systems that do 
not support bold characters). 
  
EGA.SYS

Saves and restores the display when the MS-DOS Shell Task Swapper is used with EGA monitors. 

If you have an EGA monitor, you must install the EGA.SYS device driver before using Task Swapper. 
This device driver must be loaded by a device or devicehigh command in your CONFIG.SYS file. 

Syntax

device=[drive:][path]ega.sys 

Parameters

[drive:][path]
Specifies the location of the EGA.SYS file. 

Note

If you are using a mouse on a system that has an EGA monitor, you can save memory by installing 
EGA.SYS before you install your mouse driver. 


 