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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8309f2bc055237c4 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Bit manipulation Date: 2000/11/13 Message-ID: <8up1j4$uqe$1@nnrp1.deja.com>#1/1 X-Deja-AN: 693091450 References: <8u8v6n$b7o$1@nnrp1.deja.com> <2WTH$pdrCfOd@eisner.decus.org> <8ub6kt$6nd$1@nnrp1.deja.com> <8ubeq8$cgm$1@nnrp1.deja.com> <3A0D38E9.BB87D8CD@mindspring.com> <8uoq5g$of6$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x64.deja.com:80 (Squid/1.1.22) for client 205.232.38.240 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Mon Nov 13 15:32:52 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-11-13T00:00:00+00:00 List-Id: In article , lutz@iks-jena.de (Lutz Donnerhacke) wrote: > GNAT can not compile it. Bit_Order can not be set. That is incorrect, as of version 3.13, GNAT implements the capability of setting Bit_Order in situations where this makes sense, including this one. > >Bit_Order confuses many people, since certainly it *sounds* > >as though it might do what you expected, but most certainly > >it does *not* do anything of the kind. > > Very bad. I would offer a perfect way to use the > representation clauses for > real world applications. But so they are nearly senseless. Not at all! Setting Bit_Order is quite valuable for some situations of endian independence. You are just confused about the purpose and semantics of this capability. The fact that it does not do what you want it to do does not make it senseless! A typical useful application is to specify the position of bits within a single byte as 8 record componens in a manner that is endian-independent. > >In fact the solution above is doubly wrong, because the use > >of unchecked > >conversion ensures that nothing actually happens at all! > > Sure? The return statment (with was wrong, because .data was > forgotten) > would generate a endianess prefix on reading the memory > location. This does the whole thing. (Using Alpha, Ia64, ...) Not evan vaguely. Like many people you are confusing byte endianness with bit order. I would recommend reading the section in my book on Microprocessors on this subject which is at least an attempt to sort this out. Note that a lot of people, including the designers and documenters of the 68K got confused on this issue. > >In any case, read the GNAT documentation to understand what the real > >situation here is. The operable sentence from the GNAT Reference Manual is > > > > In the case where the non-standard value is specified, the > > effect is to renumber bits within each bit, but the ordering > > of bytes is not affected. > > > >let alone ordering of bits!!!! > > We talk about bit ordering. We do indeed! The Bit_Order attribute in Ada talks ONLY about numbering of the bits, it does NOT provide a facility for reversing bits AT ALL! So that is why you should read the documentation carefully. Norman Cohen has also written a useful piece on Bit_Order, it is in one of the relevant AI's. Perhaps someone can give the reference. By the way, we find that helping people through the porting problems associated with switching endianness is a very common activity in our support efforts. One even has to wonder if the original questioner *really* wants to do what he says he wants to do. In my experience, most people who want to reverse bits, don't really want to, they are confused in the same way that Lutz was confused into thinking that endianness switching involves bit-reversal. of course there are legitimate requirements for bit order swaps in the communications area, but you have to wonder .... Sent via Deja.com http://www.deja.com/ Before you buy.