data segment
str1 db '请设置6位密码','$'
str2 db '请输入6位密码','$'
str3 db '密码正确,是否修正密码,1修正,其他离开','$'
str4 db '密码错误,请重新输入','$'
input db 100 dup(?) ;用户输入的密码的存储位置
password db '201314', '$'
data ends
sseg segment stack
db 256 dup(0)
sseg ends
code segment
assume cs:code, ds:data, ss:sseg, es:data
start: mov ax, data
mov ds, ax
mov es, ax
mov si, 0
lea dx, str1
call display
set: mov ah,08h ;输入设置密码
int 21h
cmp al,0dh
je outenter
push ax
mov dl,'*'
mov ah,02h
int 21h
pop ax
mov password[si],al
inc si
jmp set
mov si,0
inputpass: mov ah,08h ;输入密码
int 21h
cmp al,0dh
je finish
push ax
mov ah,02h
int 21h
mov input[si],al
inc si
jmp inputpass;input
finish: mov input[si], 24h ;24h是字符串结束符'$'的ASCII码
mov si, 0
mov di, 0
mov cx, 6
pwcheck: cmp cx, 0
je pwright ;比较输入密码和设置密码,cx=0表示密码输入正确
mov bl, input[si]
mov dl, password[di]
cmp dl, bl
jnz pwerror
inc si
inc di
dec cx
jmp pwcheck
pwright: call outenter
lea dx,str3
call display
mov ah,01h
int 21h
cmp al,1
je set
jmp over
pwerror: call outenter
lea dx,str3
call display
jmp inputpass
over : mov ah, 4ch
int 21h
display proc near
mov ah, 09h
int 21h
ret
display endp
outenter proc near
mov dl, 0dh
mov ah, 02h
int 21h
mov dl, 0ah
mov ah, 02h
int 21h
ret
outenter endp
code ends
end start
改了改。
已经能成功的通过编译和连接了。