Mail Archives: djgpp/1995/12/21/11:50:44
In your message dated Wednesday 20, December 1995 you wrote :
> Hi everyone. I've been having a problem running a C++ program that I've
> written. It compiles and links with no real problems. When I run it, though,
> I get this...
> Here's the class definition for Int9:
>
> class Int9: public IntHandler {
> public:
> Int9();
> Buffer<unsigned> KBbuffer;
> unsigned getkp();
> protected:
> virtual void handler();
> volatile unsigned char keypressed[256];
> private:
> volatile unsigned KBcode;
> volatile unsigned char e0flag, e1counter;
> };
>
> And here's the class definition for Int9's base class:
>
> class IntHandler {
> public:
> void install();
> void remove();
> protected:
> virtual void handler() = 0;
> int IRQnumber; //must be set by derived classes' constructors
> private:
> _go32_dpmi_seginfo oldRMint, newRMint, oldPMint, newPMint;
> _go32_dpmi_registers RMregs;
> unsigned char installed; //true if handler()'s installed
> };
Hmmm... are you passing a method to an interrupt handler? That's fatal (or was,
last time I looked) because a method expects a parameter - not that you ever see
it - called this, which is a pointer to the object which the method is being
called in reference to. If you just make a method into an interrupt handler,
when it's called it'll get some crap on the stack which isn't the expected
pointer. So any references to things inside the class are failures. Trying to
call a virtual function would definitely crash.
The solution: create some /static/ interrupt handler functions, which your
generic object sets a flag to activate, and leaves a pointer to itself
somewhere, so when the actual handler engages, it passes control to you virtual
function.
Regards,
ABW
--
Alaric B. Williams (alaric AT abwillms DOT demon DOT co DOT uk)
"A man walks into a bar, right, and he goes 'ouch' coz it's an iron bar"
- Raw text -