DATA STORAGE AND MANIPULATION
Download the Lessonotes Mobile Ghana app for faster lesson access on Android and iPhone.
Subject: Computing
Class: SHS 3
Term: 1st Term
Week: 10
Grade code: 3.1.1.LI.2
Strand code: 1
Sub-strand code: 1
Content standard code: 3.1.1.CS.1
Indicator code: 3.1.1.LI.2
Theme: COMPUTER ARCHITECTURE & ORGANISATION
Subtheme: DATA STORAGE AND MANIPULATION
This page supports the lesson note with a companion video and a short classroom-ready summary.
For class groups and homework, share this lesson page so learners also get the summary, objectives, and full lesson context.
Welcome, future programmers and computer scientists! We know that the Central Processing Unit (CPU) is the brain of the computer. But how does it perform calculations so incredibly fast? Today, we are going "under the hood" to explore some of the CPU's cleverest tricks: Shift and Rotation operations. These are not your typical addition or subtraction. They are fundamental, high-speed operations that manipulate data at its most basic level—the level of individual bits (0s and 1s).
Before we dive in, let's remember a few key things: Bit: The smallest unit of data, either a `0` or a `1`. Byte: A group of 8 bits. We will use 8-bit numbers (one byte) for our examples. Register: A small, high-speed storage location within the CPU where these operations happen. MSB (Most Significant Bit): The leftmost bit in a binary number. LSB (Least Significant Bit): The rightmost bit in a binary number. A. Shift Operations
Shift operations move the bits in a register to the left or to the right. The key difference between the types of shifts is what happens to the bits that "fall off" one end and what fills the empty space on the other. Logical Shifts
These are the simplest shifts. They treat the number as just a collection of bits, without any special meaning for the sign. Logical Shift Left (LSL) Mechanism: All bits are shifted one position to the left. A `0` is added to the rightmost position (the LSB). The leftmost bit (the MSB) is discarded. Mathematical Effect: Each single shift to the left is equivalent to multiplying the number by 2. Example: Perform LSL by 1 on `00101101` (which is 45 in decimal).
``` Original: 0 0 1 0 1 1 0 1 (Decimal 45) | | | | | | | | > > > > > > > New: 0 0 0 1 0 1 1 0 (Decimal 22) ``` The rightmost `1` is discarded. A new `0` is added on the left. Result: `00010110`. As you can see, 45 / 2 = 22.5. The integer result is 22. Arithmetic Shifts