From: sandmann AT clio DOT rice DOT edu (Charles Sandmann) Message-Id: <9801202139.AA13971@clio.rice.edu> Subject: Re: MCLSSAA2 : hooking interrupt 9 To: Anthony DOT Appleyard AT umist DOT ac DOT uk Date: Tue, 20 Jan 1998 15:39:55 -0600 (CST) Cc: djgpp-workers AT delorie DOT com In-Reply-To: <7B1E493424@fs2.mt.umist.ac.uk> from "Anthony.Appleyard" at Jan 20, 98 03:24:41 pm Content-Type: text Precedence: bulk > Then should I insert the two instructions > > mov %ss,%ax > mov %ax,%ds > > next before this instruction? > call *%ebx /* call the user function */ No, absolutely not. The SS and ESP must be consistent, but they point to an area of memory provided by the DPMI provider and thus have a differnt base value than DS. The only way to make it completely GCC compatible is to allocate a stack in the DJGPP image space, lock that memory, set SS=DS, ESP=pointer to top of stack, execute routine, restore old SS:ESP (which is what the assembler wrappers do). This also requires that interrupts not be enabled, the DPMI provider actually does the right thing and doesn't reenter - or that you have multiple or reentrant stack changing code. If you are going to this much trouble, don't bother with the user handler as implemented, since just chaining the interrupt is about the same amount of code. However, if you document the restriction that SS != DS in this routine, and thus you can't call many subroutines (fast simple rule) it will work fine.