Big-Endian and Little-Endian Test in Arm and PowerPC CPU

来源:互联网 发布:软件项目招标文件 编辑:程序博客网 时间:2024/06/05 15:38

#include void main(){ struct { unsigned char a; unsigned char b; unsigned char c; unsigned char d; } s = {0x01, 0x00, 0x00, 0x00}; unsigned int i = *(unsigned int*)&s; printf("0x%x\n", i); printf("%p %p %p %p\n", &s.a, &s.b, &s.c, &s.d);}


junli@junli-VirtualBox:~/Temp$ make
powerpc-linux-gnu-gcc -o endian.ppc endian.c --static
arm-linux-gnueabi-gcc -o endian.arm endian.c --static
junli@junli-VirtualBox:~/Temp$ qemu-ppc endian.ppc 
0x1000000
0xf6ffee7c 0xf6ffee7d 0xf6ffee7e 0xf6ffee7f
junli@junli-VirtualBox:~/Temp$ qemu-arm endian.arm 
0x1
0xf6ffefb0 0xf6ffefb1 0xf6ffefb2 0xf6ffefb3

0 0
原创粉丝点击