• retagged by
8,513 views
19 19 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}$

6 Answers

14 14 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 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 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.
2 2 votes

yahaan 2 “two‐byte integers” ki baat ho rahi hai, jo Big Endian machine par aise store huye hain:
 

Address   Data
0x104     78
0x103     56   ← (yeh pehla integer ke 2 bytes)
0x102     34
0x101     12   ← (yeh doosra integer ke 2 bytes)
  • Pehla 2‐byte integer = (78, 56) = 0x78 0x56
  • Doosra 2‐byte integer = (34, 12) = 0x34 0x12

Big Endian me “most significant byte” (MSB) higher address pe aata hai, aur “least significant byte” (LSB) lower address pe.
Iska matlab:

  • 0x104 aur 0x103 pe store  → hex me 0x7856  ( 78 is more significant than 56 ) 
  • 0x102 aur 0x101 pe store  → hex me 0x3412  ( 34 is more significant than 12 ) 

Little Endian Kya Karta Hai?

Little Endian me LSB sabse chhote address pe store hota hai aur MSB usse bade address pe.

  • Pehla integer (jo 0x7856 hai) ko little endian me store karna ho toh bytes ka order ho jaayega 0x56, 0x78. ( 78 more significant to peeche ayega ) 
  • Doosra integer (jo 0x3412 hai) ko little endian me store karna ho toh bytes ka order ho jaayega 0x12, 0x34. ( 34 more significant to peeche ayega ) 

Phir Addresses Kaise Assign Honge?

Question me addresses seedhe top to bottom diye hue hain (0x104 sabse upar, 0x101 sabse niche). Physical sense me 0x101 chhota address hai aur 0x104 bada address hai. Par table me likhne ka tarika “ulta” hai.

  • Big Endian me jo pehle integer ke liye 0x104, 0x103 use ho rahe the, Little Endian me bhi  usi pair of addresses par us integer ke “reversed bytes” likh diye jaate hain. Matlab pehla integer ke LSB 0x103 par, MSB 0x104 par.
  • Doosra integer ke liye 0x102, 0x101 use hoga, jahan LSB 0x101 pe aur MSB 0x102 pe chala jaata hai.
Yani  : 
Address   Data
0x104     56   ← (Pehle integer ka LSB ) 
0x103     78   ← (Pehle integer ka MSB)
0x102     12   ← (Doosre integer ka LSB)
0x101     34   ← (Doosre integer ka MSB)

Upvote if you liked the answer and critisism is appreiciated in comments. 

1 1 vote
Option B is correct as the storing method of multibyte data is opposite inlittle endian machine to that big endian machine.
1 flag:
✌ Low quality (꧁༒☬ĿọŗԀ 🆂🅷🅸🆅🅰☬༒꧂ “wrong ans”)
0 0 votes

Endianness (big endian vs little endian) is not about arrays themselves, but about how multibyte data items (like integers) are stored in memory.

  • Array of 2 two-byte integers (so total 4 bytes)

  • Stored in Big Endian machine as:

AddressData
10478
10356
10234
10112

 

In Big Endian, the most significant byte (MSB) of each integer is stored at the lower address. So, grouping them into 2-byte integers:

  • Integer 1:
    Address 101 → 12 (MSB)
    Address 102 → 34 (LSB)
    ⇒ Value = 0x1234

  • Integer 2:
    Address 103 → 56 (MSB)
    Address 104 → 78 (LSB)
    ⇒ Value = 0x5678

In Little Endian, the least significant byte (LSB) is stored at the lower address. So, we reverse the byte order for each integer:

  • 0x1234 → stored as 34 12

  • 0x5678 → stored as 78 56

Address   Data
0×104 → 56
0×103 → 78
0×102 → 12
0×101 → 34


Important Note: 

  • Endianness applies to how bytes of a single multi-byte data item are stored, not to the array structure itself.

  • The array order (index 0, index 1, etc.) remains unchanged.

  • What changes is the internal byte order of each element.

Answer:
Position:
Show:

Related questions

16 16 votes
6 answers 6 answers
7.0k
7.0k views
go_editor asked Jun 10, 2016
7,029 views
In the Big-Endian system, the computer storesMSB of data in the lowest memory address of data unitLSB of data in the lowest memory address of data unitMSB of data in the ...
6 6 votes
6 6 answers
10.1k
10.1k views
Satbir asked Jan 13, 2020
10,082 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...
8 8 votes
6 6 answers
8.0k
8.0k views
Satbir asked Jan 13, 2020
8,009 views
A stack organized computer is characterised by instructions withindirect addressingdirect addressingzero addressingindex addressing
11 11 votes
3 answers 3 answers
7.3k
7.3k views
Satbir asked Jan 13, 2020
7,294 views
A non-pipelined CPU has $12$ general purpose registers $(R0,R1,R2, \dots ,R12)$. Following operations are supported$\begin{array}{ll} \text{ADD Ra, Rb, Rr} & \text{Add Ra...