1. Introduction

The Debug program is a debugging tool for real mode (8086 mode) programs provided by DOS and Windows. You can use the debugging tool to:

  • View the contents of the CPU register;
  • View memory status;
  • Track program execution at machine code level;

Note: The 64-bit operating system (Windows 7 and 10) does not carry the Debug program. Please install the DOS system on a VIRTUAL machine (see: [Install MS-DOS 7.10 in VMware12]).

2. Go to the Debug program

Input directly in the DOS systemdebugTo enter:

Use 3.

There are more than 20 Debug commands, of which seven are commonly used. The following commands are introduced and explained respectively.

3.1. Summary of common commands

Commands (case insensitive) function
R View and change the contents of CPU registers
D View the contents of memory
E Overwrite the contents of memory
U Translate machine instructions in memory into assembly instructions
T Execute a machine instruction
A To write a machine instruction to memory in the format of an assembly instruction

3.2. Run the R command to view the contents of the CPU register



3.3. Use the R command to change the contents of the CPU register

useR < register name >To modify the contents of the register:Enter the data to be modified,enterThe modification is complete.

3.4. Run the D command to view the contents of the memory

In the D command, you can view the memory contents directly using the address or segment register.

  • View data at the specified address (128 memory cells by default) :D < segment address >:< offset address >

  • Query the data in the specified range:D < segment address >:< start offset address > < end offset address >

  • After viewing the content of the specified address, you can use itdThen look at

  • View the contents of the DS segment register indication:

  • View the instructions indicated by the current code snippet according to CS:

  • View current stack contents according to SS:

3.5. Run the E command to rewrite the memory

  • The overall change

  • A single change

  • One by one to modify

  • String modification

  • Write machine code

mov ax,0001 ; b80100 mov cx,0002 ; b90200 add ax,cx ; 01c8Copy the code

3.6. Translate machine code into assembly instruction with U command

3.7. Execute the command using the T command



Write assembly instruction with A command



See what disassembly looks like:



Finally, execute the following to see the effect: