Board index » delphi » How to grab 21 interrrput

How to grab 21 interrrput

Anyone who can halp me to grab a 21h interrupt in Pascal. It's very
important to me.
Please contact me. My e-mail address is pawc...@polbox.com

Pawciu M...

 

Re:How to grab 21 interrrput


Quote
Pawcia wrote:

> Anyone who can halp me to grab a 21h interrupt in Pascal. It's very
> important to me.
> Please contact me. My e-mail address is pawc...@polbox.com

Are you going to handle all the DOS interrupt by yourself? (Nay...most
probably not) You can try the GetIntVec and SetIntVec functions to get
and set the address of INT21h yourself.

Here's a sample code:

Uses Dos;

Var OldInt21h : Pointer; { Pointer to save INT21h interrupt vector }

Procedure MyInt21h; Interrupt; { Declare function as an Interrupt }
Begin
   {... Your code here ...}
End;

Begin
   GetIntVec($21, OldInt21h);           { Save original INT21h vector }
   SetIntVec($21, Addr(MyInt21h));      { Set INT21h to your own interrupt
function }
   { ... do your things ... }
   SetIntVec($21, OldInt21h);           { Remember to restore the original
vector!! }
End.

Hope that helps.

Regards,
WB Pao

--
It's always good to have a computer beside you.
You can play, work and sleep with it.

email: nirv...@cynosure.com.sg

Re:How to grab 21 interrrput


Quote
Pawcia wrote:
> Anyone who can halp me to grab a 21h interrupt in Pascal?
Pao Wee Boon wrote:
> Uses Dos;

> Var OldInt21h : Pointer; { Pointer to save INT21h interrupt vector }

> Procedure MyInt21h; Interrupt; { Declare function as an Interrupt }
> Begin
>    {... Your code here ...}
> End;

> Begin
>    GetIntVec($21, OldInt21h);           { Save original INT21h vector }
>    SetIntVec($21, Addr(MyInt21h));      { Set INT21h to your own interrupt
> function }
>    { ... do your things ... }
>    SetIntVec($21, OldInt21h);           { Remember to restore the original
> vector!! }
> End.

This isn't going to work- INT $21 returns information in the FLAGS,
whereas the Interrupt directive always produces an IRET instruction
(which restores the flags at the end).

Trapping INT $21 is messy; you have to write the new handler in ASM
to get the correct behaviour. The secret is the RETF 2 instruction
at the end, which performs a FAR RETURN and cleans the next two bytes
(the old flags) off the stack.

Chris.

Other Threads