Re: __LITTLE_ENDIAN vs. __LITTLE_ENDIAN_BITFIELD

From: Timur Tabi
Date: Fri Oct 05 2007 - 17:10:43 EST


Anton Altaparmakov wrote:

---LSB-- ---2SB-- ---3SB-- ---MSB-- [bytes] LITTLE_ENDIAN
L234567M L234567M L234567M L234567M [bits] LITTLE_ENDIAN_BITFIELD

No it is not. That makes no sense.

Why not? I honestly don't know what x86 does, but I would think that if I write a 32-bit value to a memory location, that when I examine that memory location, all 32 bits will be in order.

The whole point of little endian is that you store LSB, then 2SB, then 3SB, then MSB and then when the CPU

You're talking about byte endian. I'm talking about bit endian -- the order of bits within a byte. Software cannot know what the bit endian is, but external devices that have memory-mapped registers can know.

reads this as a 32-bit word it rotates them all around so that in the CPU register you have:

MSB_3SB_2SB_LSB
M765432L_M765432L_M765432L_M765432L

That is what little endian means and that is how shift operations can work fine on the CPU.

The CPU shift operation, yes. I'm talking about shift operations on external memory-mapped devices.

--
Timur Tabi
Linux Kernel Developer @ Freescale
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/