Mail Archives: djgpp-workers/1998/01/20/10:18:47
> 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.
- Raw text -