请问C语言里的GETVECT和SETVECT的作用是什么?
解决方案 »
- 郁闷…散分…
- vs2008为自己的库实现开特殊优化?!
- 图形学源代码
- 提问:一个字符串替换问题
- 如何在自己编写的程序中发送数据到EXCEL中,并制出一个表来?
- ADO
- 怎样取得Windows任务栏右下角的图标的显示位置?
- 串口类里的EV_CTS,EV_RXFLAG,EV_BREAK,EV_ERR,EV_RING,EV_RXCHAR是什么意思呀?
- ASP调用组件的问题!!,急!!!!
- 如何能不用MFC创建ActiveX控件?
- 怎么才能把一个文档模板拆分为左右两半,然后使用左边的按钮来控制右边的显示,正确给分
- 把程序框架(包括CMainFrame,CDocument/CView的界面结构)封在动态库内
功 能: 取得中断向量入口
用 法: 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;
}
setvect设置中断向量
#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;}