[c]代码库
#include <stdio.h>
#include <dos.h>
#include <conio.h>
/* The clock tick interrupt */
#define INTR 0X1C
void interrupt ( *oldhandler ) ( void );
int count=0;
void interrupt handler ( void )
{
/*
disable interrupts during the handling of the interrupt
*/
disable();
/* increase the global counter */
count++;
/*
re enable interrupts at the end of the handler
*/
enable();
/* call the old routine */
oldhandler();
}
int main ( void )
{
/* save the old interrupt vector */
oldhandler = getvect ( INTR );
/* install the new interrupt handler */
setvect ( INTR, handler );
/* loop until the counter exceeds 20 */
while ( count < 20 )
printf ( "count is %d\n",count );
/* reset the old interrupt handler */
setvect ( INTR, oldhandler );
return 0;
}