【发布时间】:2017-08-27 17:50:55
【问题描述】:
我想在用户输入正确密码后显示“Hello World”,但如果密码不正确,程序将提示输入 Yes(Y)/No(N),如果用户输入 Yes(Y),则程序将给用户 3 次机会显示“Hello World”,如果用户输入 No(N),程序将退出。 我的问题是,每次我选择Yes(Y)时,程序一直循环,如果我输入No(N),它就会结束,
这是我的代码(我已经跳过了一些部分)
...
org 0100h
.code
mov ah, @data
mov ds, ah
mov cx, 3
pool:
dec cx
jz full ;jump if equal to zero seems of no effect, the loop is still counting
dsply:
<codes here are for requesting and comparing the password>
...
...
...
cmp bl, al
jne errr
cmp cl, al
jmp welc
errr:
mov ah, 9
lea dx, pmpt ; Displays whether the Yes(Y)/No(N)
int 21h
mov ah, 1
mov cl, al
int 21h
cmp cl, 'Y'
je dsply
cmp cl, 'N'
je endmain
loop pool
full:
mov ah, 9
lea dx, att ;att will display You've Exceeded
int 21h
jmp endmain
welc:
mov ah, 9
lea dx, hw ; Displaying Hello World
int 21h
jmp endmain
endmain:
mov ah, 4ch
int 21h
end main
我不知道这些代码是否正确,我现在没有我的代码副本,而且,如果我的代码和问题的解释看起来很愚蠢,我很抱歉,但如果有人可以请帮忙,如果你能给我你的另一个想法,那就太好了,而且更棒:)
【问题讨论】:
-
您不应该发布甚至可能不是实际代码的代码。但是想想你在代码中对 CX 寄存器做了什么,这应该会告诉你为什么它永远不会为零。也不应该有理由使用
loop,然后手动使用dec cx。 -
您是否尝试过使用调试器单步执行此操作?
-
@SamiKuhmonen 我的错误,对不起,????,但仍然,谢谢!非常感谢您的建议
-
@PeterCordes 我没有,我不知道怎么做,
标签: loops assembly x86 tasm dosbox