我正在学习中断和键盘硬件中断,例如中断 9(在 dos 中)。我注意到,如果我按箭头键(左、右、上、下),则会出现两个连续的中断。第一个是“Shift”按钮中断,第二个是我按下的箭头键。
我注意到了这一点,因为我重写并配置了键盘的数字9中断来提示按下按钮的扫描码。
例如,当我按下右箭头键时,我会看到发生了“Shift”按钮中断(在屏幕上显示扫描码 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 …Run Code Online (Sandbox Code Playgroud)