请问C语言里的GETVECT和SETVECT的作用是什么?

解决方案 »

  1.   

    函数名: getvect 
    功  能: 取得中断向量入口 
    用  法: void interrupt(*getvect(int intr_num)); 
    程序例: 
     #include <stdio.h> 
    #include <dos.h> 
     void interrupt get_out(); /* interrupt prototype */ 
     void interrupt (*oldfunc)(); /* interrupt function pointer */ 
    int looping = 1; 
     int main(void) 

      puts("Press <Shift><Prt Sc> to terminate"); 
       /* save the old interrupt */ 
      oldfunc  = getvect(5); 
        /* install interrupt handler */ 
      setvect(5,get_out); 
        /* do nothing */ 
      while (looping); 
        /* restore to original interrupt routine */ 
       setvect(5,oldfunc); 
       puts("Success"); 
      return 0; 

    void interrupt get_out() 

      looping = 0; /* change global variable to get out of loop */ 

    函数名: setvect 
    功  能: 设置中断矢量入口 
    用  法: void setvect(int intr_num, void interrupt(*isr)()); 
    程序例: 
     /***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; 

      

  2.   

    getvect得到中断向量
    setvect设置中断向量
      

  3.   

    请问那位大哥能告诉我
    #define INTR1 0Xd
    #ifdef __cplusplus
        #define __CPPARGS ...
    #else
        #define __CPPARGS
    #endif
    void interrupt (*oldfunc1)(__CPPARGS)
    void interrupt SerialInterface(__CPPARGS)   //串行通讯中断子程序
    在下面程序中 oldfunc1=getvect(INTR1);setvect(INTR1,SerialInterface)两句的作用是什么,是否在下面程序中要调用SerialInterface(__CPPARGS)这个子程序呢?
    void InitialSerIntr(void)
    {
     Initial8251();
     oldfunc1=getvect(INTR1);
     setvect(INTR1,SerialInterface); asm mov dx,21h
     asm in al,dx;
     asm and al,11011111b;
     asm out dx,al;}