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.