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 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: "Martin Dowie" Subject: Re: Bit manipulation Date: 2000/11/14 Message-ID: <3a110356$1@pull.gecm.com>#1/1 X-Deja-AN: 693410005 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> <8up1j4$uqe$1@nnrp1.deja.com> X-Trace: 14 Nov 2000 09:18:14 GMT, superted.dsge.edinbr.gmav.gecm.com X-MSMail-Priority: Normal X-Priority: 3 Newsgroups: comp.lang.ada X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Date: 2000-11-14T00:00:00+00:00 List-Id: er, you realize that the "'Bit_Order" here is unnecessary? try it - it will make no difference if you comment them out (or make them the same) as they simply provide a way of referencing bits (i.e. High_Order_First = bit(0)MSB, Low_Order_First = bit(0)LSB) and you don't reference any bit positions! What you have tried to acheive by the use of 'Bit_Order, you have done by actually doing the assignments. 'Bit_Order played no part. Lutz Donnerhacke wrote in message news:slrn9104p4.l5.lutz@taranis.iks-jena.de... [snip] > with Ada.Unchecked_Conversion; > with System; > > procedure endian is > type word8 is mod 2**8; > type word32 is mod 2**32; > type composite is array (1..4) of word8; > pragma Pack(composite); > > type lowrec is record val: composite; end record; > type highrec is record val: composite; end record; > for lowrec'Bit_Order use System.Low_Order_First; > for highrec'Bit_Order use System.High_Order_First; > > function w32tohigh is new Ada.Unchecked_Conversion(word32, highrec); > function lowtow32 is new Ada.Unchecked_Conversion(lowrec, word32); > > function h2l32 (h : word32) return word32 is > hr : highrec := w32tohigh (h); > lr : lowrec; > begin > lr.val(1) := hr.val(4); > lr.val(2) := hr.val(3); > lr.val(3) := hr.val(2); > lr.val(4) := hr.val(1); > return lowtow32 (lr); > end h2l32; > begin > null; > end endian;