These are the notes for CS Fundamentals for Placements, episode 1. We start from absolute zero and invent a computer ourselves, one problem at a time: a machine that can do only one job, then the stored-program idea, then why RAM forgets in a power cut, then bits, bytes and words (and why a "1 TB" drive shows about 931 GB), then machine code, assembly, compilers, interpreters, linkers and loaders, then the operating system, the von Neumann bottleneck, the Harvard architecture and finally layers of abstraction. Every word is explained the first time it appears, and the Glossary at the end defines all of them again with an example. Every code sample below runs as-is; the outputs shown are real (Python 3.13, gcc 13.3 with gcc -O2).
The problems you'll solve
| Problem | What it teaches |
|---|---|
| A machine that does one job | The parts of a computer: CPU, main memory, storage, input/output |
| A new job means rewiring it? | The stored-program concept, von Neumann architecture, fetch-decode-execute |
| Power cut, work gone | RAM (volatile) vs secondary storage (non-volatile) |
| It only knows 0 and 1 | Bit, nibble, byte, word, KB vs KiB |
| Nobody can write 0s and 1s | Machine code, assembly, high-level languages; assembler, compiler, interpreter, linker, loader |
| Who manages it all? | System software vs application software, the operating system |
| One road to memory | The von Neumann bottleneck, Harvard and modified Harvard |
| Too much to think about | Abstraction and the layers from transistor to app |
Problem 1: the bill-adding machine (the parts of a computer)
Picture a busy kirana shop (a small grocery store) that adds hundreds of bills a day by hand. You build a machine that adds bills: fast, never wrong. Then the owner says: "Great, now also find the average bill." Your machine can't. It was built to add, and only to add. A new job would need a new machine.
Before fixing that, look at what any computer is made of. A shop clerk has the same four parts:
| The shop clerk | Inside a computer | What it does |
|---|---|---|
| The clerk's brain: does the sums, follows the steps | CPU (Central Processing Unit) | Calculates and controls: the worker |
| The rough notepad: today's numbers, wiped each night | Main memory (RAM) | Fast; holds what is in use right now: the desk |
| The record cupboard: old bills, kept for years | Secondary storage (SSD, hard disk, pen drive) | Slower, but keeps data with the power off: the cupboard |
| Order slips in, receipts out | Input and output (I/O) devices | Keyboard and mouse bring data in; screen and printer send it out: the doors |
Hardware vs software
Hardware = the physical parts you can touch (CPU, RAM, storage, keyboard, screen). Software = the instructions the hardware follows. The flow is Input → CPU → Output, with RAM (now, fast) and storage (forever, slower) beside the CPU. Our problem: in the bill machine, the instructions are the wires, so a new job means new wiring.
Problem 2: don't rebuild the cook, hand over a recipe (the stored program)
| In a kitchen | In a computer |
|---|---|
| One cook who can follow any recipe | One general-purpose CPU that can follow any program |
| A recipe on paper: step 1, step 2, step 3 | A program: a list of instructions |
| Recipe and ingredients on one shelf; new dish = new page | Stored-program concept: program and data in the same memory; change the job by changing memory |
Demo 1: a toy computer in Python
One Python list called memory. The first five boxes are instructions, the last three are data: 20, 22 and an empty box.
# a toy computer: ONE memory holds the program AND the data
memory = ["LOAD 5", "ADD 6", "STORE 7", "PRINT 7", "HALT", 20, 22, 0]
acc = 0 # the CPU's scratch value (a register)
pc = 0 # which memory box to read next (program counter)
while True:
op, *arg = memory[pc].split() # fetch + decode
pc = pc + 1
if op == "HALT": break
a = int(arg[0]) # execute:
if op == "LOAD": acc = memory[a]
if op == "ADD": acc = acc + memory[a]
if op == "STORE": memory[a] = acc
if op == "PRINT": print(f"memory[{a}] = {memory[a]}")
Output:
memory[7] = 42
acc(the accumulator) andpcare registers: tiny, very fast storage slots inside the CPU.accholds the number being worked on;pc, the program counter, holds the address (box number) of the next instruction.- The
while Trueloop is the fetch-decode-execute cycle. Fetch: read the instruction atmemory[pc]. Decode:split()it into the operation (op) and the address (arg). Execute: do it. Every real CPU repeats this loop, billions of times a second. LOAD 5puts 20 inacc,ADD 6adds 22,STORE 7writes 42 into box 7,PRINT 7shows it,HALTstops.
Demo 1b: a new job, same machine
New job: "add the second number twice". We don't touch the CPU code; we only change the memory line:
memory = ["LOAD 6", "ADD 7", "ADD 7", "STORE 8", "PRINT 8", "HALT", 20, 22, 0]
Output: memory[8] = 64 (20 + 22 + 22). Same machine, new job, and all we changed was a list.
von Neumann architecture on one page
- → Program and data live in one memory; the CPU loops fetch → decode → execute, using registers and the program counter.
- ★ John von Neumann's "First Draft of a Report on the EDVAC", dated 30 June 1945, described this stored-program design with one memory holding both data and instructions. The EDVAC designers, Eckert and Mauchly, also contributed to the ideas. The name von Neumann architecture comes from this report, and almost every computer still follows it.
Problem 3: the power cut (RAM vs storage)
You type the whole day's sales into the computer. The power goes for two seconds. When it comes back, everything you hadn't saved is gone. Why? It was only in RAM, and RAM needs power to hold data.
Demo 2: watch RAM forget
import os
def app_ram():
visits = 0 # a variable: lives in RAM
visits = visits + 1
return visits # app ends: RAM is wiped
def app_disk():
visits = 0
if os.path.exists("visits.txt"): # read from storage
visits = int(open("visits.txt").read())
visits = visits + 1
open("visits.txt", "w").write(str(visits)) # save to storage
return visits
for run in [1, 2, 3]:
print(f"run {run}: RAM says {app_ram()}, disk says {app_disk()}")
Output (first run, with no visits.txt yet):
run 1: RAM says 1, disk says 1
run 2: RAM says 1, disk says 2
run 3: RAM says 1, disk says 3
app_ramkeeps the count in a variable, and variables live in RAM. When the function ends, its variables are gone, so it says 1 every time.app_diskreads the count from a file, adds one and writes it back. Files live on storage, so it remembers: 1, 2, 3.- Memory that loses its data without power is volatile (RAM). Storage that keeps it is non-volatile (SSD, hard disk, pen drive). That is why apps have a Save button.
Problem 4: it only knows 0 and 1 (bits, bytes, words)
| On the wall | In a computer |
|---|---|
| One light switch: off or on, only two states | A bit (binary digit): 0 or 1 |
| Why only two? On/off is easy to tell apart | Inside a chip a bit is held by tiny electronic switches called transistors, with voltage high or low |
| A row of 8 switches: 256 different patterns | A byte = 8 bits: one English letter, or a number 0 to 255 |
Half a byte, 4 bits, is a nibble (16 patterns). A word is the chunk of bits a CPU handles in one go, usually the size of its registers.
Demo 3: ask Python
import struct
print(bin(5)) # 5 as bits
print(bin(255), len(bin(255)) - 2, "bits")
print(list("Hi".encode())) # each letter = one byte
print(struct.calcsize("P") * 8, "bit word on this machine")
# a "1 TB" drive = 10**12 bytes; counted in GiB (2**30 bytes):
print(10**12 / 2**30)
Output:
0b101
0b11111111 8 bits
[72, 105]
64 bit word on this machine
931.3225746154785
0b101is 5 in binary: 4 + 1 (the0bprefix means "binary").255is eight 1s, the biggest number one byte can hold;len(...) - 2drops the0b."Hi".encode()turns text into bytes:His 72,iis 105. Text is stored as numbers too.struct.calcsize("P")is the size in bytes of a memory address (a pointer) on this machine: 8 bytes = 64 bits, this machine's word size. On a 64-bit laptop a word is 8 bytes.
KB vs KiB: why a "1 TB" drive shows about 931 GB
| Decimal (SI), powers of 10 | Binary (IEC), powers of 2 |
|---|---|
| kilobyte KB = 10³ = 1,000 bytes | kibibyte KiB = 2¹⁰ = 1,024 bytes |
| megabyte MB = 10⁶ = 1,000,000 bytes | mebibyte MiB = 2²⁰ = 1,048,576 bytes |
| gigabyte GB = 10⁹ = 1,000,000,000 bytes | gibibyte GiB = 2³⁰ = 1,073,741,824 bytes |
| terabyte TB = 10¹² bytes | tebibyte TiB = 2⁴⁰ bytes |
Drive boxes use the decimal units. Many computers count in binary units, but often still print the label "GB". Same bytes, different ruler:
# decimal (SI) vs binary (IEC) units
for label, size in [("1 TB drive", 10**12), ("512 GB phone", 512 * 10**9), ("1 GB", 10**9)]:
print(f"{label:<13} = {size:>16,} bytes = {size / 2**30:.2f} GiB")
print("1 KiB =", 2**10, "bytes, 1 MiB =", 2**20, "bytes, 1 GiB =", 2**30, "bytes")
Output:
1 TB drive = 1,000,000,000,000 bytes = 931.32 GiB
512 GB phone = 512,000,000,000 bytes = 476.84 GiB
1 GB = 1,000,000,000 bytes = 0.93 GiB
1 KiB = 1024 bytes, 1 MiB = 1048576 bytes, 1 GiB = 1073741824 bytes
- 1 TB = 931.32 GiB and 512 GB = 476.84 GiB: the same bytes measured with different units. The IEC (the international standards body for electronics) approved the binary prefixes kibi, mebi, gibi, tebi (Ki, Mi, Gi, Ti) in December 1998.
- In exams, read carefully: KB = 1000, KiB = 1024.
Problem 5: who writes 0s and 1s? (languages and translators)
The CPU's instructions are bits too. Here is one real function, three ways (x86-64, from gcc -O1 -S and objdump):
// 1. C, a high-level language (what you write)
int add(int a, int b) { return a + b; }
# 2. assembly (x86-64, from gcc -O1 -S)
add:
leal (%rdi,%rsi), %eax # eax = a + b
ret # go back
# 3. machine code (the bytes the CPU runs)
8d 04 37 c3
- Machine code: the raw numbers a CPU runs.
8d 04 37means "add the two inputs",c3means "return". - Assembly language: machine code written as short words (
leal,ret), one line per instruction. A program called an assembler turns it into bytes. Assembly is tiny steps, and it is different for every family of CPU. - High-level language (C, Java, Python): close to how humans think, and the same code works on many CPUs. One line:
return a + b;. - (When we ran this ourselves on Ubuntu, both outputs also started with an extra
endbr64instruction, bytesf3 0f 1e fa, a security marker some gcc setups add. The add itself is the same.)
The CPU still only reads machine code, so someone must translate. There are two ways.
| Translating a Hindi book into Tamil | Translating code |
|---|---|
| Translate the whole book first, then hand over the finished copy | Compiler: translates the whole program into a machine code file, then you run that file (C works this way) |
| A live interpreter on stage, translating each sentence as it's spoken | Interpreter: reads the program one line at a time and runs each line straight away (Python works this way) |
Demo 4: an interpreter meets a typo (Python)
print("line 1")
print("line 2")
prnt("line 3") # typo
Output:
line 1
line 2
Traceback (most recent call last):
File "main.py", line 3, in <module>
prnt("line 3") # typo
^^^^
NameError: name 'prnt' is not defined. Did you mean: 'print'?
Lines 1 and 2 ran before the interpreter ever reached line 3. The error appears only when that line runs.
Demo 5: a compiler meets a missing semicolon (C)
#include <stdio.h>
int main(void) {
printf("line 1\n");
printf("line 2\n") // missing ;
printf("line 3\n");
return 0;
}
Output:
main.c: In function 'main':
main.c:5:23: error: expected ';' before 'printf'
5 | printf("line 2\n") // missing ;
| ^
| ;
6 | printf("line 3\n");
| ~~~~~~
Nothing printed, not even line 1. The compiler reads the whole program first; if any part is wrong, no machine code file is made, so nothing runs. 5:23 means line 5, column 23.
| Compiler | Interpreter | |
|---|---|---|
| Works on | The whole program, before running | One line at a time, while running |
| Errors show up | Before anything runs | Only when that line is reached |
| Output | A machine code file you can run again and again | No separate file; the interpreter runs it each time |
| Speed | The finished program usually runs faster | You start instantly and can try things line by line |
| Example | C | Python |
Demo 6: the linker can't find a function
Real programs are split into many files and use code other people wrote (like printf). Here we promise a function area but never write it:
#include <stdio.h>
int area(int w, int h); // promised, never written
int main(void) {
printf("area = %d\n", area(4, 5));
return 0;
}
Output:
/usr/bin/ld: /tmp/ccDXnR20.o: in function `main':
main.c:(.text.startup+0x13): undefined reference to `area'
collect2: error: ld returned 1 exit status
(The /tmp/ccXXXXXX.o name is a random temporary file and changes on every run.) ld is the linker: its job is to join all the compiled pieces into one program, and it couldn't find area. Compiling worked; linking failed. Now write the function:
#include <stdio.h>
int area(int w, int h) {
return w * h;
}
int main(void) {
printf("area = %d\n", area(4, 5));
return 0;
}
Output:
area = 20
The linker found area, joined it with printf from the C library, and made one complete program.
From your code to a running program
| Step | Tool | Input → output |
|---|---|---|
| 1. Write | You | main.c, high-level source code |
| 2. Compile | Compiler | main.c → assembly |
| 3. Assemble | Assembler | assembly → main.o, an object file: machine code not yet joined with other pieces |
| 4. Link | Linker (ld) |
main.o + library code (printf) → one executable file on storage |
| 5. Load | Loader (part of the OS) | copies the executable from storage into RAM and points the program counter at its first instruction |
| 6. Run | CPU | fetch, decode, execute |
Problem 6: who manages it all? (system software and the OS)
| In a hotel | In a computer |
|---|---|
| Many guests at once, all want rooms, food, Wi-Fi | Application software: programs that do a job for you (browser, music player, chat app, games) |
| The hotel manager: gives out rooms, keeps order | Operating system (OS), like Windows, Linux or Android: shares the CPU, RAM, storage and devices between programs, and protects them from each other |
| Staff and tools: electrician, keys, ledgers | System software: software that runs the computer itself (OS, drivers, compilers, linkers, loaders), so apps can run on top |
A driver is a small piece of system software that lets the OS talk to one kind of device, like a printer.
Problem 7: one road to memory (the von Neumann bottleneck)
Demo 7: count every trip to memory
# same toy computer: count every trip to memory
memory = ["LOAD 5", "ADD 6", "STORE 7", "PRINT 7", "HALT", 20, 22, 0]
acc, pc, trips = 0, 0, 0
while True:
op, *arg = memory[pc].split()
trips = trips + 1 # trip 1: fetch the instruction
pc = pc + 1
if op == "HALT": break
a = int(arg[0])
trips = trips + 1 # trip 2: fetch or store the data
if op == "LOAD": acc = memory[a]
if op == "ADD": acc = acc + memory[a]
if op == "STORE": memory[a] = acc
if op == "PRINT": print(f"memory[{a}] = {memory[a]}")
print("memory trips:", trips)
Output:
memory[7] = 42
memory trips: 9
- 4 useful instructions × 2 trips + 1 trip to fetch
HALT= 9 trips. - Instructions and data take turns on the same road (path) to memory, so the CPU often waits for memory instead of working. Real CPUs are far faster than main memory, so this waiting hurts. The single path between CPU and memory limiting the whole computer is the von Neumann bottleneck.
von Neumann vs Harvard
| von Neumann | Harvard | |
|---|---|---|
| Memory | Program + data together | Program and data apart |
| Path to the CPU | One, shared | Two, separate |
| Each step can fetch | An instruction or data | An instruction and data, at the same time |
| Plus | Simple, flexible | Faster |
| Minus | They take turns | More wiring |
| Often used in | Most computers' main memory | Microcontrollers (small chips inside devices) and DSPs (digital signal processor chips) |
- The name Harvard architecture is often said to come from the Harvard Mark I, which stored instructions on punched tape (24 bits wide) and data in electro-mechanical counters.
- Most modern processors are modified Harvard: separate instruction and data caches (small, fast memories inside the CPU; episode 9) backed by a common address space (one shared main memory). Your laptop uses both ideas.
Problem 8: you drive without knowing the engine (layers of abstraction)
| Driving a car | Using a computer |
|---|---|
| Steering, brake, accelerator: a simple outside | The app you use: tap, type, scroll |
| Engine, gearbox, fuel injection: hidden underneath | Hidden layers: OS, machine code, circuits |
| You only need the pedals; the mechanic knows the rest | Abstraction: each layer hides the one below |
Abstraction means hiding messy details behind a simple outside, so you can use something without knowing how it works inside.
The layer stack, from transistor to application
| # | Layer | What it is | Example | It hides |
|---|---|---|---|---|
| 8 | Applications | What you tap and type in | A browser, a game | Everything below |
| 7 | High-level languages | Human-friendly code that works on many CPUs | C, Java, Python: return a + b; |
Which CPU you run on |
| 6 | Operating system | Shares hardware between programs | Windows, Linux, Android | Managing devices and memory by hand |
| 5 | Assembly language | Machine code as short words | leal, ret |
Remembering raw numbers |
| 4 | CPU design + machine code | The fixed set of instructions a CPU understands | 8d 04 37 c3 |
How the circuits are wired |
| 3 | Circuits | Gates combined into useful parts | Adders, registers, memory cells | Single gates |
| 2 | Logic gates | Do AND, OR, NOT on bits | AND: 1 only if both inputs are 1 | Single transistors |
| 1 | Transistors | Billions of tiny on/off switches in one chip | Voltage high = 1, low = 0 | Physics and electricity |
Each layer uses the one below without caring how it works. Logic gates get their own episode (episode 5).
Common mistakes (and the real errors)
| Mistake | Code | Error (exact) | Who catches it | Fix |
|---|---|---|---|---|
| Typo in a name | prnt("line 3") |
NameError: name 'prnt' is not defined. Did you mean: 'print'? |
Python interpreter, only when that line runs | Fix the name; test every line, even rarely used ones |
| Missing semicolon | printf("line 2\n") // missing ; |
error: expected ';' before 'printf' |
C compiler, before anything runs | Add ; at the end of the line before the one it points to |
| Function promised but never written | int area(int w, int h); // never written |
undefined reference to `area' and collect2: error: ld returned 1 exit status |
Linker | Write the function, or link the file that has it |
Toy CPU with no HALT: it runs into the data |
memory = ["LOAD 4", "ADD 5", "STORE 6", "PRINT 6", 20, 22, 0] |
AttributeError: 'int' object has no attribute 'split' |
Our toy CPU (Python) | End every program with HALT |
The last one shows the stored-program idea biting back: it prints memory[6] = 42, then tries to "execute" the number 20 as an instruction. To the CPU, instructions and data are just boxes in the same memory.
Mini project: a toy CPU with SUB and JUMP
Add three instructions: SUB a (subtract memory[a] from acc), JUMP a (go to box a next, by changing the program counter) and JZ a (jump only if acc is zero). With them, the toy CPU can loop and decide: a countdown from 3.
# toy computer v2: SUB, JUMP and JZ (jump if acc is zero)
memory = ["LOAD 9", "PRINT 9", "SUB 10", "STORE 9", "JZ 6", "JUMP 1",
"PRINT 9", "HALT", 0, 3, 1]
# boxes 0-7: the program box 9: counter, box 10: the number 1
acc, pc, steps = 0, 0, 0
while True:
op, *arg = memory[pc].split() # fetch + decode
pc = pc + 1
steps = steps + 1
if op == "HALT": break
a = int(arg[0]) # execute:
if op == "LOAD": acc = memory[a]
if op == "ADD": acc = acc + memory[a]
if op == "SUB": acc = acc - memory[a]
if op == "STORE": memory[a] = acc
if op == "PRINT": print(f"memory[{a}] = {memory[a]}")
if op == "JUMP": pc = a # go to box a next
if op == "JZ" and acc == 0: pc = a # jump only if acc is 0
print("instructions run:", steps)
Output:
memory[9] = 3
memory[9] = 2
memory[9] = 1
memory[9] = 0
instructions run: 17
JUMP 1sends the program counter back to box 1, so boxes 1 to 5 repeat: that's a loop.JZ 6leaves the loop once the counter hits 0: that's a decision (anif).- 17 instructions ran from only 8 boxes of program, because the loop reused them (box 8 is unused). Real jump instructions work the same way: they write a new address into the program counter.
Practice
- Add a
MULinstruction to the toy computer (Demo 1) and use it to compute 6 × 7. - How many GiB does a "512 GB" phone really have?
- How many bits are in 3 KiB? How many in 3 KB?
- Count the memory trips for the "add the second number twice" program (Demo 1b).
- Sort these into hardware, system software or application software: keyboard, Linux, a music player, a C compiler, RAM, a printer driver.
- You see
undefined reference to .... Is it a compiler, interpreter or linker error? What do you check?
Solutions and hints
1. Change the memory line and add one if line to Demo 1:
memory = ["LOAD 5", "MUL 6", "STORE 7", "PRINT 7", "HALT", 6, 7, 0]
...
if op == "MUL": acc = acc * memory[a]
memory[7] = 42
2. 512 × 10⁹ / 2³⁰ = 476.84 GiB (see the units demo).
3. 3 KiB = 3 × 1024 × 8 = 24,576 bits. 3 KB = 3 × 1000 × 8 = 24,000 bits.
4. Run Demo 7 with the Demo 1b memory line:
memory = ["LOAD 6", "ADD 7", "ADD 7", "STORE 8", "PRINT 8", "HALT", 20, 22, 0]
memory[8] = 64
memory trips: 11
5 instructions × 2 + 1 for HALT = 11.
5. Hardware: keyboard, RAM. System software: Linux, a C compiler, a printer driver. Application software: a music player.
6. A linker error. Check that the function is actually written (not just declared), that its name is spelled the same everywhere, and that the file containing it is included in the build.
Quick quiz
After a power cut, which one has lost its data?
- A. the SSD
- B. a pen drive
- C. RAM
- D. the hard disk
Answer
C, RAM. RAM is volatile: it needs power to keep its data. SSDs, pen drives and hard disks are non-volatile storage.
Interview questions
- What are the main parts of a computer? CPU (calculates and controls), main memory/RAM (fast, working data), secondary storage (keeps data without power), and input/output devices.
- What is the stored-program concept? Instructions are stored in memory like data, so a new job is a new program in memory, not new wiring.
- What is von Neumann architecture? One memory holds both program and data, reached through one shared path; the CPU repeats fetch-decode-execute.
- What does the program counter do? It holds the address of the next instruction; jumps work by changing it.
- What is the von Neumann bottleneck? The single shared path between CPU and memory: instructions and data take turns, so a fast CPU waits on slower memory.
- Harvard vs modified Harvard? Harvard keeps instructions and data in separate memories with separate paths; modified Harvard has separate instruction and data caches backed by one common address space (most modern processors).
- Volatile vs non-volatile memory? Volatile (RAM) loses data without power; non-volatile (SSD, hard disk) keeps it.
- Compiler vs interpreter? A compiler translates the whole program to machine code before running (errors first, usually faster); an interpreter runs line by line (errors appear when reached).
- What do the assembler, linker and loader do? Assembler: assembly → object file. Linker: joins object files and libraries into an executable. Loader: copies the executable into RAM and sets the program counter.
- System vs application software? System software runs the computer (OS, drivers, compilers); application software does a job for the user.
- How many GiB in a 1 TB drive? 10¹² / 2³⁰ = 931.32 GiB.
- What is abstraction? Hiding details behind a simple interface so each layer can use the one below without knowing how it works.
Glossary
| Term | Meaning in plain words | Example |
|---|---|---|
| Hardware | The physical parts of a computer you can touch | CPU, RAM, keyboard, screen |
| Software | The instructions (programs) the hardware follows | A browser, the OS, our toy program |
| CPU (Central Processing Unit) | The part that calculates and controls; runs instructions one after another | The clerk's brain; the while True loop in Demo 1 |
| Main memory (RAM) | Fast working memory for what is in use right now; loses data without power | The rough notepad; the memory list |
| Secondary storage | Slower memory that keeps data with the power off | SSD, hard disk, pen drive; visits.txt |
| Input devices | Devices that bring data into the computer | Keyboard, mouse |
| Output devices | Devices that send results out of the computer | Screen, printer |
| Application software | Programs that do a job for the user | A music player, a game |
| System software | Software that runs the computer itself so apps can run on top | OS, drivers, compilers, linkers, loaders |
| Operating system (OS) | System software that shares the CPU, memory, storage and devices between programs and protects them from each other | Windows, Linux, Android |
| Driver | System software that lets the OS talk to one kind of device | A printer driver |
| Program | A list of instructions | ["LOAD 5", "ADD 6", ...] |
| High-level language | A human-friendly language whose code works on many CPUs | C, Java, Python: return a + b; |
| Assembly language | Machine code written as short words, one per instruction; different per CPU family | leal (%rdi,%rsi), %eax |
| Machine code | The raw numbers (bits) a CPU actually runs | 8d 04 37 c3 |
| Compiler | Translates a whole program into machine code before it runs | gcc turning main.c into a program |
| Interpreter | Reads and runs a program one line at a time | python3 running Demo 4 |
| Assembler | Turns assembly language into machine code (an object file) | assembly → main.o |
| Object file | Machine code for one source file, not yet joined with other pieces | main.o |
| Linker | Joins object files and library code into one executable | ld, which reported undefined reference to `area' |
| Library | Ready-made code written by others that you link into your program | The C library that provides printf |
| Executable | A complete program file on storage, ready to be loaded and run | The main file made by gcc ... -o main |
| Loader | Part of the OS that copies an executable into RAM and points the program counter at its first instruction | What happens when you run ./main |
| Register | A tiny, very fast storage slot inside the CPU | acc in the toy CPU |
| Program counter (PC) | The register holding the address of the next instruction | pc; JUMP 1 sets it to 1 |
| Address | The number of a memory box | 7 in STORE 7 |
| Fetch-decode-execute | The CPU's loop: read the next instruction, work out what it means, do it | memory[pc], split(), the if lines |
| Stored-program concept | Keeping the program in the same memory as the data, so a new job is just new memory | Demo 1b: new list, same CPU code |
| von Neumann architecture | The stored-program design with one memory for data and instructions and one shared path | Our toy computer; most computers |
| von Neumann bottleneck | The single CPU-memory path limits speed, because instructions and data take turns | Demo 7: 9 trips for 4 instructions |
| Harvard architecture | Separate memories and paths for instructions and data, so both can be fetched at once | Often used in microcontrollers and DSPs |
| Modified Harvard | Separate instruction and data caches backed by one common address space | Most modern processors, including laptops |
| Cache | A small, fast memory inside the CPU that keeps recently used data close (episode 9) | Instruction cache, data cache |
| Volatile | Loses its data when the power goes off | RAM |
| Non-volatile | Keeps its data without power | SSD, hard disk, pen drive |
| Transistor | A tiny electronic switch, on or off; chips contain billions | Voltage high = 1, low = 0 |
| Logic gate | A small circuit made of transistors that does AND, OR or NOT on bits | AND gives 1 only if both inputs are 1 |
| Bit | A binary digit: 0 or 1; the smallest piece of data | One light switch |
| Nibble | 4 bits (16 patterns); half a byte | 1010 |
| Byte | 8 bits (256 patterns): one English letter or a number 0 to 255 | H = 72, 11111111 = 255 |
| Word | The chunk of bits a CPU handles in one go, usually the size of its registers | 64 bits = 8 bytes on a 64-bit laptop |
| KB vs KiB | Kilobyte = 1,000 bytes (powers of 10); kibibyte = 1,024 bytes (2¹⁰) | 3 KB = 3,000 bytes; 3 KiB = 3,072 bytes |
| MB vs MiB | Megabyte = 10⁶ bytes; mebibyte = 2²⁰ = 1,048,576 bytes | 1 MB = 0.95 MiB |
| GB vs GiB | Gigabyte = 10⁹ bytes; gibibyte = 2³⁰ = 1,073,741,824 bytes | 512 GB = 476.84 GiB; 1 TB = 931.32 GiB |
| IEC | The international standards body for electronics; approved the binary prefixes in December 1998 | kibi, mebi, gibi, tebi |
| Abstraction | Hiding messy details behind a simple outside, so you can use something without knowing how it works | Driving with pedals, not the engine |
| Layers of abstraction | A stack where each layer uses the one below without caring how it works: transistors → gates → circuits → CPU/machine code → assembly → OS → high-level languages → apps | Tapping an app runs machine code on transistors |
Summary
- Hardware is what you can touch: CPU, RAM, storage, I/O. Software is the instructions it follows.
- The stored-program concept (von Neumann's 1945 EDVAC report) puts program and data in one memory; the CPU loops fetch → decode → execute using registers and the program counter.
- RAM is volatile (forgets without power); storage is non-volatile (remembers). Save your work.
- Everything is bits: 4 = nibble, 8 = byte, a word is what the CPU handles at once. KB = 1000, KiB = 1024; 1 TB = 931.32 GiB.
- The CPU reads only machine code. Assembly names it; high-level languages are translated by a compiler (all first) or an interpreter (line by line). The assembler, linker and loader finish the journey into RAM.
- The OS is system software that shares the hardware between applications.
- One shared road to memory causes the von Neumann bottleneck; Harvard splits the roads, and modern CPUs are modified Harvard.
- Abstraction stacks layers from transistors up to apps, each hiding the one below.
Next episode: number systems. We wrote 5 as 101; now we learn to count like a computer: binary, octal, decimal and hexadecimal, and how to convert between them by hand, the way placement tests ask.