Re: Bit twiddling



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
.