🧮 ⚙️ 💻
The fundamental building blocks of CPU computation
🔍 The Arithmetic Logic Unit (ALU) performs micro-operations, which are the smallest and most basic operations executed directly by the hardware on binary data stored in CPU registers.
Mathematical operations on binary data
Bit-level logical operations using logic gates
Shifting bits left or right
Moving data between registers
These deal with mathematical operations on binary data.
R3 ← R1 + R2
R3 ← R1 – R2 (done using 2's complement)
R1 ← R1 + 1
R1 ← R1 – 1
These perform bit-level logical operations using logic gates.
R3 ← R1 AND R2
R3 ← R1 OR R2
R3 ← R1 XOR R2
R1 ← NOT R1
These shift the bits of a binary number left or right.
Shifts all bits left, fills 0 in the rightmost bit
Shifts all bits right, fills 0 in the leftmost bit
Preserves the sign bit for signed numbers
Bits rotate around instead of being lost
These move data from one register to another without processing.
R2 ← R1
Move data from one register to another
R1 ← M[1000]
Load data from memory address 1000 into register R1
M[1000] ← R1
Save data from register R1 to memory address 1000
💡 Data transfer operations are essential for moving data between different components of the CPU and between the CPU and memory.
After executing micro-operations, the ALU updates flags in the status register:
Set if result = 0
Set if an arithmetic operation generates a carry out
Set if result is negative (MSB = 1)
Set if signed result exceeds range
📝 Status flags are crucial for conditional branching and decision-making in programs.
Micro-operations are the building blocks of all computations in the CPU.
🔍 A micro-operation is the smallest operation the CPU can perform on data stored in registers.
Move data between registers or memory
Basic math operations
Bit-level operations
Move bits left or right
Operands come from registers into ALU input registers (A & B)
The Control Unit tells ALU what to do (add, AND, shift, etc.)
ALU uses adders, logic gates, or shifters to process data
Result goes into a result register or back to memory
✅ In short: Micro-operations are the tiny steps that ALU performs — moving data, doing arithmetic, applying logic, and shifting bits. The Control Unit tells ALU which micro-operation to do, and results are stored back for the CPU to continue execution.