Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the DEBUG command

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to use the DEBUG command, the article is very detailed, has a certain reference value, interested friends must read it!

DEBUG is an external command in DOS and has been with it since DOS 1.0, so you can see the importance of this command. Although this command is very powerful and can solve many problems, it is very difficult for many people, especially for beginners.

Debug:A (compilation)

Merge the 8086Compact 8087Comp8088 memory code directly into memory.

This command creates executable machine code from assembly language statements. All numeric values are in hexadecimal format and must be entered in one to four characters. Specify a prefix memory code before the referenced operation code (opcode).

A [address]

Parameters.

Address

Specifies where to type assembly language instructions. Use hexadecimal values for address and type each value that does not end with the "h" character. If you do not specify an address, a will start assembly where it last stopped.

For information about entering data into the 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

Use memory code

The alternative memory codes for segments are 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, you can move 16-bit strings with movsw and 8-bit byte strings with movsb.

Assembler jump and call

The assembler automatically assembles short, near, and far jumps and calls to the target address based on byte substitution. Such a jump or call can be replaced by using the near or far prefix, as shown in the following example:

-a0100PUR 0500

0100Rom 0500 jmp 502; a 2-byte short jump

0100 0502 jmp near 505; a 3-byte near jump

0100Rom 0505 jmp far 50a; a 5-byte far jump

You can abbreviate the near prefix to ne.

Distinguish between word and byte memory locations

When an Operand can reference a word memory location or a byte memory location, the data type must be specified with the prefix word ptr or the prefix byte ptr. The acceptable abbreviations are wo and by, respectively. The following example shows two formats:

Dec wo [si]

Neg byte ptr [128]

Specify Operand

Debug refers to the idiom of the memory address using operands enclosed in parentheses ([]). This is because, on the other hand, Debug cannot distinguish between immediate operands and operands of memory addresses. 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

Use pseudo instruction

Use the a command to provide two commonly used pseudo-instructions: db opcodes, which assemble byte values directly into memory, and dw opcodes, which assemble word values directly into memory. Here are two examples of 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"

Example

The 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 8087 opcodes, 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 (compare)

Compare the two parts of memory.

C range address

Parameters.

Range

Specify the start and end addresses of the first area of memory to compare, or the start address and length. For information about valid range values, click Debug description in the related topics list.

Address

Specifies the starting address of the second area of memory 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 anything. If there is a difference, the Debug will be displayed in the following format:

Address1 byte1 byte2 addess2

Example

The following commands have the same effect:

C100,10f 300

C100l10 300

Each command compares 100h to 10Fh memory blocks with 300h to 30Fh memory blocks.

Debug responds to the previous 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

Notice that the addresses 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 range of memory addresses.

D [range]

Parameters.

Range

Specify the start and end address, or start 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 the range,Debug program, it will display 128 bytes starting at the end of the address range specified in the previous d command.

For information about displaying the contents of the register, click Debug R (register) in the related topics list.

Description

When using the d command, Debug displays the contents of memory in two parts: the hexadecimal part (the value of each byte is represented in hexadecimal format) and the ASCII code part (the value of each byte is represented by the ASCII character). Each non-print character is represented by a period (.) in the ASCII part of the display. It means. Each display line displays 16 bytes of content, with a hyphen between the 8th and 9th bytes. Each display line 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 54 4F 4D 00 53 41 57 59-45 52 00 00 00 TOM.SAWYER.

If you type the d command without arguments, Debug formats the display as described in the previous example. Each line displayed begins with an address 16 bytes larger than the address on the previous line (or 8 bytes in the case of a screen that displays 40 columns).

For each subsequent d command with no arguments, Debug displays the byte contents immediately after the last displayed command.

"if you type the following command, Debug displays 20h bytes starting with 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 of the CS segment:

Dcs:100 115

Debug:E (type)

Enter data to the specified address in memory.

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

E address [list]

Parameters.

Address

Specifies the first memory location of the input data.

List

Specifies the data in consecutive bytes to enter into memory.

For information about integrating memory codes, click Debug A (Assembly) in the related topics list.

For information about displaying the memory portion, click Debug D (dump) in the related topics list.

Description

Use the address parameter

If you specify the value of address without specifying the value of 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 a 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 numbers, Debug does not echo invalid or extra characters.

Proceed to the next byte. To do this, press SPACEBAR (spacebar). To change the value in this byte, type a new value after the current value. If you press SPACEBAR (spacebar) and move beyond the 8-digit limit, the Debug program will display a new line and a new address at the beginning of the line.

Return to the previous byte. To do this, press HYPHEN (-). You can repeatedly press the HYPHEN key (-) to move backwards more than multiple bytes. When you press HYPHEN, Debug starts a new line and displays the current address and byte values.

Stop executing the e command. To do this, press ENTER. You can press ENTER at any byte position.

Use the list parameter

If you specify a value for the list parameter, 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. The string must be enclosed in single or double quotation marks.

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 consecutive byte values with an e command. Press SPACEBAR (Spacebar) instead of ENTER after typing the new value. Debug displays the next value. In this example, if you press SPACEBAR (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 the decision value of 10 should be 6F. To correct this value, press HYPHEN 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 to change the value at the insertion point, as follows:

04BA:0101 10.6f_

Press ENTER to stop the e command and return to the Debug prompt.

Here is an example of a string entry:

Eds:100 "This is the text example"

The string will be filled with 24 bytes starting with DS:100

Debug:F (fill)

Populates the address in the specified memory area with the specified value.

You can specify data in hexadecimal or ASCII format. 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 populated. For information about valid range values, click Debug description in the related topics list.

List

Specify the data to import. List can consist of hexadecimal numbers or strings enclosed in quotation marks.

Description

Use the range parameter

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

If any memory in range is corrupted or does not exist, Debug displays an error message and stops the f command.

Use 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 populates the memory location from 04BA:100 to 04BA:1FF with the specified value. Debug repeats these five values until all 100h bytes are filled.

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 start execution. If you do not specify address,Windows 2000, the program starts at the current address in the CS:IP register.

Breakpoints

Specify 1 to 10 temporary breakpoints that can be set to the part of the g command.

For information about executing loops, repeated string instructions, software interrupts, or subroutines, click Debug P (execute) in the related topics list.

For information about executing instructions, click Debug T (tracking) in the related topics list.

Debug:H (hexadecimal)

Performs a hexadecimal operation on the two specified parameters.

H value1 value2

Parameters.

Value1

Represents any hexadecimal number in the range from 0 to FFFFh.

Value2

Represents the second hexadecimal number from 0 to FFFFh.

Description

Debug first adds the two specified parameters and then subtracts the second parameter from the first parameter. The results of these calculations are shown on one line: sum is calculated first, and then the difference is calculated.

Example

Suppose you type the following command:

H29f 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

Specify 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

It is also assumed that the byte value of the port is 42 hours. Debug reads the byte and displays its value as follows:

forty-two

Debug:L (load)

Loads the contents of a file or a specific disk sector into memory.

To load the number of 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 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 you do not specify address,Debug, 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 numerical: 0 = A, 1 = B, 2 = C, etc.

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. The drive, start, and number parameters can be used only if you want to load the contents of a specific sector instead of the file specified in the debug command line or the most recent Debug n (name) command.

For information about specifying the file to use for the l command, click Debug n (name) in the related topics list.

For information about writing files that are debugged to disk, click Debug w (write) in the related topics list.

Be careful

Use the l command with no arguments

When you use the l command with no arguments, the file specified on the debug command line is loaded into memory, starting with the address CS:100. Debug sets both the BX and CX registers to the number of bytes loaded. If you do not specify a file on the debug command line, the loaded file will be the one you have recently specified frequently with the 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 specify the contents of the 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 contents of the specified disk sector instead of the file.

Load the contents of a specific sector

Each sector in the specified range is read from drive. Debug loads from start until all of the contents of the number of sectors specified in number are loaded.

Load .exe file

Debug ignores the address address parameter of the .exe file. If you specify an .exe file, Debug relocates the file to the load address specified in the title of the .exe file. Before the .exe file is loaded into memory, the title itself is detached from the .exe file, so the size of the .exe file on disk is different from that in memory. If you want to check the entire .exe file, rename the file with a different extension.

The above is all the contents of this article "how to use DEBUG commands". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report