“This is the 14th day of my participation in the August More Text Challenge. For details, see: August More Text Challenge.”

After building the development environment of 8086 assembly, the debug mode of 8086 is introduced. Run debug.exe to enter the debug mode and enter commands in DOS to interact with each other

The -r command

The R command is used to view and modify the values of registers in the CPU in debug mode

-d command

The D command is used to view the contents of the memory

The above is the view mode of (segment address: offset address). By default, the D command displays the contents of 128 memory cells from the beginning of the addressing address in hexadecimal format (8 bits per memory cell, up to 16 memory cells per line), while the rightmost part will translate the binary data in memory cells into ASCLL code

Sometimes, however, we just want to focus on the contents of a particular memory address, and the memory view shown by default is not very convenient.

The D command provides another memory access mode (segment address: offset start address, offset end address), and displays the memory information (segment address: offset start address to segment address: offset end address). Both ends of the range are closed

The -e command

The E command changes the contents of memory.

Different from the view and modification of registers in the CPU, the view and modification of memory are more complex. For this purpose, two different commands are designed to control the debug (E command to modify memory, D command to view memory).

Through (E start address data 1 Data 2 Data 3…) Command to change the value of N memory units starting with the starting address (N is the number of actual parameters passed).

You can also change the value of a specific memory unit by prompting it, similar to the way the R command changes a register value in the CPU. 00.12 00 represents the value of the memory unit before modification, and 12 is the new value that we manually enter and need to modify

-u command

The U command is used to convert binary data in memory into assembly instruction display (disassembly).

The D command can display data in memory in hexadecimal or ASCLL code, but sometimes when we need to look at 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 instruction we entered at 1000:0 earlier, using the U 1000:0 command (U memory address) can present the data in memory as an assembly language instruction

-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 U command is more convenient; The E command can write data into memory, but for writing program instructions, direct manipulation of binary machine code is too hard core. To do this, debug provides A command with which we can write to memory in the form of assembly instructions.

Mov ax,0001, mov bx,0002, add ax,bx

Writing commands through A achieves the same effect as using E, but is more convenient to use. A command can automatically identify the length of the input assembler instructions, correctly write program instructions in memory.

The debug command D and E are used to perform general operations (read and write binary and hexadecimal data) on the memory.

For program instructions, debug provides U and A commands to read and write instructions in memory in A more user-friendly way

-t command

The T command is used to debug single – step machine instructions

The -g command

The G command is used to Debug breakpoints

-g Code address (CS + IP) Indicates the addressCopy the code

-p command

The p command is used to skip execution and can be used for debugging loops