I'm learning about interrupts and keyboard hardware interrupts such as interrupt 9 ( in dos ). and I noticed that if I press on an arrow key ( left, right, up, down ) then there will be two consecutive interrupts. the first one is the 'Shift' button interrupt and the second is the arrow key that I have pressed.
I noticed that, since I rewrote and configured the keyboard's number 9 interrupt to prompt the scan code of the pressed button.
for example, when I will press on the right arrow key, I will see that a 'Shift' button interrupt have happend ( shows on the screen the scane code 42 ) and then the arrow key that I have pressed ( the right arrow key ) also send an Interrupt ( scan Code 77 ).
My question is, why this is happening ?
My code for 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
}
}
after I press an arrow key ( for example the right arrow key ), I'll get :
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
so far It is happening only with the arrows keys. and the 'Shift' isn't pressed. I'm using a Logitech Wave keyboard.