retagged by
3,736 views
8 votes
8 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}$
retagged by

4 Answers

5 votes
5 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
2 votes
2 votes
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
2 votes
2 votes
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.
1 votes
1 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

11 votes
11 votes
5 answers
1
6 votes
6 votes
5 answers
2
Satbir asked Jan 13, 2020
4,443 views
A computer which issues instructions in order, has only $2$ registers and $3$ opcodes $\text{ADD, SUB}$ and $\text{MOV}$. Consider $2$ different implementations of the fo...
4 votes
4 votes
5 answers
3
Satbir asked Jan 13, 2020
4,262 views
A stack organized computer is characterised by instructions withindirect addressingdirect addressingzero addressingindex addressing
9 votes
9 votes
1 answer
4