DOS DEBUG 跟踪命令无法正常工作

DOS DEBUG trace command doesn't work as I would expect

我有使用循环语法打印 abc 的 ASM 代码。这是我的代码

;abc.com
.model small
.code
org 100h
start:
    mov ah, 02h
    mov dl, 'a'
    mov cx, 3h

ulang:
    int 21h
    inc dl
    loop ulang

    int 20h
end start

COM程序运行正常

debug abc.com 后跟 -t 的结果看起来像

问题是为什么INT 21之后是NOP,而不是INC dl? AFAIK 它应该 INC dl 然后 LOOP xxxx 三次然后 INT 20.

当我连续按-t时它会跑到我不知道的地方直到崩溃,意味着找不到INT 20h

debug abc.com-u不一样

显示 INC dlLOOP 0107 表示循环。

仅供参考:

调试中的 Trace 命令等同于现代调试器的 STEP INTO 功能。 int 指令(如 call)执行一系列指令,然后 returns 返回给调用者。 Trace 将进入软件中断处理程序或函数并一次执行每条指令。 MSDN 调试文档说明了 Trace:

Executes one instruction and displays the contents of all registers, the status of all flags, and the decoded form of the instruction executed.

在您的情况下,您点击 int 21h 并跳转到 CS:IP 00A7:107C 处的软件中断处理程序代码。如果您跟踪所有中断处理程序代码,您最终会到达 1400:0109 的 CS:IP,其中 INC DL 指令所在。

为了执行函数或中断而不单步执行与之关联的每条指令,您可以使用 proceed 命令。继续类似于现代调试器的 STEP OVER 功能。中断处理程序或 function/subroutine 的代码将执行,然后在 INTCALL 指令之后的指令处中断。

文档是这样说的 PROCEED:

When the p command transfers control from Debug to the program being tested, that program runs without interruption until the loop, repeated string instruction, software interrupt, or subroutine at the specified address is completed, or until the specified number of machine instructions have been executed. Control then returns to Debug.