From: bernd@petrovitsch.priv.at (Bernd Petrovitsch)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How to figure out the byteorder only with one byte number?
Date: Tue, 21 Feb 2012 13:48:13 +0100 [thread overview]
Message-ID: <1329828494.616.13.camel@thorin> (raw)
In-Reply-To: <CAOe6JY0wJPVd7w0k3QVUOP8CM4U6M=W6F6cBbR=ath_Qhuaafg@mail.gmail.com>
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
next prev parent reply other threads:[~2012-02-21 12:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2012-02-22 11:27 ` Tao Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1329828494.616.13.camel@thorin \
--to=bernd@petrovitsch.priv.at \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).