From: anon@anon.org (anon)
Subject: Re: copying data between memory locations
Date: Wed, 05 Sep 2007 04:39:55 GMT
Date: 2007-09-05T04:39:55+00:00 [thread overview]
Message-ID: <vqqDi.68416$ax1.3448@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: 1188809968.217323.145640@r29g2000hsg.googlegroups.com
-------------------------------------------
pragma Ada_83 ; -- limit GNAT to Ada 83. --
-------------------------------------------
with Interfaces ;
with System ;
procedure ytest is
function Read_Memory ( Addr : System.Address )
return Interfaces.Unsigned_8 is
begin -- Read_Memory
declare
Mem : Interfaces.Unsigned_8 ;
for Mem'Address use Addr ;
begin
return Mem ;
end ;
end Read_Memory ;
procedure Write_Memory ( Addr : System.Address ;
Data : Interfaces.Unsigned_8 ) is
begin -- Write_Memory
declare
Mem : Interfaces.Unsigned_8 ;
for Mem'Address use Addr ;
begin
Mem := Data ;
end ;
end Write_Memory ;
begin -- ytest
null ;
end ytest ;
--
-- I think you can modify the code to fit your needs for records
--
In <1188809968.217323.145640@r29g2000hsg.googlegroups.com>, jef.mangelschots@gmail.com writes:
>In our current design, we have a package that maintains a list of
>descriptors of various buffers in the application. We don't want to
>know their datatypes or how to write data into them. We only want to
>maintain a physical address of them and use that address to directly
>write data into these buffers (this data comes out incoming packets
>over the network).
>
>In C, this is very straightforward and use the address as a pointer
>and simply copy the packet into the memory location.
>I can't figure out a way to do this in Ada (at least not Ada83).
>
>suppose the following:
>
>type BUFFER_DETAILS_RECORD is
>record
> num_bytes : integer;
> start_address : system.address;
>end record;
>type BUFFER_DETAILS_ARRAY_TYPE is array(1..2) of
>BUFFER_DETAILS_RECORD;
>BUFFER_DETAILS : constant BUFFER_DETAILS_ARRAY_TYPE :=
>BUFFER_DETAILS_ARRAY_TYPE'(1 => (num_bytes => 100, start_address =>
>16#123# ), 1 => (num_bytes => 200, start_address => 16#456# ));
>
>procedure insert_block(idx : in integer; num_bytes : in integer;
>offset : in integer; data : BYTE_ARRAY_TYPE) is
>begin
> ??? how do I copy the content of data into the memory pointed to by
>BUFFER_DETAILS(idx).start_address + offset
>end;
>
prev parent reply other threads:[~2007-09-05 4:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-03 8:59 copying data between memory locations jef.mangelschots
2007-09-03 10:38 ` Martin Krischik
2007-09-04 15:57 ` Adam Beneschan
2007-09-04 18:16 ` jef.mangelschots
2007-09-04 20:12 ` Jeffrey R. Carter
2007-09-03 11:09 ` Niklas Holsti
2007-09-03 16:26 ` Steve
2007-09-03 17:22 ` Jeffrey R. Carter
2007-09-04 11:31 ` Stephen Leake
2007-09-05 4:39 ` anon [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox