by N = a power of two, so that a shift by 13 places is a shift by 1 place, followed by a shift by 4 places, and then a shift by 8 places, as 13 = 1 + 4 + 8. We shall illustrate the shift types by considering them as applied to an eight-bit shift register, with contents labeled as R7 R6 R5 R4 R3 R2 R1 R0. We use 1001 0110 as an example. Logical Shifts Logical shifts just move bits in the indicated direction, padding out with 0’s. Shifts can be by any count, but shifts by more than the size of the register leave it all 0’s. For left shifting an N-bit register by 1 RJ+1 RJ for 0 J < (N 1) – R0 0, R(N 1) is lost – As an example of a of an 8-bit register 1001 0110 becomes 0010 1100 For shifts by 1 place RJ+1 RJ for 0 J < (N 1) – R(N 1) 0, R0 is lost – As an example of a 8-bit register shift 1001 0110 becomes 0100 1011 Left shift by 2 places: 1001 0110 becomes 0101 1000 Right shift by 2 places: 1001 0110 becomes 0010 0101 Note that shifting either left or right by eight or more places produces the result 0000 0000, so that the shift count will normally be in the range 0 through 7 inclusive. The general rule for an N-bit register is that the shift count is usually in the range from 0 to (N 1) inclusive, a modulo-N non-negative number. – Arithmetic Shifts Arithmetic shifts are identical to logical shifts except that the sign bits are preserved. Arithmetic shifting is normally defined only for right shifts. For right shifts by 1 place RJ+1 RJ for 0 J < (N 1) – R(N 1) R(N 1), R0 is lost – –
by N = a power of two, so that a shift by 13 places is a shift by 1 place, followed by a shift by 4 places, and then a shift by 8 places, as 13 = 1 + 4 + 8. We shall illustrate the shift types by considering them as applied to an eight-bit shift register, with contents labeled as R7 R6 R5 R4 R3 R2 R1 R0. We use 1001 0110 as an example. Logical Shifts Logical shifts just move bits in the indicated direction, padding out with 0’s. Shifts can be by any count, but shifts by more than the size of the register leave it all 0’s. For left shifting an N-bit register by 1 RJ+1 RJ for 0 J < (N – 1) R0 0, R(N – 1) is lost As an example of a of an 8-bit register 1001 0110 becomes 0010 1100 For shifts by 1 place RJ+1 RJ for 0 J < (N – 1) R(N – 1) 0, R0 is lost As an example of a 8-bit register shift 1001 0110 becomes 0100 1011 Left shift by 2 places: 1001 0110 becomes 0101 1000 Right shift by 2 places: 1001 0110 becomes 0010 0101 Note that shifting either left or right by eight or more places produces the result 0000 0000, so that the shift count will normally be in the range 0 through 7 inclusive. The general rule for an N-bit register is that the shift count is usually in the range from 0 to (N – 1) inclusive, a modulo-N non-negative number. Arithmetic Shifts Arithmetic shifts are identical to logical shifts except that the sign bits are preserved. Arithmetic shifting is normally defined only for right shifts. For right shifts by 1 place RJ+1 RJ for 0 J < (N – 1) R(N – 1) R(N – 1), R0 is lost