KEY4 EQU 30H
KEY2 EQU 31H
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
CLR EA
MOV SP,#5FH
MOV KEY2,#0
MOV KEY4,#0
LOOP:
JB P1.0,LOOP
MOV R7,#10
LCALL DELAY
JB P1.0,LOOP
JNB P1.0,$
MOV P3,#0C0H
LOOP0:
LCALL KEYDEAL
MOV A,KEY4
JNZ LOOP41
MOV A,P3
ANL A,#0F0H
ORL A,#0EH
MOV P3,A
SJMP LOOP21
LOOP41:
DEC A
JNZ LOOP42
MOV A,P3
ANL A,#0F0H
ORL A,#0DH
MOV P3,A
SJMP LOOP21
LOOP42:
DEC 察者A
JNZ LOOP43
MOV A,P3
ANL A,#0F0H
ORL A,#0BH
MOV P3,A
SJMP LOOP21
LOOP43:
DEC A
JNZ 芹没贺LOOP21
MOV A,P3
ANL A,#0F0H
ORL A,#07H
MOV P3,A
LOOP21:
MOV A,KEY2
JNZ LOOP22
MOV A,P3
ANL A,#0FH
ORL A,#20H
MOV P3,A
SJMP LOOP3
LOOP22:
DEC A
JNZ LOOP3
MOV A,P3
ANL A,#0FH
ORL A,#10H
MOV P3,A
LOOP3:
LJMP LOOP0
;----------------------------
DELAY:
MOV R2,#2
DLY1:
MOV R3,#250
DJNZ R3,$
DJNZ R2,DLY1
DJNZ R7,DELAY
RET
;-----------------------------
KEYDEAL:
JB P1.1,KEYEN1
MOV R7,#10
LCALL DELAY
JB P1.1,KEYEN1
JNB P1.1,$
INC KEY4
MOV A,KEY4
ANL A,#03H
MOV KEY4,A
KEYEN1:
JB P1.2,KEYEN2
MOV R7,#10
LCALL DELAY
JB P1.2,KEYEN2
JNB P1.2,$
INC KEY2
MOV A,KEY2
嫌派ANL A,#01H
MOV KEY2,A
KEYEN2:
RET
;-----------------------------
END