From: sandmann AT clio DOT rice DOT edu (Charles Sandmann) Message-Id: <9801201504.AA13767@clio.rice.edu> Subject: Re: MCLSSAA2 : hooking interrupt 9 To: Anthony DOT Appleyard AT umist DOT ac DOT uk Date: Tue, 20 Jan 1998 09:04:18 -0600 (CST) Cc: djgpp-workers AT delorie DOT com In-Reply-To: <741A416BE6@fs2.mt.umist.ac.uk> from "Anthony.Appleyard" at Jan 20, 98 08:23:45 am Content-Type: text Precedence: bulk > When the hook routine calls the user function, should it save everything so > that the user function can be a C/C++ function? Or should it save nothing and > the user function must be in assembler and itself save and restore everything > that it uses? Anything which passes arguments on the stack, or uses automatic arrays will potentially not work. GCC assumes that SS = DS, so that you can reference addresses interchangably with [EBX] or [EBP]. Simple functions don't trip over this, complicated ones will. This is one of the things the wrapper routines do (set up a local SS=DS stack). But the extra overhead isn't needed for fast and simple routine. If we pusha/popa (with seg regs too) and set up DS/ES properly, I don't see a problem with the routine being in C (or C++) as long as someone keeps it simple. A gcc -S and examination of the generated assembler would be prudent; if you avoid calling subroutines you are probably OK.