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,13f10cac2d21b84f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-02 06:58:26 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.utk.edu!washdc3-snf1!washdc3-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3CD145A5.214C67E8@raytheon.com> From: Mark Johnson X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Is this a GNAT bug??? References: <3CC992D6.A87A3443@raytheon.com> <5ee5b646.0204291844.21d7f5f0@posting.google.com> <3CCF12E9.6CA14A29@raytheon.com> <3cd06b13.12244473@news.blueyonder.co.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 02 May 2002 08:56:53 -0500 NNTP-Posting-Host: 192.27.48.39 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 1020347905 192.27.48.39 (Thu, 02 May 2002 08:58:25 CDT) NNTP-Posting-Date: Thu, 02 May 2002 08:58:25 CDT Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:23408 Date: 2002-05-02T08:56:53-05:00 List-Id: Nick Roberts wrote: > > On Tue, 30 Apr 2002 16:55:53 -0500, Mark Johnson > 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