comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Johnson <Mark_H_Johnson@Raytheon.com>
Subject: Re: Size and pack
Date: Thu, 11 Oct 2001 08:20:15 -0500
Date: 2001-10-11T08:20:15-05:00	[thread overview]
Message-ID: <3BC59C8E.BADA210D@Raytheon.com> (raw)
In-Reply-To: 3bc55ea1.3939494@news.demon.co.uk

John McCabe wrote:

> On 10 Oct 2001 23:24:27 -0700, byhoe@greenlime.com (Adrian Hoe) wrote:
> [snip]

> You may need to be concerned about endianness- although there is
> a 'Bit_Order attribute, in my experience a compiler is unlikely to
> allow you to specify a bit order that is contrary to its native
> ordering.

Since Bit_Order is described in Chapter 13, all compilers should support
it. However, the way GNAT (and perhaps other compilers) implement this is
not the way I expected it. I expected on an Intel PC (little endian) when
you say...
  for T'Bit_Order use System.High_Order_First;
on a data type that has 'Size=32, that bit zero is the most significant bit
(as it would be on an big endian sgi). That is NOT true. Bit zero is the
MSB of byte zero (the least significant byte) of a four byte value.

Basically, the storage place attributes ('Position, 'First_Bit, 'Last_Bit)
are generated after normalizing the values so that 'First_Bit is less than
Storage_Unit. So something like...
 for C at 0 range 24..24;
with Storage_Size =8, you compute 'Position=3, 'First_Bit=0, 'Last_Bit=0.
This is the most significant bit in a 32 bit value if you applied
High_Order_First to the bit order.

[sigh]

It is a pain to define structures that are portable between both big and
little endian machines. Almost as big a pain as the related byte swapping
that is often needed. If someone wants a more detailed explanation of what
we found w/ this, I suggest starting a new thread.
  --Mark





  reply	other threads:[~2001-10-11 13:20 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-10  8:05 Size and pack Adrian Hoe
2001-10-10  8:59 ` Alfred Hilscher
2001-10-10  9:50   ` John McCabe
2001-10-11  6:36     ` Adrian Hoe
2001-10-11  8:55       ` John McCabe
2001-10-31  1:53         ` Robert Dewar
2001-10-31  1:50     ` Robert Dewar
2001-10-31  9:17       ` John McCabe
2001-10-31 11:58       ` Jeff Creem
2001-11-01  1:58         ` Adrian Hoe
2001-11-01  2:34           ` Jeff Creem
2001-11-01 14:58             ` Marin David Condic
2001-11-01  3:53           ` Matthew Heaney
2001-11-01 18:37             ` Jeff Creem
2001-11-02  3:39               ` Robert Dewar
2001-11-01  3:45         ` Jeffrey Carter
2001-11-01  6:00         ` Robert Dewar
2001-10-10  9:24 ` Pi
2001-10-10  9:27 ` Lutz Donnerhacke
2001-10-11  6:24   ` Adrian Hoe
2001-10-11  8:58     ` John McCabe
2001-10-11 13:20       ` Mark Johnson [this message]
2001-10-11 16:23         ` John McCabe
2001-10-11 16:00           ` Pat Rogers
2001-10-12  8:37             ` John McCabe
2001-10-28  1:30         ` Robert Dewar
2001-10-11  9:30     ` Lutz Donnerhacke
2001-10-11 10:12 ` Vincent Smeets
2001-10-11 10:19   ` Lutz Donnerhacke
2001-10-11 11:18     ` David C. Hoos, Sr.
2001-10-11 12:06       ` Lutz Donnerhacke
2001-10-11 13:49 ` Ted Dennison
2001-10-26  4:00 ` Smark
2001-10-26  6:14   ` tmoran
2001-10-26 17:51     ` Smark
2001-10-26 23:21       ` Jeffrey Carter
2001-10-26 23:39       ` tmoran
2001-10-29  1:01         ` Adrian Hoe
2001-10-29  2:21           ` tmoran
2001-10-29 10:42             ` Adrian Hoe
2001-10-29 23:15               ` tmoran
2001-10-29  9:52         ` Lutz Donnerhacke
2001-10-29 10:29           ` Larry Kilgallen
2001-10-29 10:50             ` Lutz Donnerhacke
2001-10-29 11:12               ` Larry Kilgallen
2001-10-31  2:02                 ` Robert Dewar
2001-10-31  2:00               ` Robert Dewar
2001-10-31  2:51                 ` Larry Kilgallen
2001-10-31  1:59           ` Robert Dewar
2001-10-31  1:57       ` Robert Dewar
2001-10-31  1:55   ` 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