ORG 0000H LJMP KKEYI ORG 0030H DAT1 DATA 28H CLK bit P3.0 DAT bit P3.1 CS bit P3.2 KKEYI: LCALL KKS1 ; ;键盘信号搜索KEY SCANNING PROG JNZ KLK1 ; 有键盘, 转跳 KLK1 LCALL DELAY LCALL DELAY SJMP KKEYI ; 无键,转跳 KKEYI 继续测键 K0: MOV DAT1,A LJMP DISP MOV DAT1,#00H LJMP DISP KLK1: LCALL DELAY LCALL DELAY LCALL KKS1 JNZ KLK2 ; 确实有键,转跳至 KLK2 LCALL DELAY LJMP KKEYI ; -------------------------------------------- KLK2: MOV P1,#0FEH ; THERE IS KEYI NOP JB P1.4,NOK1 MOV A,#00H LJMP NUM NOK1: NOP JB P1.5,NOK2 MOV A,#01H LJMP NUM NOK2: NOP JB P1.6,NOK3 MOV A,#02H LJMP NUM NOK3: NOP JB P1.7,NOK4 MOV A,#03H LJMP NUM NOK4: NOP MOV P1,#0FDH ; THERE IS KEYI NOP JB P1.4,NOK5 MOV A,#04H LJMP NUM NOK5: NOP JB P1.5,NOK6 MOV A,#05H LJMP NUM NOK6: NOP JB P1.6,NOK7 MOV A,#06H LJMP NUM NOK7: NOP JB P1.7,NOK8 MOV A,#07H LJMP NUM NOK8: NOP MOV P1,#0FBH ; THERE IS KEYI NOP JB P1.4,NOK9 MOV A,#08H LJMP NUM NOK9: NOP JB P1.5,NOKA MOV A,#09H LJMP NUM NOKA: NOP JB P1.6,NOKB MOV A,#0AH LJMP NUM NOKB: NOP JB P1.7,NOKC MOV A,#0BH LJMP NUM NOKC: NOP MOV P1,#0F7H NOP JB P1.4,NOKD MOV A,#0CH LJMP NUM NOKD: NOP JB P1.5,NOKE MOV A,#0DH LJMP NUM NOKE: NOP JB P1.6,NOKF MOV A,#0EH LJMP NUM NOKF: NOP JB P1.7,BACK MOV A,#0FH NUM: MOV DAT1,A LJMP DISP KKS1: MOV P1,#0F0H ; IS THERE ANY MOV A,P1 MOV R4,A ORL A,#0FH CPL A RET BACK: LJMP KKEYI DISP: MOV 29H,#0C8H ACALL SEND MOV 29H,DAT1 ACALL SEND LJMP KKEYI SEND: CLR cs MOV R3,#08H ACALL LONG SEND_LOOP:MOV C,29H.7 MOV dat,C SETB clk ACALL SHORT CLR clk ACALL SHORT MOV A,29H RL A MOV 29H,A DJNZ R3,SEND_LOOP CLR clk RET LONG:MOV R5,#02H LLP:DJNZ R5,LLP SHORT:MOV R6,#08H SLP:DJNZ R6,SLP RET DELAY:MOV R7,#08H LP:DJNZ R7,LP RET END