如何在程序集中打印"Hello World"以进行DOS调试.exe



为什么这个代码没有显示"Hello World"我目前在dos框中使用汇编语言。这是我第一次编写汇编语言代码

-a
073F:0100 jmp 126
073F:0102 db 0d, 0a, 'Hello, World!'
073F:0111 db 0d, 0a, '$'
073F:0114 xor ax, ax
073F:0116 mov ah, 9
073F:0118 mov dx, 102
073F:011B int 21
073F:011D mov ax, 4c
073F:0120 int 21
073F:0122
-g 0100

当我输入-g 0100时,Hello World没有显示。代码也没有抛出任何错误,我只是得到了这个输出

AX=0000 BX=0000 CX=0000 DX=0000 SP=00FD BP=0000 SI=0000
DI=0000 DS=073F ES=073F SS=073F IP=0100 NV UP EI PL NZ NA PO NC
073F:0100 EB24     JMP    0126

该输出是您的错误消息。它通常被称为";寄存器转储";,或者故障发生时每个寄存器中的值的列表。

073F:0100 jmp 126
073F:0102 db 0d, 0a, 'Hello, World!'
073F:0111 db 0d, 0a, '$'
073F:0114 xor ax, ax
073F:0116 mov ah, 9
073F:0118 mov dx, 102
073F:011B int 21
073F:011D mov ax, 4c
073F:0120 int 21
073F:0122 ?? (anything could be here since you didn't write to it.)
073F:0123 ?? (anything could be here since you didn't write to it.)
073F:0124 ?? (anything could be here since you didn't write to it.)
073F:0125 ?? (anything could be here since you didn't write to it.)
073F:0126 ?? JMP 126 takes you here, but who knows what is here.
-g 0100

一开始的jmp是正确的想法,因为您需要在字符串上jmp,以防止CPU试图将其解释为可执行代码。然而,在这种情况下,你跳得太远了。jmp 114应该做这项工作。不过,我还是建议使用合适的汇编程序。

最新更新