comp.lang.ada
 help / color / mirror / Atom feed
From: vladimir@speedy.intrepid.com (Vladimir Vukicevic)
Subject: Re: Importing C Structures
Date: 24 Mar 1995 08:51:29 GMT
Date: 1995-03-24T08:51:29+00:00	[thread overview]
Message-ID: <VLADIMIR.95Mar24005132@speedy.intrepid.com> (raw)
In-Reply-To: rswhite@cacd.rockwell.com's message of 23 Mar 1995 18:55:02 GMT

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



  reply	other threads:[~1995-03-24  8:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-23  6:34 Importing C Structures Chris O'Regan
1995-03-23  7:55 ` Vladimir Vukicevic
1995-03-23 18:55   ` Robert S. White
1995-03-24  8:51     ` Vladimir Vukicevic [this message]
1995-03-25  9:57       ` Keith Thompson
1995-03-26 13:16         ` Larry Kilgallen, LJK Software
1995-03-27  0:00           ` Kevin F. Quinn
1995-04-07  0:00             ` Larry Kilgallen
1995-03-27 15:35           ` Theodore Dennison
1995-03-28  0:00             ` Robert Dewar
1995-03-28 11:44             ` Keith Thompson
1995-03-29  0:00               ` misattrubation (was: Re: Importing C Structures) Theodore Dennison
1995-03-31  0:00                 ` Theodore Dennison
1995-03-27 23:39           ` Importing C Structures Keith Thompson
1995-03-27 16:00       ` Norman H. Cohen
1995-03-24 16:08     ` Robert I. Eachus
1995-03-24 20:20     ` Bob Gilbert
1995-03-25 18:07     ` Robert Dewar
1995-03-24 17:30   ` Robert Dewar
1995-03-24 15:32 ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox