Article View: gnu.gcc.help
Article #53352Byte Order test
From: henryf
Date: Mon, 10 Feb 1992 19:23
Date: Mon, 10 Feb 1992 19:23
40 lines
1561 bytes
1561 bytes
We're trying to write code that takes into account byte order of
potential platforms. Apparently, things aren't as simple as
"Big-Endian", "Little-Endian", so I'm taking an informal poll of
various CPU's byte orders.
Could people compile the following program and mail back the output?
I'm particularly interested in the various Intel families, Sparc's,
Mips, and RS-6000's. Also, if you think you have a particularly
wierd processor, give this a run on it.
I.e., please run the program this way:
% test | od -x
Thanks!
Henry Flurry
Imagine Multimedia, Inc.
*** Program ***
#include <stdio.h>
#include <string.h>
char a[16],b[8] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 }
;
void *p = b, *q = a;
main()
{
memset(q,0,16); *(short *)q = *(short *)p;
fwrite(q,16,1,stdout);
memset(q,0,16); *(long *)q = *(long *)p;
fwrite(q,16,1,stdout);
memset(q,0,16); *(float *)q = *(float *)p;
fwrite(q,16,1,stdout);
memset(q,0,16); *(double *)q = *(double *)p;
fwrite(q,16,1,stdout);
}
Technical Details
Message-ID:
<9202101923.AA00711@_imagine.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!imagine.COM!henryfShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,6db3c7f415d342d8,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1992-02-10 12:13:05 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!imagine.COM!henryf From: henryf@imagine.COM Subject: Byte Order test Message-ID: <9202101923.AA00711@_imagine.com> Sender: daemon@cis.ohio-state.edu Organization: GNUs Not Usenet Distribution: gnu Date: Mon, 10 Feb 1992 19:23:51 GMT Lines: 42