Board index » delphi » ISR Q: ES:DI not passing?

ISR Q: ES:DI not passing?

Quote
In article <325ff185.3756...@news.sover.net> Luckyy wrote:

>I have written a program that installs an ISR and then launches an
>application which uses that ISR.  The problem I am having, is, I need
>to pass-back a pointer address (ES:DI) for a block of data.  I assignthe
>values, but ES:DI does not seem to pass the values to the callingprogram.
>For some reason it seems that they remain the same whether or not Iset
>them.  Is this a Borland Pascal quirk?  Does anybody have any ideas?

Hi Luckyy,

I assume you are using the "interrupt" keyword so that the routine
will issue the proper iret instruction when it terminates.  This
keyword also triggers the compiler to generate the necessary code
to "push" all registers to the stack and "pop" then when the routine
terminates.  The keyword also causes the compiler to "load" the
program's DS register (e.g.  mov DS,@DATA) so you can access global
variables, etc.

Whether you specify them or not, _all_ registers are saved.  What
you need to do is to define the registers as parameters as shown
under the "interrupt" topic of on-line help.

You can alter any of the registers using Pascal statements, but if
you are using BASM (Borland ASM-END Blocks) you will have to use
the & operator as in &ES and &DI to inform the assembler that the
references to ES and DI refer to the parameters of that name and
not the cpu registers.

If all this seems a bit much and you opt to remove the "interrupt"
keyword you must be aware that in addition to DS being undefined,
the "int" instruction pushes the flags to the stack before calling
the interrupt vector.  Since no registers are saved it will be
your responsibility to preserve any registers that the invoking
program doesn't expect to be altered.  

If you specify a word parameter for the flags the compiler will
establish a stack frame. You can then let the routine terminate
normally which will abandon the original flags (this will turn
TRACE off, possibly interfering with debugging, or you can insert
your own termination code, like ASM mov SP,BP; pop BP; iret END.

There are other combinations of entry exit code that would/could
be generated under various circumstances.  Suffice it to say that
if you omit the "interrupt" keyword you will probably need to know
more about interrupts, assembly language, and the code generated by
the compiler than you currently do.

    ...red

 

Re:ISR Q: ES:DI not passing?


I have written a program that installs an ISR and then launches an
application which uses that ISR.  The problem I am having, is, I need
to pass-back a pointer address (ES:DI) for a block of data.  I assign the
values, but ES:DI does not seem to pass the values to the calling program.
For some reason it seems that they remain the same whether or not I set
them.  Is this a Borland Pascal quirk?  Does anybody have any ideas?

TIA!

Re:ISR Q: ES:DI not passing?


Quote
Luckyy wrote:

> I have written a program that installs an ISR and then launches an
> application which uses that ISR.  The problem I am having, is, I need
> to pass-back a pointer address (ES:DI) for a block of data.  I assign the
> values, but ES:DI does not seem to pass the values to the calling program.
> For some reason it seems that they remain the same whether or not I set
> them.  Is this a Borland Pascal quirk?  Does anybody have any ideas?

> TIA!

If you use the interrupt keyword in the procedure header, then all regs
are pushed and poped, which means that your assigned values will be
overwritten. I'm not sure how to avoid it, but maybe you could drop the
interrupt keyword and push 'n pop the reg's yourself(not including es, di
of coz).

procedure IntHandler; asm;
asm
   push ax
   push bx
   ...
   push ds
   mov ax, @data
   mov ds, ax

   ...

  { result int es:di }

   pop ds
   ...
   pop bx
   pop ax

   iret
end;

Well, I'm not positive. Try.

- Asbj?rn

Re:ISR Q: ES:DI not passing?


Quote
In article <325ff185.3756...@news.sover.net>, Luckyy <luc...@sover.net> wrote:
>I have written a program that installs an ISR and then launches an
>application which uses that ISR.  The problem I am having, is, I need

 [...]

If you are using the stock-standard header of
rocedure Interrupt (flags, cs, ip, ax,cx,dx,bx...:word); interrupt;  
then you will need to access the copies of ES, DI etc found in this
header, so that when the interrupt pops it's values off the stack at the
end of the interrupt they are correct.

Try posting some snippets, if this isn't your problem.

--

Quote
>:-P

Sam Vilain, diony...@sans.vuw.ac.nz
...And on the seventh day, He connected to the WWW and did nothing...

Other Threads