One position right barrel shift using ALU Operators?

Posted by Tomek on Stack Overflow See other posts from Stack Overflow or by Tomek
Published on 2009-10-12T04:45:15Z Indexed on 2010/04/07 1:43 UTC
Read the original article Hit count: 242

I was wondering if there was an efficient way to perform a shift right on an 8 bit binary value using only ALU Operators (NOT, OR, AND, XOR, ADD, SUB)

Example:

input:  00110101
output: 10011010

I have been able to implement a shift left by just adding the 8 bit binary value with itself since a shift left is equivalent to multiplying by 2. However, I can't think of a way to do this for shift right.

The only method I have come up with so far is to just perform 7 left barrel shifts. Is this the only way?

© Stack Overflow or respective owner

Related posts about bit-shift

Related posts about operators