Re: Bit twiddling
- From: Joe Wright <joewwright@xxxxxxxxxxx>
- Date: Sat, 04 Jun 2005 09:11:56 -0400
Chris Croughton wrote:
On Fri, 03 Jun 2005 16:54:58 -0700, glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> wrote:
*** T. Winter wrote:
In article <ln1x7jb47t.fsf@xxxxxxxxxxxxxxx> Keith Thompson <kst-u@xxxxxxx> writes:
> Whether bit 0 is the least or most significant bit is probably > system-specific; the bits in a 32-bit word might be numbered 0..31 or > 31..0. Which way they're numbered is probably more a matter of > terminology than actual semantics, unless the CPU provides > instructions that take bit numbers as arguments.
And if the instructions are consistent. That is not the case with all processors...
IBM machines derived from S/360 consistently number them with the MSB as zero. The terminology gets a little confusing now that the architecture has been extended to 64 bits. The old instructions now operate on bits 32-63 of the general registers.
That's a good reason for numbering with 0 as LSB! European comms specifications had the 'standard' of numbering 0 as MSB, I believe that it got into some early RFCs as well (I've certainly seen it in some non-European spec.s). Most confusing, especially when dealing with multiple specifications in the same project (the lower layers have bit 0 as most significant, whereas the higher layers have bit 0 as LSB -- or is it the other way round? Madness!)
Chris C
In the end, happily, it doesn't matter. It's just a matter of notation. It doesn't change the way the machine works, only how it's described in the docs.
More interesting is a bit's value in time. Think of async serial bytes: start bit, 8 data bits and stop bit. It is of crucial importance that we know whether the bit after the start bit is the lsb or the msb of the byte. I used to know. Really. :-)
-- Joe Wright mailto:joewwright@xxxxxxxxxxx "Everything should be made as simple as possible, but not simpler." --- Albert Einstein --- .
- Follow-Ups:
- Re: Bit twiddling
- From: Chris Croughton
- Re: Bit twiddling
- From: CBFalconer
- Re: Bit twiddling
- References:
- Re: Bit twiddling
- From: grid
- Re: Bit twiddling
- From: Paul Mesken
- Re: Bit twiddling
- From: Keith Thompson
- Re: Bit twiddling
- From: *** T. Winter
- Re: Bit twiddling
- From: glen herrmannsfeldt
- Re: Bit twiddling
- From: Chris Croughton
- Re: Bit twiddling
- Prev by Date: Re: Robustify code dealing with input
- Next by Date: Re: Newbie question
- Previous by thread: Re: Bit twiddling
- Next by thread: Re: Bit twiddling
- Index(es):