淮安信息职业技术学院毕业设计论文
MOV p0,#01h; call write_instruction;
MOV p0,#3fh; call write_instruction;
MOV p0,#0fh; call write_instruction;
MOV p0,#06h; call write_instruction; ;液晶初始化完毕
MOV r4,#10; MOV tmod,#11h; MOV th0,#3ch; MOV tl0,#0b0h; setb ea; setb et0;
;定时器T0,0.5S定时中断初始化完毕
ret;
;系统初始化完毕
;;;;;;;;;;;;;;;;;;;;;;中断服务程序 intermit_t0:
push acc; push psw; MOV th0,#3ch; MOV tl0,#0b0h; djnz r4,return; cpl led;
MOV r4,#10; return: pop psw; pop acc; reti;
intermit_t1:
push acc; push psw; MOV th1,#9eh; MOV tl1,#58h; djnz r4,return_t1; cpl led; cpl speaker; MOV r4,#10; return_t1:pop psw; pop acc; reti;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;键盘扫描 key: call ks; jnz k1; jmp key; k1:
call delay; call ks; jnz k2; jmp key; k2:
clr tr0; clr led; MOV r2,#0feh;
30
附录
MOV r6,#00h;
k3: MOV a,r2; MOV p2,a; MOV a,p2; jb acc.4,l1; MOV a,#0; LJMP lk;
l1: jb acc.5,l2; MOV a,#4; LJMP lk;
l2: jb acc.6,l3; MOV a,#8; LJMP lk;
l3: jb acc.7,next_key; MOV a,#12;
lk: add a,r6; MOV r6,a;
k4: call ks; jnz k4; MOV a,r6; MOV dptr,#table0; MOVc a,@a+dptr;
MOV 50h,a; 查表取值存入50h,保护键值
ret;
next_key: inc r6; MOV a,r2; jnb acc.7,key; rl a; MOV r2,a; jmp k3;
;;;;;;;;;;;;;;;;;;;;;;;;;; ks: MOV p2,#0f0h; MOV a,p2; xrl a,#0f0h; ret;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;设置密码程序 set_password:
call clear_display; MOV dptr,#table4; call input_hint;
MOV r0,#40h; call password;
jbc returnbit,set_password; ;先输入原密码完毕
MOV r5,#6; MOV r0,#40h; MOV r1,#34h; input_compere: MOV a,@r0; xrl a,@r1; jnz input_error; inc r0;
31
淮安信息职业技术学院毕业设计论文
inc r1; nop; nop;
djnz r5,input_compere; ;验证输入密码完毕 jmp set_password0;
input_error:
setb speaker; setb led;
call clear_display; MOV dptr,#table5; call input_hint; call delay1_5s;
clr speaker; clr led;
inc 52h; MOV a,52h;
cjne a,#3,set_password; sjmp $;
;输入密码错误次数超过3次,锁死
set_password0:
call clear_display; MOV dptr,#table2; call input_hint;
MOV r0,#40h; call password;
jbc returnbit,set_password; ;第一次输入新密码完毕
call clear_display; MOV dptr,#table3; call input_hint; call delay1_5s;
;显示再次输入新密码完毕
call clear_display; MOV dptr,#table4; call input_hint;
MOV r0,#46h; call password;
jbc returnbit,set_password; ;第二次输入新密码完毕
MOV r5,#6; MOV r0,#40h; MOV r1,#46h; set_compere:
MOV a,@r0; xrl a,@r1; jnz set_error; inc r0; inc r1;
djnz r5,set_compere;
MOV 34h,40h; MOV 35h,41h; MOV 36h,42h; MOV 37h,43h;
32
附录
MOV 38h,44h; MOV 39h,45h; ;存入新密码完毕
jmp main0;
;设置新密码成功,返回主程序 set_error:
setb speaker; setb led;
call clear_display; MOV dptr,#table5; call input_hint; call delay1_5s;
clr speaker; clr led;
LJMP set_password0; ;前后两次输入新密码不一致,返回重设
;;;;;;;;;;;;;;;;;;输入密码开锁程序 input_password:
call clear_display; MOV dptr,#table4; call input_hint;
MOV r0,#40h; call password;
jbc returnbit,input_password;
;输入原密码完毕
MOV r5,#6; MOV r0,#40h; MOV r1,#34h; input_compere0: MOV a,@r0; xrl a,@r1; jnz input_error22; inc r0; inc r1; nop; nop;
djnz r5,input_compere0; ;验证输入密码完毕 jmp display_right;
input_error22: setb speaker; setb led;
call clear_display; MOV dptr,#table5; call input_hint; call delay1_5s;
clr speaker; clr led;
inc 52h; MOV a,52h;
cjne a,#3,input_password; sjmp $;
33
淮安信息职业技术学院毕业设计论文
;输入密码错误超过3次,锁死
display_right:
call clear_display; MOV dptr,#table6; call input_hint;
;显示输入密码正确提示完毕
setb open; 开锁 next_key1:call key; nop; nop;
cjne a,#'F',next_key1; clr open; 按下关锁键,关锁
jmp main0; 返回主程序
;;;;;;;;;;;;;;;;;;;;;;;; strat_display:
MOV p0,#80h; call write_instruction; MOV dptr,#table1; call input_hint;
MOV p0,#0c0h; call write_instruction; MOV dptr,#table11; call input_hint; ret;
clear_display:
MOV display,#01h; call write_instruction; MOV p0,#06h; call write_instruction; ret;
input_hint:
MOV r5,#16; MOV a,#00h; all_or_not:
MOVc a,@a+dptr; MOV display,a; call writedata; inc dptr; clr a; nop; nop;
djnz r5,all_or_not; ret;
password:
MOV r5,#6; MOV r1,#0c0h; MOV a,r1; MOV p0,a;
call write_instruction; loop1: call key; nop; nop;
cjne a,#'C',next_to; setb returnbit; jmp endt; next_to:
34