I have run a 16 bit program using the Borland C++ 3.1 compiler. The program is supposed to replace the ISR for the system timer, without changing its frequency, the function I replaced it with is supposed to alternate a message that shows up in plain text mode. I only wanted to observe a simple message that showed the underlying timer interrupt at work. Instead, I get erratic (or so it would seem) behavior. Sometimes it works for indefinite amounts of time, and sometimes it ends, and only a fraction of those unexpected terminations are followed by the abhored message telling me that the Virtual DOS Machine has encountered an illegal operation. My question is: Am I doing something to cause this malfunction within the code that I show here? or could the restrictions that go along with running my program within the NTVDM be causing it?
Code:unsigned long i; unsigned char t; int main() { old_timer_isr = getvect(TIMER); i = 0; setvect(TIMER, timer_isr); /* while(!kbhit()); setvect(TIMER, old_timer_isr); */ return 0; } void interrupt timer_isr(__CPPARGS) { i++; t = i % 60; if(t == 14) puts("C++"); else if(t == 29) clrscr(); else if(t == 44) puts("C"); else if(t == 59) clrscr(); }



LinkBack URL
About LinkBacks


