debug使用詳解
首先,向大家推薦使用DR-DOS7所帶的DR-DEBUG,指令支持到Pemtium pro,功能強大,且支持宏。最方便的是可以用回車代替上一條u/d/p/t指令,方便察看和調試。
下面把其幫助翻譯如下:
匯編,把輸入的匯編語言轉成機器碼
A                                 (example: Acs:100)
設置中斷點以調試
B          (example: B100 2 al=80)
比較兩段内存内容
Compare     C range address                       (example: C200 20d 500)
顯示指定内存數據
Dump        D                              (example: Dcs:500 L 10)
編輯内存數據
Enter       E                  (example: Eds:500 "Hello ")
填充内存
Fill        F range data                      (example: F100 13f "Test ")
運行程序從指定點
Go          G                  (example: Gcs:4bb0)
計算
Hex         H                          (example: H10e 01)
從I/O埠輸入
Input       I port                                        (example: I3f2)
載入文件或指定邏輯扇區内容
Load        L       (ex: L0Cff 3 09 10)
移動(複製)内存内容
Move        M range address                 (example: Mcs:200 220 cs:400)
指定操作文件名
Name        N   filename               (example: Ntest.com)
向I/O埠輸出
Output      O port value                               (example: O3ff 10)
單步執行(跳過int/rep/call等)
Proceed     P                      (example: P=ds:3fff)
退出debug
Quit        Q
更改或顯示寄存器
Register    R                          (example: Rax 1000)
搜索數據于指定内存
Search      S range data                        (example: Sds:200 500 32)
單步執行(進入int/rep/call等)
Trace       T                 (example: T=3cff:0100 10)
反匯編指定内存中機器碼
Unassemble  U                            (example: U3cff:0200 400)
顯示屏幕内容(相當於)
Viewswap    V                                           (any key returns)
寫入文件或指定邏輯扇區内容
Write       W     (ex: Wds:200 0 16 0f)
(range 可以是: 開始偏移 結束偏移  或  開始地址 L 長度)
以下是詳細使用説明:
                   --- 術語表 ---
pathname  - 文件名(路徑可選)
testparms - 參數
address   - 内存地址偏移
            如果省略段地址,以CS用作匯編\反匯編;DS用於其他功能
range     - 可以是: 開始偏移 結束偏移  
                    開始地址 L 長度
                    開始地址, +長度
reg       - 寄存器名
list      - 由空格或逗號分開的一些數值(給定類型的)
drive     - 0 = A:, 1 = B:, ...
firstsec  - 邏輯扇區號(以0開始)
                   --- 運算符號 ---
數可以是16進制(默認的), #十進制, \八進制, %二進制, ''字符串''("chars"),
寄存器, , ^堆棧。
可以使用運算符(+ - * /) 及 (括號) 。
例:Rax=(^ + (bl * %1001) + ''a'').
-代表基本debug命令
+代表dr-debug特有命令
x代表只能在dr-debug擴展模式下執行的指令,用/s進入默認模式,用/x進入擴展模式
                   --- Dump commands ---
-D           x 設置/查詢默認顯示長度(按字節)
-DB          x 設置/查詢默認顯示長度,並返回按字節模式
D=     x 設置/查詢 察看開始點(0-f)
D             - 顯示指定内存内容(/S 模式) / 重復上一次D? 命令(/X 模式)
DB            - 顯示指定内存内容(按字節)
DW            x 顯示指定内存内容(按字)
DD            x 顯示指定内存内容(按雙字)
DP            x 顯示指定内存的指針(遠間指針-段:偏移)
DI            x 顯示中斷向量表(range=中斷號)
                   --- Enter commands ---
                       (省略list時,回車後輸入數據,"."退出)
E ]   + 輸入數據
EB]   x 輸入數據(按字節)
EW]   x 輸入數據(按字)
ED]   x 輸入數據(按雙字)
EP]   x 輸入數據(按遠間指針)
EI]   x 輸入中斷向量
                   --- Compare commands ---
C range,address      - 比較兩段内存内容
CBrange,address      x 比較兩段内存内容(按字節)
CWrange,address      x 比較兩段内存内容(按字)
CDrange,address      x 比較兩段内存内容(按雙字)
CPrange,address      x 比較兩段内存内容(按遠間指針)
                   --- Fill commands ---
F range,list         - 填充數據到内存
FBrange,list         x 填充數據到内存(按字節)
FWrange,list         x 填充數據到内存(按字)
FDrange,list         x 填充數據到内存(按雙字)
FPrange,list         x 填充數據到内存(按遠間指針)
                   --- Search commands ---
S address list       - 搜索數據於指定内存
-Saddress list       x 搜索數據於指定内存並保存第(cx+1)個匹配的偏移地址於cx中
SBaddress list    x 搜索數據於指定内存(按字節)(-SB 如前)
SWaddress list    x 搜索數據於指定内存(按字)(-SW 如前)
SDaddress list    x 搜索數據於指定内存(按雙字)(-SD 如前)
SPaddress list    x 搜索數據於指定内存(按遠間指針)(-SP 如前)
                   --- Port I/O commands ---
I  port              - 從I/O埠輸入
IB port              x 從I/O埠輸入(按字節)
IW port              x 從I/O埠輸入(按字)
ID port              x 從I/O埠輸入(按雙字)(386以上支持)
O  port,value        - 向I/O埠輸出
OB port,value        x 向I/O埠輸出(按字節)
OW port,value        x 向I/O埠輸出(按字)
OD port,value        x 向I/O埠輸出(按雙字)(386以上支持)
                   --- Macro commands ---
-:                   + 清除所有宏
:macroname           + 定義宏
=         + 列出宏或執行宏
                   --- Disk I/O commands ---
N                    - 為下一個磁盤操作釋放參數
N?                   + 顯示參數
N 
                     - 指定文件
L                    - 載入文件
Laddress             - 載入文件到指定内存地址
W                    - 寫内存到文件,始於cs:100 長度為BX-CX
W           - 寫内存到文件,始於指定地址 長度為BX-CX
Laddress,drive,firstsec,number
                     - 載入指定邏輯扇區到指定内存(num=載入扇區個數)
Waddress,drive,firstsec,number
                     - 保存指定内存到指定邏輯扇區(num=保存扇區個數,或用BX-CX來指定其長度-按字節)
                   --- Trace commands ---
-B                   x 清除所有斷點(breakpoint所譯,下同)
-Baddress            x 清除指定地址處斷點
B                    + 列出斷點
Baddress]
                     + 設置斷點于指定内存,每count次中斷,中斷條件:reg=val
T  - 單步執行從指定地址開始的number條指令
TU + 同于 T ,但不顯示中間指令的執行結果
P  - 同于 T ,但跳過call和int子程序
PU + 同于 P ,但不顯示中間指令的執行結果
G 執行從指定地址開始(或CS:IP),停止在
                   --- Assemble command ---
A           - 進入輸入匯編語言模式(回車/. 退出),支持註釋
                   --- Unassemble commands ---
-Unumber             x 設置/查詢默認反匯編長度
U             - 反匯編指定内存指令
                   --- Help commands ---
?                    - 顯示基本幫助
?topic               + 顯示特定主題或頁數(1..8)
?? or ?0             + 顯示所有幫助
                   --- Display and input modes ---
A=            x 設置/查詢默認地址模式(16位/32位)
O=            x 設置/查詢默認操作數模式(16位/32位)
R=            + 設置/查詢默認寄存器顯示模式(16位/32位)
RF                   - 設置/查詢標誌位寄存器
RDR                  x 按16位寄存器方式顯示標誌位寄存器(/X 模式下默認)
RMS                  x 按標準方式顯示標誌位寄存器(/S 模式下默認)
                   --- Utility commands ---
ASCII         + 顯示一個ASCII表
CLS                  + 清屏
CPU                  + 顯示CPU類型(支持到Pentium pro)和工作模式(實模式/32位保護模式/虛擬86模式)
H value              + 顯示 ''value'' 按16進制、十進制、字符、八進制和二進制
H value1 value2      + 顯示value1,value2 相加、減、乘、除以及取模的結果
V                    + 顯示用戶屏幕(程序執行結果,如同c中的)
; comment            + 註釋
Detailed Explanation of debug
First of all, I would like to recommend using DR-DEBUG that comes with DR-DOS7. It supports instructions up to Pentium pro, is powerful, and supports macros. The most convenient thing is that you can use the Enter key to replace the previous u/d/p/t instruction, which is convenient for viewing and debugging.
The following is the translation of its help:
Assemble, convert the input assembly language into machine code
A                                 (example: Acs:100)
Set breakpoints for debugging
B          (example: B100 2 al=80)
Compare the contents of two segments of memory
Compare     C range address                       (example: C200 20d 500)
Display the specified memory data
Dump        D                              (example: Dcs:500 L 10)
Edit memory data
Enter       E                  (example: Eds:500 "Hello ")
Fill memory
Fill        F range data                      (example: F100 13f "Test ")
Run the program from the specified point
Go          G                  (example: Gcs:4bb0)
Calculate
Hex         H                          (example: H10e 01)
Input from I/O port
Input       I port                                        (example: I3f2)
Load the content of a file or a specified logical sector
Load        L       (ex: L0Cff 3 09 10)
Move (copy) the content of memory
Move        M range address                 (example: Mcs:200 220 cs:400)
Specify the operation file name
Name        N   filename               (example: Ntest.com)
Output to I/O port
Output      O port value                               (example: O3ff 10)
Step through (skip int/rep/call, etc.)
Proceed     P                      (example: P=ds:3fff)
Quit debug
Quit        Q
Change or display registers
Register    R                          (example: Rax 1000)
Search for data in the specified memory
Search      S range data                        (example: Sds:200 500 32)
Step through (enter int/rep/call, etc.)
Trace       T                 (example: T=3cff:0100 10)
Unassemble the machine code in the specified memory
Unassemble  U                            (example: U3cff:0200 400)
Display the screen content (equivalent to)
Viewswap    V                                           (any key returns)
Write the content of a file or a specified logical sector
Write       W     (ex: Wds:200 0 16 0f)
(range can be: start  offset end offset or start address L length)
The following are detailed usage instructions:
                   --- Glossary ---
pathname  - File name (optional path)
testparms - Parameters
address   - Memory address  offset
            If the segment address is omitted, CS is used for assembly/disassembly; DS is used for other functions
range     - Can be: start  offset end offset
                    start address L length
                    start address, + length
reg       - Register name
list      - Some values separated by spaces or commas (of a given type)
drive     - 0 = A:, 1 = B:, ...
firstsec  - Logical sector number (starting from 0)
                   --- Operators ---
Numbers can be hexadecimal (default), # decimal, \ octal, % binary, '' string '' ("chars"),
Registers, , ^ stack.
Operators (+ - * /) and (parentheses) can be used.
Example: Rax=(^ + (bl * %1001) + ''a'').
- represents basic debug commands
+ represents commands unique to dr-debug
x represents instructions that can only be executed in dr-debug extended mode. Enter /s to enter default mode, and enter /x to enter extended mode
                   --- Dump commands ---
-D           x Set/query default display length (in bytes)
-DB          x Set/query default display length and return in byte mode
D=     x Set/query the start point of viewing (0-f)
D             - Display the specified memory content (/S mode) / repeat the last D? command (/X mode)
DB            - Display the specified memory content (in bytes)
DW            x Display the specified memory content (in words)
DD            x Display the specified memory content (in double words)
DP            x Display the pointer of the specified memory (far pointer - segment: offset)
DI            x Display the interrupt vector table (range = interrupt number)
                   --- Enter commands ---
                       (When the list is omitted, enter data after pressing Enter, "." to exit)
E ]   + Enter data
EB]   x Enter data (in bytes)
EW]   x Enter data (in words)
ED]   x Enter data (in double words)
EP]   x Enter data (in far pointers)
EI]   x Enter interrupt vector
                   --- Compare commands ---
C range,address      - Compare the contents of two segments of memory
CBrange,address      x Compare the contents of two segments of memory (in bytes)
CWrange,address      x Compare the contents of two segments of memory (in words)
CDrange,address      x Compare the contents of two segments of memory (in double words)
CPrange,address      x Compare the contents of two segments of memory (in far pointers)
                   --- Fill commands ---
F range,list         - Fill data into memory
FBrange,list         x Fill data into memory (in bytes)
FWrange,list         x Fill data into memory (in words)
FDrange,list         x Fill data into memory (in double words)
FPrange,list         x Fill data into memory (in far pointers)
                   --- Search commands ---
S address list       - Search for data in the specified memory
-Saddress list       x Search for data in the specified memory and save the offset address of the (cx+1)th match in cx
SBaddress list    x Search for data in the specified memory (in bytes) (-SB is as before)
SWaddress list    x Search for data in the specified memory (in words) (-SW is as before)
SDaddress list    x Search for data in the specified memory (in double words) (-SD is as before)
SPaddress list    x Search for data in the specified memory (in far pointers) (-SP is as before)
                   --- Port I/O commands ---
I  port              - Input from I/O port
IB port              x Input from I/O port (in bytes)
IW port              x Input from I/O port (in words)
ID port              x Input from I/O port (in double words) (supported above 386)
O  port,value        - Output to I/O port
OB port,value        x Output to I/O port (in bytes)
OW port,value        x Output to I/O port (in words)
OD port,value        x Output to I/O port (in double words) (supported above 386)
                   --- Macro commands ---
-:                   + Clear all macros
:macroname           + Define macro
=         + List macro or execute macro
                   --- Disk I/O commands ---
N                    - Release parameters for the next disk operation
N?                   + Display parameters
N 
                     - Specify file
L                    - Load file
Laddress             - Load file to the specified memory address
W                    - Write memory to file, starting from cs:100 with length BX-CX
W           - Write memory to file, starting from the specified address with length BX-CX
Laddress,drive,firstsec,number
                     - Load the specified logical sector to the specified memory (num = number of sectors to load)
Waddress,drive,firstsec,number
                     - Save the specified memory to the specified logical sector (num = number of sectors to save, or use BX-CX to specify its length - in bytes)
                   --- Trace commands ---
-B                   x Clear all breakpoints (translated as breakpoint, the same below)
-Baddress            x Clear the breakpoint at the specified address
B                    + List breakpoints
Baddress]
                     + Set breakpoint at the specified memory, interrupt every count times, interrupt condition: reg=val
T  - Step through starting from the specified address for number instructions
TU + Same as T, but do not display the execution result of intermediate instructions
P  - Same as T, but skip call and int subroutines
PU + Same as P, but do not display the execution result of intermediate instructions
G Execute starting from the specified address (or CS:IP), stop at 
                   --- Assemble command ---
A           - Enter the input assembly language mode (press Enter/. to exit), support comments
                   --- Unassemble commands ---
-Unumber             x Set/query default unassemble length
U             - Unassemble the specified memory instructions
                   --- Help commands ---
?                    - Display basic help
?topic               + Display specific topic or page number (1..8)
?? or ?0             + Display all help
                   --- Display and input modes ---
A=            x Set/query default address mode (16-bit/32-bit)
O=            x Set/query default operand mode (16-bit/32-bit)
R=            + Set/query default register display mode (16-bit/32-bit)
RF                   - Set/query flag register
RDR                  x Display flag register in 16-bit register mode (default in /X mode)
RMS                  x Display flag register in standard mode (default in /S mode)
                   --- Utility commands ---
ASCII         + Display an ASCII table
CLS                  + Clear screen
CPU                  + Display CPU type (support up to Pentium pro) and working mode (real mode/32-bit protected mode/virtual 86 mode)
H value              + Display ''value'' in hexadecimal, decimal, character, octal and binary
H value1 value2      + Display the results of adding, subtracting, multiplying, dividing and taking modulus of value1 and value2
V                    + Display the user screen (execution result of the program, just like in c)
; comment            + Comment