一旦用户输入了正确的密码,我想显示“Hello World”,但是如果密码不正确,程序会提示输入Yes(Y)/ No(N),如果用户输入Yes Y),程序将给用户三次机会显示“Hello World”,如果用户输入了No(N),程序将退出。 我的问题是,每次我选择是(Y),该程序保持循环,其刚刚结束,如果我进入否(N),Tasm - Assembly Loop
这里是我的代码(我已经跳过某些部分)
...
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我的错误,对不起,但仍然,谢谢你!您的建议非常感谢 – user8141558