题目要求是输入密码,正确显示Welcome,错误显示error,并且最多输入三次密码,错误的话返回,我的程序密码是123456789,我先把输入的密码跟9(密码长度)比较,正确的话在一个一个比较,这段没有问题,但是如果输入错误的话,我让al=0,每次让它加1.密码错误的话,跟3比较,等于的话就跳出程序,也就是只能输入三系密码,问题就出在这里,每次都不只让输入三次,也就是,al出了什么问题吧,但是本人找不到,求高手指点~
data segment
password db '123456789'
string1 db 'Please input the password:$'
string2 db 50,0,50 dup(?)
string3 db 'Welcome to use!$'
string4 db 'Password error!$'
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov al,0
start_1:mov ah,9
lea dx,string1
int 21h
mov ah,2
mov dl,10
int 21h
mov ah,2
mov dl,13
int 21h
mov ah,0ah
lea dx,string2
int 21h
lea si,string2[1]
lea di,password
mov dl,[si]
cmp dl,9
jne error
mov cx,0
mov cl,9
lop:inc si
mov bh,[si]
mov bl,[di]
cmp bh,bl
jne error
inc di
loop lop
jmp r
error: mov ah,9
lea dx,string4
int 21h
mov ah,2
mov dl,10
int 21h
mov ah,2
mov dl,13
int 21h
inc al
cmp al,3
jne start_1
jmp exit
r:mov ah,9
lea dx,string3
int 21h
exit:mov ah,4ch
int 21h
code ends
end start