kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* How to figure out the byteorder only with one byte number?
@ 2012-02-18 14:33 Tao Jiang
  2012-02-18 15:59 ` Peter Senna Tschudin
  0 siblings, 1 reply; 12+ messages in thread
From: Tao Jiang @ 2012-02-18 14:33 UTC (permalink / raw)
  To: kernelnewbies

Hi:

As far as I know, we can use an integer 0x12345678 with four bytes
and bytes[4] array to figure out a machine's byteorder

Is there a method use only one byte 0x01
and some shifts do the same work?

Thank you.

---------------
jiangtao

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-18 14:33 How to figure out the byteorder only with one byte number? Tao Jiang
@ 2012-02-18 15:59 ` Peter Senna Tschudin
  2012-02-19 12:08   ` Tao Jiang
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Senna Tschudin @ 2012-02-18 15:59 UTC (permalink / raw)
  To: kernelnewbies

I found:

http://stackoverflow.com/questions/2100331/c-macro-definition-to-determine-big-endian-or-little-endian-machine

On Sat, Feb 18, 2012 at 12:33 PM, Tao Jiang <jiangtao.jit@gmail.com> wrote:
> Hi:
>
> As far as I know, we can use an integer 0x12345678 with four bytes
> and bytes[4] array to figure out a machine's byteorder
>
> Is there a method use only one byte 0x01
> and some shifts do the same work?
>
> Thank you.
>
> ---------------
> jiangtao
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



-- 
Peter Senna Tschudin
peter.senna at gmail.com
gpg id: 48274C36

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-18 15:59 ` Peter Senna Tschudin
@ 2012-02-19 12:08   ` Tao Jiang
  2012-02-19 14:24     ` Bernd Petrovitsch
  0 siblings, 1 reply; 12+ messages in thread
From: Tao Jiang @ 2012-02-19 12:08 UTC (permalink / raw)
  To: kernelnewbies

Peter:

Thank you very much!
I've read the url.
But it's not what i mean to ask for.
Those methods all use an int or a short number and converting.
What I really want to ask for is:

unsigned char byte = 0b00000100;
do some shifts like byte << 1
then find out the machine's byteorder

Is there some difference of the storge between BE and LE machine inside a byte?


Thank you.



2012/2/18 Peter Senna Tschudin <peter.senna@gmail.com>:
> I found:
>
> http://stackoverflow.com/questions/2100331/c-macro-definition-to-determine-big-endian-or-little-endian-machine
>
> On Sat, Feb 18, 2012 at 12:33 PM, Tao Jiang <jiangtao.jit@gmail.com> wrote:
>> Hi:
>>
>> As far as I know, we can use an integer 0x12345678 with four bytes
>> and bytes[4] array to figure out a machine's byteorder
>>
>> Is there a method use only one byte 0x01
>> and some shifts do the same work?
>>
>> Thank you.
>>
>> ---------------
>> jiangtao
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
> --
> Peter Senna Tschudin
> peter.senna at gmail.com
> gpg id: 48274C36

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-19 12:08   ` Tao Jiang
@ 2012-02-19 14:24     ` Bernd Petrovitsch
  2012-02-19 17:19       ` Graeme Russ
  0 siblings, 1 reply; 12+ messages in thread
From: Bernd Petrovitsch @ 2012-02-19 14:24 UTC (permalink / raw)
  To: kernelnewbies

On Sun, 2012-02-19 at 20:08 +0800, Tao Jiang wrote:
[...]
> Is there some difference of the storge between BE and LE machine inside a byte?

No. At least TTBOMK there exists no such hardware.

	Bernd
-- 
Bernd Petrovitsch                  Email : bernd at petrovitsch.priv.at
                     LUGA : http://www.luga.at

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-19 14:24     ` Bernd Petrovitsch
@ 2012-02-19 17:19       ` Graeme Russ
  2012-02-20 11:25         ` Tao Jiang
  0 siblings, 1 reply; 12+ messages in thread
From: Graeme Russ @ 2012-02-19 17:19 UTC (permalink / raw)
  To: kernelnewbies

On 02/20/2012 01:24 AM, Bernd Petrovitsch wrote:
> On Sun, 2012-02-19 at 20:08 +0800, Tao Jiang wrote:
> [...]
>> Is there some difference of the storge between BE and LE machine inside a byte?
> 
> No. At least TTBOMK there exists no such hardware.

Using SHL/SHR would tell you - SHL normally results in a multiply by 2, SHR
a divide by 2. If the byte was little endian, the results would be visa-versa

But I agree, I doubt there is any such hardware

Regards,

Graeme

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-19 17:19       ` Graeme Russ
@ 2012-02-20 11:25         ` Tao Jiang
  2012-02-20 13:53           ` Subramaniam Appadodharana
  0 siblings, 1 reply; 12+ messages in thread
From: Tao Jiang @ 2012-02-20 11:25 UTC (permalink / raw)
  To: kernelnewbies

Hi:

Thank you all.

Take a byte number 0b00000001 for example
                                     ^             ^
                               high bit     low bit

I used to think in a LE machine it will be stored as 0b10000000 low bit first

            ^             ^

        low bit     high bit

and in a BE machine will be 0b00000001 high bit first
                                                ^             ^
                                             high bit    low bit

not only the byteorder is different, but inside a byte is also different.

But actually they are the same, right?
Thank you.



2012/2/20 Graeme Russ <graeme.russ@gmail.com>:
> On 02/20/2012 01:24 AM, Bernd Petrovitsch wrote:
>> On Sun, 2012-02-19 at 20:08 +0800, Tao Jiang wrote:
>> [...]
>>> Is there some difference of the storge between BE and LE machine inside a byte?
>>
>> No. At least TTBOMK there exists no such hardware.
>
> Using SHL/SHR would tell you - SHL normally results in a multiply by 2, SHR
> a divide by 2. If the byte was little endian, the results would be visa-versa
>
> But I agree, I doubt there is any such hardware
>
> Regards,
>
> Graeme
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-20 11:25         ` Tao Jiang
@ 2012-02-20 13:53           ` Subramaniam Appadodharana
  2012-02-20 22:32             ` THAI NGUYEN
  0 siblings, 1 reply; 12+ messages in thread
From: Subramaniam Appadodharana @ 2012-02-20 13:53 UTC (permalink / raw)
  To: kernelnewbies

Hi Tao,


On Mon, Feb 20, 2012 at 5:25 AM, Tao Jiang <jiangtao.jit@gmail.com> wrote:
> Hi:
>
> Thank you all.
>
> Take a byte number 0b00000001 for example
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^ ? ? ? ? ? ? ^
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? high bit ? ? low bit
>
> I used to think in a LE machine it will be stored as 0b10000000 low bit first
>
> ? ? ? ? ? ?^ ? ? ? ? ? ? ^
>
> ? ? ? ?low bit ? ? high bit
>
> and in a BE machine will be 0b00000001 high bit first
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^ ? ? ? ? ? ? ^
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? high bit ? ?low bit
>
> not only the byteorder is different, but inside a byte is also different.
>
> But actually they are the same, right?
yes they are same. In fact it is termed as 'byte' order not 'bit'
order. Hope this helps.
> Thank you.
>
>
>
> 2012/2/20 Graeme Russ <graeme.russ@gmail.com>:
>> On 02/20/2012 01:24 AM, Bernd Petrovitsch wrote:
>>> On Sun, 2012-02-19 at 20:08 +0800, Tao Jiang wrote:
>>> [...]
>>>> Is there some difference of the storge between BE and LE machine inside a byte?
>>>
>>> No. At least TTBOMK there exists no such hardware.
>>
>> Using SHL/SHR would tell you - SHL normally results in a multiply by 2, SHR
>> a divide by 2. If the byte was little endian, the results would be visa-versa
>>
>> But I agree, I doubt there is any such hardware
>>
>> Regards,
>>
>> Graeme
>>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-20 13:53           ` Subramaniam Appadodharana
@ 2012-02-20 22:32             ` THAI NGUYEN
  2012-02-21  1:22               ` Sri Ram Vemulpali
  0 siblings, 1 reply; 12+ messages in thread
From: THAI NGUYEN @ 2012-02-20 22:32 UTC (permalink / raw)
  To: kernelnewbies



Just as an FYI, way back in the early '90s, Texas Instruments came out with a graphics processor (I believe the TMS340x0 praphics processor) that actually did do the little-ending and big-endian down to the bit level.



________________________________
 From: Subramaniam Appadodharana <c.a.subramaniam@gmail.com>
To: Tao Jiang <jiangtao.jit@gmail.com> 
Cc: Graeme Russ <graeme.russ@gmail.com>; Bernd Petrovitsch <bernd@petrovitsch.priv.at>; Peter Senna Tschudin <peter.senna@gmail.com>; kernelnewbies at kernelnewbies.org 
Sent: Monday, February 20, 2012 8:53:10 AM
Subject: Re: How to figure out the byteorder only with one byte number?
 
Hi Tao,


On Mon, Feb 20, 2012 at 5:25 AM, Tao Jiang <jiangtao.jit@gmail.com> wrote:
> Hi:
>
> Thank you all.
>
> Take a byte number 0b00000001 for example
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^ ? ? ? ? ? ? ^
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? high bit ? ? low bit
>
> I used to think in a LE machine it will be stored as 0b10000000 low bit first
>
> ? ? ? ? ? ?^ ? ? ? ? ? ? ^
>
> ? ? ? ?low bit ? ? high bit
>
> and in a BE machine will be 0b00000001 high bit first
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^ ? ? ? ? ? ? ^
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? high bit ? ?low bit
>
> not only the byteorder is different, but inside a byte is also different.
>
> But actually they are the same, right?
yes they are same. In fact it is termed as 'byte' order not 'bit'
order. Hope this helps.
> Thank you.
>
>
>
> 2012/2/20 Graeme Russ <graeme.russ@gmail.com>:
>> On 02/20/2012 01:24 AM, Bernd Petrovitsch wrote:
>>> On Sun, 2012-02-19 at 20:08 +0800, Tao Jiang wrote:
>>> [...]
>>>> Is there some difference of the storge between BE and LE machine inside a byte?
>>>
>>> No. At least TTBOMK there exists no such hardware.
>>
>> Using SHL/SHR would tell you - SHL normally results in a multiply by 2, SHR
>> a divide by 2. If the byte was little endian, the results would be visa-versa
>>
>> But I agree, I doubt there is any such hardware
>>
>> Regards,
>>
>> Graeme
>>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120220/ca6f9c53/attachment.html 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-20 22:32             ` THAI NGUYEN
@ 2012-02-21  1:22               ` Sri Ram Vemulpali
  2012-02-21 12:30                 ` Tao Jiang
  0 siblings, 1 reply; 12+ messages in thread
From: Sri Ram Vemulpali @ 2012-02-21  1:22 UTC (permalink / raw)
  To: kernelnewbies

Guys,

I was late to the party. But this whole  discussion throughs me off.
When you say byte order, it applied when the width of data is more
than a byte, lets say our width is 4 bytes, a typical word length.

Now how is that there will be byte order on a byte width data. Are you
talking about nibble order.

When you talk byte order -- either little endian or big endian, we are
talking how is our data should be interpreted. Depending on order we
start reading data from left or right a byte at a time.

So, I am confused on your discussions. Please clarify.

Thanks,
Sri.

On Mon, Feb 20, 2012 at 5:32 PM, THAI NGUYEN <thai-n@rogers.com> wrote:
>
> Just as an FYI, way back in the early '90s, Texas Instruments came out with
> a graphics processor (I believe the TMS340x0 praphics processor) that
> actually did do the little-ending and big-endian down to the bit level.
>
>
> ________________________________
> From: Subramaniam Appadodharana <c.a.subramaniam@gmail.com>
> To: Tao Jiang <jiangtao.jit@gmail.com>
> Cc: Graeme Russ <graeme.russ@gmail.com>; Bernd Petrovitsch
> <bernd@petrovitsch.priv.at>; Peter Senna Tschudin <peter.senna@gmail.com>;
> kernelnewbies at kernelnewbies.org
> Sent: Monday, February 20, 2012 8:53:10 AM
> Subject: Re: How to figure out the byteorder only with one byte number?
>
> Hi Tao,
>
>
> On Mon, Feb 20, 2012 at 5:25 AM, Tao Jiang <jiangtao.jit@gmail.com> wrote:
>> Hi:
>>
>> Thank you all.
>>
>> Take a byte number 0b00000001 for example
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^ ? ? ? ? ? ? ^
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? high bit ? ? low bit
>>
>> I used to think in a LE machine it will be stored as 0b10000000 low bit
>> first
>>
>> ? ? ? ? ? ?^ ? ? ? ? ? ? ^
>>
>> ? ? ? ?low bit ? ? high bit
>>
>> and in a BE machine will be 0b00000001 high bit first
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^ ? ? ? ? ? ? ^
>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? high bit ? ?low bit
>>
>> not only the byteorder is different, but inside a byte is also different.
>>
>> But actually they are the same, right?
> yes they are same. In fact it is termed as 'byte' order not 'bit'
> order. Hope this helps.
>> Thank you.
>>
>>
>>
>> 2012/2/20 Graeme Russ <graeme.russ@gmail.com>:
>>> On 02/20/2012 01:24 AM, Bernd Petrovitsch wrote:
>>>> On Sun, 2012-02-19 at 20:08 +0800, Tao Jiang wrote:
>>>> [...]
>>>>> Is there some difference of the storge between BE and LE machine inside
>>>>> a byte?
>>>>
>>>> No. At least TTBOMK there exists no such hardware.
>>>
>>> Using SHL/SHR would tell you - SHL normally results in a multiply by 2,
>>> SHR
>>> a divide by 2. If the byte was little endian, the results would be
>>> visa-versa
>>>
>>> But I agree, I doubt there is any such hardware
>>>
>>> Regards,
>>>
>>> Graeme
>>>
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>



-- 
Regards,
Sri.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-21  1:22               ` Sri Ram Vemulpali
@ 2012-02-21 12:30                 ` Tao Jiang
  2012-02-21 12:48                   ` Bernd Petrovitsch
  0 siblings, 1 reply; 12+ messages in thread
From: Tao Jiang @ 2012-02-21 12:30 UTC (permalink / raw)
  To: kernelnewbies

Hi:

I think I'm clear now.
What's I originally wanted to ask for is whether 'bit order' equals to
'byte order'
And is there a method to find out the 'bit order' then find out the
'byte order' ?

Now I know in the most modern machine there is no difference between BE and LE
at so called 'bit order' level.
Right?

Thank you all.


2012/2/21 Sri Ram Vemulpali <sri.ram.gmu06@gmail.com>:
> Guys,
>
> I was late to the party. But this whole ?discussion throughs me off.
> When you say byte order, it applied when the width of data is more
> than a byte, lets say our width is 4 bytes, a typical word length.
>
> Now how is that there will be byte order on a byte width data. Are you
> talking about nibble order.
>
> When you talk byte order -- either little endian or big endian, we are
> talking how is our data should be interpreted. Depending on order we
> start reading data from left or right a byte at a time.
>
> So, I am confused on your discussions. Please clarify.
>
> Thanks,
> Sri.
>
> On Mon, Feb 20, 2012 at 5:32 PM, THAI NGUYEN <thai-n@rogers.com> wrote:
>>
>> Just as an FYI, way back in the early '90s, Texas Instruments came out with
>> a graphics processor (I believe the TMS340x0 praphics processor) that
>> actually did do the little-ending and big-endian down to the bit level.
>>
>>
>> ________________________________
>> From: Subramaniam Appadodharana <c.a.subramaniam@gmail.com>
>> To: Tao Jiang <jiangtao.jit@gmail.com>
>> Cc: Graeme Russ <graeme.russ@gmail.com>; Bernd Petrovitsch
>> <bernd@petrovitsch.priv.at>; Peter Senna Tschudin <peter.senna@gmail.com>;
>> kernelnewbies at kernelnewbies.org
>> Sent: Monday, February 20, 2012 8:53:10 AM
>> Subject: Re: How to figure out the byteorder only with one byte number?
>>
>> Hi Tao,
>>
>>
>> On Mon, Feb 20, 2012 at 5:25 AM, Tao Jiang <jiangtao.jit@gmail.com> wrote:
>>> Hi:
>>>
>>> Thank you all.
>>>
>>> Take a byte number 0b00000001 for example
>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ^ ? ? ? ? ? ? ^
>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? high bit ? ? low bit
>>>
>>> I used to think in a LE machine it will be stored as 0b10000000 low bit
>>> first
>>>
>>> ? ? ? ? ? ?^ ? ? ? ? ? ? ^
>>>
>>> ? ? ? ?low bit ? ? high bit
>>>
>>> and in a BE machine will be 0b00000001 high bit first
>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^ ? ? ? ? ? ? ^
>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? high bit ? ?low bit
>>>
>>> not only the byteorder is different, but inside a byte is also different.
>>>
>>> But actually they are the same, right?
>> yes they are same. In fact it is termed as 'byte' order not 'bit'
>> order. Hope this helps.
>>> Thank you.
>>>
>>>
>>>
>>> 2012/2/20 Graeme Russ <graeme.russ@gmail.com>:
>>>> On 02/20/2012 01:24 AM, Bernd Petrovitsch wrote:
>>>>> On Sun, 2012-02-19 at 20:08 +0800, Tao Jiang wrote:
>>>>> [...]
>>>>>> Is there some difference of the storge between BE and LE machine inside
>>>>>> a byte?
>>>>>
>>>>> No. At least TTBOMK there exists no such hardware.
>>>>
>>>> Using SHL/SHR would tell you - SHL normally results in a multiply by 2,
>>>> SHR
>>>> a divide by 2. If the byte was little endian, the results would be
>>>> visa-versa
>>>>
>>>> But I agree, I doubt there is any such hardware
>>>>
>>>> Regards,
>>>>
>>>> Graeme
>>>>
>>>
>>> _______________________________________________
>>> Kernelnewbies mailing list
>>> Kernelnewbies at kernelnewbies.org
>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>>
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>
>
>
> --
> Regards,
> Sri.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-21 12:30                 ` Tao Jiang
@ 2012-02-21 12:48                   ` Bernd Petrovitsch
  2012-02-22 11:27                     ` Tao Jiang
  0 siblings, 1 reply; 12+ messages in thread
From: Bernd Petrovitsch @ 2012-02-21 12:48 UTC (permalink / raw)
  To: kernelnewbies

On Die, 2012-02-21 at 20:30 +0800, Tao Jiang wrote:
[...]
> Now I know in the most modern machine there is no difference between BE and LE
> at so called 'bit order' level.
> Right?

One main difference between *byte* order and *bit* order is:

What are the means to address individual *bits*?
a) Bit shift and masking as in "1 << bit-number":
   This has a mathematical background and - implicitly - the
   least-significant bit has - thus - the number 0.
   I can't even think of an insane reason (let alone a sane one) to
   break the "shift left is for unsigned numbers equivalent to
   doubling" property - apart from the fact that it is defined in that
   way by C - and all other languages I came across. And the same holds
   for all CPUs/assembler instruction sets ....
b) use a bit-field as in "unsigned char b0:1, b1:1, b2:1, b3:1, b4:1,
   b5:1, b6:1, b7:1;":
   It is not defined by any C-standard and is - thus - up to the
   compiler, if b0 == (1 << 0) or b0 == (1 << 7) or anything else.
c) bit-test/st/clr assembler instructions in the architecture: Go read
   *if* your CPU has such stuff and how it relates to the "bit-shift and
   mask" method.
   I would be greatly surprised if it is different (on i386, it is equal
   since ages BTW) mainly because it makes absolutely no sense.
d) There is hardware with bit-addressable memory out there. Go read the
   manual and the same as c)
I doubt that it is different even for really old machines ....

	Bernd
-- 
Bernd Petrovitsch                  Email : bernd@petrovitsch.priv.at
                     LUGA : http://www.luga.at

^ permalink raw reply	[flat|nested] 12+ messages in thread

* How to figure out the byteorder only with one byte number?
  2012-02-21 12:48                   ` Bernd Petrovitsch
@ 2012-02-22 11:27                     ` Tao Jiang
  0 siblings, 0 replies; 12+ messages in thread
From: Tao Jiang @ 2012-02-22 11:27 UTC (permalink / raw)
  To: kernelnewbies

Hi:

Thank you all very much.


2012/2/21 Bernd Petrovitsch <bernd@petrovitsch.priv.at>:
> On Die, 2012-02-21 at 20:30 +0800, Tao Jiang wrote:
> [...]
>> Now I know in the most modern machine there is no difference between BE and LE
>> at so called 'bit order' level.
>> Right?
>
> One main difference between *byte* order and *bit* order is:
>
> What are the means to address individual *bits*?
> a) Bit shift and masking as in "1 << bit-number":
> ? This has a mathematical background and - implicitly - the
> ? least-significant bit has - thus - the number 0.
> ? I can't even think of an insane reason (let alone a sane one) to
> ? break the "shift left is for unsigned numbers equivalent to
> ? doubling" property - apart from the fact that it is defined in that
> ? way by C - and all other languages I came across. And the same holds
> ? for all CPUs/assembler instruction sets ....
> b) use a bit-field as in "unsigned char b0:1, b1:1, b2:1, b3:1, b4:1,
> ? b5:1, b6:1, b7:1;":
> ? It is not defined by any C-standard and is - thus - up to the
> ? compiler, if b0 == (1 << 0) or b0 == (1 << 7) or anything else.
> c) bit-test/st/clr assembler instructions in the architecture: Go read
> ? *if* your CPU has such stuff and how it relates to the "bit-shift and
> ? mask" method.
> ? I would be greatly surprised if it is different (on i386, it is equal
> ? since ages BTW) mainly because it makes absolutely no sense.
> d) There is hardware with bit-addressable memory out there. Go read the
> ? manual and the same as c)
> I doubt that it is different even for really old machines ....
>
> ? ? ? ?Bernd
> --
> Bernd Petrovitsch ? ? ? ? ? ? ? ? ?Email : bernd at petrovitsch.priv.at
> ? ? ? ? ? ? ? ? ? ? LUGA : http://www.luga.at
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-02-22 11:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-18 14:33 How to figure out the byteorder only with one byte number? Tao Jiang
2012-02-18 15:59 ` Peter Senna Tschudin
2012-02-19 12:08   ` Tao Jiang
2012-02-19 14:24     ` Bernd Petrovitsch
2012-02-19 17:19       ` Graeme Russ
2012-02-20 11:25         ` Tao Jiang
2012-02-20 13:53           ` Subramaniam Appadodharana
2012-02-20 22:32             ` THAI NGUYEN
2012-02-21  1:22               ` Sri Ram Vemulpali
2012-02-21 12:30                 ` Tao Jiang
2012-02-21 12:48                   ` Bernd Petrovitsch
2012-02-22 11:27                     ` Tao Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).