我正在学习中断和键盘硬件中断,例如中断9(在dos中)。 我注意到,如果我按下箭头键(左,右,上,下),则会出现两个连续的中断。第一个是'Shift'按钮中断,第二个是我按下的箭头键。按下箭头键拍摄两个键盘中断? (int 09h)
我注意到,因为我重写并配置了键盘的9号中断来提示按下按钮的扫描码。例如,当我按下右箭头键时,我会看到发生了'Shift'按钮中断(在屏幕上显示了scane代码42),然后是我按下的箭头键(右箭头键)也发送中断(扫描码77)。
我的问题是,为什么会发生这种情况?
我对INT 9代码:
void interrupt interrupt_9_Implementation{
unsigned char scanCode;
asm{
in al, 60h // read the keyboard input from port 60h (96 Decimal) into al;
mov scanCode, al // save the keyboard input into 'scanCode' varaible
in al, 61h // read 8255 port 61h (97 Decimal) into al
or al, 128 // set the MSB - the keyboard acknowlege signal
out 61h, al // send the keyboard acknowlege signal from al
xor al, 128 // unset the MSB - the keyboard acknowlege signal
out 61h, al // send the keyboard acknowlege signal from al
}
if(128 > scanCode){ // if the button is being pressed or being released. if the button is being pressed then the MSb isn't set and therfore it must be smaller than 128
printf("You pressed key assigned scan code = %d\n", scanCode);
if(EscScanCode == scanCode)
EscPressed = _True;
else
printf("Press any key (almost)\n:");
}
// send EOI
asm{
mov al, 20h
out 20h, al
}
}
后,我按箭头键(例如右箭头键),我会得到:
Press any key (almost)
:You pressed key assigned scan code = 42 // the 'shift' key scan code
Press any key (almost)
:You pressed key assigned scan code = 77 // the right arrow button scan code
到目前为止,这是唯一的发生用箭头键。而'Shift'没有被按下。 我使用的是Logitech Wave键盘。