DATAS SEGMENT
;此处输入数据段代码
DOC DB 0DH, 0AH, '======================================='
DB 0DH, 0AH, '| Simple password sysytem |'
DB 0DH, 0AH, '| Copy Right By DDDDD 2014-3-28 |'
DB 0DH, 0AH, '=======================================$'
XING DB 0DH, 0AH, '*************************************$'
SETPASS DB 0DH, 0AH, 'Please set your password:$'
RESPASS DB 0DH, 0AH, 'Please set your password again:$'
SORRY DB 0DH, 0AH, 'The two password you have set is not same!!!$'
INPUT DB 0DH, 0AH, 'Please input your password:$'
SUCCESS DB 0DH, 0AH, 'WOW! Your card has 10000 dollars!$'
FAIL DB 0DH, 0AH, 'SORRY! your password is not right$'
TWO DB 0DH, 0AH, 'YOU have only two chance now!$'
ONE DB 0DH, 0AH, 'YOU have only one chance now!$'
ZERO DB 0DH, 0AH, 'YOU have no chance now!$'
PASS DB 7 ;设置密码 存放位置
DB ?
DB 7 DUP(?)
PASS1 DB 7 ;再次设置密码 存放位置
DB ?
DB 7 DUP(?)
PASS2 DB 7 ;输入密码 存放位置
DB ?
DB 7 DUP(?)
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
EXTRA SEGMENT
PASS11 DB 9 DUP(?) ;PASS1 拷贝到PASS11
PASS22 DB 9 DUP(?) ;PASS2 拷贝到PASS22
EXTRA ENDS
CODES SEGMENT
ASSUME CS:CODES, DS:DATAS, SS:STACKS, ES:EXTRA
START:
MOV AX, DATAS
MOV DS, AX
MOV AX, EXTRA
MOV ES, AX
;此处输入代码段代码
MOV AH, 9 ;9号功能,屏幕输出字符串
LEA DX, DOC ;打印版权,将字符串首地址给DX
INT 21H
MOV AH, 9
LEA DX, XING ;打印*****
INT 21H
MOV AH, 9H
LEA DX, SETPASS ;打印Please set your password:
INT 21H
MOV AH, 0AH ;0AH 等待输入字符串
LEA DX, PASS ;设置密码,密码存放在PASS
INT 21H
MOV AH, 9H
LEA DX, RESPASS ;打印Please set your password again:
INT 21H
MOV AH, 0AH
LEA DX, PASS1 ;再次设置密码,密码存放在PASS1
INT 21H
CALL CMPPASS01 ;比较两次设置密码是否相同
JE SAME
MOV AH, 9H
LEA DX, SORRY ;两次设置密码不同,打印The two password you have set is not same!!!
INT 21H
JMP START
SAME: ;密码设置正确
MOV AH, 9
LEA DX, XING ;打印******
INT 21H
MOV AH, 9H
LEA DX, INPUT ;打印please input your password:
INT 21H
MOV AH, 0AH ;输入密码
LEA DX, PASS2 ;密码存放在PASS2
INT 21H
CALL CMPPASS02 ;比较输入的密码和设置的密码
JE RMB ;相同,则会显示余额
MOV AH, 9H
LEA DX, FAIL ;不相同提示失败,SORRY! your password is not right
INT 21H
MOV AH, 9H
LEA DX, TWO ;还有2次机会,YOU have only two chance now!
INT 21H
MOV AH, 9H
LEA DX, XING ;打印*******************
INT 21H
MOV AH, 9H
LEA DX, INPUT ;打印please input your password:
INT 21H
MOV AH, 0AH
LEA DX, PASS2 ;第二次输入密码,密码存放在PASS2
INT 21H
CALL CMPPASS02 ;比较输入的密码和设置的密码
JE RMB ;相同,则会显示余额
MOV AH, 9H
LEA DX, FAIL ;不相同提示失败,SORRY! your password is not right
INT 21H
MOV AH, 9H
LEA DX, ONE ;还有1次机会,YOU have only one chance now!
INT 21H
MOV AH, 9
LEA DX, XING ;打印**********
INT 21H
MOV AH, 9H
LEA DX, INPUT ;打印please input your password:
INT 21H
MOV AH, 0AH
LEA DX, PASS2 ;第三次输入密码,密码存放在PASS2
INT 21H
CALL CMPPASS02 ;比较输入的密码和设置的密码
JE RMB ;相同,则会显示余额
MOV AH, 9H
LEA DX, FAIL ;不相同提示失败,SORRY! your password is not right
INT 21H
MOV AH, 9H
LEA DX, ZERO ;没有机会了 you have no chance
INT 21H
JMP OVER
RMB:
MOV AH, 9H
LEA DX, XING ;打印*****
INT 21H
MOV AH, 9H
LEA DX, SUCCESS ;显示余额 your card have 10000 dollars!
INT 21H
OVER:
MOV AH,4CH
INT 21H
CMPPASS01 PROC
LEA SI, PASS1 ;源地址PASS1
LEA DI, PASS11 ;目标地址PASS11
MOV CX, 9
CLD
REP MOVSB ;将输入的密码移动到附加段PASS11,字节移动,重复次数cx
LEA SI, PASS ;源地址PASS,数据段
LEA DI, PASS11 ;目标地址PASS11,附加段
MOV CX, 9
REPE CMPSB ;比较输入的密码和设置的密码,字节比较重复次数cx,不等于会自动退出比较
RET
CMPPASS01 ENDP
CMPPASS02 PROC
LEA SI, PASS2
LEA DI, PASS22
MOV CX, 9
CLD
LAST11:
MOVSB ;采用loop循环进行字节移动,循环次数cx
LOOP LAST11
LEA SI, PASS
LEA DI, PASS22
MOV CX, 9
CLD
LAST21:
CMPSB
JNE OVER11 ;发现不等于就跳出,不比较了
LOOP LAST21
OVER11:
RET
CMPPASS02 ENDP
CODES ENDS
END START
阅读(16565) | 评论(3) | 转发(1) |