口令识别
题目:设计一个程序,实现用户口令验证功能,程序中预先设置好若干个用户的帐号信息(包括用户名和口令)。
程序执行后,给出简单明了的操作提示,请用户输入用户名和口令。当用户键入的帐号信息与程序内置的某个用户帐号一致时,给出欢迎信息,否则给出拒绝信息。
我的代码:
DATA SEGMENT
n equ 20
buf1 db n+1
count1 db 0
string1 db n+1 dup('$')
buf2 db n+1
count2 db 0
string2 db n+1 dup('$')
C0 DB 0DH,0AH,"$"
C1 DB "please input the username: $"
C2 DB "please input the code: $"
C3 DB "welcome!",0DH,0AH,"$"
C4 DB "error!",0DH,0AH,"$"
S1 DB "hello$"
N1 EQU 5
T1 DB "hello08$"
M1 EQU 7
S2 DB "world$"
N2 EQU 5
T2 DB "world08$"
M2 EQU 7
S3 DB "lidong$"
N3 EQU 6
T3 DB "lidong08$"
M3 EQU 8
DATA ENDS
STACK SEGMENT STACK
DB 100 DUP(?)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:
mov ax, DATA
mov ds, ax
mov ah, 09h
mov dx, offset C1
int 21h
lea dx, buf1
mov ah, 0ah
int 21h
lea dx, C0
mov ah, 09h
int 21h
mov ah, 09h
mov dx, offset C2
int 21h
lea dx, buf2
mov ah, 0ah
int 21h
lea dx, C0
mov ah, 09h
int 21h
mov al, count1
mov bl, count2
mov cx, 0
cmp al, N1
jnz L1
lea di, string1
lea si, S1
mov cl, al
repz cmpsb
jnz L1
mov cx, 0
cmp bl, M1
jnz L1
lea di, string2
lea si, T1
mov cl, bl
repz cmpsb
jnz L1
jmp right
L1:
cmp al, N2
jnz L2
lea di, string1
lea si, S2
mov cl, al
repz cmpsb
jnz L2
cmp bl, M2
jnz L2
lea di, string2
lea si, T2
mov cl, bl
repz cmpsb
jnz L2
jmp right
L2:
cmp al, N3
jnz wrong
lea di, string1
lea si, S3
mov cl, al
repz cmpsb
jnz wrong
cmp bl, M3
jnz wrong
lea di, string2
lea si, T3
mov cl, bl
repz cmpsb
jnz wrong
jmp right
wrong:
mov ah, 09h
mov dx, offset C4
int 21h
jmp end1
right:
mov ah, 09h
mov dx, offset C3
int 21h
jmp end1
end1:
mov ah, 09h
mov dx, offset string2
int 21h
mov ah, 4ch
int 21h
code ends
end start
结果:
编译连接均正确,生成了有效的exe文件,可是结果总是不对,我输入用户名为hello,密码为hello08,结果总是error!
请各位大虾帮帮我,程序是哪里错了,谢谢~