From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c9d5fc258548b22a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!news.tornevall.net!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Thu, 03 Feb 2011 11:07:24 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: NNTP-Posting-Host: d250b876c7545a2f1cb96c280ac5fbf1 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: de9ae58494d76189d0c6fb247fdef37a X-Complaints-To: abuse@tornevall.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: X-UserIDNumber: 1738 X-Validate-Post: http://news.tornevall.net/validate.php?trace=de9ae58494d76189d0c6fb247fdef37a X-Complaints-Italiano: Non abbiamo padronanza della lingua italiana - se mandate una email scrivete solo in Inglese, grazie X-Posting-User: 0243687135df8c4b260dd4a9a93c79bd Xref: g2news2.google.com comp.lang.ada:17822 Date: 2011-02-03T11:07:24-07:00 List-Id: On 02/03/2011 01:08 AM, mockturtle wrote: > > I do not have any experience about this part of Ada, but maybe I can give you > a "pointer" to some bootstrapping information. Maybe you could want to use > an attribute representation clause for Vidmem'Address (see Section 13.3 of > the RM) . With some improvisation, I would write something like > > type Vidmem_Array is array (natural range<>) of Character; Vidmem : > Vidmem_Array (0 .. Max_Size); > > for Vidmem'Address use 16#000B_8000#; An address clause is the usual approach. If one is going to write to such memory, one probably doesn't care what the Ada runtime might do to initialize it, but if one is planning to read predefined information stored there, one probably wants to prevent any initialization through a pragma Import: pragma Import (Ada, Vidmem); System.Address is an implementation-defined type, and an address clause takes a value of that type. A universal integer may or may not be acceptable. Any such code is not portable. Other possibilities include Ada.Storage_IO (ARM A.9) and System.Address_To_Access_Conversions (ARM 13.7.2). Masochists (such as those who use C-family languages by choice) might want to use address arithmetic, found in System.Storage_Elements (ARM 13.7.1). Note that the quoted C code will happily read from memory not part of message and write to memory not part of vidmem; Ada will not. -- Jeff Carter "How'd you like to hide the egg and gurgitate a few saucers of mocha java?" Never Give a Sucker an Even Break 101