Debug of DOS Debug tool

Source: Internet
Author: User
Tags printable characters


Debug is a DOS utility, a program debugging tool for programmers to use to check bytes anywhere in memory and to modify bytes anywhere. It can be used to execute a program on a per-instruction basis to verify that the program is running correctly, to track execution, to compare values before and after an instruction executes, to compare and to move the range of data in memory, to read and write files and disk sectors. Debug handles all the data as a byte sequence. So it can read any type of file. Debug recognizes two types of data: hexadecimal data and Ascⅱ code characters. Its display format is the hexadecimal value of each byte and the corresponding Ascⅱ code character for the byte between 32 and 126.
There are two ways to enter data in debug: The prompt method and the non-prompt method. When prompted, the user can enter a command to enter data, followed by the address to be entered by the data. The user can then see what is already in the site and a colon prompt. At this point the user can enter a new value at the prompt or press ENTER or CTRL + C to return to the short horizontal (-) prompt. When using a non-prompt method, the user can enter the memory address to enter data and the bytes to be entered. However, unlike using a word processor or body editing program, when using debug, the user cannot move the cursor directly to an entry point to enter or modify data, but to enter one or several bytes at a time.
When using debug, you can only refer to the in-memory data, so you usually specify the memory address to be processed, the address input format is: [Segment address]: [displacement]. If no address is entered, debug assumes the current memory segment, starting at the byte at address 100H. The first 100H bytes are reserved for the program segment prefix, and this dedicated zone is used to establish the connection between DOS and the program. Debug always uses a four-digit hexadecimal number to represent the address. The hexadecimal data is represented by a two-digit number.
Here we should have a preliminary understanding of debug, but the light know that this is not enough, then I will talk about the debug command format and command. When the input
DEBUG
When the debug program is called, a short horizontal prompt will appear and the user can enter the command for the debug program after this short cross. Some debug commands display a memory address and produce a colon as a prompt. After these prompts, the user can enter a new value to change the original value of the displayed position. If the user does not enter a new value but presses ENTER or CTRL + C, the original value does not change.
There is no need to separate the address from the command name. For example, using dump command D to see data for address 100th, this command can be entered in any of the following situations:
D100
D 100
D. 100
d,100
If an error occurs in the input command, debug will mark the wrong position on the next line, for example:
-s100 d 12
^error
The commands and functions of Debug are as follows:
* a[Address] Assembly command
Function: Assemble the instruction directly into the machine code input into memory.
Description: For the assembly of small program and modify the target program, all the input numbers are 16-based, the user loaded into the memory of the assembly statement is continuous storage, if no address is specified, and the assembly command is not used, the change statement is compiled into the cs:0100 area.

* c[Source address range [Destination address] Comparison command
Function: Compare the contents of the two memory areas, and display their addresses and contents if they are different.

* d[Address] or d[start address [destination address] dump command
Function: Displays the information in memory in memory image mode.
Description: The dump uses the left and right parts to display the memory image content, the left side is 16 binary, and the ASCII character is displayed on the side, all non-printable characters with a period (. Said Each row shows 16 bytes of content, and there is a hyphen between the eighth and Nineth bytes-This command implies that the segment address is the value of DS. If no start address is specified, the D command is displayed starting from the next cell in the last cell that is displayed, and if it was not previously used for the D command, the contents of the initial segment register, plus the address offset of 0100H, are displayed.

* e[address] [byte string] Modify memory command
Function: Modifies the memory value starting at the specified address.
Note: If only the offset is entered in the Address section, the E command considers the segment to be included in the DS register. There are two kinds of command formats: one is to replace the contents of multiple bytes from the specified address with the byte string contained in the command, and the other is to allow sequential display and modification of bytes, and then to display the next byte content by pressing the space bar, and enter the corresponding value directly if you want to modify it.

* f[address Range] [byte or byte string] fill command
Function: Fills the byte or byte string to fill in the memory specified by the address range.

* g[= start Address] [[breakpoint] ...] execute command
Function: Executes the program being debugged, stops execution when a breakpoint is reached, and displays the register flag and the next command to execute.
Note: If the start address is not specified, the current instruction address is determined by the contents of the CS,IP register, if the user specifies the starting address from the specified start address. If a breakpoint is specified, stop execution when the instruction arrives at the instruction address and display the contents of each register flag bit and the next command to execute, allowing the user to set a maximum of 10 breakpoints.

* h[values [numeric] hex arithmetic Operations Command
Function: Displays the sum of two hexadecimal numbers plus the difference of the first number minus the second number, respectively.
Description: Perform a simple hexadecimal number operation for the user.

* i[Port Address]
Function: Enter and display (in hexadecimal) one byte from the specified port.

* l[Address [disk number:] [logical Sector Code] [number of sectors]
Function: The absolute sector of a file or disk is loaded into the memory.
Note: The maximum number of sectors a single L command can mount is 80H, where the disk number 0,1,2,3 ... Represent A,b,c, respectively, ... A read wreathes its appears, displaying an error message.

* m[address range [start address] data transfer command
Function: Move the contents of the memory cell within the address range to the address specified in the Start address
Note: The source and target areas can be partially overlapped during transmission, and the source area data remains intact after delivery.

* n[:] [path] [file name] [extension]
Function: Defines the action file name.
Description: Can define two operation files at the same time, and will form the file control block corresponding set in memory cs:5c and CS:6C, for later L and W command operation.

* o[port address [data] output command
Function: Sends bytes to the specified output port.

* p[= address] [data] process command
Function: A subroutine call instruction, loop instruction, interrupt instruction or a repeating string instruction, stop the next instruction.
Note: When executing a strip program call instruction, loop instruction, interrupt instruction, or a repeating string instruction, issue the P command to execute the instruction and return to the next instruction to be executed. The P command has the same syntax as the T command.

* Q Exit command.

* r[Register] Register command
Functions: One, displays the contents of a single register, and provides modification functions. Two, display all register contents, plus the letter flag status and the next instruction to be executed. Three, display 8 flag bit status, and provide modification function.

* s[address Range] [string]
Function: Finds the given string within the specified address range.
Description: Used to specify the address range to find a string, if found to display its address, or directly display the debug prompt. The implied address is the DS segment value.

* t[= Address [number of instructions] tracking command
Function: Each tracking program executes, each instruction will display the contents of each register.
Note: Usually follow a command, but the user can also set the number of instructions to track multiple instructions, after each execution of an instruction, display the contents and flag status of all registers.

* u[start Address] or [address range]
Function: Converts the contents of memory into assembly statements.
Description: The number of disassembled bytes depends on the user's system display, as well as the options that are used in the U command.

* w[address] [disk symbol:] [start sector] [sector number] Write command
Function: Writes the modified data to disk.
Description:  can write data at the beginning of the specified memory address on disk, and can write the debug file on disk without specifying a parameter,  or specifying an address parameter.

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.