in CO and Architecture edited by
1,932 views
5 votes
5 votes

An array of $2$ two byte integers is stored in big endian machine in byte addresses as shown below. What will be its storage pattern in little endian machine ?

$$\begin{array}{c|c}\text{Address}& \text{Data}\\\hline0 \times 104&78\\0 \times 103&56\\0 \times 102&34\\0 \times 101&12\end{array}$$

  1. $\begin{array}{c|c}\text{Address}& \text{Data}\\\hline0 \times 104&12\\0 \times 103&56\\0 \times 102&34\\0 \times 101&78 \\ \\\end{array} $
  2. $\begin{array}{c|c}\text{Address}& \text{Data}\\\hline0 \times 104&12\\0 \times 103&34\\0 \times 102&56\\0 \times 101&78\\\\\end{array} \\$
  3. $\begin{array}{c|c}\text{Address}& \text{Data}\\\hline0 \times 104&56\\0 \times 103&78\\0 \times 102&12\\0 \times 101&34\\\\\end{array} \\$
  4. $\begin{array}{c|c}\text{Address}& \text{Data}\\\hline0 \times 104&56\\0 \times 103&12\\0 \times 102&78\\0 \times 101&34\end{array}$
in CO and Architecture edited by
by
1.9k views

4 Answers

2 votes
2 votes

In Big endian, the Most significant byte within the word is stored first(at lower address).

In Little endian, the Least significant byte within the word is stored first(at lower address).

So, if word size is 1 Byte, then little-endian and Big-endian have no difference. Data will be stored in the same way in both of them.

If word size is 2Bytes and this is how 10,11,12,13 are stored in big endian:-

                                                    WORD1                                                   WORD2
00001010(1st byte within word1)     00001011(2nd byte within word1) 00001100(1st byte within word2)    00001101(2nd byte within word2)

 

 

Then this is how it will be stored in little endian:-

                                                  WORD1                                                   WORD2
00001011(1st byte within word1)      00001010(2nd byte within word1) 00001101(1st byte within word2)    00001100(2nd byte within word2)

 

In question, there are two words in the array. Each word has two Bytes. In little and big endian , these bytes within the word will be reverse of each other.

first byte of word1 is 12 and second byte of word1 is 34. So in little endian, first byte of word1 will have 34 and second byte of word1 will have 12. 

first byte of word2 is 56 and second byte of word2 is 78. So in little endian, first byte of word1 will have 78 and second byte will have 56. 

So, answer is option (C)

edited by
1 vote
1 vote
Answer: c) 0x104: 56 | 0x103: 78 | 0x102: 12 | 0x101: 34

The little-endian storage scheme is just the opposite of Big-endian. So just the reverse of what is given in the question.

In little-endian lower address contains lower byte or in other words, the least significant byte is stored first and then Most significant byte.
edited by

1 comment

but its given integer is of 2 bytes..isn't option c correct..?
1
1
1 vote
1 vote
In little endian the LSB parts of the data are stored first, whereas in big endian the MSB parts are stored first.
In the given question each integer is two bytes. 0x101, 0x102 are part of one word.
In the big endian 0x101 has 12 and 0x102 has 34. In the little endian 0x101 will have 34 and 0x102 will have 12.
Similarly in the big endian 0x103 has 56 and 0x104 has 78...in the little endian 0x103 will have 78 and 0x104 will have 56.
0 votes
0 votes
Option B is correct as the storing method of multibyte data is opposite inlittle endian machine to that big endian machine.
Answer:

Related questions