Question

3) Assume a computer has 32-bit integers. Show how the value 0xCAFEBABE would be stored sequentially...

3) Assume a computer has 32-bit integers. Show how the value 0xCAFEBABE would be stored sequentially in memory, starting at address 0x100, on both a big-endian machine and a little-endian machine, assuming that each address holds one byte.

 Address Big Endian Little Endian 0x100 0x101 0x102 0x103

Little Endian and Big Endian are two ways of storing multiple bytes of data on memory locations.

In Little Endian machine the lower byte(byte starting from LSB) will be stored at lower address which is 100 in the question

In Big Endian machine the lower byte(byte starting from LSB) will be stored at highest address which is 103 in the question.

In the above example the hexadecimal value 0xCAFEBABE in binary is as follows:

CA FE BA BE
11001010 11111110 10111010 10111110
MSB------------------------------------------------------LSB
Higher byte(CA) lower byte(BE)

So In Little Endian the data will be stored as :
100 101 102 103

 10111110(BE) 10111010(BA) 11111110(FE) 11001010(CA)

So In Big Endian the data will be stored as :
100 101 102 103

 11001010(CA) 11111110(FE) 10111010(BA) 10111110(BE)