Shifting question

Rob McMahon cudcv at warwick.ac.uk
Tue Jul 26 07:23:22 AEST 1988


In article <19962 at watmath.waterloo.edu> rbutterworth at watmath.waterloo.edu (Ray Butterworth) writes:
|> In some article, someone whose name is lost in the mists of time writes:
|> > action of doing:
|> > 	x >>= 16; x>>= 16;
|> > better be the same as:
|> > 	x = x>>32;
|
|I can see why the Committee should NOT require that (for n>0)
|"x >>= n;"  be the same as  "while (n--!=0) x>>=1;".
|
|Imagine a machine with 16 bit words and a logical right shift
|instruction that only looks at the lowest 4 bits of the shift size.
|...
|No, I don't know of any such machine.

Okay, to make this concrete, have a look at a Gould sometime.  This hasn't
actually got any `shift by variable' instructions, only shift by constant.  A
shift by variable is done by constructing an instruction in a register and
then executing it.  At the moment this requires AND-OR-EXECUTE, the people who
are suggesting fixing the behaviour when `n' is < 0 or >= bits per word would
force the compiler to add tests for n >= 32 or n < 0 to this.
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv at uk.ac.warwick             ARPA:   cudcv at warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England



More information about the Comp.std.c mailing list