Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”
This article also participated in the “Digitalstar Project” to win a creative gift package and creative incentive money
After setting up the development environment for 8086 assembly, the debug mode of 8086 is introduced. Run debug.exe to enter the debug mode and interact with each other by entering commands in DOS
# # -r command
The R command is used to view and modify the register value of the CPU in debug mode
# # – D command
The D command is used to view the contents of the memory
** (Segment address: offset address) is displayed above. By default, the D command displays the contents of the last 128 memory cells from the address in hexadecimal format (8 bits per cell, up to 16 memory cells in a row), while the binary data in the memory cells in asCLL code ** is translated to the far right
Sometimes, however, we just want to focus on the contents of a particular memory address, and the default memory view is not very convenient.
The D command provides another way to access memory (segment address: offset start address offset end address), which displays memory information from segment address: offset start address to segment address: offset end address. Both ends of the range are closed ranges
The -e command
The E command changes the contents of memory.
Different from checking and modifying CPU registers, checking and modifying memory is complicated. For this purpose, the DEBUG designs two different commands, E command to modify memory and D command to check memory respectively.
Pass (E start address data 1 data 2 data 3…) Command to modify the values of N memory cells, starting with the starting address (N is the actual number of arguments passed)
You can also use prompts to change the value of a specific memory location, similar to the R command to change the value of a register in the CPU. 00.1200 represents the value of the memory unit before modification, and 12 is the new value we entered manually that needs to be modified
-u command
The U command is used to convert binary data in memory into assembly instruction presentation (disassembly)
The D command can display the data in memory in the form of hexadecimal or ASCLL code, but sometimes when we need to observe the machine instructions in memory, the VIEW of the D command is too abstract to understand. Debug provides the U command to solve this problem.
For the machine instructions we entered at 1000:0, the U 1000:0 command (U memory address) can be used to display the data in memory as assembly language instructions
-a command
The A command can write to memory in the form of assembly instructions
For memory operations, the D command can view the contents of memory, but if you want to view program instructions, obviously the U command is more convenient. The E command can write data to memory, but for writing program instructions, direct manipulation of binary machine code is too hardcore. To do this, debug provides the A command, through which we can write to memory in the form of assembly instructions.
Mov AX,0001, mov bx,0002, add AX,bx
Writing instructions through command A achieves the same effect as command E, but it is more convenient to use. A command can automatically identify the length of the input assembly instruction, correctly write program instruction in memory.
The DEBUG provides D and E commands to perform common operations on the memory, such as reading and writing binary and hexadecimal data.
For program commands, debug provides U and A commands to read and write instructions in the memory in A more user-friendly way
-t command
The function of the T command is to debug single step machine instructions
The -g command
The G command is used to Debug program breakpoints
-g Code address (CS + IP) addressCopy the code
-p command
The p command is used to skip execution of breakpoints and can be used for loop debugging