Click to See Complete Forum and Search --> : interrupt


deghost
September 13th, 2001, 03:29 PM
Hi Gurus,
how do i assign an interrupt in Cpp for a later use in another program? I have some code for assigning an interrupt and it works in the prog it was assigned in but doesn't seem to work in the testing prog.

plz hlp, thnx!

----------
The @host is everywhere!
----------

Umair Ahmad
September 19th, 2001, 05:57 AM
I dont understand your question, but if you are asking about installing an interrupt handler, then I may help you. Note that all the things below are relevant to Turbo C++ 3.0 or higher compilers.

First you have to write the interrupt handler routine. This routine will be a function declared by using the keyword interrupt e.g.

void interrupt Func( /*arguments*/ )



The function is passed all the x86 registers. So you have to declare it in a specifc way. See your compiler help for this.
Next you have to install the handler. The functions used for these can be found in dos.h (i dont remember them).

Writing interrupt handlers is best done in assembly, since it gives you more control, and there are less chances of obscure, hidden bugs.

The more control, the more that needs control.

deghost
September 21st, 2001, 03:21 PM
Hi,
That is exactly what i want to do. I did make an interrupt handler but that interrupt only works in the interrupt handler assigning program. I need to use that interrupt in other programs but i suppose that when my program finishes doing what it does it is being erased from memory and the "interrupt code" is erased.
i have to do this in C++.
how do i make the code of the interrupt not to erase when the program is done working. Should I use "asm iret;" function in the end or is that not nessesary.
If i do this in asm, how do i keep the program from erasing also?
Thanks a lot.

----------
The @host is everywhere!
----------

Umair Ahmad
September 23rd, 2001, 11:19 PM
You dont need to do asm iret. A function declared with interrupt keyword automatically returns with iret.

You have to make your interrupt handler memory resident. You can find the code in any low-level programming book, or give me some time, I'll dig up some old code to help you out. I remember that it was a simple function in dos.h

The more control, the more that needs control.

deghost
September 24th, 2001, 02:59 PM
Thanx, i'll try looking it up. If you could, find me that function/functions.

----------
The @host is everywhere!
----------

deghost
September 27th, 2001, 02:58 PM
think i've found it! it should be keep() right?

----------
The @host is everywhere!
----------