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-Thread: 103376,90212413571e3e8b X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!uio.no!fi.sn.net!newsfeed1.fi.sn.net!news.song.fi!not-for-mail Date: Sat, 15 Mar 2008 14:22:36 +0200 From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20060628 Debian/1.7.8-1sarge7.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Endian-problem/bug with system.bit_ops (gnat3.15)... References: <47DB8194.62FE76B0@baigar.de> In-Reply-To: <47DB8194.62FE76B0@baigar.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <47dbbacc$0$23854$4f793bc4@news.tdc.fi> Organization: TDC Internet Services NNTP-Posting-Host: laku61.adsl.netsonic.fi X-Trace: 1205582540 news.tdc.fi 23854 81.17.205.61:32907 X-Complaints-To: abuse@tdcnet.fi Xref: g2news1.google.com comp.lang.ada:20416 Date: 2008-03-15T14:22:36+02:00 List-Id: Erik Baigar wrote: > Dear Ada users, > > in porting an application from Meridian's Ada83 to gnat3.15 I > encountered some issues with the system.bit_ops... > > Bit_And ( MEMORY (OPERAND_ADDRESS)'Address,18, ACCUMULATOR'Address,18, > ACCUMULATOR'Address); > > ... This code works well > on the Intel (little endian) platform but fails on SPARC (big endian). > It required some investigation to locate the problem, but replacing > the length 18 by 32 (all are integers here), i.e. using > > Bit_And ( MEMORY (OPERAND_ADDRESS)'Address,32, ACCUMULATOR'Address,32, > ACCUMULATOR'Address); > > solved the problem and the code now runs on little and big endian > systems. Anything that accesses a variable using Variable'Address but then operates only on a part of the variable (eg. 18 bits of a 32-bit variable) sounds very likely to have problems with endianness, if the storage unit is smaller than the size of the variable. Did you have a question to ask, or did you just want to report this problem and your solution? I think that your program could be made more portable by avoiding 'Address (and, of course, System.Bit_Ops) and using instead modular types (not available in Ada83) and their predefined bitwise "and" and "or" operations. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .