comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Johnson <mark_h_johnson@raytheon.com>
Subject: Re: Is this a GNAT bug???
Date: Thu, 02 May 2002 08:56:53 -0500
Date: 2002-05-02T08:56:53-05:00	[thread overview]
Message-ID: <3CD145A5.214C67E8@raytheon.com> (raw)
In-Reply-To: 3cd06b13.12244473@news.blueyonder.co.uk

Nick Roberts wrote:
> 
> On Tue, 30 Apr 2002 16:55:53 -0500, Mark Johnson
> <mark_h_johnson@raytheon.com> wrote:
> [both examples snipped]
> 
> Am I actually correct?

I believe so, but I am not sure what you are trying to show with your
examples - the values as loaded into a register? I was showing the in
memory representation of the data for the two byte orders. Note that it
takes different code to solve the "equivalence problem" for in memory
and in register representations.

If you were trying to show the in register data (as an 8, 16, and 32 bit
value) I suggest a different layout of the data to make it more clear to
the reader. Something like...

Big endian (Bit_Order == System.High_Order_First)
16 bit value...
Byte 00000000 11111111
Bit  01234567 01234567
Ind  00000000 00111111
-ex  01234567 89012345

32 bit value...
Byte 00000000 11111111 22222222 33333333
Bit  01234567 01234567 01234567 01234567
Ind  00000000 00111111 11112222 22222233
-ex  01234567 89012345 67890123 45678901

Little endian (Bit_Order == System.Low_Order_First)
16 bit value...
Byte 11111111 00000000 
Bit  76543210 76543210
Ind  11111100 00000000
-ex  54321098 76543210

32 bit value...
Byte 33333333 22222222 11111111 00000000 ...
Bit  76543210 76543210 76543210 76543210 ...
Ind  33222222 22221111 11111100 00000000 
-ex  10987654 32109876 54321098 76543210 

Which more clearly shows that the bytes are swapped when the data from
memory is loaded into a register and shows the relative position (2^n as
you described) of each bit within the 16 or 32 bit value. For example,
on a big endian machine index 0 is the most significant bit and on a
little endian machine it is the least significant bit.

For problems where you interface with C programs - values are often
represented in header files as bits shifted so this way of looking at
the problem is often better. However, many Ada programs must be able to
read a stream of bytes and manipulate the data in those streams. In
those cases the in memory way of looking at the problem tends to be
better.
  --Mark



  reply	other threads:[~2002-05-02 13:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-26 16:36 Is this a GNAT bug??? Robert Quinn
2002-04-26 17:48 ` Mark Johnson
2002-04-26 22:20   ` Robert Dewar
2002-04-29 15:45   ` Robert Quinn
2002-04-30  2:44     ` Robert Dewar
2002-04-30 14:15       ` Larry Kilgallen
2002-04-30 16:41       ` Robert Quinn
2002-04-30 18:20         ` tmoran
2002-05-01  1:31           ` Robert Quinn
2002-05-01 17:08             ` Ted Dennison
2002-05-02  1:55               ` Larry Kilgallen
2002-05-02 14:04                 ` Mark Johnson
2002-05-02 15:25                   ` Larry Kilgallen
2002-04-30 21:55         ` Mark Johnson
2002-05-01 22:59           ` Nick Roberts
2002-05-02 13:56             ` Mark Johnson [this message]
2002-05-02 20:19               ` Nick Roberts
2002-05-02 21:55                 ` Mark Johnson
  -- strict thread matches above, loose matches on Subject: below --
2003-09-20 22:50 Is this a gnat bug? Waldek Hebisch
2003-09-20 23:09 ` Ludovic Brenta
2003-09-21  2:37 ` Waldek Hebisch
replies disabled

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