comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon.j.wright@mac.com>
Subject: Re: Enumeration representation clause surprise.
Date: Fri, 13 Jun 2008 06:49:09 +0100
Date: 2008-06-13T06:49:09+01:00	[thread overview]
Message-ID: <m23anhriju.fsf@mac.com> (raw)
In-Reply-To: 0120c799-fd71-41dc-bad1-c5e4f71c87f4@34g2000hsh.googlegroups.com

Mike Silva <snarflemike@yahoo.com> writes:

> On Jun 12, 4:52�pm, Simon Wright <simon.j.wri...@mac.com> wrote:

>> The only reason I have ever written representation clauses is to
>> ensure that the contents of raw memory are what some external
>> hardware (or software, eg at the other end of a network connection)
>> requires them to be.
>
> OK, I understand that - so how would you pass this raw memory to the
> external hardware or software?

Obtain the address to which the hardware registers are mapped (talking
VME here) & convert to a pointer to a structure which describes how
the hardware expects to see memory, then write through that pointer.

Or, for example, function To_Stream_Element here:

http://coldframe.cvs.sourceforge.net/coldframe/adasntp/SNTP.impl/sntp_support.adb?revision=1.4&view=markup

where I'm packing an unrepresented Status into a single byte for
transmission.

Nowadays I might do this using shift-and-mask to avoid messing with
endianness (this code has to work with Ada 95, even if the new 05
features would help).

>                                 And in this case, how did the use of
> biased representations ever get into compilers at all?  Is there any
> possible use of biased representations that does not fail the
> requirement you have established?

If I don't care how the compiler wedges the data into the record so
long as it's as small as possible (pragma Pack) then a biased rep
would be quite reasonable.



  reply	other threads:[~2008-06-13  5:49 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-11 11:38 Enumeration representation clause surprise Markus Schoepflin
2008-06-11 12:30 ` christoph.grein
2008-06-11 12:56   ` Markus Schoepflin
2008-06-11 13:08     ` christoph.grein
2008-06-11 13:28     ` Samuel Tardieu
2008-06-11 13:48       ` Markus Schoepflin
2008-06-11 13:56         ` Samuel Tardieu
2008-06-11 14:58       ` Adam Beneschan
2008-06-11 15:23         ` Markus Schoepflin
2008-06-12  2:37           ` Randy Brukardt
2008-06-12  2:37           ` Randy Brukardt
2008-06-11 15:56         ` Samuel Tardieu
2008-06-11 19:10           ` Adam Beneschan
2008-06-11 19:59             ` Niklas Holsti
2008-06-12  1:16               ` tmoran
2008-06-12  8:27                 ` christoph.grein
2008-06-12  8:45               ` Markus Schoepflin
2008-06-12 16:43                 ` Mike Silva
2008-06-12 18:41                   ` Markus Schöpflin
2008-06-12 20:10                     ` Mike Silva
2008-06-12 20:52                       ` Simon Wright
2008-06-12 23:36                         ` Mike Silva
2008-06-13  5:49                           ` Simon Wright [this message]
2008-06-13  7:21                       ` Keith Thompson
2008-06-13 13:31                         ` Mike Silva
2008-06-13 14:45                           ` Markus Schoepflin
2008-06-13 17:52                           ` Keith Thompson
2008-06-13  9:14                       ` Jean-Pierre Rosen
2008-06-12 19:05 ` richtmyer
2008-06-12 21:26   ` Samuel Tardieu
2008-06-12 22:42     ` Adam Beneschan
2008-06-13  7:11       ` Samuel Tardieu
2008-06-13  8:27       ` christoph.grein
2008-06-13 16:21         ` Adam Beneschan
2008-06-15 19:33           ` Robert A Duff
2008-06-16 14:50             ` Adam Beneschan
2008-06-16 19:18               ` Robert A Duff
2008-06-17  6:03               ` christoph.grein
2008-06-17  7:22                 ` christoph.grein
2008-06-13  8:24     ` Peter Hermann
2008-06-13 14:47       ` Samuel Tardieu
2008-06-14 11:48         ` John B. Matthews
replies disabled

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