Debug is an external command in DOS, with this command from DOS 1.0, so the importance of this command is visible. Although the function of this command is very powerful, can solve many problems, but for many people, especially beginners, but very difficult to grasp. Therefore, the Debug command is introduced in detail to let you know how it is used.
DEBUG:A (Compendium)
Merges the 8086/8087/8088 memory code directly into memory.
This command creates the executable machine code from the assembly language statement. All values are in hexadecimal format and must be entered in one to four characters. Specifies the prefix memory code before the referenced operation code (opcode).
A [address]
Parameters
Address
Specifies where to type assembly-language instructions. Use a hexadecimal value for address and type each value that does not end with the "H" character. If you do not specify an address, a will start the Assembly at its last stop.
For information about entering data into a specified byte, click Debug E (type) in the Related Topics list.
For information about disassembly bytes, click Debug U (Disassembly) in the Related Topics list.
Description
Using Memory codes
The substitution memory code for the segment is CS:, ds:, es: and SS:. The remote return of the memory code is RETF. The memory code for string processing must explicitly declare the string size. For example, you can use MOVSW to move a 16-bit string and use MOVSB to move a 8-bit byte string.
Assembly jumps and calls
The assembler automatically assembles short, near, and far jumps and calls to the destination address based on byte substitution. You can override such a jump or call by using the 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
You can abbreviate the near prefix to NE.
Distinguishing between word and byte memory locations
When an operand can refer to a Word memory location or byte memory location, the data type must be specified with the prefix word ptr or prefix byte ptr. The acceptable abbreviations are wo and by. The following example shows two formats:
Dec wo [Si]
Neg byte ptr [128]
Specify operands
Debug uses the idioms that include the operands in brackets ([]) to refer to the memory address. This is because Debug, on the other hand, cannot differentiate between immediate operands and memory address operands. The following example shows two formats:
MOV ax,21; Load AX with 21h
mov ax,[21]; Load AX with the
; Contents of
; Memory Location 21h
Using pseudo directives
Use a command to provide two commonly used pseudo directives: db opcode, the byte value is compiled directly into memory, DW opcode, the word value is compiled directly into memory. The following are examples of two pseudo directives:
DB 1,2,3,4, "This is a EXAMPLE"
DB ' is A quotation MARK: '
DB "This is A quotation MARK: '"
DW 1000,2000,3000, "BACH"
Example
A command supports all forms of indirect registration commands, as shown in the following example:
Add bx,34[bp+2]. [Si-1]
Pop [Bp+di]
push [SI])
All opcode synonyms are also supported, as shown in the following example:
Loopz 100
Loope 100
JA 200
Jnbe 200
For the 8087 opcode, you must specify a wait or fwait prefix, as shown in the following example:
Fwait Fadd st,st (3); This line assembles
; An fwait prefix
DEBUG:C (comparison)
Compare two parts of memory.
C Range Address
Parameters
Range
Specifies the starting and ending addresses, or the starting address and length, of the first area of memory to be compared. For information about valid range values, click Debug Description in the related Topics list.
Address
Specifies the starting address of the second memory area to compare. For information about valid address values, click Debug Description in the related Topics list.
Description
If the range and address memory areas are the same, debug will return directly to the debug prompt without displaying any content. If there are differences, Debug will appear in the following format:
Address1 byte1 Byte2 Addess2
Example
The following command has the same effect:
c100,10f 300
C100L10 300
Each command compares 100h to 10Fh memory blocks with 300h to 30Fh memory data blocks.
Debug responds to the previous command and displays the following information (assuming DS = 197F):
197f:0100 4D E4 197f:0300
197f:0101 197f:0301
197f:0102 A3 197f:0302
197f:0103 F3 197f:0303
197f:0104 BD 197f:0304
197f:0105 197f:0305
197f:0107 197f:0307
197f:0108 E6 197f:0308
197f:0109 2C 197f:0309
197F:010A 0A 197f:030a
197f:010b 7F 197f:030b
197f:010c be 197f:030c
197f:010d 197f:030d
197f:010e 197f:030e
197f:010f 4F 8A 197f:030f
Note the address 197f:0106 and 197f:0306 are missing from the list. This indicates that the values in those addresses are the same.
Debug:d (Dump)
Displays the contents of a certain 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 you want to display. For information about valid range values, click Debug Description in the related Topics list. If you do not specify that the RANGE,DEBUG program will display 128 bytes of content from the end of the range of addresses specified in the previous D command.
For information about displaying register contents, click Debug R (register) in the related Topics list.
Description
When you use the D command, Debug displays memory content in two parts: the hexadecimal portion (the value of each byte is represented in hexadecimal format) and the ASCII portion (the value of each byte is represented by an ASCII character). Each non-printing character is represented by a period (.) in the ASCII portion of the display. Each display line displays 16 bytes of content, and a hyphen between byte 8th and 9th bytes. Each display row starts at a 16-byte boundary.
Example
Suppose you type the following command:
dcs:100 10f
Debug Displays the contents of the range in the following format:
04ba:0100 4F 4D to 59-45 the same as TOM. SAWYER ...
If you type the D command without parameters, Debug formats the display as described in the previous example. Each row displayed is 16 bytes larger than the previous one (8 bytes if the screen showing 40 columns) begins.
For each subsequent d command that you type without parameters, Debug displays the byte content immediately after the last command displayed.
If you type the following command, Debug will display 20h bytes of content starting with cs:100:
dcs:100 L 20
If you type the following command, Debug displays the contents of all bytes from 100h to 115h in the range from CS segment:
DCS:100 115
Debug:e (Type)
Enter data into the specified address in memory.
You can type data 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 of the input data.
List
Specifies the data to be entered into contiguous bytes of memory.
For information about integrated memory codes, click Debug A (assembly) in the related Topics list.
For information about displaying portions of memory, click Debug D (Dump) in the related Topics list.
Description
Using the address parameter
If you specify the value of address without specifying the value of the optional list parameter, Debug displays the addresses and contents, repeats the address on the next line, and waits for your input. At this point, you can do one of the following:
Replaces the byte value. To do this, type the new value after the current value. If you type a value that is not a valid hexadecimal value, or if the value contains more than two digits, Debug does not echo the invalid or extra characters.
Enter the next byte. To do this, press SPACEBAR (space bar). To change the value in this byte, type the new value after the current value. If you press SPACEBAR (SPACEBAR), the move exceeds the 8-bit limit, and the Debug program displays a new row and displays the new address at the beginning of the line.
Returns to the previous byte. To do this, press the hyphen key (-). You can repeatedly press the hyphen key (-) to move more than one byte backwards. When you press hyphen, Debug starts a new row and displays the current address and byte values.
Stop the Execute e command. To do this, press the ENTER key. You can press ENTER at any byte position.
Using the list parameter
If you specify the value of the list parameter, the subsequent e command replaces the existing byte value with the value in the list. If an error occurs, no byte values are changed.
The List value can be a hexadecimal byte or a string. Use spaces, commas, or tabs to separate values. You must include the string in single or double quotes.
Example
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 the value to 41, type 41 at the insertion point as follows:
04ba:0100 eb.41_
You can type a contiguous byte value with an e command. Press SPACEBAR (SPACEBAR) after typing the new value instead of pressing the ENTER key. Debug displays the next value. In this example, if you press three times SPACEBAR (SPACEBAR), Debug displays the following value:
04ba:0100 eb.41 10. Bc._
To change the hexadecimal value BC to 42, type 42 at the insertion point as follows:
04ba:0100 eb.41 10. Bc.42_
Suppose the decision value of 10 should be 6F. To correct this value, press the hyphen key two times to return to address 0101 (value 10). Debug Displays the following:
04ba:0100 eb.41 10. bc.42-
04ba:0102 00.-
04ba:0101 10._
Type the 6f change value at the insertion point 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"
The string will populate 24 bytes starting with ds:100
Debug:f (fill)
Fills the address in the specified memory area with the specified value.
You can specify data that is represented 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, to populate the memory area. For information about valid range values, click Debug Description in the related Topics list.
List
Specifies the data to enter. A List can consist of hexadecimal numbers or strings that are included in quotes.
Description
Using the range parameter
If the range contains a larger number of bytes than the list, Debug repeats the value in the list until all the bytes in the range are filled.
If any memory in the range is corrupted or does not exist, Debug displays an error message and stops the F command.
Using the list parameter
If the list contains more values than the number of bytes in the range, Debug ignores the extra values in the list.
Example
Suppose you type the following command:
F04BA:100L100 42 45 52 54 41
In response, Debug fills the memory location from 04ba:100 to 04ba:1ff with the specified values. Debug repeats these five values until the 100h bytes are fully populated.
DEBUG:G (Steering)
Run the program that is currently in memory.
g [=address] [breakpoints]
Parameters
=address
Specifies the address of the program currently in memory to begin execution. If you do not specify Address,windows 2000, the program will begin executing from the current address in the CS:IP register.
Breakpoints
Specifies 1 to 10 temporary breakpoints that can be set to a portion of the G command.
For information about performing loops, duplicate string directives, software interrupts, or subroutines, click Debug P (execute) in the Related Topics list.
For information about executing instructions, click Debug T (Trace) in the Related Topics list.
Debug:h (hex)
Performs a hexadecimal operation on the specified two parameters.
H value1 value2
Parameters
Value1
Represents any hexadecimal number from 0 through the FFFFh range.
value2
Represents the second hexadecimal number in the range from 0 to FFFFh.
Description
Debug first adds the specified two parameters, and then subtracts the second argument from the first argument. The results of these calculations are shown on a single line: first calculate and then compute the difference.
Example
Suppose you type the following command:
h19f 10a
Debug performs the operation and displays the following results.
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 byte values to the output port, click Debug O (Output) in the Related Topics list.
Example
Suppose you type the following command:
I2f8
Also assume that the port's byte value is 42h. Debug reads the byte and displays its value as follows:
42
Debug:l (Loaded)
Loads the contents of a file or a specific disk sector into memory.
To load the contents of the byte number specified in the BX:CX register from the 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 in which to load the contents of the file or sector. If Address,debug is not specified, the current address in the CS register will be used.
Drive
Specifies the drive that contains the disk that reads the specified sector. The value is numeric: 0 = A, 1 = B, 2 = C, and so on.
Start
Specifies the hexadecimal number of the first sector whose contents you want to load.
Number
Specifies the hexadecimal number of contiguous sectors whose contents you want to load. You can use the drive, start, and number parameters only if you want to load the contents of a particular sector instead of loading the files specified in the debug command line or the most recent debug n (name) command.
For information about specifying a file for the L command, click Debug N (name) in the Related Topics list.
For information about writing to a file that is debugged to disk, click Debug W (write) in the related Topics list.
Attention
Use l command with no parameters
When the L command with no parameters is used, the file specified on the debug command line is loaded into memory, starting with the address cs:100. Debug also sets BX and CX registers to the number of bytes loaded. If you do not specify a file on the debug command line, the mounted file will be the file that was frequently specified by the most recent n command.
Use the 1 command with the address parameter
If you use the L command with the address parameter, Debug starts loading the file or the contents of the specified sector from 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 the specified disk sector instead of loading the file.
Load the contents of a specific sector
Each sector within the specified range is read from drive. Debug loads from start until the contents of the sectors specified in number are loaded.
Loading an. exe file
Debug ignores the address addressing parameter of the. exe file. If you specify an. exe file, Debug will relocate the file to the load address specified in the header of the. exe file. The header itself is detached from the. exe file before the. exe file is loaded into memory, so the size of the. exe file on the disk differs from memory. If you want to check the entire. exe file, rename the file with a different extension.
Current 1/2 page
12 Next read the full text