Samll-endian machine: Intel x86
e.g.
program value 0a0b0c0d // set data= 0x0a0b0c0d in program
register value 0a0b0c0d // 0a is high bits(31-24), and 0d is low bits(7-0)
memory value 0d0c0b0a // data in memory
suppose you input 0x00 00 00 a1 from the terminal, you use scanf to read it into a integer in C, it's value is 161.
however, it stores in memory as following: a1 00 00 00
In x86 machine, the format of file on disk is same as the format on memory.
suppose in a binary file, there are 4 byte content in the file, the content is as following: a1000000, if you use fread() to read this 4 byte into an integer
fread(&i, 4, 1), the value of i is 161.
the register value is the same as our real life value.
another example will be:
10th bytes of the memory: 0x0000000a
if you store this memroy address in memory, it should be 0a 00 00 00
Big-endian machine: PowerPC
please see more information at wiki:
http://en.wikipedia.org/wiki/Endianness
some thoughts about little endian:
integer 15 stores at file or memory at X86 is (4 bytes ):
e.g. int a = 15; a stores in memory is:
00001111 00000000 00000000 00000000
File is same as memory, everything in file need to load into memory first.
However, number 15 written in file is different, becuase it is two digits (open a new file, and write 15 in that file, and save it).
supposed to use ASICI Code to translate these two digits.
No comments:
Post a Comment