Setting a handler for interrupts to over-ride the existing one (Turbo C - DOS)
Posted on 2003-10-31
Hi, I am trying to write a program that has it's own handler for interrupts.
For simplicity's sake, let's say the program is getting 2 numbers from a user, and dividing them. If a divide by 0 error occurs, the handler is called.
Here's the code I would use for that:
void interrupt (*oldhandle)();
void interrupt divide0();
oldhandle = getvect(0x00); /*0x00 is processor / 0 error*/
c = a / b;
printf("%d / %d = %d\n",a,b,c);
void interrupt divide0()
printf("Error: Divide by Zero\n");
This code works fine if the 2 numbers are non-zero, and if number 1 is 0.
However, if number 2 is zero, divide0() is called, and the error is printed, but another interrupt handler is called afterwards, which prints Divide Error, and exits the program.
I think that this error is built into the operating system, and is the default handler for divide errors.
I want the program to continue, although this interrupt has occured.
How can I tell the system that the interrupt is completed and to move on?
Thanks in advance