Processor Fundamentals and Assembly Language: Question 7
Syllabus 4.3
A processor register holds the 8-bit two's complement value 11101000. Three kinds of shift are available:
- a logical shift moves every bit left or right by a stated number of places, filling any vacated bit positions with 0.
- an arithmetic shift moves every bit left or right by a stated number of places, but on a right shift the sign bit (the most significant bit) is preserved, and vacated positions are filled with copies of the original sign bit, so the value is treated as a signed two's complement number.
- a cyclic shift moves every bit left or right by a stated number of places, but any bit shifted out of one end of the register re-enters at the opposite end, so no bits are lost.
Each part below applies a shift to the original, unchanged value 11101000.
(a) State the result, in binary, of applying a logical shift left by 1 place to 11101000, and state the denary value of this result if it is interpreted as an unsigned 8-bit binary integer. [2]
(b) State the result, in binary, of applying an arithmetic shift right by 1 place to 11101000, and state the denary value of this result if it is interpreted as a signed two's complement integer. [2]
(c) State the result, in binary, of applying a cyclic shift left by 3 places to 11101000. [2]
Show worked solution Hide worked solution
Worked solution
Part (a): Logical shift left by 1
Shift every bit one place to the left, dropping the leftmost bit (1) and filling the vacated rightmost position with 0:
Original: 1 1 1 0 1 0 0 0
Shifted: 1 1 0 1 0 0 0 [0] -> 1 1 0 1 0 0 0 0
Result: 11010000.
As an unsigned 8-bit integer, 11010000 = 128 + 64 + 16 = 208.
[2 marks]: 1 for the correct binary result 11010000, 1 for the correct unsigned value 208.
Part (b): Arithmetic shift right by 1
Shift every bit one place to the right, but keep the sign bit (the leftmost bit, 1) unchanged and copy it into the new bit shifted in on the left; the bit shifted out on the right (0) is discarded:
Original: 1 1 1 0 1 0 0 0
Sign copied: [1]1 1 1 0 1 0 0 (rightmost 0 discarded)
Result: 11110100.
To check this as a signed two’s complement integer: invert 11110100 to get 00001011, add 1 to get 00001100 = 12, so the value is -12. This is consistent with an arithmetic shift right by 1 being equivalent to signed division by 2: the original value 11101000 is -24 (invert 11101000 → 00010111, +1 → 00011000 = 24, so 11101000 = -24), and -24 ÷ 2 = -12.
[2 marks]: 1 for the correct binary result 11110100, 1 for the correct signed value -12.
Part (c): Cyclic shift left by 3
Each one-place left rotation moves every bit one place left, and the bit shifted out on the left re-enters at the right-hand end. Applying this three times:
Start: 1 1 1 0 1 0 0 0
Rotate left 1: 1 1 0 1 0 0 0 1
Rotate left 2: 1 0 1 0 0 0 1 1
Rotate left 3: 0 1 0 0 0 1 1 1
Result: 01000111.
[2 marks]: 1 for correctly rotating the leading bits out and back in at the opposite end (rather than losing them), 1 for the correct final result 01000111 after three rotations.
Final answers
- (a) 11010000 (unsigned value 208)
- (b) 11110100 (signed value -12)
- (c) 01000111