- WinCE Security...
- xdebug配置说明
- VC++ 获取文件的创建、修...
- ASP进度条
- 简单代理服务器C代码实现(S...
- 程序设计竞赛试题选(02)
- 如何在ASP程序中打印Acc...
- UTF-8和16进制区间
- ASP实用技巧:强制刷新和判...
- 运行中程序删除自己的方法
- asp提高首页性能的一个技巧
- [J2EE]J2EE 应用服务器技术
- VB变量命名规范
- C语言常见错误小结
- (摘自网络)如何在IIS中调...
利用中断实现每500毫秒接收一次数据
//DOS的时钟中断 int 21H AH=0x1C 每秒产生18.2次中断
//该程序时间间隔为550毫秒 可以由count的值算出。
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#define INTR 0X1C //0x1c为时钟中断
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
void interrupt ( *oldhandler)(__CPPARGS);
int count=0;
int a=0,b=0;
struct time t;
void interrupt handler(__CPPARGS) // 执行DOS中断时调用的程序
{
count++;
if(count==10)
{ gettime(&t);
b=t.ti_hund;
printf("(2) %d\n",b);
if(b<a)printf("Delay %d ms",((100-a)+b)*10);
else printf("Delay %d ms",(b-a)*10);}
}
int main(void)
{
oldhandler = getvect(INTR); //取得原来的中断向量
setvect(INTR, handler); //设置现在的中断向量
gettime(&t);a=t.ti_hund;
printf("(1) %d\n",a);
while (count < 11); //循环等待。执行DOS的时钟中断
setvect(INTR, oldhandler); //执行完毕,恢复原来的中断向量
return 0;
}