CLR TR0 ; 关闭定时器T0
NOKEY2: MOV P3,#0FFH ;设置P3口为输入模式 CLR P3.6 ; 清0 P3.6,按键的第三行扫描 MOV A,P3 ANL A,#0FH XRL A,#0FH JZ NOKEY3
LCALL DELY10MS ; 延时10ms MOV A,P3 ANL A,#0FH XRL A,#0FH JZ NOKEY3 MOV A,P3 ANL A,#0FH CJNE A,#0EH,NK9 MOV KEYBUF,#8 LJMP DK3
NK9: CJNE A,#0DH,NK10 ;K9键按下 MOV KEYBUF,#9 LJMP DK3
NK10: CJNE A,#0BH,NK11 ;K10键按下 MOV KEYBUF,#10 LJMP DK3
NK11: CJNE A,#07H,NK12 ;K11键按下 MOV KEYBUF,#11 LJMP DK3
NK12: NOP ; K12键按下 DK3: MOV A,KEYBUF MOV B,#2
MUL AB ;因为查表里都是字,所以乘2的查表数据
MOV TEMP,A
MOV DPTR,#TABLE ;指向表头 MOVC A,@A+DPTR ;查表 MOV STH0,A