Board index » delphi » Direct Memory Acces

Direct Memory Acces

Hi there,

I'm using Delphi 2.0 and I have a problem directly accessing a memory
location ($0300). Under Win32 it is not possible to refer to this address to
get some data. I need this because I must read data from an ISA interface
board which gets data from a machine and puts this data on that location.
Under Delphi 1.0 I used 'Portw[ $0300 ] ' to access this address but this is
no longer possible under Delph 2.0. I tried to use 'absolete' but the
compiler! generates an error that this is 'not done' under Win32.

Is there a simple or tricky sollution to this problem or should I stay with
Delphi 1.0 (Win16).

Greetings,

Martin Joon. (The Netherlands, Email:mj...@caiw.nl)

 

Re:Direct Memory Acces


Quote
> Martin Joon <mj...@caiw.nl> wrote in article <31E4084F.7...@caiw.nl>...
> I'm using Delphi 2.0 and I have a problem directly accessing a memory
> location ($0300). Under Win32 it is not possible to refer to this
address to
> get some data. I need this because I must read data from an ISA
interface
> board which gets data from a machine and puts this data on that
location.
> Under Delphi 1.0 I used 'Portw[ $0300 ] ' to access this address but
this is
> no longer possible under Delph 2.0. I tried to use 'absolete' but the
> compiler! generates an error that this is 'not done' under Win32.

> Is there a simple or tricky sollution to this problem or should I stay
with
> Delphi 1.0 (Win16).

First off, absolute memory address $0300 is not the same as
PortW[$0300]...  Aside from that, neither direct memory access or Port
access is valid under 32 bits.  You will need to write a device driver to
access this port (device drivers are allowed to do such things) and give
the info to your program when it asks for it.  Or, stick with 16 bit
apps...  Hmm, supposedly you can 'thunk' a 16 bit DLL so that you can get
at it from a 32 bit app.  Perhaps you could write a 16 bit DLL to get this
info, then 'thunk' it for use with your 32 bit app...  (Don't ask me HOW
though, I don't know!)

--
David S. Becker
ADP Dealer Services (Plaza R&D)
mailto:d...@plaza.ds.adp.com
(503)402-3236

Re:Direct Memory Acces


Quote
Martin Joon wrote:

> Hi there,

> I'm using Delphi 2.0 and I have a problem directly accessing a memory
> location ($0300).

Under Delphi 2.0 and Win95:

procedure SetPort(address,value:Word);
var bvalue:byte;
begin
   bvalue:=trunc(value and 255);
   asm
      mov dx,address
      mov AL,bvalue
      out DX,AL
   end;
end;

function GetPort(address:Word):Word;
var bvalue:byte;
begin
   asm
   mov dx,address
   in aL,dx
   mov bvalue,aL
   end;
   result:=bvalue;
end;

and then use as
var i,j:word;
begin
   Setport(i,j);
   j:=GetPort(i);
end;

HTH
Brian

Re:Direct Memory Acces


H|!

Quote
>First off, absolute memory address $0300 is not the same as
>PortW[$0300]...  Aside from that, neither direct memory access or Port
>access is valid under 32 bits.  You will need to write a device driver to
>access this port (device drivers are allowed to do such things) and give
>the info to your program when it asks for it.  Or, stick with 16 bit
>apps...  Hmm, supposedly you can 'thunk' a 16 bit DLL so that you can get
>at it from a 32 bit app.  Perhaps you could write a 16 bit DLL to get this
>info, then 'thunk' it for use with your 32 bit app...  (Don't ask me HOW
>though, I don't know!)

I think that you can read from ports and write to them through direct assembler
commands. I haven't tested that, but I know that you can use assembler in
DELPHI 32-Bit(in ASM END; block).

                                           SBR.
---
Bu...@stk.ksu.ras.ru
{Excuse me please for my bad russian, my native language is DELPHI 32-bit}

Other Threads