将字符串写入文件会在程序集中输出带有奇怪字符的输出

Writing a string to a file gives output with weird characters in assembly

我试图将我的字符串保存到汇编文件中,但它给了我这个奇怪的输出 "ver 2.40 (all kinds of special characters)"

我就是这样做的:

mov ah,09
mov dx,200
int 21
int 20

e 200 "Test$"
n test.com
r cx
:0009
w
q

保存成功,当我不退出程序并使用 "g" 但当我 "q" 并尝试 运行 时它也 运行 没问题test.com 它给出了我提到的输出。

我的 DOS 书说 int 20h

This was the standard way to terminate DOS programs on DOS V1. With the introduction of DOS functions 4Ch and 31h this is no longer the recommended way to terminate a program unless it must maintain compatibility with DOS V1 systems.

我建议您使用 int 21h 函数 AH = 4Ch 并将 AL 设置为 return 代码。

我猜你正在使用 DEBUG.EXE。

e 200 "Test$" 之后做一个 d 200。您会看到内存转储从偏移量 200 开始。这看起来像:

16C7:0200  54 65 73 74 24 00 00 00-00 00 00 00 00 00 00 00   Test$...........
16C7:0210  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
16C7:0220  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
16C7:0230  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
16C7:0240  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
16C7:0250  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
16C7:0260  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................
16C7:0270  00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00   ................

现在计算偏移量,直到达到 24:200、201、202、203、204 - 您要存储从偏移量 100h 到 204h 的内存,这是 105h 字节(204h-100h +1).

这个值要存储在CX:

r cx
:0105

w 你写 CX 字节。

int 20不是我认为的问题。 cx 中的 9 不足以编写 100(大概)的代码和 200 的字符串。我想你也想要 w 100。如果这不是DEBUG,请见谅。