#include "libepc.h" void MyTimerISR(void); void MyKeyboardISR(void); DWORD32 clockTickCount = 0; int row=1, col=1; main() { SetISR(IRQ2INT(IRQ_TICK), MyTimerISR) ; // install our timer ISR in the old location outportb(0x21, inportb(0x21) & ~0x01) ; /* Unmask IRQ0 (Timer IRQ) */ SetISR(241, MyKeyboardISR) ; outportb(0x21, inportb(0x21) & ~0x02) ; /* Unmask IRQ1 (Keyboard IRQ) */ enable(); ClearScreen(0x07); SetCursorPosition(row,col); while ( TRUE ) ; } void MyTimerISR() { enable(); // enable higher priority interrupts clockTickCount++; if ( clockTickCount > 1500 ) Sound(1000); // get to work! outportb(0x20,0x20); // send end of interrupt (EOI) to the // Programmable Interrupt Controller (PIC) __asm__(" LEAVE; IRET; "); } void MyKeyboardISR() { BYTE8 scanCode; char ch; enable(); // enable higher priority interrupts scanCode = inportb(0x60); // read the keyboard port (thereby acknowledging the // interrupt if ( !(scanCode & 0x80)) { // key press, not key release ch = (char ) ScanCode2Ascii(scanCode); if ( col > 78) { row++; col = 1; } PutCharAt(ch,row,col++); SetCursorPosition(row,col); PUSHF; CLI; clockTickCount = 0; Sound(-1); POPF; } outportb(0x20,0x20); // send end of interrupt (EOI) to the __asm__(" LEAVE; IRET; "); }