Timer Interrupt Program - C
#include <dos.h>
#include <conio.h>
#include <stdio.h>
volatile unsigned long count = 0;
void interrupt (*oldhandler)();
void interrupt newhandler()
{
count++;
/* Execute the original timer interrupt */
oldhandler();
}
int main()
{
clrscr();
/* Get the original timer interrupt handler */
oldhandler = getvect(0x08);
/* Install our new timer interrupt handler */
setvect(0x08, newhandler);
gotoxy(10, 10);
printf("Timer Interrupt Program");
gotoxy(10, 12);
printf("Press any key to stop...");
while (!kbhit())
{
gotoxy(10, 14);
printf("Timer Count = %lu ", count);
}
/* Read the pressed key */
getch();
/* Restore the original timer interrupt */
setvect(0x08, oldhandler);
gotoxy(10, 16);
printf("Timer interrupt restored.");
getch();
return 0;
}
0 Comments