Starting debug in the command window, the startup command is typically: Debug [file name] [parameter table]. Where: filename Specifies the file to be debugged, including the name and suffix, and the parameter table is the parameter that is required when the debug file is run. The files being debugged can be any file in the system, but they are usually suffixed with. EXE or. COM. When debug starts successfully, the connector "-" is displayed, and various debug commands can be entered. All commands in debug and their meanings are shown in the description table of the Debug commands function. A few notes on the use of the command: Under the prompt "-" to enter the command, after pressing the "enter" key, the command will begin to execute the command is a single letter, the case of commands and parameters can be mixed input F1, F2, F3, Ins, Del, left Shift key, Edit the line with the right SHIFT key. When a syntax error occurs on a command, "^ error" is displayed in the error location with CTRL + C or ctrl+break to terminate the execution of the current command, and Ctrl+s or ctrl+num lock can be used to pause the screen display ( When the information is displayed continuously)
The following 19 examples are implemented to familiarize themselves with the debug command set and the basic assembly instructions.
Use of the R command
R command function: Watch and modify the value of the register.
Under the prompt "-", enter the following command: R. Debug will show the status of all current registers and flag bits.
Then enter the command RCX. Enter 100 after the prompt ":". The purpose of this command is to set the value of the Register CX to 100 (note: Debug uses hexadecimal, where 100 is equivalent to 256 in decimal.) )
Finally, execute the r command and watch the modified register value.
Use of the H command
H Command function: Calculates the and and the difference of two hexadecimal numbers.
Enter the following command under the Prompt "–": H 10 1. Watch the command execution results.
The previous number of running results is calculated and the latter number is calculated as the difference. The calculated results are expressed in 16 binary form.
Use of the D command
d Command function: Displays the contents of the memory area.
Execute commands R, D, D continuously under the prompt "–". Watch the command execution results.
As explained earlier, the function of command R is to display the value of the current register. The function of command D is to display the contents of the memory area, the leftmost is the starting address of the memory, the memory value is displayed in the middle of 16, the right side is the ASCII code to display the memory value. A maximum of 16 bytes of content is displayed per line.
Command d can take parameters or omit parameters. Set the value of the DS at debug startup to X, and when omitted, the command D displays the content with x:100 as the starting point, displaying 128 bytes of content at a time. When you execute command D with no arguments at a later time, the debug will continue to appear at the last location.
Debug is able to display the contents of the specified address range with parameters. There are three ways to take parameters:
Mode one: D [start position]. Debug displays 128 bytes of content starting from the starting position. Execute Command D 1af5:100 under the prompt "-". Watch the command execution results.
Mode two: D [start position] [end position]. Debug starts from the start position until the end position is displayed. Execute the command under the prompt "-" D ds:100 1FF. Watch the command execution results.
Method Three: D [Start position] [l length], length is identified by L parameter. Debug displays the contents of the specified length starting from the starting position. Execute command D ds:100 L10 under the prompt "-". Watch the command execution results.
Use of the e command
e command function: Changes the contents of the memory unit.
The e command is used in the following way: E [start position].
Under the prompt "-", enter the following command: E 1af5:100.
Debug first displays the contents of [1af5:0000] 00., you can modify the value of this byte. If you also want to modify the subsequent content, you can press the SPACEBAR to continue. When you want to skip a byte, you can jump to the next byte by two consecutive spaces.
Use of the F command
F command: Fills the address in the specified memory area with the specified value.
The f command is used in the following way: F [Range] [fill list].
Under the prompt "-", enter the following command: F 1af5:100 L20 1 2 3 4 5. Execute command D 1af5:100 watch the command execution results.
Note: This command is filled with byte sequences 01, 02, 03, 04, 05 to fill the memory area starting at 20H in length from 1af5:100.
Under the prompt "-", enter the following command: F 1af5:100 13F 41 42 43 44.
Note: This command is filled with byte sequences 41, 42, 43, 44 to fill the memory area starting from 1af5:100 to 1af5:13f.
Use of the M command
M command: Copies the data of the specified memory area to the specified address.
The M command is used in the following way: M [Range] [specify address].
Under Prompt "-" Enter the following command: M 1af5:100 13F 1af5:140. Execute command D 1af5:100 watch the command execution results.
Use of the C command
C command: Compares the contents of two blocks of memory.
The C command is used in the following way: c [Range] [specify address], which means to compare the memory area of the specified range with the byte-by-bit memory area of the same length starting at the specified address, listing the different contents.
Under the prompt "-", enter the following command: C 1af5:100 13F 1af5:140. Because the two pieces of content are identical, the command executes without any display.
Under the prompt "-", enter the following command: C 1af5:100 107 1af5:180, the area length of the comparison is 8 bytes. Lists the different bytes of the comparison results after the command executes.
Use of the S command
s command: Searches for the specified string in the specified memory area.
The s command is used in the following way: s [Range] [specify string].
Under the prompt "-", enter the following command: D 1af5:100 11F. Displays the memory value for this zone.
Under Prompt "-" Enter the following command: S 1af5:100 11F 41 42 43 44. Search for the region for the presence of byte strings 41 42 43 44 and list the search results.
As can be seen from the implementation results, a total of eight search.
Use of a command
A command function: Enter assembly instructions.
The following program displays the "ABCD" four characters on the screen.
First, the "abcd$" four characters are pre-placed in the memory cs:200 with the e command, and then the A100 command is executed to enter the assembler code:
MOV Ax,cs
MOV Ds,ax
MOV dx,200
MOV ah,9
INT 21
INT 20
(Note: The first two lines of assembly instructions are used to assign the value of the segment register CS to the Segment Register DS.) The third to fifth line of assembly code is to display a string that ends with "$". The last line is used to end the program.
Use of the G command
G Command function: Execute assembly instruction.
The use of the G command is: g[= start address] [breakpoint address], which means execution from the start address to the breakpoint address. If you do not set a breakpoint, the program runs until the abort instruction stops.
Run these assembly codes after you have set up the memory data for example nine and have entered the program for example nine. Execute the command g=100 in debug and watch the results of the operation.
After the assembler runs, the "ABCD" four characters are displayed on the screen.
Next, execute g=100 10B in debug, which means starting from address cs:100 and running until cs:10b stops. Watch the running results.
After the command executes, it displays not only the string "ABCD", but also the value of the current register and the flag bit.
Use of the U command
u command function: Disassemble the machine code display.
The use of the U command is: u[Range]. If the range parameter only enters the start address, only the 20H bytes of machine code are disassembled. Execute the command U100 and watch the disassembly results.
Execute the command U100 10B and watch the disassembly results. The purpose of this command is to disassemble the machine code from 100 to 10B.
Use of the n command
n command: Set the file name to prepare the assembler that you just wrote.
The following debug command sequence acts as a COM executable that saves just the assembler program as a disk.
D200 20F
U100 10C
N E:\FIRST.COM
RCX
: 110
W
The role of the first and second commands is to examine the assembly instructions just written. The function of the third command is to set the disk file name to E:\FIRST.COM, and the fourth command is to set the disk file size to 110H bytes. The last command is to save the file.
After the file is saved, execute the E:\FIRST.COM, and watch the executable file run effect.
Use of the W command
W Command: Writes a file or a specific sector to disk.
You have experimented with using the W command to save a file in the use of the example "N command".
In the absence of a good grasp of assembly language and disk file system, do not use the W command to write disk sectors, it is easy to damage the disk files, or even destroy the entire disk file system.
L Use of commands
L Command: Reads the file or sector contents from disk into memory.
You must first set the file name with the Debug n command in order to transfer the files into memory. The following example is the E:\FIRST. COM read-in content.
N first.com
L
Watch the assembly code of the incoming program can use the Debug u command, with U100 to watch the incoming COM file.
The disk sector is read by: L [memory address] [disk drive letter] [start sector] [number of sectors]. Memory address Specifies the memory location in which to load the file or sector content, and if you do not specify a memory address, Debug uses the current address in the CS register. Disk drive letter Specifies the drive that contains the disk that reads the specified sector, which is numeric: 0=a,1=b,2=c, and so on. Start sector specifies the hexadecimal number of the first sector whose content is to be loaded. Number of sectors specifies the hexadecimal number of contiguous sectors whose contents are to be loaded.
You can use the disk drive letter [start sector] [sector number] parameter only if you want to load the contents of a specific sector instead of loading the file.
For example, to read the first sector of the C drive to the memory ds:300 location, the corresponding debug command is L ds:300 2 1 1. However, due to the Windows operating system's protection of the file system, this command may be disabled by the operating system.
Use of the T command
T command function: Execute assembler, single-step tracking.
The T command is used in t [= address] [instruction number]. If "Address" is omitted, the T command starts at CS:IP. "Instruction Count" is the number of instructions to step into.
The following example is for E:\FIRST. COM for single-step tracking.
N E:\FIRST.COM
L
U100 10B
R
t=100
T
The first to second command is to load the file, the third command is to list the program disassembly code, the fourth command is to display the current register value, the fifth command is to start a single step tracking from Cs:100, the sixth command is to continue to track subsequent instructions.
Use of the P command
P Command function: Execute assembler, single-step tracking. Unlike the T command, the p command does not track incoming subroutines or soft interrupts.
The P command is used exactly the same way as the T command.
Use of the I command
I command: Reads and displays data from the computer input port.
The usage of the i command is I [Port address]. For example, reading data from Port 3F8 and displaying the command is: I 3F8. The command is not explained here.
o Use of commands
o Command: Send data to the computer output port.
o The use of the command is O [port address] [byte value]. For example, the command to issue data 20H to Port No. 278 is: I 278 20. The command is not explained here.
Use of the Q command
The function of the Q command is to exit Debug and return to the DOS state.
Debug commands Detailed description