Lesson 2 of 48 beginner

Microprocessor vs Microcontroller

General-purpose brain vs all-in-one specialist

Open interactive version (quiz + challenge)

Real-world analogy

A microprocessor is like a brilliant but empty-handed surgeon -- incredibly skilled, but needs a hospital (external memory, I/O devices, power supply) to operate. A microcontroller is like a field medic with a backpack -- not as powerful, but carries everything needed (RAM, ROM, I/O ports) right on board and can work anywhere independently.

What is it?

A microprocessor is a CPU-only chip that needs external components (RAM, ROM, I/O) to form a complete system, optimized for high-performance general computing. A microcontroller is a single chip containing CPU, memory, and peripherals, optimized for dedicated control tasks in embedded systems.

Real-world relevance

Your laptop contains a microprocessor (like an Intel Core i7) surrounded by separate RAM sticks, SSD storage, and I/O controllers. Your washing machine contains a microcontroller with everything on one chip, running a simple program that reads the door sensor, controls the water valve, and spins the motor on a fixed schedule.

Key points

Code example

; 8086 Microprocessor: Reading input from an external 8255 PIO chip
; This shows why a microprocessor needs external support chips

.MODEL SMALL
.STACK 100h
.CODE
MAIN PROC
  ; Configure 8255 Programmable I/O
  ; Port A = Output, Port B = Input
  MOV AL, 82h         ; Control word: A=out, B=in, C=out
  OUT 06h, AL          ; Write to 8255 control register

READ_LOOP:
  IN  AL, 02h          ; Read switches from Port B
  NOT AL               ; Invert (active-low switches)
  OUT 00h, AL          ; Echo to LEDs on Port A

  JMP READ_LOOP        ; Continuous loop

  MOV AH, 4Ch
  INT 21h
MAIN ENDP
END MAIN

Line-by-line walkthrough

  1. 1. MOV AL, 82h -- Loads the control word into AL. The value 82h configures the 8255 chip: Port A as output, Port B as input, Port C lower as output.
  2. 2. OUT 06h, AL -- Sends the control word to I/O address 06h, which is the 8255 control register. This programs the chip's behavior.
  3. 3. IN AL, 02h -- Reads one byte from I/O address 02h (Port B of the 8255). This could be connected to DIP switches or push buttons.
  4. 4. NOT AL -- Inverts all bits. If switches are active-low (0 = pressed), this converts them so 1 = pressed, making the logic more intuitive.
  5. 5. OUT 00h, AL -- Writes the processed byte to I/O address 00h (Port A of the 8255). This could be connected to LEDs showing which switches are pressed.
  6. 6. JMP READ_LOOP -- Jumps back to read the switches again, creating an infinite polling loop. This is a common pattern in embedded systems.

Spot the bug

MOV AL, 82h
OUT 06h, AL
IN  AX, 02h
OUT 00h, AX
Need a hint?
The 8255 PIO has 8-bit ports. Check which register size is being used for the I/O operations.
Show answer
The code uses AX (16-bit) for IN and OUT, but the 8255 ports are 8-bit. Using AX would try to read/write 16 bits and access an unintended adjacent port. The fix is to use AL (8-bit): IN AL, 02h and OUT 00h, AL.

Explain like I'm 5

Imagine you have two kinds of toy robots. The first robot is super smart but has no arms, no eyes, and no ears -- you have to plug in separate arms, eyes, and ears for it to do anything. That is a microprocessor. The second robot is not as smart, but it already has arms, eyes, ears, and a little battery pack all built in, so you can just turn it on and it works. That is a microcontroller.

Fun fact

The Apollo Guidance Computer that landed humans on the Moon in 1969 had less processing power than a modern $0.50 microcontroller. It ran at 2 MHz with 74KB of memory. Today, an Arduino Uno (ATmega328P) at $3 has 32KB flash and runs at 16 MHz -- and you can buy ten of them for the price of a pizza.

Hands-on challenge

Draw (on paper or digitally) a block diagram of a minimum-mode 8086 system. Include the CPU, clock generator (8284), address latch (8282), data transceiver (8286), bus controller (8288), RAM, ROM, and an 8255 PIO. Label the address bus (20-bit) and data bus (16-bit) connections.

More resources

Open interactive version (quiz + challenge) ← Back to course: Microprocessor A–Z