2012-03-21 6 views
1

私は割り込みやキーボードのハードウェア割り込み(割り込みDOS 9など)について学んでいます。 と私は矢印キー(左、右、上、下)を押すと、2つの連続した割り込みが存在することに気づいた。最初のものは 'Shift'ボタン割り込みで、もう1つは私が押した矢印キーです。矢印キーを押すと2つのキーボード割り込みが発生しますか? (int 09h)

私は、押したボタンのスキャンコードを促すためにキーボードの番号9割り込みを書き換えて設定しているので、気づいた。

たとえば、右矢印キーを押すと、「Shift」ボタンの割り込みが発生していることがわかります(画面には、scane code 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 

は、これまでのところそれだけ起こっています矢印キーで。 「シフト」は押されていません。 Logitech Waveキーボードを使用しています。 http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.htmlによると

答えて

0

1.7 Added non-fake shifts 

On my 121-key Nokia Data keyboard there are function keys F1, ..., F24, where F1, ..., F12 
send the expected codes 3b, ..., 58, and F13, ..., F24 send the same codes together with 
the LShift code 2a. Thus, F13 gives 2a 3b on press, and bb aa on release. Similarly, there 
are keys with added LCtrl code 1d. But there are also keys with added fake shifts e0 2a. 

Delorie reports that the "Preh Commander AT" keyboard with additional F11-F22 keys treats 
F11-F20 as Shift-F1..Shift-F10 and F21/F22 as Ctrl-F1/Ctrl-F2; the Eagle PC-2 keyboard 
with F11-F24 keys treats those additional keys in the same way. 

これはまさにあなたが記述するものではありませんが、それはかなり奇妙な行動にいくつかの光を投げかけています。別のキーボードを試してみて、どうなるか見てみましょう。

(私はこれはコメントではなく、答えとして属していると思うが、私はコメントボックスを見ることができない...)

3

あなたのNumLockキーがオンになっています。

実際に受信しているすべてのスキャンコードを印刷しているわけではありません。コードが128未満の場合のみ印刷します。ただし、スキャンコードの前に0xE0を付けて、拡張コードを示すことができます。

E0 2A E0 4D 

あなたのコードは「doesnのので:

    Base Make Base Break 
Right Arrow  E0 4D  E0 CD 
... 
Num Lock ON  Precede Base   follow Base Break 
        Make code with   code with 
Final Key only E0 2A     E0 AA 

それでは、あなたが実際に受信していることは、このキーシーケンスは次のとおりです。

マイクロソフトは、以下の記述があり、キーボードのスキャンコードのrather nice write-up、持っています128以上のものを印刷すると(0xE0は224)、0x2A(42)と0x4D(77)の印刷のみが表示されます。

関連する問題