发布网友 发布时间:2024-05-15 14:15
共2个回答
热心网友 时间:2024-06-16 21:51
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:MOV SP,#7EH
MOV 22H,#00H
CLR P2.0
CLR P2.3
MOV 20H,#00H
MOV 21H,#00H
MOV 30H, #00H
MOV 31H, #00H
MOV 32H, #00H ;初始化
SU: MOV 7DH,#0FFH
MOV 7EH,#0FFH
MOV 7FH,#0FFH
KEYI:ACALL KS1
CJNE A,#0F0H,LK1
ACALL DIR
AJMP KEYI
LK1:ACALL DIR
ACALL DIR
ACALL KS1
CJNE A, #0F0H,LK2
ACALL DIR
AJMP KEYI
LK2: ACALL KS1
MOV R2,A
ORL A,#0FH
MOV P0,A
ANL A,#0FH
ADD A,R2 ;键特征值
CJNE A,#0EEH,JZHI1
MOV A,#00H
PUSH ACC
JZHI1: CJNE A,#0DEH,JZHI2
MOV A,#01H
PUSH ACC
JZHI2: CJNE A,#0BEH, JZHI3
MOV A,#02H
PUSH ACC
JZHI3: CJNE A,#7EH,JZHI4
MOV A,#03H
PUSH ACC
JZHI4: CJNE A, #0EDH, JZHI5
MOV A,#04H
PUSH ACC
JZHI5: CJNE A,#0DDH, JZHI6
MOV A, #05H
PUSH ACC
JZHI6: CJNE A,#0BDH, JZHI7
MOV A, #06H
PUSH ACC
JZHI7: CJNE A,#07DH, JZHI8
MOV A, #07H
PUSH ACC
JZHI8: CJNE A,#0EBH, JZHI9
MOV A, #08H
PUSH ACC
JZHI9: CJNE A,#0DBH, JZHI10
MOV A, #09H
PUSH ACC
JZHI10: CJNE A,#0BBH, JZHI11
MOV 20H,#01H
JZHI11: CJNE A,#07BH,FAN
MOV 21H, #01H
LCALL GMI
SETB P2.2 ;灭绿灯
LJMP SU ;改密
FAN: MOV A, 81H
CJNE A,#7FH, KEYI
JNB (20H).0, KEYITMP
MOV 20H,#00H
JBC (21H).0,LOOP
POP ACC
CJNE A,32H,NOTE
MOV 7FH,A
POP ACC
CJNE A,31H,NOTE
MOV 7EH,A
POP ACC
CJNE A,30H,NOTE
MOV 7DH,A
CLR P2.2
KEYITMP:LJMP KEYI
NOTE:LCALL BAOJ ;NOT是保留字不能做标号
SUTMP:LJMP SU
BAOJ:MOV SP,#7EH
INC 22H
JNB (22H).1, SUTMP
CLR P2.1
SETB P2.3
ACALL DELY1
CPL P2.1
CPL P2.3
MOV 22H,#00H
RET
GMI:JNB P2.2,SUTMP
LOOP:POP 32H
POP 31H
POP 30H
RET
DIR:MOV R0,#7DH
MOV R3,#01H
LD1: MOV A,@R0
MOV P1,A
MOV P3,R3
LCALL DELY
INC R0
MOV A,R3
JB ACC.2,LD2
RL A
MOV R3,A
SJMP LD1
LD2:RET ;显示
DELY:MOV R7,#249
DL:DJNZ R7,DL
RET ;1ms延时
DELY1:MOV R5,#200
MOV R4,#50
LOOP1:MOV R3,#248
NOP
LOOP2:DJNZ R3,LOOP2
DJNZ R5,LOOP1
DJNZ R4,LOOP1
RET ;10s延时
KS1:MOV P0,#0F0H
MOV A,P0
ANL A, #0F0H
RET ;键是否按下
end
热心网友 时间:2024-06-16 21:50
没有现成的