Friday, October 24, 2008

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

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).

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

No comments:

Just Answer


JustAnswer.com