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,91e38895ea853f4b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-26 10:09:11 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-FFM2.ecrc.net!news.iks-jena.de!lutz From: lutz@iks-jena.de (Lutz Donnerhacke) Newsgroups: comp.lang.ada Subject: Re: Query on portable bit extraction Date: Fri, 26 Oct 2001 17:08:31 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: <3BD99406.62B13405@Raytheon.com> NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1004116111 11416 217.17.192.37 (26 Oct 2001 17:08:31 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Fri, 26 Oct 2001 17:08:31 +0000 (UTC) User-Agent: slrn/0.9.6.3 (Linux) Xref: archiver1.google.com comp.lang.ada:15265 Date: 2001-10-26T17:08:31+00:00 List-Id: * Mark Johnson wrote: >We have code that we want to run on both a big (sgi) and little (pc) >endian machine. As an example, the layout of the data in memory is... >[big_endian bit order] >Byte 0 1 2 3 4 5 6 7 >21 - X X X Y Y Y Y Y >22 - Y Y Z Z Z Z Z Z >where we need to extract XXX as the "wait code", YYYYYYY as the "value", >and ZZZZZZ is a pad area (don't care). >Thinking of records & representation specifications, I'd like to be able >to do something like this... > subtype Wv is Natural range 0..7; > subtype Vv is Natural range 0..127; > subtype Pv is Natural range 0..63; > type Wait_Value is > record > Wait : Wv; > Value : Vv; > Pad : Pv; > end record; > for Wait_Value use > record > Wait at 0 range 0..2; > Value at 0 range 3..9; > Pad at 1 range 2..7; > end record; > for Wait_Value'Bit_Order use System.High_Order_First; Incorrect code: Value does cross a Storage_Element boundary. Split it into two parts and combine them later. Example: http://www.iks-jena.de/mitarb/lutz/ada/net/ --> i.e. IPV4 Header >which looks pretty reasonable until I get the following GNAT error >messages on the PC... > error: attempt to specify non-contiguous field not permitted > error: (caused by non-standard Bit_Order specified) Correct. for xx'Bit_Order use ... does only define the direction of counting. It does not swap or correct alignments. >somewhere, I recode the representation specification to be... > for Wait_Value use > record > Wait at 1 range 5..7; > Value at 0 range 6..12; > Pad at 0 range 0..5; > end record; >(assuming System.Low_Order_First bit order) which works as expected. On both systems? Very strange.