电子密码锁.docx

上传人:b****5 文档编号:12389477 上传时间:2023-04-18 格式:DOCX 页数:15 大小:15.97KB
下载 相关 举报
电子密码锁.docx_第1页
第1页 / 共15页
电子密码锁.docx_第2页
第2页 / 共15页
电子密码锁.docx_第3页
第3页 / 共15页
电子密码锁.docx_第4页
第4页 / 共15页
电子密码锁.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

电子密码锁.docx

《电子密码锁.docx》由会员分享,可在线阅读,更多相关《电子密码锁.docx(15页珍藏版)》请在冰豆网上搜索。

电子密码锁.docx

电子密码锁

enbitp3.5;

rwbitp3.4;

rsbitp3.3;

displayequp0;

speakerbitp2.6;

ledbitp2.7;

openbitp2.0;

returnbitbit20h.1;

ORG0000h;

LJMPstart;

ORG000bh;

LJMPintermit_t0;

ORG001bh;

LJMPintermit_t1;

ORG0030h;

start:

MOVsp,#60h;

lcallsys_initialization;

main0:

lcallstrat_display;

main:

MOV52h,#0;52h;判断输入错误次数存储地址

setbled;

setbtr0;

lcallkey;

cjnea,#'A',next1;

LJMPset_password;

next1:

cjnea,#'B',next2;

LJMPinput_password;

next2:

ajmpmain;

sys_initialization:

clrled;

clropen;

clrspeaker;

MOV34h,#'1';

MOV35h,#'1';

MOV36h,#'1';

MOV37h,#'1';

MOV38h,#'1';

MOV39h,#'1';;存放初始密码

MOVr7,#12;

MOVr0,#40h;

loop:

MOV@r0,#10h;

incr0;

djnzr7,loop;;密码键值存放区清零完毕

lcalldelay0_1s;

MOVp0,#03h;

callwrite_instruction;;液晶软复位

MOVp0,#01h;

callwrite_instruction;

movp0,#3fh;

callwrite_instruction;

movp0,#0fh;

callwrite_instruction;

movp0,#06h;

callwrite_instruction;;液晶初始化完毕

movr4,#10;

movtmod,#11h;

movth0,#0b0h;

setbea;

setbet0;;定时器t0,0.5s定时中断初始化完毕

ret;;系统初始化完毕

intermit_t0:

pushacc;

pushpsw;

movth0,#3ch;

movtl0,#0b0h;

djnzr4,return;

cplled;

movr4,#10;

return:

poppsw;

popacc;

reti;

intermit_t1:

pushacc;

pushpsw;

movth1,#9eh;

movtl1,#58h;

djnzr4,return_t1;

cplled;

cplspeaker;

movr4,#10;

return_t1:

poppsw;

popacc;

reti;

;;;;;;;;;;;;;;;;;键盘扫描

key:

callks;

jnzk1;

jmpkey;

k1:

calldelay;

callks;

jnzk2;

jmpkey;

k2:

clrtr0;

clrled;

movr2,#0feh;

movr6,#00h;

k3:

mova,r2;

movp1,a;

mova,p1;

jbacc.4,l1;

mova,#0;

LJMPlk;

l1:

jbacc.5,l2;

mova,#4;

ljmplk;

l2:

jbacc.6,l3;

mova,#8;

ljmplk;

l3:

jbacc.7,next_key;

mova,#12;

lk:

adda,r6;

movr6,a;

k4:

callks;

jnzk4;

mova,r6;

movdptr,#table0;

movca,@a+dptr;

mov50h,a;;查表取值存入50H,保护键值

ret;

next_key:

incr6;

mova,r2;

jnbacc.7,key;

rla;

movr2,a;

jmpk3;

;;;;;;;;;;;;

ks:

movp1,#0f0h;

mova,p1;

xrla,#0f0h;

ret;

;;;;;;;;;;;;;;;;;设置密码程序

set_password:

callclear_display;

movdptr,#table4;

callinput_hint;

movr0,#40h;

callpassword;

jbcreturnbit,set_password;;先输入原密码完毕

movr5,#6;

movr0,#40h;

movr1,#34h;

input_compere:

mova,@r0;

xrla,@r1;

jnzinput_error;

incr0;

incr1;

nop;

nop;

djnzr5,input_compere;;验证输入密码完毕

jmpset_password0;

input_error:

setbled;

callclear_display;

movdptr,#table5;

callinput_hint;

calldelay1_5s;

clrspeaker;

clrled;

inc52h;

mova,52h;

cjnea,#3,set_password;

sjmp$;;输入密码错误次数超过3次,锁死

set_password0:

callclear_display;

movdptr,#table2;

callinput_hint;

movr0,#40h;

callpassword;

jbcreturnbit,set_password;;第一次输入新密码完毕

callclear_display;

movdptr,#table3;

callinput_hint;

calldelay1_5s;;显示再次输入新密码完毕

callclear_display;

movdptr,#table4;

callinput_hint;

movr0,#46h;

callpassword;

jbcreturnbit,set_password;;第二次输入新密码完毕

movr5,#6;

movr0,#40h;

movr1,#46h;

set_compere:

mova,@r0;

xrla,@r1;

jnzset_error;

incr0;

incr1;

djnzr5,set_compere;

mov34h,40h;

mov35h,41h;

mov36h,42h;

mov37h,43h;

mov38h,44h;

mov39h,45h;;存入新密码完毕

jmpmain0;;设置新密码成功,返回主程序

set_error:

setbspeaker;

setbled;

callclear_display;

movdptr,#table5;

callinput_hint;

calldelay1_5s;

clrspeaker;

clrled;

ljmpset_password0;;前后两次输入新密码不一致,返回重设

;;;;;;;;;;;;;;;;;输入密码开锁程序

input_password:

callclear_display;

movdptr,#table4;

callinput_hint;

movr0,#40h;

callpassword;

jbcreturnbit,input_password;;输入原密码完毕

movr5,#6;

movr0,#40h;

movr1,#34h;

input_compere0:

mova,@r0;

xrla,@r1;

jnzinput_error22;

incr0;

incr1;

nop;

nop;

djnzr5,input_compere0;;验证输入密码完毕

jmpdisplay_right;

input_error22:

setbspeaker;

setbled;

callclear_display;

movdptr,#table5;

callinput_hint;

calldelay1_5s;

clrspeaker;

clrled;

inc52h;

mova,52h;

cjnea,#3,input_password;

sjmp$;;输入密码错误超过3次,锁死

display_right:

callclear_display;

movdptr,#table6;

callinput_hint;;显示输入密码正确提示完毕

setbopen;;开锁

next_key1:

callkey;

nop;

nop;

cjnea,#'F',next_key1;

clropen;;按下开锁键,开锁

jmpmain0;;返回主程序

;;;;;;;;;;;;;;;

strat_display:

movp0,#80h;

callwrite_instruction;

movdptr,#table1;

callinput_hint;

movp0,#0c0h;

callwrite_instruction;

movdptr,#table11;

callinput_hint;

ret;

clear_display:

movdisplay,#01h;

callwrite_instruction;

ret;

input_hint:

movr5,#16;

mova,#00h;

all_or_not:

movca,@a+dptr;

movdisplay,a;

callwritedata;

incdptr;

clra;

nop;

nop;

djnzr5,all_or_not;

ret;

password:

movr5,#6;

movr1,#0c0h;

mova,r1;

movp0,a;

callwrite_instruction;

loop1:

callkey;

nop;

nop;

cjnea,#'C',next_to;

setbreturnbit;

jmpendt;

next_to:

mova,50h;

mov@r0,a;

movdisplay,#'*';

callwritedata;

incr1;

incr0;

djnzr5,loop1;

endt:

ret;

;;;;;;;;;;;;;;写数据指令

writedata:

SETBrs;

CLRrw;

clren;

setben;

nop;

nop;

clren;

calldelay;

ret;

;;;;;;;;;;;;;;;;写指令

write_instruction:

CLRrs;

CLRrw;

clren;

setben;

nop;

nop;

clren;

calldelay;

ret;

;;;;;;;;;;;;;;;;;;延时程序

delay1_5s:

push07h;

push02h;

push03h;

movr7,#15;

del22s:

MOVr3,#0;

del11s:

MOVr2,#0;

djnzr2,$;

djnzr3,del11s;

djnzr7,del22s;

pop03h;

pop02h;

pop07h;

ret;

delay0_1s:

push02h;

push03h;

movr3,#0;

del21s:

movr2,#0;

nop;

nop;

djnzr2,$;

djnzr3,del21s;

pop03h;

pop02h;

ret;

delay:

push07h;

push06h;

movr7,#10;

dl:

movr6,#248;

nop;

nop;

djnzr6,$;

djnzr7,dl;

pop06h;

pop07h;

ret;

;;;;;;;;;;;;;;;;;;;

table0:

db'C','B','0','A';

db'D','9','8','7';

db'E','6','5','4';

db'F','3','2','1';

table1:

db'PASSWORD:

ASET';

table11:

db'BOPEN';

table2:

db'SETPASSWORD:

';

table3:

db'INPUTAGAIN!

';

table4:

db'INPUTPASSWORD:

';

table5:

db'PASSWORDERROR!

';

table6:

db'PASSWORDOK!

!

!

';

;;;;;;;;;;;;;;;;

end

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 公共行政管理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1