Detailed Explanation of the DEBUG Command --This post is a repost
Debug:A (assemble)
Directly assembles 8086/8087/8088 mnemonics into memory.
This command creates executable machine code from assembly-language statements. All numeric values are in hexadecimal format, and these values must be entered as one to four characters. Specify prefix mnemonics before the referenced operation code (opcode).
a [address]
Parameters
address
Specifies the location where assembly-language instructions are to be typed. Use a hexadecimal value for address, and type each value without ending it with the “h” character. If no address is specified, a begins assembling where it last stopped.
For information about entering data into specified bytes, see Debug E (enter).
For information about disassembling bytes, see Debug U (unassemble)
Notes
Using mnemonics
The segment override mnemonics are cs:, ds:, es:, and ss:. The mnemonic for a far return is retf. The mnemonics for string handling must explicitly declare the string size. For example, movsw moves a 16-bit word string, and movsb moves an 8-bit byte string.
Assembling jumps and calls
The assembler automatically assembles short, near, and far jumps and calls to the target address according to byte displacement. You can override such a jump or call by using a near or far prefix, as shown in the following example:
-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
The near prefix can be abbreviated as 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. The acceptable abbreviations are wo and by respectively. The following examples show both formats:
dec wo [si]
neg byte ptr [128]
Specifying operands
Debug uses the convention of operands enclosed in square brackets ([ ]) to refer to memory addresses. This is because otherwise Debug cannot distinguish immediate operands from memory-address operands. The following examples show both formats:
mov ax,21 ; load AX with 21h
mov ax,[21] ; load AX with the
; contents of
; memory location 21h
Using pseudo-instructions
The a command provides two commonly used pseudo-instructions: the db opcode, which assembles byte values directly into memory, and the dw opcode, which assembles word values directly into memory. The following are examples of the two pseudo-instructions:
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 indirect register commands, as shown in the following examples:
add bx,34[bp+2].[si-1]
pop [bp+di]
push [si] )
It also supports all opcode synonyms, as shown in the following examples:
loopz 100
loope 100
ja 200
jnbe 200
For 8087 opcodes, you must specify the wait or fwait prefix, as shown in the following example:
fwait fadd st,st(3) ; this line assembles
; an fwait prefix
Debug:C (compare)
Compares two portions of memory.
c range address
Parameters
range
Specifies the starting and ending addresses, or the starting address and length, of the first memory area to compare.
address
Specifies the starting address of the second memory area to compare. For information about valid address values, see “Debug Notes.”
Notes
If the range and address memory areas are the same, Debug displays nothing and returns directly to the Debug prompt. If there are differences, Debug displays them in the following format:
address1 byte1 byte2 addess2
Examples
The following commands have the same effect:
c100,10f 300
c100l10 300
Each command compares the block of memory data from 100h to 10Fh with the block of memory data from 300h to 30Fh.
Debug responds to the preceding command and displays the following information (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
Note that addresses 197F:0106 and 197F:0306 are missing from the list. This indicates that the values at those addresses are the same.
Debug:D (dump)
Displays the contents of a range of memory addresses.
d [range]
Parameters
range
Specifies the starting and ending addresses, or the starting address and length, of the memory area whose contents are to be displayed. If range is not specified, Debug displays 128 bytes of content starting from the end of the address range specified in the previous d command.
For information about displaying register contents, see Debug R (registers).
Notes
When using the d command, Debug displays memory contents in two parts: the hexadecimal part (the value of each byte is represented in hexadecimal format) and the ASCII part (the value of each byte is represented as an ASCII character). Each nonprinting character is represented by a period (.) in the displayed ASCII part. Each displayed line shows 16 bytes, with a hyphen between the 8th and 9th bytes. Each displayed line begins on a 16-byte boundary.
Examples
Suppose you type the following command:
dcs:100 10f
Debug displays the contents in 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 displayed line begins with an address 16 bytes greater than the previous line’s address (8 bytes if displayed on a 40-column screen).
For each subsequent d command typed without parameters, Debug displays the byte contents immediately following the last displayed command.
If you type the following command, Debug displays 20h bytes of content starting at CS:100:
dcs:100 l 20
If you type the following command, Debug displays the contents of all bytes in the range from 100h to 115h in the CS segment:
dcs:100 115
Debug:E (enter)
Enters data into a specified address in memory.
Data can be typed in hexadecimal or ASCII format. Any data previously stored at the specified location is lost.
e address [list]
Parameters
address
Specifies the first memory location for entering data.
list
Specifies the data to be entered into consecutive bytes of memory.
For information about assembling mnemonics, see Debug A (assemble).
For information about displaying the contents of a portion of memory, see Debug D (dump).
Notes
Using the address parameter
If you specify the value of address without specifying the optional list parameter, Debug displays the address and contents, repeats the address on the next line, and waits for your input. At this point, you can do one of the following:
Replace the byte value. To do this, type the new value after the current value. If the value you type is not a valid hexadecimal value, or if the value contains more than two digits, Debug does not echo the invalid or extra characters.
Move to the next byte. To do this, press SPACEBAR. To change the value in that byte, type the new value after the current value. If pressing SPACEBAR moves past an 8-byte boundary, Debug displays a new line and displays the new address at the beginning of the line.
Return to the previous byte. To do this, press the HYPHEN key (-). You can press the HYPHEN key (-) repeatedly to move back past multiple bytes. When HYPHEN is pressed, Debug starts a new line and displays the current address and byte value.
Stop executing the e command. To do this, press ENTER. ENTER can be pressed at any byte position.
Using the list parameter
If the value of the list parameter is specified, the following e command replaces the existing byte values with the values in the list. If an error occurs, no byte values are changed.
List values can be hexadecimal bytes or strings. Use spaces, commas, or tabs to separate values. Strings must be enclosed in 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 insertion point, as follows:
04BA:0100 EB.41_
You can type consecutive byte values with one e command. After typing the new value, press SPACEBAR instead of ENTER. Debug displays the next value. In this example, if you press 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 insertion point, as follows:
04BA:0100 EB.41 10. 00. BC.42_
Suppose you decide that 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 insertion point 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 item:
eds:100 "This is the text example"
This string will fill 24 bytes starting at DS:100
Debug:F (fill)
Fills addresses in a specified memory area with specified values.
The data can be specified in hexadecimal or ASCII format. Any data previously stored at the specified location will be lost.
f range list
Parameters
range
Specifies the starting and ending addresses, or the starting address and length, of the memory area to fill. For information about valid range values, see “Debug Notes.”
list
Specifies the data to enter. List can consist of hexadecimal numbers or strings enclosed in quotation marks.
Notes
Using the range parameter
If range contains more bytes than there are values in list, Debug repeatedly assigns the values in list until all bytes in range are filled.
If any memory in range is damaged or does not exist, Debug displays an error message and stops the f command.
Using the list parameter
If list contains more values than there are bytes in range, Debug ignores the extra values in list.
Examples
Suppose you type the following command:
f04ba:100l100 42 45 52 54 41
In response, Debug fills the memory locations from 04BA:100 to 04BA:1FF with the specified values. Debug repeats these five values until all 100h bytes are filled.
Debug:G (go)
Runs the program currently in memory.
g [=address] [breakpoints]
Parameters
=address
Specifies the address at which the program currently in memory is to start executing. If address is not specified, Windows 2000 starts executing the program from the current address in the CS:IP registers.
breakpoints
Specifies 1 to 10 temporary breakpoints that can be set as part of the g command.
For information about executing loops, repeated string instructions, software interrupts, or subroutines, see Debug P (proceed).
For information about executing instructions, see Debug T (trace)
Debug:H (hexadecimal)
Performs hexadecimal arithmetic on the two specified parameters.
h value1 value2
Parameters
value1
Represents any hexadecimal number in the range from 0 to FFFFh.
value2
Represents a second hexadecimal number in the range from 0 to FFFFh.
Notes
Debug first adds the two specified parameters, then subtracts the second parameter from the first. The results of these calculations are displayed on one line: first the sum, then the difference.
Examples
Suppose you type the following command:
h19f 10a
Debug performs the operation and displays the following result.
02A9 0095
Debug:I (input)
Reads and displays a byte value from the specified port.
i port
Parameters
port
Specifies the input port by address. The address can be a 16-bit value.
For information about sending a byte value to an output port, see Debug O (output).
Examples
Suppose you type the following command:
i2f8
Also suppose the byte value of the port is 42h. Debug reads the byte and displays its value as follows:
42
Debug:L (load)
Loads the contents of a file or specific disk sectors into memory.
To load the number of bytes specified in the BX:CX registers from a disk file, use the following syntax:
l [address]
To bypass the Windows 2000 file system and load specific sectors directly, use the following syntax:
l address drive start number
Parameters
address
Specifies the memory location where the file or sector contents are to be loaded. If address is not specified, Debug uses the current address in the CS register.
drive
Specifies the drive containing the disk from which the specified sectors are read. The value is numeric: 0 = A, 1 = B, 2 = C, etc.
start
Specifies the hexadecimal number of the first sector whose contents are to be loaded.
number
Specifies the hexadecimal number of consecutive sectors whose contents are to be loaded. The drive, start, and number parameters can be used only when loading the contents of specific sectors rather than loading the file specified on the debug command line or in the most recent Debug n (name) command.
For information about specifying a file for the l command, see Debug n (name).
For information about writing the debugged file to disk, see Debug w (write).
Note
Using the l command without parameters
When the l command is used without parameters, the file specified on the debug command line is loaded into memory, starting at address CS:100. Debug also sets the BX and CX registers to the number of bytes loaded. If no file is specified on the debug command line, the loaded file will be the file most recently specified with the n command.
Using the 1 command with the address parameter
If the l command is used with the address parameter, Debug loads the contents of the file or specified sectors starting at memory location address.
Using the l command with all parameters
If the l command is used with all parameters, Debug loads the contents of the specified disk sectors instead of loading a file.
Loading the contents of specific sectors
Each sector in the specified range is read from drive. Debug begins loading at start until all contents in the number of sectors specified in number have been loaded.
Loading .exe files
Debug ignores the address address parameter for .exe files. If a .exe file is specified, Debug relocates the file to the load address specified in the header of the .exe file. Before the .exe file is loaded into memory, the header itself is stripped from the .exe file, so the size of the .exe file on disk differs from that in memory. If you want to examine the entire .exe file, rename the file with a different extension.
Opening hexadecimal files
Debug treats files with the .hex extension as hexadecimal-format files. Type the l command without parameters to load the hexadecimal file starting at the address specified in the hexadecimal file. If the l command you type contains the address parameter, Debug adds the specified address to the address found in the hexadecimal 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 you need to load the contents of 109 (6Dh) sectors, starting with logical sector 15 (0Fh), from drive C into memory starting at address 04BA:0100. To do this, type the following command:
l04ba:100 2 0f 6d
Debug:M (move)
Copies the contents of one memory block into another memory block.
m range address
Parameters
range
Specifies the starting and ending addresses, or the starting address and length, of the memory area whose contents are to be copied.
address
Specifies the starting address to which the contents of range are to be copied.
Notes
The effect of the copy operation on existing data
If the new data is not written to an address in the block of data being copied, the source data remains unchanged. However, if the destination block already contains data (as it does in an overlapping copy operation), that data is overwritten. (An overlapping copy operation is one in which part of the destination data block overlaps part of the original data block.)
Performing an overlapping copy operation
The m command performs an overlapping copy operation to the destination address without losing data. The contents of the addresses to be overwritten are copied first. Therefore, if data at higher addresses is copied to lower addresses, the copy operation starts at the lowest address of the original block and proceeds toward the highest address. Conversely, if data is copied from lower addresses to higher addresses, the copy operation starts at the highest address of the original block and proceeds toward the lowest address.
Examples
Suppose you type the following command:
mcs:100 110 cs:500
Debug first copies the contents of address CS:110 to address CS:510, then copies the contents of address CS:10F to CS:50F, and so on until the contents of address CS:100 have been copied to address CS:500. To view the result, use the Debug d (dump) command, and use the destination address specified with the m command
Debug:N (name)
Specifies the name of the executable file for the Debug l (load) or w (write) command, or specifies parameters for the executable file being debugged.
n [drive:][path] filename
To specify parameters for the executable file to be tested, use the following syntax:
n file-parameters
Parameters
If used without parameters, the n command clears the current specification.
[drive:][path] filename
Specifies the location and name of the executable file to be tested.
file-parameters
Specifies parameters and switches for the executable file being tested.
For information about loading a file or the contents of specified disk sectors into memory, see Debug L (load).
For information about writing the debugged file to disk, see Debug W (write).
Notes
The two uses of the n command
The n command can be used in two ways. First, you can use it to specify the file used by a subsequent l (load) or w (write) command. If you start Debug without naming the file to be debugged, you must use the command nfilename before using the l command to load the file. The filename is correctly formatted for the file control block (FCB) 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 memory areas are all 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 the n command line (in characters)
CS:81
Beginning of the n command-line characters
The first filename specified for the n command is placed in the FCB at CS:5C. If a second filename is specified, this name is placed in the FCB at CS:6C. The number of characters typed on the n command line (except for the first character, n) is stored at location CS:80. The actual characters on the n command line (again, except for the letter n) are stored starting at CS:81. Note that these characters can be any switches and separators valid in commands typed at the Windows 2000 command prompt.
Examples
Suppose Debug has already been started and the program being debugged, Prog.com, has been loaded. Then you decide to specify two parameters for Prog.com and run the program. The following is the command sequence 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 Windows 2000 command prompt:
prog param1 param2
Therefore, testing and debugging reflect the normal run-time environment of Prog.com.
In the following command sequence, the first n command specifies File1.exe as the file for the following l (load) command, which loads File1.exe into memory. The second n command specifies the parameters that File1.exe will use. Finally, the g command runs the File1.exe file as if you had typed File1 File2.dat File2.dat at the Windows 2000 command line.
nfile1.exe
nfile2.dat file3.dat
g
Note
Do not use the l command after the second form of the n command. Also note that if you now use the w (write) command, Windows 2000 will save the file being debugged, File1.exe, using the name File2.dat. To avoid this result, you should always use the first form of the n command immediately before an l or w command.
Debug:A (assemble)
Directly assembles 8086/8087/8088 mnemonics into memory.
This command creates executable machine code from assembly-language statements. All numeric values are in hexadecimal format, and these values must be entered as one to four characters. Specify prefix mnemonics before the referenced operation code (opcode).
a [address]
Parameters
address
Specifies the location where assembly-language instructions are to be typed. Use a hexadecimal value for address, and type each value without ending it with the “h” character. If no address is specified, a begins assembling where it last stopped.
For information about entering data into specified bytes, see Debug E (enter).
For information about disassembling bytes, see Debug U (unassemble)
Notes
Using mnemonics
The segment override mnemonics are cs:, ds:, es:, and ss:. The mnemonic for a far return is retf. The mnemonics for string handling must explicitly declare the string size. For example, movsw moves a 16-bit word string, and movsb moves an 8-bit byte string.
Assembling jumps and calls
The assembler automatically assembles short, near, and far jumps and calls to the target address according to byte displacement. You can override such a jump or call by using a near or far prefix, as shown in the following example:
-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
The near prefix can be abbreviated as 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. The acceptable abbreviations are wo and by respectively. The following examples show both formats:
dec wo [si]
neg byte ptr [128]
Specifying operands
Debug uses the convention of operands enclosed in square brackets ([ ]) to refer to memory addresses. This is because otherwise Debug cannot distinguish immediate operands from memory-address operands. The following examples show both formats:
mov ax,21 ; load AX with 21h
mov ax,[21] ; load AX with the
; contents of
; memory location 21h
Using pseudo-instructions
The a command provides two commonly used pseudo-instructions: the db opcode, which assembles byte values directly into memory, and the dw opcode, which assembles word values directly into memory. The following are examples of the two pseudo-instructions:
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 indirect register commands, as shown in the following examples:
add bx,34[bp+2].[si-1]
pop [bp+di]
push [si] )
It also supports all opcode synonyms, as shown in the following examples:
loopz 100
loope 100
ja 200
jnbe 200
For 8087 opcodes, you must specify the wait or fwait prefix, as shown in the following example:
fwait fadd st,st(3) ; this line assembles
; an fwait prefix
Debug:C (compare)
Compares two portions of memory.
c range address
Parameters
range
Specifies the starting and ending addresses, or the starting address and length, of the first memory area to compare.
address
Specifies the starting address of the second memory area to compare. For information about valid address values, see “Debug Notes.”
Notes
If the range and address memory areas are the same, Debug displays nothing and returns directly to the Debug prompt. If there are differences, Debug displays them in the following format:
address1 byte1 byte2 addess2
Examples
The following commands have the same effect:
c100,10f 300
c100l10 300
Each command compares the block of memory data from 100h to 10Fh with the block of memory data from 300h to 30Fh.
Debug responds to the preceding command and displays the following information (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
Note that addresses 197F:0106 and 197F:0306 are missing from the list. This indicates that the values at those addresses are the same.
Debug:D (dump)
Displays the contents of a range of memory addresses.
d [range]
Parameters
range
Specifies the starting and ending addresses, or the starting address and length, of the memory area whose contents are to be displayed. If range is not specified, Debug displays 128 bytes of content starting from the end of the address range specified in the previous d command.
For information about displaying register contents, see Debug R (registers).
Notes
When using the d command, Debug displays memory contents in two parts: the hexadecimal part (the value of each byte is represented in hexadecimal format) and the ASCII part (the value of each byte is represented as an ASCII character). Each nonprinting character is represented by a period (.) in the displayed ASCII part. Each displayed line shows 16 bytes, with a hyphen between the 8th and 9th bytes. Each displayed line begins on a 16-byte boundary.
Examples
Suppose you type the following command:
dcs:100 10f
Debug displays the contents in 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 displayed line begins with an address 16 bytes greater than the previous line’s address (8 bytes if displayed on a 40-column screen).
For each subsequent d command typed without parameters, Debug displays the byte contents immediately following the last displayed command.
If you type the following command, Debug displays 20h bytes of content starting at CS:100:
dcs:100 l 20
If you type the following command, Debug displays the contents of all bytes in the range from 100h to 115h in the CS segment:
dcs:100 115
Debug:E (enter)
Enters data into a specified address in memory.
Data can be typed in hexadecimal or ASCII format. Any data previously stored at the specified location is lost.
e address [list]
Parameters
address
Specifies the first memory location for entering data.
list
Specifies the data to be entered into consecutive bytes of memory.
For information about assembling mnemonics, see Debug A (assemble).
For information about displaying the contents of a portion of memory, see Debug D (dump).
Notes
Using the address parameter
If you specify the value of address without specifying the optional list parameter, Debug displays the address and contents, repeats the address on the next line, and waits for your input. At this point, you can do one of the following:
Replace the byte value. To do this, type the new value after the current value. If the value you type is not a valid hexadecimal value, or if the value contains more than two digits, Debug does not echo the invalid or extra characters.
Move to the next byte. To do this, press SPACEBAR. To change the value in that byte, type the new value after the current value. If pressing SPACEBAR moves past an 8-byte boundary, Debug displays a new line and displays the new address at the beginning of the line.
Return to the previous byte. To do this, press the HYPHEN key (-). You can press the HYPHEN key (-) repeatedly to move back past multiple bytes. When HYPHEN is pressed, Debug starts a new line and displays the current address and byte value.
Stop executing the e command. To do this, press ENTER. ENTER can be pressed at any byte position.
Using the list parameter
If the value of the list parameter is specified, the following e command replaces the existing byte values with the values in the list. If an error occurs, no byte values are changed.
List values can be hexadecimal bytes or strings. Use spaces, commas, or tabs to separate values. Strings must be enclosed in 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 insertion point, as follows:
04BA:0100 EB.41_
You can type consecutive byte values with one e command. After typing the new value, press SPACEBAR instead of ENTER. Debug displays the next value. In this example, if you press 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 insertion point, as follows:
04BA:0100 EB.41 10. 00. BC.42_
Suppose you decide that 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 insertion point 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 item:
eds:100 "This is the text example"
This string will fill 24 bytes starting at DS:100
Debug:F (fill)
Fills addresses in a specified memory area with specified values.
The data can be specified in hexadecimal or ASCII format. Any data previously stored at the specified location will be lost.
f range list
Parameters
range
Specifies the starting and ending addresses, or the starting address and length, of the memory area to fill. For information about valid range values, see “Debug Notes.”
list
Specifies the data to enter. List can consist of hexadecimal numbers or strings enclosed in quotation marks.
Notes
Using the range parameter
If range contains more bytes than there are values in list, Debug repeatedly assigns the values in list until all bytes in range are filled.
If any memory in range is damaged or does not exist, Debug displays an error message and stops the f command.
Using the list parameter
If list contains more values than there are bytes in range, Debug ignores the extra values in list.
Examples
Suppose you type the following command:
f04ba:100l100 42 45 52 54 41
In response, Debug fills the memory locations from 04BA:100 to 04BA:1FF with the specified values. Debug repeats these five values until all 100h bytes are filled.
Debug:G (go)
Runs the program currently in memory.
g [=address] [breakpoints]
Parameters
=address
Specifies the address at which the program currently in memory is to start executing. If address is not specified, Windows 2000 starts executing the program from the current address in the CS:IP registers.
breakpoints
Specifies 1 to 10 temporary breakpoints that can be set as part of the g command.
For information about executing loops, repeated string instructions, software interrupts, or subroutines, see Debug P (proceed).
For information about executing instructions, see Debug T (trace)
Debug:H (hexadecimal)
Performs hexadecimal arithmetic on the two specified parameters.
h value1 value2
Parameters
value1
Represents any hexadecimal number in the range from 0 to FFFFh.
value2
Represents a second hexadecimal number in the range from 0 to FFFFh.
Notes
Debug first adds the two specified parameters, then subtracts the second parameter from the first. The results of these calculations are displayed on one line: first the sum, then the difference.
Examples
Suppose you type the following command:
h19f 10a
Debug performs the operation and displays the following result.
02A9 0095
Debug:I (input)
Reads and displays a byte value from the specified port.
i port
Parameters
port
Specifies the input port by address. The address can be a 16-bit value.
For information about sending a byte value to an output port, see Debug O (output).
Examples
Suppose you type the following command:
i2f8
Also suppose the byte value of the port is 42h. Debug reads the byte and displays its value as follows:
42
Debug:L (load)
Loads the contents of a file or specific disk sectors into memory.
To load the number of bytes specified in the BX:CX registers from a disk file, use the following syntax:
l [address]
To bypass the Windows 2000 file system and load specific sectors directly, use the following syntax:
l address drive start number
Parameters
address
Specifies the memory location where the file or sector contents are to be loaded. If address is not specified, Debug uses the current address in the CS register.
drive
Specifies the drive containing the disk from which the specified sectors are read. The value is numeric: 0 = A, 1 = B, 2 = C, etc.
start
Specifies the hexadecimal number of the first sector whose contents are to be loaded.
number
Specifies the hexadecimal number of consecutive sectors whose contents are to be loaded. The drive, start, and number parameters can be used only when loading the contents of specific sectors rather than loading the file specified on the debug command line or in the most recent Debug n (name) command.
For information about specifying a file for the l command, see Debug n (name).
For information about writing the debugged file to disk, see Debug w (write).
Note
Using the l command without parameters
When the l command is used without parameters, the file specified on the debug command line is loaded into memory, starting at address CS:100. Debug also sets the BX and CX registers to the number of bytes loaded. If no file is specified on the debug command line, the loaded file will be the file most recently specified with the n command.
Using the 1 command with the address parameter
If the l command is used with the address parameter, Debug loads the contents of the file or specified sectors starting at memory location address.
Using the l command with all parameters
If the l command is used with all parameters, Debug loads the contents of the specified disk sectors instead of loading a file.
Loading the contents of specific sectors
Each sector in the specified range is read from drive. Debug begins loading at start until all contents in the number of sectors specified in number have been loaded.
Loading .exe files
Debug ignores the address address parameter for .exe files. If a .exe file is specified, Debug relocates the file to the load address specified in the header of the .exe file. Before the .exe file is loaded into memory, the header itself is stripped from the .exe file, so the size of the .exe file on disk differs from that in memory. If you want to examine the entire .exe file, rename the file with a different extension.
Opening hexadecimal files
Debug treats files with the .hex extension as hexadecimal-format files. Type the l command without parameters to load the hexadecimal file starting at the address specified in the hexadecimal file. If the l command you type contains the address parameter, Debug adds the specified address to the address found in the hexadecimal 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 you need to load the contents of 109 (6Dh) sectors, starting with logical sector 15 (0Fh), from drive C into memory starting at address 04BA:0100. To do this, type the following command:
l04ba:100 2 0f 6d
Debug:M (move)
Copies the contents of one memory block into another memory block.
m range address
Parameters
range
Specifies the starting and ending addresses, or the starting address and length, of the memory area whose contents are to be copied.
address
Specifies the starting address to which the contents of range are to be copied.
Notes
The effect of the copy operation on existing data
If the new data is not written to an address in the block of data being copied, the source data remains unchanged. However, if the destination block already contains data (as it does in an overlapping copy operation), that data is overwritten. (An overlapping copy operation is one in which part of the destination data block overlaps part of the original data block.)
Performing an overlapping copy operation
The m command performs an overlapping copy operation to the destination address without losing data. The contents of the addresses to be overwritten are copied first. Therefore, if data at higher addresses is copied to lower addresses, the copy operation starts at the lowest address of the original block and proceeds toward the highest address. Conversely, if data is copied from lower addresses to higher addresses, the copy operation starts at the highest address of the original block and proceeds toward the lowest address.
Examples
Suppose you type the following command:
mcs:100 110 cs:500
Debug first copies the contents of address CS:110 to address CS:510, then copies the contents of address CS:10F to CS:50F, and so on until the contents of address CS:100 have been copied to address CS:500. To view the result, use the Debug d (dump) command, and use the destination address specified with the m command
Debug:N (name)
Specifies the name of the executable file for the Debug l (load) or w (write) command, or specifies parameters for the executable file being debugged.
n [drive:][path] filename
To specify parameters for the executable file to be tested, use the following syntax:
n file-parameters
Parameters
If used without parameters, the n command clears the current specification.
[drive:][path] filename
Specifies the location and name of the executable file to be tested.
file-parameters
Specifies parameters and switches for the executable file being tested.
For information about loading a file or the contents of specified disk sectors into memory, see Debug L (load).
For information about writing the debugged file to disk, see Debug W (write).
Notes
The two uses of the n command
The n command can be used in two ways. First, you can use it to specify the file used by a subsequent l (load) or w (write) command. If you start Debug without naming the file to be debugged, you must use the command nfilename before using the l command to load the file. The filename is correctly formatted for the file control block (FCB) 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 memory areas are all 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 the n command line (in characters)
CS:81
Beginning of the n command-line characters
The first filename specified for the n command is placed in the FCB at CS:5C. If a second filename is specified, this name is placed in the FCB at CS:6C. The number of characters typed on the n command line (except for the first character, n) is stored at location CS:80. The actual characters on the n command line (again, except for the letter n) are stored starting at CS:81. Note that these characters can be any switches and separators valid in commands typed at the Windows 2000 command prompt.
Examples
Suppose Debug has already been started and the program being debugged, Prog.com, has been loaded. Then you decide to specify two parameters for Prog.com and run the program. The following is the command sequence 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 Windows 2000 command prompt:
prog param1 param2
Therefore, testing and debugging reflect the normal run-time environment of Prog.com.
In the following command sequence, the first n command specifies File1.exe as the file for the following l (load) command, which loads File1.exe into memory. The second n command specifies the parameters that File1.exe will use. Finally, the g command runs the File1.exe file as if you had typed File1 File2.dat File2.dat at the Windows 2000 command line.
nfile1.exe
nfile2.dat file3.dat
g
Note
Do not use the l command after the second form of the n command. Also note that if you now use the w (write) command, Windows 2000 will save the file being debugged, File1.exe, using the name File2.dat. To avoid this result, you should always use the first form of the n command immediately before an l or w command.
ko20010214
=================================
大功告成,打个Kiss!
ko20010214@MSN.com
神州优雅Q300C
Intel CeleronM 370处理器 | 256MbDDR内存
40G硬盘 | USB2.0 | IEEE 1394
13.3 ' WXGA 宽屏(16:10) | COMBO光驱
10/100M网卡 | 四合一读卡器
=================================
大功告成,打个Kiss!
ko20010214@MSN.com
神州优雅Q300C
Intel CeleronM 370处理器 | 256MbDDR内存
40G硬盘 | USB2.0 | IEEE 1394
13.3 ' WXGA 宽屏(16:10) | COMBO光驱
10/100M网卡 | 四合一读卡器

