我写了下面这段C语言测试程序,在MSC6.0与32位的WatcomC下都能编译产生出可执行的EXE文件,
运行MSC6.0下编译产生的EXE文件,结果正常:中断处理timer_rtn()有效,表现在记数标志clock_ticks能++,
但运行32位的WatcomC下编译产生的EXE文件,结果是:中断处理timer_rtn()无效,记数标志clock_ticks始终等于0
想请各位高手帮忙看看这是怎回事?如何解决?谢谢了
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <time.h>
#include "fcntl.h"
#include "sys\types.h"
#include "sys\stat.h"
#include <io.h>
#include <bios.h>
#include <dos.h>
#include <direct.h>
#include <process.h>
#include <conio.h>
#include <string.h>
#include <malloc.h>
#include <search.h>
#include <conio.h>
volatile int clock_ticks;
/*void (__interrupt __far *p_1c)();*/
void (interrupt far *p_1c)();
/*void __interrupt __far timer_rtn()*/
void interrupt timer_rtn()
{
++clock_ticks;
/* _chain_intr(p_1c);*/
}
int delays = 0;
int base = 0x1c;
void main(argc,argv)
int argc;
char *argv[];
{
/* if ( argc >= 2 )
base = atoi(argv[1]);
*/
clock_ticks = 0;
p_1c = _dos_getvect(base);
_dos_setvect(base, timer_rtn);
while ( compile_a_line() ) {
printf("ticks=%d\n",clock_ticks);
}
_dos_setvect(base, p_1c);
}
int compile_a_line()
{
long i,j=0L;
if ( delays > 15 ) return 0;
for ( i =0L; i<1000000L;i++)
j++ ;
delays ++;
return 1;
}