Board index » delphi » DPMI: Direct memory access

DPMI: Direct memory access

Hi everybody,

How can I (using Delphi 1.0) access memory directly? I have to access an
expansion card which read memory $C800 - $C9FF. I understood that
accessing this memory under protected mode is done via selectors but I
don't know how to do this. An example would be great...

Please respond also by mail if possible.

Many Thancks

Jo Van Geite
j...@ficsgrp.com

 

Re:DPMI: Direct memory access


Jo Van Geite <jo.vange...@ficsgrp.com> wrote:

Quote
>How can I (using Delphi 1.0) access memory directly? I have to access an
>expansion card which read memory $C800 - $C9FF. I understood that
>accessing this memory under protected mode is done via selectors but I
>don't know how to do this. An example would be great...

The "Mem", "MemW" and "MemL" special arrays are used to access memory in
general.  The more difficult part of your question is how to access
specific physical memory areas.

It turns out the Windows kernel exports symbols which map to the protect
mode selectors for the segments at 0000, 0040, A000, B000, B800, C000,
D000, E000 and F000.  Delphi already defines a few of these, but it's not
hard to add the others.

Here, I even tested this code, on NT no less.  You could easily modify this
to have the function below return a pointer instead, which you could cast
as required.

---

procedure __C000H; far; external 'KERNEL' index 195;

{ SelC000 returns the protect mode selector for physical segment C000. }

function SelC000: integer; assembler;
asm
         MOV   AX, offset __C000H
end;

procedure TForm1.FormClick(Sender: TObject);
begin
  ShowMessage(IntToHex(SelC000, 4));
  { This statement prints the 4 bytes at C000:8000, which is the same
    as C800:0000. }
  ShowMessage(IntToHex(MemL[SelC000:$8000], 8));
end;

end.

- Tim Roberts, t...@probo.com
  Providenza & Boekelheide, Inc.

Re:DPMI: Direct memory access


How about I do you one better and give you a complete solution of mine?
:-)  Attached you will find a unit which makes such memory access very
simple.  If you are familiar with the normal Mem[], MemW[] or MemL[]
functions for accessing memory, simply add my REALMODE unit to your uses
clause and then do RealMem.Mem[], RealMem.MemW[], or RealMem.MemL[] --
almost like you normally would!  The one difference is that while you would
normally do Mem[$C800:$0000] you have to now do RealMem.Mem[$C800,$0000].
(Note the comma instead of a semicolon -- the compiler won't let you use
semicolons in you own code...)  Pretty easy, huh?

--
David S. Becker
ADP Dealer Services (Plaza R&D)
d...@plaza.ds.adp.com
(503)402-3236
 Jo Van Geite wrote in article <33B9F385.5...@ficsgrp.com>...

Quote
>Hi everybody,

>How can I (using Delphi 1.0) access memory directly? I have to access an
>expansion card which read memory $C800 - $C9FF. I understood that
>accessing this memory under protected mode is done via selectors but I
>don't know how to do this. An example would be great...

>Please respond also by mail if possible.

>Many Thancks

>Jo Van Geite
>j...@ficsgrp.com

begin 666 realmode.pas
<uuencoded_portion_removed>
Quote
>;V-E9'5R92!F;W(@8VQE86X@=7 @?0T*96YD+@T*

`
end

Other Threads