[C] 设置中断矢量入口 →→→→→进入此内容的聊天室

来自 , 2019-05-26, 写在 C, 查看 116 次.
URL http://www.code666.cn/view/e77dbaf6
  1. /***NOTE:
  2.     This is an interrupt service routine.  You can NOT compile this
  3.     program with Test Stack Overflow turned on and get an executable
  4.     file which will operate correctly. */
  5.  
  6. #include <stdio.h>
  7. #include <dos.h>
  8. #include <conio.h>
  9.  
  10. #define INTR 0X1C    /* The clock tick interrupt */
  11.  
  12. void interrupt ( *oldhandler)(void);
  13.  
  14. int count=0;
  15.  
  16. void interrupt handler(void)
  17. {
  18. /* increase the global counter */
  19.    count++;
  20.  
  21. /* call the old routine */
  22.    oldhandler();
  23. }
  24.  
  25. int main(void)
  26. {
  27. /* save the old interrupt vector */
  28.    oldhandler = getvect(INTR);
  29.  
  30. /* install the new interrupt handler */
  31.    setvect(INTR, handler);
  32.  
  33. /* loop until the counter exceeds 20 */
  34.    while (count < 20)
  35.       printf("count is %d\n",count);
  36.  
  37. /* reset the old interrupt handler */
  38.    setvect(INTR, oldhandler);
  39.  
  40.    return 0;
  41. }
  42.  

回复 "设置中断矢量入口"

这儿你可以回复上面这条便签

captcha