汇编 电子密码锁 程序.docx
《汇编 电子密码锁 程序.docx》由会员分享,可在线阅读,更多相关《汇编 电子密码锁 程序.docx(10页珍藏版)》请在冰豆网上搜索。
汇编电子密码锁程序
最终程序代码:
DATASEGMENT
KEYDB'ABCDEF'
TRYKEYDB7
DB?
DB7DUP(?
)
OLDKEYDB7
DB?
DB7DUP(?
)
NEWKEY1DB7
DB?
DB7DUP(?
)
NEWKEY2DB7
DB?
DB7DUP(?
)
FLAGDB1
DB?
ESUMDB0
STR1DB'PLEASEINPUTKEYCODE:
',0DH,0AH
DB'$'
STR3DB'Youareright!
',0DH,0AH
DB'$'
STR4DB'Keycodeerror!
',0DH,0AH,24H
STR5DB'PleaseInputoldkeycode:
',0DH,0AH
DB'$'
STR6DB'PleaseInputnewkeycode:
',0DH,0AH
DB'$'
STR7DB'PleaseReInputnewkeycode:
',0DH,0AH
DB'$'
STR8DB'Keycodemodificationsucceed!
',0DH,0AH
DB'$'
STR9DB'Thetwokeycodesaredifferent!
',0DH,0AH
DB'$'
STRaDB'ESC:
ChoicetoEXIT;ENTER:
Choicetogoon;',0DH,0AH
DB'$'
STRcDB'ESC:
ChoicetoEXIT;ENTER:
ChoicetoModifykeycode;',0DH,0AH
DB'$'
STRbDB'ESC:
ChoicetoEXIT;BACKSPACE:
RETURN;ENTER:
Choicetogoon',0DH,0AH
DB'$'
STRdDB'ESC:
ChoicetoEXIT;BACKSPACE:
RETURN;',0DH,0AH
DB'$'
DATAENDS
STACKSEGMENT
DW100DUP(?
)
STACKENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
START:
MOVAX,DATA
MOVDS,AX
MOVES,AX
INPUT:
MOVAH,9;屏幕显示,提示输入密码
LEADX,STR1
INT21H
MOVAH,0AH;输入密码
LEADX,OFFSETTRYKEY
INT21H
MOVAH,9;屏幕显示,菜单选项
LEADX,STRa
INT21H
MOVAH,1;密码正确后下一步选择
INT21H
CMPAL,1BH;选择ESC则退出
JZEXIT
CMPAL,0DH;选择ENTER验证密码
JZCOMPARE
COMPARE:
;输入密码与实际密码比较验证
MOVAX,DS
MOVES,AX
MOVSI,OFFSETKEY
MOVDI,OFFSETTRYKEY
INCDI
INCDI
MOVCX,6
REPECMPSB
JZRIGHT
JNZE1
E1:
MOVDI,OFFSETESUM
INCBYTEPTR[DI]
MOVAH,9;屏幕显示,输入密码错误
LEADX,STR4
INT21H
MOVSI,OFFSETFLAG;密码错误时的音效选择
INCSI
MOVBYTEPTR[SI],'F'
CMPBYTEPTR[DI],3;判断输入是否超过3次
JBSHENGYIN;没超过3次连错就调用音效提示错误
JMPEXIT;输入密码超过3次自动结束程序
RIGHT:
MOVAH,9;屏幕显示,输入密码正确
LEADX,STR3
INT21H
MOVAH,9;屏幕显示,菜单选项
LEADX,STRc
INT21H
MOVAH,1;密码正确后下一步选择
INT21H
CMPAL,1BH;选择ESC则退出
JZEXIT
CMPAL,0DH;选择ENTER则修改密码
JZMODIFY
MODIFY:
A1:
MOVAH,9;屏幕显示,输入原密码
LEADX,STR5
INT21H
MOVAH,0AH;原密码输入
LEADX,OFFSETOLDKEY
INT21H
MOVAX,DS
MOVES,AX
MOVSI,OFFSETKEY
MOVDI,OFFSETOLDKEY
INCDI
INCDI
MOVCX,6
REPECMPSB
JZAb
MOVAH,9
LEADX,STR4
INT21H
JMPC1
C1:
MOVAH,9;屏幕显示,菜单选项
LEADX,STRd
INT21H
MOVAH,1;密码正确后下一步选择
INT21H
CMPAL,1BH;选择ESC则退出
JZEXIT
CMPAL,08H;选择BACKSPACE则返回上一级继续输入原密码
JZA1
Ab:
MOVAH,9;屏幕显示,菜单选项
LEADX,STRb
INT21H
MOVAH,1;密码正确后下一步选择
INT21H
CMPAL,1BH;选择ESC则退出
JZEXIT
CMPAL,0DH;选择ENTER则修改密码
JZA2
A2:
MOVAH,9;屏幕提示输入新密码
LEADX,STR6
INT21H
MOVAH,0AH;输入新密码
LEADX,OFFSETNEWKEY1
INT21H
MOVAH,9;屏幕显示,菜单选项
LEADX,STRb
INT21H
MOVAH,1;密码正确后下一步选择
INT21H
CMPAL,1BH;选择ESC则退出
JZEXIT
CMPAL,0DH;选择ENTER则修改密码
JZA5
CMPAL,08H;选择BACKSPACE则返回上级菜单
JZA2
A5:
MOVAH,9;屏幕显示,再次输入新密码
LEADX,STR7
INT21H
MOVAH,0AH;新密码再次输入
LEADX,OFFSETNEWKEY2
INT21H
MOVAH,9;屏幕显示,菜单选项
LEADX,STRb
INT21H
MOVAH,1;密码正确后下一步选择
INT21H
CMPAL,1BH;选择ESC则退出
JZEXIT
CMPAL,0DH;选择ENTER则修改密码
JZA6
CMPAL,08H;选择BACKSPACE则返回上级菜单
JZA2
A6:
MOVAX,DS;两次输入的新密码验证
MOVES,AX
MOVSI,OFFSETNEWKEY1
MOVDI,OFFSETNEWKEY2
MOVCX,6
REPECMPSB
JNZA3
JMPA4
A3:
MOVAH,9;屏幕显示两次输入密码不同,再次输入新验证密码
LEADX,STR9
INT21H
JMPA5
A4:
MOVAH,9;修改密码成功
LEADX,STR8
INT21H
LEASI,NEWKEY1
INCSI
INCSI
LEADI,KEY
MOVCX,6
CLD
REPMOVSB
MOVSI,OFFSETFLAG;修改密码成功时的音效选择
INCSI
MOV[SI],'T'
JMPSHENGYIN
DELAY:
MOVAH,00H;延时5s程序PC机提供的CLK信号频率为1.1931816MHZ
INT1AH
ADDDL,91
MOVBL,DL
LOP:
MOVAH,00H
INT1AH
CMPDL,BL
JNZLOP
JMPINPUT
SHENGYIN:
SING:
MOVBX,200
CALLSOUND
MOVBX,1000
CALLSOUND
JMPDELAY
SOUNDPROC
MOVAL,10110110B
OUT43H,AL
PUSHSI
MOVSI,OFFSETFLAG
CMP[SI],'F'
JZB1
B1:
MOVAX,4553
CMP[SI],'T'
JZB2
B2:
MOVAX,604
POPSI
OUT42H,AL
MOVAL,AH
OUT42H,AL
INAL,61H
MOVAH,AL
ORAL,03H
OUT61H,AL
MOVCX,0FFFFH
DELAY1:
LOOPDELAY1
MOVAL,AH
OUT61H,AL
RET
SOUNDENDP
EXIT:
HLT
MOVAH,4CH
INT21H
CODEENDS
ENDSTART