The Arithmetic Logic Unit (ALU)
What you'll learn: How the ALU performs arithmetic and logical operations on binary data from registers.
What Is the ALU?
The Arithmetic Logic Unit (ALU) is the computational workhorse of the CPU. It's a dedicated digital circuit that performs all the mathematical calculations (like addition and subtraction) and logical operations (like AND, OR, NOT) on binary data. Think of it as a specialized calculator built directly into the processor's hardware.
How the ALU Works
The ALU receives binary inputs from CPU registers—temporary storage locations that hold data the processor is currently working with. When you execute an instruction like "add these two numbers," here's what happens:
- Input: Two binary values are fetched from registers and sent to the ALU
- Operation Selection: A control signal tells the ALU which operation to perform (add, subtract, compare, etc.)
- Processing: The ALU's internal circuits execute the operation on the binary inputs
- Output: The result is sent back to a register, and status flags (like overflow or zero) are set
What Operations Can It Perform?
Arithmetic operations:
- Addition and subtraction (using two's complement for signed integers)
- Increment/decrement
Logical operations:
- Bitwise AND, OR, XOR, NOT
- Bit shifting and rotation
- Comparison (equal, greater than, less than)
The ALU doesn't store data—it just transforms it. It works purely with the binary representations you learned about: unsigned integers, two's complement signed integers, and the various bit patterns that represent numbers in hardware.
Key Takeaway: The ALU is the CPU component that actually performs all arithmetic and logical operations on binary data from registers, acting as the processor's computational engine.