From: Dennis Ritchie <email@example.com>
Subject: Re: shift instructions on different processors
Date: Tue, 12 Feb 2002 04:47:05 +0000
glen herrmannsfeldt wrote:
> There have been questions on both C and Java newsgroups about
> the effect of shift operations when the shift value equals or
> exceeds the number of bits available to be shifted.
> I know that the reason for such a restriction is that many architectures
> use only some bits of the shift amount.
> x86 uses the low 5 bits for 32 bit shifts, and low 6 bits for 64 bits.
> IBM S/360, S/370, S/390 etc., use the low 6 bits for 32 and 64 bits.
Meissner followed up with various other architectures as well.
I looked at my Interdata 8/32 manual (1975), which describes
a 32-bit machine, and was amused to find, under the
"Shift Left Logical" instruction,
"... the shift count is specified by the least significant
five bits of the second operand."
I added a contemporaneous hand-written notation "!!" to this.
On the next page, under "Shift Right Logical," it similarly
says, "the least significant five bits of the second operand."
Here my notation is an underlining, accompanied by "Shit!!"
And that, children, is why the C and Java rules are as they are.
The C manual in 6th Edition Unix didn't have the value restriction.
K&R I did.