ORG 0000H
LJMP MAIN
ORG 0030H
MAIN: ACALL KEYSCAN
MOV A,30H
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV P2,A
ACALL DELAY
SJMP MAIN
KEYSCAN: MOV P3,#0FH
MOV A,P3
ANL A,#0FH
MOV R3,A
MOV P3,#0F0H
MOV A,P3
ANL A,#0F0H
ORL A,R3
CJNE A,#0FFH,KEYPRO
RET
KEYPRO: MOV R3,A
MOV DPTR,#KEYVALUE
MOV R4,#0FFH
KEY1: INC R4
MOV A,R4
MOV DPTR,#KEYVALUE
MOVC A,@A+DPTR
MOV 20H,R3
CJNE A,20H,KEY1
MOV A,R4
MOV 30H,A
RET
DELAY:MOV R5,#40H
NEXT1:MOV R6,#80H
NEXT2:MOV R7,#90H
DJNZ R7,$
DJNZ R1,NEXT2
DJNZ R0,NEXT1
RET
KEYVALUE:DB 0E7H,0D7H,0B7H,77H,0EBH,0DBH,0BBH,7BH
DB 0EDH,0DDH,0BDH,7DH,0EEH,0DEH,0BEH,7EH
TABLE:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,88H,83H,0C6H,0A1H,86H,8EH
END
|