2012-03-21 2 views
1

인터럽트 9 (dos)와 같은 키보드 하드웨어 인터럽트에 대해 배우고 있습니다. 그리고 화살표 키 (왼쪽, 오른쪽, 위, 아래)를 누르면 두 개의 연속적인 인터럽트가 있음을 알았습니다. 첫 번째는 'Shift'버튼 인터럽트이고 두 번째는 내가 누른 화살표 키입니다.화살표 키를 누르면 두 개의 키보드 인터럽트가 발생합니까? (int 09h)

키보드의 번호 9 인터럽트를 다시 작성하고 구성하여 누를 수있는 버튼의 검색 코드를 묻는 메시지가 나타났습니다.

예를 들어, 오른쪽 화살표 키를 누르면, 'Shift'버튼 인터럽트가 발생했다는 것을 알게 될 것입니다. (화면 42에 scane code 42가 표시됩니다.) 그리고 내가 누른 화살표 키 오른쪽 화살표 키)도 인터럽트 (스캔 코드 77)를 보냅니다.

제 질문은 왜 이런 일입니까?

INT (9)에 대한 나의 코드 : I (예 : 오른쪽 화살표 키) 화살표 키를 누른 후

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 키보드를 사용하고 있습니다. 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 

코드가 '아무튼 이후 :

    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 

그래서 당신이 실제로 받고있는 것은이 키 순서는 다음과 같습니다

Microsoft는 다음과 같은 설명이 키보드 스캔 코드에 rather nice write-up있다 128 (0xE0은 224)보다 높은 값을 인쇄하면 0x2A (42) 및 0x4D (77)의 인쇄물 만 표시됩니다.

관련 문제