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,febd9e55846c9556 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-03 18:33:43 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!cyclone.bc.net!sjc70.webusenet.com!sjc72.webusenet.com!news.webusenet.com!newsfeed1.easynews.com!easynews.com!easynews!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3E641073.8030600@acm.org> From: Jeffrey Carter User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Endianness independance References: <5115eb96.0303010248.1b2b8d37@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 04 Mar 2003 02:33:48 GMT NNTP-Posting-Host: 63.184.32.157 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1046745228 63.184.32.157 (Mon, 03 Mar 2003 18:33:48 PST) NNTP-Posting-Date: Mon, 03 Mar 2003 18:33:48 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:34843 Date: 2003-03-04T02:33:48+00:00 List-Id: Stephen Leake wrote: > "Marin David Condic" writes: > > >>Well, but if hardware is not standardized, then why would you expect >>languages to be standardized? (With respect to data representations.) > > > The point is that Ada provides a _standard_, _single_ representation > clause that works for both kinds of hardware: > > -- Abstract : > -- > -- Define constants to reflect hardware bit and word endianness in > -- record representation clauses. Obviously, this file is highly > -- system-dependent. > -- > with System; > package SAL.Endianness is > pragma Pure; > > -- This is for gnat on a Mongoose processor > System_Name : constant System.Name := System.SYSTEM_NAME_GNAT; > > type Byte_Order_Type is (Big_Endian, Little_Endian); > Byte_Order : constant Byte_Order_Type := Big_Endian; > > -- The Mongoose documentation numbers bits with LSB = 0. However, > -- the byte order is Big_Endian, so the Ada compiler assumes bits > -- are numbered with MSB = 0, since that allows representation > -- clauses with fields that cross natural boundaries. > > Bit_Order : constant := -1; -- 1 or -1 > High_Bit_First : constant := 1; -- 0 or 1 > Low_Bit_First : constant := 0; -- 1 or 0 > > -- Use one of these, corresponding to the natural size of the > -- record you are laying out. > LSBit_8 : constant := 7; -- 0 or 7 > LSBit_16 : constant := 15; -- 0 or 15 > LSBit_32 : constant := 31; -- 0 or 31 > LSBit_56 : constant := 55; -- 0 or 55 > > end SAL.Endianness; You can make this system independent by using System.Default_Bit_Order, which, thanks to an AI (I don't remember which, but you can look it up) is static. -- Jeff Carter "If I could find a sheriff who so offends the citizens of Rock Ridge that his very appearance would drive them out of town ... but where would I find such a man? Why am I asking you?" Blazing Saddles