예전에 다니던 S사에서 교육 받은 내용을 네이버에 정리했던 내용이다. 네이버의 블로그에 있는 글들을 옮기는 작업을 시작했다.



[code type=c]#include <stdio.h>
int main(void)
{
  unsigned int a = 0x01020304;
  printf("%x\n", *(unsigned char *)&a);
  printf("%x\n", *(unsigned short *)&a);
  printf("%x\n", *(unsigned int *)&a);
  return 0;
}[/code]

실행 화면

4

304

1020304

------------------------------

0x01020304의 메모리상의 표현


01 02 03 04    --> Big endian, Motorola계열 CPU

04 03 02 01    --> Little endian, Intel 계결 CPU


Power CPU는 register 조작으로 선택 가능


movl $0x01020304, %eax                   --> AT&T 어셈블리, EAX로 값을 옮긴다.


01 02 03 04  --> register는 Big/Little 모두 같은 방식으로 저장된다.

메모리 저장시

 Big endian                              Little endian

01 02  03 04                             04 03 02 01

즉 register 저장시까지는 Big/Little endian 사이에 관계가 없이 그대로 저장되지만,

메모리상에 저장될때 두 방식이 차이가 난다.

assembly로 확인할 수 있다.... --> 해보자!!!



웬지 모르지만 네이버의 내 블르그에 트랙백이 안 걸린다.

http://blog.naver.com/asca99/80013206812

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기(0) 이올린에 추천하기(0)
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://www.cipher.pe.kr/tt/cipher/rss/response/113

댓글+트랙백 ATOM :: http://www.cipher.pe.kr/tt/cipher/atom/response/113

트랙백 주소 :: http://www.cipher.pe.kr/tt/cipher/trackback/113

트랙백 RSS :: http://www.cipher.pe.kr/tt/cipher/rss/trackback/113

트랙백 ATOM :: http://www.cipher.pe.kr/tt/cipher/atom/trackback/113

댓글을 달아 주세요

댓글 RSS 주소 : http://www.cipher.pe.kr/tt/cipher/rss/comment/113
댓글 ATOM 주소 : http://www.cipher.pe.kr/tt/cipher/atom/comment/113
[로그인][오픈아이디란?]