3×4的矩阵键盘通过并行接口芯片8255A与微机相连。8255A的A口定义为输出口,与键盘行线相连;B口定义为输入口,与键盘列线相连。设8255A A口地址为40H,B口地址为41H,控制寄存器地址为43H。
MOV AL,82H
OUT 43H,AL
BEGIN:MOV AL,0
OUT 40H,AL
WAIT : IN AL,41H
AND AL,0FH
CMP AL,0FH
JZ WAIT
MOV CX,7FFH
L0: LOOP L0
ST: MOV BL,3
MOV BH,4
MOV AL,0FEH
MOV CL,0FH
MOV CH,0FFH
L1: OUT 40H,AL
ROL AL
MOV AH,AL
IN AL,41H
AND AL,CL
CMP AL,CL
JNZ L2
ADD CH,BH
MOV AL,AH
DEC BL
JNZ L1
JMP BEGIN
L2: INC CH
RCR AL
JC L2
MOV AL,CH
JMP KEYTABLE
图12-1 非编码键盘接口硬件框图
更多矩阵键盘知识请访问http://www.elecfans.com/zhuanti/20111025226587.html