China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 17:30
中国DOS联盟论坛 » DOS讨论区 » DOS学习入门 & 精彩文章 (教学室)
DOS学习入门 & 精彩文章 (教学室)Moderators: ko20010214zzz19760225
大家可以在这儿学习、交流和分享关于DOS的入门和安装等方面的基础知识和经验,将新手培养成各类DOS高手,以实现共同推广和发展DOS。
View digest Search this forum 4,336 threads / 174 pages
Subject
Author
Replies
Views
Last post
热门 / New replies
10
2,878
2009-03-12 23:58
by wama
New replies
0
933
2009-03-08 16:06
by bbgeek
New replies
7
14,082
2009-03-08 07:44
by tongtong2009
New replies
4
1,341
2009-03-08 07:09
by fujianabc
New replies
5
2,037
2009-03-08 01:33
by 5566ljlj
New replies
5
1,288
2009-03-07 11:30
by djp2001
New replies
3
1,331
2009-03-04 11:55
by crazii
热门 / New replies
12
1,563
2009-02-26 06:42
by tianxingren
Closed thread
11
2,219
2009-02-21 22:56
by huwentao000
New replies
3
967
2009-02-18 23:03
by machill
New replies
7
1,445
2009-02-14 06:22
by VAF
New replies
### 一、Debug简介 Debug是DOS系统下的一个强大的调试工具,它可以用来调试程序、查看内存、跟踪程序执行等。 ### 1. Debug的启动 在DOS提示符下输入`debug`命令即可启动Debug。例如: ``` C:\>debug ``` 启动后会进入Debug的命令行界面,显示`-`提示符。 ### 二、常用Debug命令 #### 1. R命令 - 查看和修改寄存器内容 - **查看寄存器内容**:输入`r`命令,会列出所有寄存器的当前值。例如: ``` -a MOV AX,1234 MOV BX,5678 INT 20H -r AX=0000 BX=0000 CX=0000 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000 CS=075C DS=075C ES=075C SS=075C IP=0000 NV UP EI PL NZ NA PO NC 075C:0000 B83412 MOV AX,1234 ``` - **修改寄存器内容**:例如要修改AX寄存器的值为`5555`,可以输入`r ax`,然后输入`5555`,回车后AX寄存器的值就被修改为`5555`。 #### 2. D命令 - 查看内存内容 - **格式**:`d [地址范围]` - **示例**:查看内存地址从`0B800:0000`开始的16个字节的内容,输入`d 0b80:0000` ``` -d 0b80:0000 0B80:0000 F04F 0700 F04F 0700-F04F 0700 F04F 0700 O.......O.......O.... 0B80:0010 0000 0000 0000 0000-0000 0000 0000 0000 ................ ``` #### 3. E命令 - 编辑内存内容 - **格式**:`e [地址] [字节1] [字节2]...` - **示例**:将内存地址`0000:0100`处的字节修改为`12`和`34`,输入`e 0:100 12 34` #### 4. U命令 - 反汇编 - **格式**:`u [地址范围]` - **示例**:反汇编从地址`075C:0000`开始的内容,输入`u 075c:0000` ``` -u 075c:0000 075C:0000 B83412 MOV AX,1234 075C:0003 CD20 INT 20H ``` #### 5. T命令 - 单步执行 - **格式**:`t [步数]`,如果不指定步数,默认执行1条指令 - **示例**:从当前指令开始单步执行1条指令,输入`t` ``` -t AX=1234 BX=0000 CX=0000 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000 CS=075C DS=075C ES=075C SS=075C IP=0003 NV UP EI PL NZ NA PO NC 075C:0003 CD20 INT 20H ``` #### 6. A命令 - 汇编 - **格式**:`a [地址]`,如果不指定地址,从当前IP指向的地址开始汇编 - **示例**:输入`a`后,会进入汇编状态,逐行输入汇编指令,输入完后按Ctrl + C结束 ``` -a 075C:0000 MOV AX,1234 075C:0003 INT 20H ^C ``` ### 三、Debug调试程序示例 以一个简单的汇编程序为例,编写一个将`AX`寄存器的值设置为`1234`并终止程序的程序。 1. 用文本编辑器编写汇编代码,保存为`test.asm`,代码如下: ```asm MOV AX,1234 INT 20H ``` 2. 用MASM汇编该文件得到`test.obj`,再用LINK链接得到`test.exe`。 3. 在DOS下用Debug调试`test.exe`,输入`debug test.exe` 4. 用`u`命令反汇编查看程序: ``` -u 075C:0000 B83412 MOV AX,1234 075C:0003 CD20 INT 20H ``` 5. 用`t`命令单步执行,观察寄存器变化等情况。 以上就是Debug的基本教程,通过这些命令可以对程序进行调试和分析。The complete tutorial of Debug ### 1. Introduction to Debug Debug is a powerful debugging tool under the DOS system. It can be used to debug programs, view memory, track program execution, etc. ### 1. Startup of Debug Enter the `debug` command at the DOS prompt to start Debug. For example: ``` C:\>debug ``` After startup, it will enter the command line interface of Debug, displaying the `-` prompt. ### 2. Commonly used Debug commands #### 1. R command - View and modify register contents - **View register contents**: Enter the `r` command, and all register values will be listed. For example: ``` -a MOV AX,1234 MOV BX,5678 INT 20H -r AX=0000 BX=0000 CX=0000 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000 CS=075C DS=075C ES=075C SS=075C IP=0000 NV UP EI PL NZ NA PO NC 075C:0000 B83412 MOV AX,1234 ``` - **Modify register contents**: For example, to modify the value of the AX register to `5555`, you can enter `r ax`, then enter `5555`, and press Enter to modify the value of the AX register to `5555`. #### 2. D command - View memory contents - **Format**: `d [address range]` - **Example**: To view the contents of 16 bytes starting from the memory address `0B800:0000`, enter `d 0b80:0000` ``` -d 0b80:0000 0B80:0000 F04F 0700 F04F 0700-F04F 0700 F04F 0700 O.......O.......O.... 0B80:0010 0000 0000 0000 0000-0000 0000 0000 0000 ................ ``` #### 3. E command - Edit memory contents - **Format**: `e [address] [byte 1] [byte 2]...` - **Example**: Modify the bytes at the memory address `0000:0100` to `12` and `34`, enter `e 0:100 12 34` #### 4. U command - Disassemble - **Format**: `u [address range]` - **Example**: Disassemble the contents starting from the address `075C:0000`, enter `u 075c:0000` ``` -u 075c:0000 075C:0000 B83412 MOV AX,1234 075C:0003 CD20 INT 20H ``` #### 5. T command - Single - step execution - **Format**: `t [number of steps]`. If the number of steps is not specified, 1 instruction is executed by default - **Example**: Single - step execute 1 instruction starting from the current instruction, enter `t` ``` -t AX=1234 BX=0000 CX=0000 DX=0000 SP=FFFE BP=0000 SI=0000 DI=0000 CS=075C DS=075C ES=075C SS=075C IP=0003 NV UP EI PL NZ NA PO NC 075C:0003 CD20 INT 20H ``` #### 6. A command - Assemble - **Format**: `a [address]`. If the address is not specified, assembly starts from the address pointed to by the current IP - **Example**: Enter `a`, and it will enter the assembly state. Input assembly instructions line by line. After inputting, press Ctrl + C to end ``` -a 075C:0000 MOV AX,1234 075C:0003 INT 20H ^C ``` ### 3. Example of Debug debugging program Take a simple assembly program as an example. Write an assembly program that sets the value of the `AX` register to `1234` and terminates the program. 1. Write assembly code with a text editor, save it as `test.asm`, and the code is as follows: ```asm MOV AX,1234 INT 20H ``` 2. Assemble this file with MASM to get `test.obj`, and then link it with LINK to get `test.exe`. 3. Debug `test.exe` under DOS, enter `debug test.exe` 4. Use the `u` command to disassemble and view the program: ``` -u 075C:0000 B83412 MOV AX,1234 075C:0003 CD20 INT 20H ``` 5. Use the `t` command to single - step execute and observe the register changes and other situations. The above is the basic tutorial of Debug. Through these commands, programs can be debugged and analyzed.
7
1,685
2009-02-14 01:36
by upcjinjin
Prev 1 1617181920 174 Next