을 바이트 순서 관련 문제에 대한 프로그램을 테스트하기 위해 내 리틀 엔디안 Intel 시스템에서 -endian 에뮬레이션을 사용합니다. QEMU PowerPC 에뮬레이터는 좋은 해결책처럼 보였다. 아래에 설명 된 단계를 문서화했습니다.
1) 설치된 QEMU.
nifty:~# aptitude update && aptitude install qemu
2) 다운로드 한 http://sourceforge.net/projects/mac-on-linux/files/에서 온 리눅스 맥 및 '는/usr/share/QEMU'에 다운로드의 'video.x'파일을 복사. 이것은 qemu-system-ppc가 그것에 대해 불평하는 것을 막기 위해 필요했습니다.
nifty:~# tar -xjf mol-0.9.72.1.tar.bz2
nifty:~# cp mol-0.9.72.1/mollib/drivers/video.x /usr/share/qemu
3) PowerPC 용 데비안을 다운로드하여 QEMU 하드 디스크 이미지에 설치했습니다.
[email protected]:~/qemu$ wget --no-verbose http://cdimage.debian.org/debian-cd/5.0.4/powerpc/iso-cd/debian-504-powerpc-CD-1.iso
2010-06-19 02:55:06 URL:http://caesar.acc.umu.se/debian-cd/5.0.4/powerpc/iso-cd/debian-504-powerpc-CD-1.iso[675569664/675569664] -> "debian-504-powerpc-CD-1.iso" [1]
[email protected]:~/qemu$ qemu-img create powerpc.img 2G
Formatting 'powerpc.img', fmt=raw size=2147483648
[email protected]:~/qemu$ qemu-system-ppc -hda powerpc.img -cdrom debian-504-powerpc-CD-1.iso -boot d -m 512
4) QEMU PowerPC 에뮬레이터를 하드 디스크 이미지로 부팅했습니다.
[email protected]:~/qemu$ qemu-system-ppc -hda powerpc.img -m 512
5) 간단한 C 프로그램을 작성하여 실제로 빅 엔디안 시스템에 있음을 확인했습니다.
[email protected]:~$ cat endian.c
#include <stdio.h>
int main()
{
int n = 0x1;
printf(*((char *) &n) ? "little-endian\n" : "big-endian\n");
return 0;
}
[email protected]:~$ gcc endian.c && ./a.out
big-endian
[email protected]:~$
당신이 말장난을 놓친 경우, 릴리 푸티 아는 원래 빅 엔디안이었습니다.
[빅 엔디안 아키텍처를 사용하는 컴퓨터에서 코드를 테스트하는 방법?] (http://stackoverflow.com/q/2839087/995714) –