setvect

基本介紹

  • 外文名:setvect
  • 功 能::設定中斷矢量入口
  • 用 法:void setvect(int intr_num,
  • 函式名: : setvect
基本信息,程式例,

基本信息

函式名: setvect
功 能: 設定中斷矢量入口
用 法: void setvect(int intr_num, void interrupt(*isr)());
setvect(int 中斷號,void interrupt(*中斷函式名));

程式例

/***NOTE: This is an interrupt service routine. You can NOT compile this program with Test Stack Overflow turned on and get an executable file which will operate correctly. */
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#define INTR 0X1C /* The clock tick interrupt */
void interrupt ( *oldhandler)(void);
int count=0;
void interrupt handler(void)
{
/* increase the global counter */
count++;
/* 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;
}

相關詞條

熱門詞條

聯絡我們