Can't pin down bug related to timer interrupt handler.
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?
unsigned long i;
unsigned char t;
old_timer_isr = getvect(TIMER);
i = 0;
void interrupt timer_isr(__CPPARGS)
t = i % 60;
if(t == 14) puts("C++");
else if(t == 29) clrscr();
else if(t == 44) puts("C");
else if(t == 59) clrscr();
I ought to be more careful with interrupts
Thanks a lot for the information. From now on I'll be a lot more careful with details that are never apparent in the code itself. There's obviously still loads I have to learn about how to work with interrupts. As for disabling and enabling interrupts, I think Borlandc 3.1 still uses the friendly enable() and disable() functions, which I will keep in mind from now on. Thanks again.