Shift instructions
Nefastor
Posts: 14
Hi all,
I'm using shifts (SHL, SHR) and I am wondering this : suppose I shift left, are the LSB's cleared or set ? (resp, if I shift right, are the MSB's cleared or set ?)
The chip's manual does not indicate this (page 402)
I assume the bits are cleared, since this is the most sensible behavior : SHL can then be used to multiply by powers of 2.
Still, I'd prefer to be sure
Jean
I'm using shifts (SHL, SHR) and I am wondering this : suppose I shift left, are the LSB's cleared or set ? (resp, if I shift right, are the MSB's cleared or set ?)
The chip's manual does not indicate this (page 402)
I assume the bits are cleared, since this is the most sensible behavior : SHL can then be used to multiply by powers of 2.
Still, I'd prefer to be sure
Jean
Comments
otherwise, 0's are shifted in.
Not sure you got this right : a shift where the MSB is copied from the previous MSB would be a right arithmetic shift, not a right logical shift : keeping the MSB preserves the sign bit.
My question still stands.
Jean
Mathmatically its:
shl = multiply by two
shr = divide by two unsigned
sar = divide by two signed
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 1/3/2007 10:19:36 PM GMT
doing an extended (33-bit) "rotate".