;;;;;;;;;;定义单元;;;;;;;;;;
COUNT EQU 30H
;;;;;;;;;;入口地址;;;;;;;;;;
ORG 0000H
LJMP START
ORG 0003H
RETI
ORG 000BH
RETI
ORG 0013H
RETI
ORG 001BH
RETI
ORG 0023H
RETI
ORG 002BH
RETI
;;;;;;;;;;主程序入口;;;;;;;;;;
ORG 0100H
START: LCALL CHUSHIHUA
LCALL PANDUAN
LCALL XIANSHI
LJMP START
;;;;;;;;;;初始化程序;;;;;;;;;;
CHUSHIHUA: MOV COUNT,#00H
RET
;;;;;;;;;;判断哪个按键按下程序;;;;;;;;;;
PANDUAN: MOV P3,#0FFH
CLR P3.4
MOV A,P3
ANL A,#0FH
XRL A,#0FH
JZ SW1
LCALL DELAY10MS
JZ SW1
MOV A,P3
ANL A,#0FH
CJNE A,#0EH,K1
MOV COUNT,#0
LJMP DK
K1: CJNE A,#0DH,K2
MOV COUNT,#4
LJMP DK
K2: CJNE A,#0BH,K3
MOV COUNT,#8
LJMP DK
K3: CJNE A,#07H,K4
MOV COUNT,#12
K4: NOP
LJMP DK
SW1: MOV P3,#0FFH
CLR P3.5
MOV A,P3
ANL A,#0FH
XRL A,#0FH
JZ SW2
LCALL DELAY10MS
JZ SW2
MOV A,P3
ANL A,#0FH
CJNE A,#0EH,K5
MOV COUNT,#1
LJMP DK
K5: CJNE A,#0DH,K6
MOV COUNT,#5
LJMP DK
K6: CJNE A,#0BH,K7
MOV COUNT,#9
LJMP DK
K7: CJNE A,#07H,K8
MOV COUNT,#13
K8: NOP
LJMP DK
SW2: MOV P3,#0FFH
CLR P3.6
MOV A,P3
ANL A,#0FH
XRL A,#0FH
JZ SW3
LCALL DELAY10MS
JZ SW3
MOV A,P3
ANL A,#0FH
CJNE A,#0EH,K9
MOV COUNT,#2
LJMP DK
K9: CJNE A,#0DH,KA
MOV COUNT,#6
LJMP DK
KA: CJNE A,#0BH,KB
MOV COUNT,#10
LJMP DK
KB: CJNE A,#07H,KC
MOV COUNT,#14
KC: NOP
LJMP DK
SW3: MOV P3,#0FFH
CLR P3.7
MOV A,P3
ANL A,#0FH
XRL A,#0FH
JZ SW4
LCALL DELAY10MS
JZ SW4
MOV A,P3
ANL A,#0FH
CJNE A,#0EH,KD
MOV COUNT,#3
LJMP DK
KD: CJNE A,#0DH,KE
MOV COUNT,#7
LJMP DK
KE: CJNE A,#0BH,KF
MOV COUNT,#11
LJMP DK
KF: CJNE A,#07H,KG
MOV COUNT,#15
KG: NOP
LJMP DK
SW4: LJMP PANDUAN
DK: RET
;;;;;;;;;;显示程序;;;;;;;;;;
XIANSHI: MOV A,COUNT
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV P0,A
LCALL DELAY
SK: MOV A,P3
ANL A,#0FH
XRL A,#0FH
JNZ SK
RET
;;;;;;;;;;10ms延时程序;;;;;;;;;;
DELAY10MS: MOV R6,#20
D1: MOV R7,#248
DJNZ R7,$
DJNZ R6,D1
RET
;;;;;;;;;;200ms延时程序;;;;;;;;;;
DELAY: MOV R5,#20
LOOP: LCALL DELAY10MS
DJNZ R5,LOOP
RET
;;;;;;;;;;共阴码表;;;;;;;;;;
TABLE: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H
DB 7FH,6FH,77H,7CH,39H,5EH,79H,71H
;;;;;;;;;;结束标志;;;;;;;;;;
END