DEBUG Command details page 1/2

Source: Internet
Author: User

DEBUG is an external command in DOS. It is carried from DOS 1.0, so the importance of this command is obvious. Although this command is very powerful and can solve many problems, it is very difficult for many people, especially beginners. Therefore, we will introduce the DEBUG command in detail to let everyone know how to use it.
Debug: A (assembly)
Directly merge the 8086/8087/8088 Memory code into the memory.
This command creates executable machine codes from assembly language statements. All values are in hexadecimal format and must be entered by one to four characters. Specify the prefix memory before the referenced operation code.
A [address]
Parameters
Address
Specifies the location where the assembly language instruction is entered. Use a hexadecimal value for address and type each value that does not end with the character "h. If no address is specified, a starts assembly at the last stop.
For information about inputting data into a specified byte, click Debug E in the related topic list ).
For information about disassembly bytes, click Debug U (disassembly) in the related topics list ).
Description
Use the Memory code
The alternative Memory code of the segment is cs:, ds:, es:, and ss :. The memory code returned remotely is retf. The memory code for string processing must explicitly declare the string size. For example, movsw can be used to move 16-bit strings and movsb can be used to move 8-bit byte strings.
Assembly jump and call
The assembler automatically assembles short, near and far jumps and calls to the target address based on the replacement of bytes. You can use the near or far prefix to replace such a jump or call, 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 abbreviated the near prefix as ne.
Differentiate characters and byte memory locations
When an operand can reference a word memory location or byte memory location, you must use the prefix word ptr or byte ptr to specify the data type. Acceptable abbreviations are wo and. The following example shows two formats:
Dec wo [si]
Neg byte ptr [128]
Specified operand
Debug uses the memory address referenced by the operands included in brackets. This is because Debug cannot distinguish between the immediate operand and the memory address operand. The following example shows two formats:
Mov ax, 21; load AX with 21 h
Mov ax, [21]; load AX with
; Contents
; Memory location 21 h
Use pseudoinstructions
Use the command to provide two commonly used pseudo commands: db operation code, which assembles byte values directly into the memory, dw operation code, and word values directly into the memory. The following are examples of two pseudo commands:
Db 1, 2, 3, 4, "this is an example"
Db 'this is a quotation mark :"'
Db "this is a quotation mark :'"
Dw 3000, "BACH"
Example
Command a 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 operation code synonyms are also supported, as shown in the following example:
Loopz 100
Loope 100
Ja 200
Jnbe 200
For the 8087 operation code, 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 (comparison)
Compare two parts of the memory.
C range address
Parameters
Range
Specify the start and end addresses, or the start 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 be compared. For information about valid address values, click "Debug description" in the "related topics" list ".
Description
If the range and address memory regions are the same, Debug returns directly to the Debug prompt without displaying any content. If there are differences, Debug will be displayed in the following format:
Address1 byte1 byte2 addess2
Example
The following command has the same effect:
C100, 10f 300
C100l10 300
Each Command compares the memory data blocks of 100 h to 10 FH with those of 300 h to 30 FH.
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 the addresses 197F: 0106 and 197F: 0306 are missing in the list. This indicates that the values in the addresses are the same.
Debug: D (dump)
Display the content of a certain range of memory addresses.
D [range]
Parameters
Range
Specify the start and end addresses, or the start address and length of the memory area where the content is to be displayed. For information about valid range values, click "Debug description" in the "related topics" list ". If range is not specified, the Debug program displays 128 bytes of content starting from the end of the address range specified in the previous d command.
For information on displaying the register content, click Debug R (Register) in the "related topics" list ).
Description
When the d command is used, Debug displays the memory content in two parts: the hexadecimal part (the value of each byte is expressed in hexadecimal format) and ASCII code (each byte value is represented by ASCII characters ). Each non-printable character is represented by a period (.) In the displayed ASCII section. Each display line displays 16 bytes of content, with a hyphen between 8th bytes and 9th bytes. Each display line starts at the boundary of 16 bytes.
Example
Run the following command:
Dcs: 100 10f
Debug displays the content in the following format:
04BA: 0100 54 4F 4D 00 53 41 57 59-45 52 00 00 00 00 00 TOM. SAWYER ......
If you enter the d command without parameters, Debug orchestrates the display format according to the content described in the previous example. The displayed line starts with a address that is 16 bytes larger than the address of the previous line (if the screen of 40 columns is displayed, It is 8 bytes.
For each d command without Parameters entered later, Debug displays the byte content immediately after the last command is displayed.
If you type the following command, Debug displays 20 h bytes of content starting from CS: 100:
Dcs: 100 l 20
If you type the following command, Debug displays all bytes in the range from 100 h to 115 h in the CS segment:
Dcs: 100 115
Debug: E (type)
Input data to the address specified in the memory.
You can enter data in hexadecimal or ASCII format. All data previously stored at the specified location is lost.
E address [list]
Parameters
Address
Specify the first memory location of the input data.
List
Specifies the data in consecutive bytes to be input into the memory.
For information about the integrated memory, click Debug A (assembly) in the "related topics" list ).
For information on displaying the memory part, click Debug D (dump) in the "related topics" list ).
Description
Use address parameters
If you specify the address value without specifying the optional list parameter value, Debug displays the address and content, repeat the address in the next line, and waits for your input. In this case, you can perform one of the following operations:
Replace the byte value. To do this, enter a new value after the current value. If the entered value is not a valid hexadecimal value or contains more than two numbers, Debug does not display invalid or additional characters.
Enter the next byte. Therefore, Press SPACEBAR (Space key ). To change the value in this byte, enter a new value after the current value. If you press the SPACEBAR (Space key) and the Movement exceeds the 8-bit limit, the Debug program displays a new line and a new address at the beginning of the line.
Returns the first byte. Therefore, press the HYPHEN key (-). You can repeatedly press the HYPHEN key (-) to move more than one byte backward. When you press HYPHEN, Debug starts a new line and displays the current address and byte value.
Stop executing the e command. Therefore, press ENTER. You can press ENTER at any byte location.
Use list Parameters
If the value of the list parameter is specified, the subsequent e command replaces the existing byte value with the value in the list. If an error occurs, no byte value will be changed.
The List value can be a hexadecimal byte or string. Use spaces, commas, or tabs to separate values. Strings must be included in single or double quotation marks.
Example
Run the following command:
Ecs: 100
Debug displays the content of the first byte in the following format:
04BA: 0100 EB.
To change the value to 41, type 41 at the insertion point, as shown below:
04BA: 0100 EB.41 _
You can use an e command to Type Continuous byte values. Press SPACEBAR (Space key) instead of ENTER after you type a new value. 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 shown below:
04BA: 0100 EB.41 10. 00. BC.42 _
Assume 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 content:
04BA: 0100 EB.41 10. 00. BC.42-
04BA: 0102 00 .-
04BA: 0101 10 ._
At the insert point, type 6f to change the value, as shown below:
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:
Eds: 100 "This is the text example"
The string will be filled with 24 bytes starting from DS: 100
Debug: F (fill)
Fill in the address in the specified memory area with the specified value.
Data in hexadecimal or ASCII format can be specified. Any data previously stored in the specified location will be lost.
F range list
Parameters
Range
Specify the start and end addresses, or the start address and length of the memory area to be filled. For information about valid range values, click "Debug description" in the "related topics" list ".
List
Specify the data to be input. A List can be a string consisting of hexadecimal numbers or quotation marks.
Description
Use range parameter
If the number of bytes in a range is greater than the value in the list, Debug assigns a value repeatedly in the list until all bytes in the range are filled.
If any memory in the range is corrupted or does not exist, Debug displays the error message and stops the f command.
Use list Parameters
If the list contains more values than the number of bytes in the range, Debug ignores the additional values in the list.
Example
Run the following command:
F04ba: 100l100 42 45 52 54 41
In response, Debug uses the specified value to fill the memory position from 04BA: 100 to 04BA: 1FF. Debug repeats these five values until 100 h bytes are fully filled.
Debug: G (redirection)
Run the program in the memory.
G [= address] [breakpoints]
Parameters
= Address
Specifies the address of the program to be executed in the memory. If address is not specified, Windows 2000 runs the program from the current address in the CS: IP address Register.
Breakpoints
Specify 1 to 10 temporary breakpoints that can be set as part of the g command.
For information on execution cycles, repeated string commands, software interruptions, or subroutines, click Debug P in the related topics list ).
For information on executing commands, click Debug T in the related topics list ).
Debug: H (hexadecimal)
Perform the hexadecimal operation on the specified two parameters.
H value1 value2
Parameters
Value1
Represents any hexadecimal number from 0 to FFFFh.
Value2
Represents the second hexadecimal number in the range from 0 to FFFFh.
Description
Debug first adds the specified two parameters, and then removes the second parameter from the first parameter. The calculation results are displayed in one row: Calculate the sum first, and then calculate the difference.
Example
Run the following command:
H19f 10a
Debug executes the operation and displays the following results.
02A9 0095
Debug: I (input)
Reads data from the specified port and displays a byte value.
I port
Parameters
Port
Specify the input port by address. The address can be a 16-bit value.
For information on sending the byte value to the output port, click Debug O (output) in the related topics list ).
Example
Run the following command:
I2f8
It is also assumed that the port's byte value is 42 h. Debug reads the byte and displays the value as follows:
42
Debug: L (load)
Load the content of a file or a specific disk sector to the memory.
To load the bytes specified in the BX: CX register from a disk file, use the following syntax:
L [address]
To skip the Windows 2000 file system and directly load a specific sector, use the following syntax:
L address drive start number
Parameters
Address
Specify the memory location where the file or slice content is to be loaded. If no address is specified, Debug uses the current address in the CS register.
Drive
The drive that contains the disk that reads the specified sector. This value is Numeric: 0 = A, 1 = B, 2 = C, etc.
Start
Specify the hexadecimal number of the first slice to load its content.
Number
Specify the hexadecimal number of consecutive slices to load. You can use the drive, start, and number parameters only when you want to load the content of a specific sector rather than the Files specified in the debug command line or the latest Debug n (name) command.
For information about the file used for the l command, click Debug n (name) in the "related topics" list ).
For information about the files written for debugging to the disk, click Debug w (write) in the "related topics" list ).
Note:
Use the l command without Parameters
When the l command without parameters is used, the files specified on the debug command line will be loaded into the memory, starting from the address CS: 100. Debug sets the BX and CX registers as the number of loaded bytes at the same time. If you do not specify a file in the debug command line, the mounted file will be the file that is frequently specified by the recent n command.
Use the 1 command with the address Parameter
If you use the l command with the address parameter, Debug will load the file or the content of the specified sector from the memory location address.
Use the l command with all parameters
If you use the l command with all parameters, Debug loads the content of the specified disk sector instead of the file.
Load content of a specific slice
Each sector within the specified range is read from drive. Debug is loaded from start until all the content in the specified number of slice is loaded.
Load the. exe file
Debug ignores the address parameter of the. exe file. If the. exe file is specified, Debug locates the file again to the load address specified in the title of the. exe file. Before the. exe file is loaded to the memory, the title itself is detached from the. exe file. Therefore, the size of the. exe file on the disk is different from that in the memory. If you want to check the entire. exe file, use different extensions to rename the file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.