Thank you for your help. My doubt is how do I code, or call, that the callback routine
in DOSEMU ?
The example below, show the procedure in the TSR application service, which running on
DOS. How
would it look like converted for DOSEMU ?
/*------------------------------
Handle call back routine
*/
void interrupt (*RotCmd) (void);
void CallBackRot(void)
{
if (!Ptr->rotserv)
return;
RotCmd = Ptr->rotserv;
_ES = FP_SEG (Ptr->Args); // _ES is real register of CPU
_BX = FP_OFF (Ptr->Args);
(*RotCmd) ();
}
-----Mensagem Original-----
De: Karsten Hilbert <[EMAIL PROTECTED]>
Para: Dio� <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Enviada em: S�bado, 21 de Agosto de 1999 20:30
Assunto: Re: Help!
On Fri, 20 Aug 1999, Dio� wrote:
> I implemented a interrput 0x53 service at DOSEMU, and I have a function in
> service by where I pass a
> pointer of a callback function from DOS application, when my function
> service is completed. The
> callback function receive args in ES:BX pointer. How do I make to call that funcion
> callback from
> DOSEMU ? I'm don't knowing to code?!?!? (C or Assembler)
OK, I would like to help you. But still I am not sure about your
problem.
How I understand you:
1) You have hacked the DOSEMU code. Your additional code in
DOSEMU is executed whenever some program calls software
interrupt 0x53.
2) Your 0x53 code (that is part of DOSEMU now) wants to call back
to the calling program (for instance so the calling program
does not have to wait idly for the finalization of some
lengthy procedure that is executed inside int 0x53) some time
later.
3) Later Int 0x53 will call back a function inside your program
and pass arguments to it in a data block referenced by ES:BX
(rather unusual combination, methinks, is there a special
reason why you do not use something like ES:DI ?).
IF SO THEN:
- you must tell int 0x53 the absolute address of the function to
be called back - there is a way to find out the address of a
function in C, look it up in your C's docu
- from 0x53 you call that address after you setup the arguments
properly
Now: you need to make sure that the callback routine does not do
any fancy stuff since the OS (the DOS part, that is) will be in
an - albeit defined - yet arbitrary, presently unknown state
because the callback interrupt can occur pretty much anytime. Be
careful about changing data structures used elsewhere, about disk
access, screen access, calls to other functions, etc. etc.
It's a nasty desaster best avoided.
The safest though not the most elegant bet is to just save the
arguments in your callback routine into some data storage area
that will be written _only_ by that routine and read by other
functions _only_ when a "valid flag" is set which you do at the
very end of your callback routine and which you clear upon
invocation of the call to 0x53 that plants the callback. Now,
that flag must be local to _this_ instance of the callback since
two callbacks could overlap. The best is to setup a data area
_before_ invoking 0x53 in the first place and passing that
pointer to 0x53 along with the callback address pointer. Then
0x53 will call your callback function with that data area in
ES:BX. Make sure your valid-flag resides inside the data area.
Thus you will have a flag local to this instance of the callback.
Correct me where I'm wrong.
Just my 2 cents but I hope it helps.
I guess, however, this is off-topic.
Karsten (ncq)