Hi Vichy,

 

To q1, 

I think the memory contents should be (on Linux):

         0 34

         1 ef

         2 cd

         3 00

         4 .

 

To q2, 

If both of the i/o address and i/o value are ints, I think the final value
should be like these on Linux:

         i/o value 0xdfef4523

         i/o value 0x00000102

 

To q3,

The large value should be (on any system):

         0x00AA36AB..F5

 

 

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of vichy
Sent: Wednesday, January 23, 2008 3:48 PM
To: kernelnewbies@nl.linux.org
Subject: Question about Endian Order

 

Dear all:

While studying the kernel source code, I always confused with the Endian
Order.

I have studied the article about Endian order on the net.

Usually they gave an example as below: 

 

A 4 byte LongInt

    0xabcdefgh

will be arranged in memory as follows: 

    Base Address+0   gh

    Base Address+1   ef

    Base Address+2   cd

    Base Address+3   ab

 

But what is the correct unit I should take to interpret the content of
memory?

I purposely use data not 4-bytes alignment in the following questions.

 

Question 1:

What does the memory arrangement look like as the value is 0xcdef34?

Will it be 

   Base Address+0   34

   Base Address+1   ef

   Base Address+2   cd

 

Question 2:

if the answer of Q1 is right and some document tells me that 

offset 0   i/o address

offset 3   i/o value 

and I got the memory content as

    Base Address+0   23

    Base Address+1   45

    Base Address+2   ef

    Base Address+3   df

    Base Address+4   02

    Base Address+5   01

 

Does that mean the i/o address is 0xef4523 and i/o value is 0x0102df?

 

Question 3:

If I got a big array which represents a large number like below:

    static unsigned char n[] =

"\x00\xAA\x36\xAB\xCE\x88\xAC\xFD\xFF\x55\x52\x3C\x7F\xC4\x52\x3F"

"\x90\xEF\xA0\x0D\xF3\x77\x4A\x25\x9F\x2E\x62\xB4\xC5\xD9\x9C\xB5"

"\xAD\xB3\x00\xA0\x28\x5E\x53\x01\x93\x0E\x0C\x70\xFB\x68\x76\x93"

"\x9C\xE6\x16\xCE\x62\x4A\x11\xE0\x08\x6D\x34\x1E\xBC\xAC\xA0\xA1"

"\xF5";

 

Should the value be 0xF5A1A0ACBc ...., from 0xn[end] ~ n[0], just like
little-endian order, or 0x00AA36AB..F5, just like big-endian order.

Or this value will be different under different machine even it is a c
source code.

 

Appreciate your help,

vichy

 

 

 

 

 

Reply via email to