取键值程序
功用:等候键入,并改写显现,并回来键值放A
占用:PSW,A,DPTR,R0,R2,R3,R4,R6,R7
进口:无出口:A
ORG0190H
WAT_KB:MOVR0,#3FH
WAT_0:ACALLDISP_0;改写显现器
ACALLT_KB
JZWAT_0;无键,循环
ACALLKEY_LD;延时消抖,改写显现
JZWAT_0;无键,循环
KB_VUL:CLRA
CPLA
MOVDPTR,#PORT_B
MOVX@DPTR,A;关显现
MOVR2,#0FEH
MOVR4,#0
KB_1:MOVDPTR,#PORT_A
MOVA,R2
MOVX@DPTR,A;扫描键盘
INCDPTR
INCDPTR
MOVXA,@DPTR;读键盘
CPLA
ANLA,#0FH;屏蔽无效位
JNZKB_2;有键,转键剖析
INCR4
MOVA,R2
JNBACC.7,WAT_0;无键,回来
RLA
MOVR2,A
SJMPKB_1;无键,扫描下一行
KB_2:RRCA
JCKB_3;有键,转取键值
XCHA,R4;取下一行
ADDA,#8
XCHA,R4
SJMPKB_2;无键,循环
KB_3:MOVR2,#21
KB_4:ACALLDISP_0
ACALLT_KB
JZKB_5;改写显现,等键开释
DJNZR2,KB_4
KB_5:MOVDPTR,#KEY_TB
MOVA,R4
MOVCA,@A+DPTR;取键值
RET
KEY_LD:ACALLDISP_0
ACALLDISP_0
ACALLT_KB
RET
KEY_TB:DB07H,08H,09H,0AH;7,8,9,A
DB1CH,1DH,1EH,11H;FFIS/FUNC,FFNO/USER,FILL/MODE,空
DB04H,05H,06H,0BH;4,5,6,B
DB1AH,1BH,1FH,10H;COMP/DEC,MOVE/HEX,OFST/HIST,MON
DB01H,02H,03H,0CH;1,2,3,C
DB18H,19H,14H,15H;BP/BTOP,BT/BENT,EXEC,SCAL
DB00H,0FH,0EH,0DH;0,F,E,D
DB16H,17H,12H,13H;NEXT/+,LAST/-,TRAC,STEP