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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,610e53a911ec64b3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-24 12:28:07 PST Path: nntp.gmd.de!news.rwth-aachen.de!news.rhrz.uni-bonn.de!news.uni-stuttgart.de!rz.uni-karlsruhe.de!xlink.net!howland.reston.ans.net!gatech!udel!news.mathworks.com!uunet!intrepid.intrepid.com!usenet From: vladimir@speedy.intrepid.com (Vladimir Vukicevic) Newsgroups: comp.lang.ada Subject: Re: Importing C Structures Date: 24 Mar 1995 08:51:29 GMT Organization: Intrepid Technology, Inc. Message-ID: References: <3kr4q3$jd9@newsflash.concordia.ca> <3ksg66$h1c@newssvr.cacd.rockwell.com> NNTP-Posting-Host: speedy.intrepid.com In-reply-to: rswhite@cacd.rockwell.com's message of 23 Mar 1995 18:55:02 GMT Date: 1995-03-24T08:51:29+00:00 List-Id: In article <3ksg66$h1c@newssvr.cacd.rockwell.com> rswhite@cacd.rockwell.com (Robert S. White) writes: > Do you have a clean way to handle hardware registers that have one > meaning when you read them and another when you write to them with > nice seperate names for each type of usage? I know "use at" for > Ada 83 can overide this but it seems to be not in the spirit of > the 83 LRM; > 13.5 "Address clauses should not be used to achieve overlays of > objects...Any program using address clauses to achieve > such effects is erroneous." > A work around is to have a dual meaning name for the register and > use one procedure, appropriately named, to write to it and a function, > again with a suitable name, for reading it. There is no such clause in the Ada 95 LRM... the "Erroneous Execution" section for using a X'Address representation clause (13.3 (13)) states: If an Address is specified, it is the programmer's responsibility to ensure that the address is valid; otherwise, program execution is erroneous. So, it is perfectly valid to use the same 'Address for two objects, as long as the Address you specify is valid :-) > This is a case where C programmers use the union structure. I > confess that I have not ferreted out in the Ada 95 RM or Rational > the right (and very concise) way to do this now. > > Recommendations? Something like this (in Ada 95): Input_Register : Integer; for Input_Register'Address use System.Storage_Elements.To_Address (16#0020); Output_Register : Integer; for Output_Register'Address use System.Storage_Elements.To_Address (16#0020); This is perfectly valid and within the spirit of the 95 LRM. - Vladimir