Board index » delphi » What's wrong here (Intr in PM)?

What's wrong here (Intr in PM)?

Hi again,

I've got another (dumb?) question:
I'm trying to gather information on MCBs, i.e. programs in memory.
That's working fine in real mode, but hangs right in the following
routine:

{**********************************************************************}
 Function FirstMcb : Pointer; assembler;
{-----------------} {-------}
Asm { get address of  first MCB  }
    mov ah, 52h
    int 21h
    mov dx, es:[bx-2]
    xor ax, ax
End;
{**********************************************************************}

I think the problem is the call of the interrupt. Unfortuantely I don't
know what exactly is wrong.
Can anyone help me??

Thanx in advance.

Greetings

   Bernd Heutling

 

Re:What's wrong here (Intr in PM)?


Quote
Bernd Heutling wrote:
> I'm trying to gather information on MCBs, i.e. programs in memory.
> That's working fine in real mode, but hangs right in the following
> routine:

> {**********************************************************************}
>  Function FirstMcb : Pointer; assembler;
> {-----------------} {-------}
> Asm { get address of  first MCB  }
>     mov ah, 52h
>     int 21h
>     mov dx, es:[bx-2]
>     xor ax, ax
> End;
> {**********************************************************************}

> I think the problem is the call of the interrupt. Unfortuantely I don't
> know what exactly is wrong.

You don't need assembler for this at all.  Using the "MsDOS" system call
will save and restore registers for you.  Try:

uses DOS;
function FirstMcb : Pointer;
  type
    wptr = ^word;
  var
    regs: registers;
  begin
    regs.ah := $52;
    MsDOS(regs);
    FirstMCB := ptr(wptr(ptr(regs.es,regs.bx))^,0);
  end;

Note: I tried this in Protect Mode.  It doesn't hang the machine, but
it does generate a Runtime Error 216 (general protection fault).
Perhaps DPMI does not support this DOS call in Protect Mode?

     - Rich

Re:What's wrong here (Intr in PM)?


Quote
Bernd Heutling wrote:
> Hi again,

> I've got another (dumb?) question:
> I'm trying to gather information on MCBs, i.e. programs in memory.
> That's working fine in real mode, but hangs right in the following
> routine:

> {**********************************************************************}
>  Function FirstMcb : Pointer; assembler;
> {-----------------} {-------}
> Asm { get address of  first MCB  }
>     mov ah, 52h
>     int 21h
>     mov dx, es:[bx-2]
>     xor ax, ax
> End;
> {**********************************************************************}

> I think the problem is the call of the interrupt. Unfortuantely I don't
> know what exactly is wrong.
> Can anyone help me??

Not all real mode interrupts can be called directly from protected mode, and
those that require explicit memory addresses will just about never work
because the addressing schemes are different (since protected mode doesn't use
physical addresses like real mode does).

You'll have to use int 31h, ax=0300h to call the interrupt.  Of course, any
memory references will be grounded in real mode, so you'll also need to alias
the real mode segment to a valid selector before you can reference the
location in memory.  There might be a function in WinAPI that does this,
otherwise you'll have to use another int 31h call (I forget offhand which
one).  If you have Ralf Brown's Interrupt List handy, the PM interrupts will
be documented.  You could also locate a copy of the DPMI 0.9 specification,
which should also have the same info.

Quote
> Thanx in advance.

> Greetings

>    Bernd Heutling

--
Scott Earnest            | SPAM protection in effect. Remove  |
setech@_ix.netcom.com    | "_" as needed for true addresses.  |
earnests@_homenet.lm.com |    UIN:1136443  EFnet:pale_blue    |
sinykal@_{*word*104}space.org  | URL: http://www.netcom.com/~setech |

Other Threads