From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 25589 invoked from network); 19 Jun 1998 02:50:39 -0000 Received: from ppp0a037.std.com (HELO pentium.localnet) (@208.192.100.37) by mail2.redhat.com with SMTP; 19 Jun 1998 02:50:39 -0000 Received: from jrp.tiac.net (jrp@localhost [127.0.0.1]) by pentium.localnet (8.8.7/8.8.7) with ESMTP id VAA01551 for ; Thu, 18 Jun 1998 21:35:03 -0400 From: jrp@jrp.tiac.net Message-Id: <199806190135.VAA01551@pentium.localnet> Date: Thu, 18 Jun 1998 21:35:00 -0400 (EDT) Reply-To: jrp@jrp.tiac.net Subject: Re: Byte orders To: axp-list@redhat.com In-Reply-To: <199806152030.QAA04912@horizon.ess.sunysb.edu> MIME-Version: 1.0 Content-Type: TEXT/plain; CHARSET=US-ASCII On 15 Jun, Aakin N. Patel wrote: > I've managed to aquire a few binary data sets I need to work with, which > are in big-endian format. Does anyone know of a quick simple byte-swapping > utility that I can use to change the bytes around so that I can read the > data on my alphas? Unfortunately, this is a problem that can't be solved in the general case. The reason is how you swap depends on the format of your data. Character strings typically don't get swapped at all, longwords get swapped four bytes end-for-end, words get swapped two bytes end-for-end. Any program that seeks to swap your data around therefore has to know what data format it is to begin with. We studied this problem *very* closely when we implemented Freeport Express (the Sparc->Alpha translator), then concluded that there was no transform we could apply at translate time to the data segment of the executable. So yes, we swap on data accesses. (Not on *every* data access; our optimizer does a ton of analysis to determine when we have to swap and when we can get away without doing so...) -- Jim Paradis jrp@jrp.tiac.net "The early bird gets the worm. http://www.tiac.net/users/jrp/index.html If you want something else for breakfast, get up later."