* [Linux-ia64] big endian code of NUE gcc
@ 2000-09-19 0:54 Fujio Ikegami
2000-09-19 1:21 ` Jim Wilson
0 siblings, 1 reply; 2+ messages in thread
From: Fujio Ikegami @ 2000-09-19 0:54 UTC (permalink / raw)
To: linux-ia64
Hi,
I tried to get big endian code by using NUE gcc under IA-32 Linux as follows:
gcc -mbig-endian -o endian endian.c
But the code I got was not big endian.
Question:
Is the compiler option of -mbig-endian effective?
Does Red Hat support big endian code?
Best Regards,
Fujio Ikegami
<attachement>
1. Operation
[ikegami@alfard hit]$ nue
bash$ gcc -mbig-endian -o endian endian.c
bash$ endian
u16\x1234 u32\x12345678 u64\x1234567890ABCDEF
u16
FFFFF98E 3412 |4 |
u32
FFFFF988 78563412 |xV4 |
u64
FFFFF980 EFCDAB90 78563412 | xV4 |
bash$
2. endian.c
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
void dump(char *title,void *vp,int len);
int main() {
unsigned short int u16;
unsigned int u32;
unsigned long long int u64;
u16=0x1234;
u32=0x12345678;
u64=0x1234567890abcdef;
printf("u16=%x u32=%x u64=%lX\n",u16,u32,u64);
dump("u16",&u16,2);
dump("u32",&u32,4);
dump("u64",&u64,8);
return 0;
}
void dump(char *title,void *vp,int len) {
// hex dump */
unsigned char *p;
int i,j,c;
char buf[32];
p=(unsigned char *)vp;
printf("%s\n",title);
for(i=j=0;i<len;i++) {
c=p[i];
if (i%16=0) {
if (i>0) printf(" |%s|\n",buf);
printf("%08X ",p+i);
j=0;
}
if (i%4=0) printf(" ");
printf("%02X",c);
sprintf(&buf[j++],"%c",to_char(c));
}
for(i=j;i<16;i++) {
if (i%4=0) printf(" ");
printf(" ");
}
printf(" |%s|\n",buf);
return;
}
int to_char(int c) {
if (c<' ' || c>0x7f) return ' ';
return c;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Linux-ia64] big endian code of NUE gcc
2000-09-19 0:54 [Linux-ia64] big endian code of NUE gcc Fujio Ikegami
@ 2000-09-19 1:21 ` Jim Wilson
0 siblings, 0 replies; 2+ messages in thread
From: Jim Wilson @ 2000-09-19 1:21 UTC (permalink / raw)
To: linux-ia64
ia64-linux is little-endian. The -mbig-endian option won't do anything useful
on an ia64-linux system. You probably should have gotten a linker error
message though. I think gcc needs to pass an option to the assembler so
that it can set the big-endian bit in the elf header. Or else emit an
assembler directive to do this.
If you are emitting code for a different OS, and that OS has big-endian
support, and gcc has support for that OS, then -mbig-endian should do something
useful. I do not know of any big-endian IA-64 targets at this time though,
so the big-endian support has never been tested.
Jim
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-09-19 1:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-09-19 0:54 [Linux-ia64] big endian code of NUE gcc Fujio Ikegami
2000-09-19 1:21 ` Jim Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox