Advertisement
m1o2

RealTime Lab 1 scan code int9

May 18th, 2012
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void interrupt interrupt_9_Implementation(){
  2.  
  3.     unsigned char scanCode;
  4.  
  5.     asm{
  6.    
  7.         in al, 60h          // read the keyboard input from port 60h ( 96 Decimal ) into al;
  8.         mov scanCode, al    // save the keyboard input into 'scanCode' varaible
  9.         in al, 61h          // read 8255 port 61h ( 97 Decimal ) into al
  10.         or al, 128          // set the MSB - the keyboard acknowlege signal
  11.         out 61h, al         // send the keyboard acknowlege signal from al
  12.         xor al, 128         // unset the MSB - the keyboard acknowlege signal
  13.         out 61h, al         // send the keyboard acknowlege signal from al
  14.     }
  15.  
  16.     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
  17.  
  18.         PromptFormattedString( FormattedString, scanCode, asciiTable[ scanCode ] );
  19.  
  20.         if( EscScanCode == scanCode )
  21.             EscPressed = _True;
  22.         else
  23.             PromptMessage( PromptString );
  24.     }
  25.  
  26.      //send EOI
  27.     asm{
  28.         mov al, 20h
  29.         out 20h, al
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement