A compendium of How Computers Really Work (WIP)
Notes on How Computers Really Work by Matthew Justice (No Starch Press, 2020). Chapter summaries in my own words, plus the sums and notes I worked through while reading. Unfinished.
Chapter 1: Computing concepts
Analog systems represent a value by something proportional to it, like a scale's needle or mercury in a thermometer. Digital systems represent data as a sequence of symbols from a small fixed set, and in computers that set is just 0 and 1, because two symbols keep the hardware simple and reliable.
| Prefix | Symbol | Base 10 | English word |
| tera | T | 1012 | trillion |
| giga | G | 109 | billion |
| mega | M | 106 | million |
| kilo | k | 103 | thousand |
| centi | c | 10-2 | hundredth |
| milli | m | 10-3 | thousandth |
| micro | μ | 10-6 | millionth |
| nano | n | 10-9 | billionth |
| pico | p | 10-12 | trillionth |
ISPs advertise in bits per second (base 10), so 50 megabits per second is about 6 megabytes per second.
Hexadecimal is base 16, using 0 to 9 and then A to F for ten to fifteen. It exists because long runs of bits are hard for people to read, and each hex digit maps to exactly four bits.
Hexadecimal is base 16: Ones – 16; Tens – 256; Hundreds – 4096
SUMS:
467b -> 11 + (7*16) = 112 + (256*6) = 1536 + 16384 = 1659 + 16384 = 18043 = 0100 0110 0011 1011
ad48 -> 8 + 64 + 208 + 2560 = 2848
a8f4 -> 4 + 240 + 2048 + 40960 = 43252
Chapter 2: Binary logic and encoding
Encoding is turning data into bits, and decoding is interpreting them. The same bits mean different things depending on the program reading them: text, a pixel's colour, or a number. Logic operators (AND, OR, NOT, and derived ones like NAND and XOR) combine true and false values.
Chapter 3: Electrical circuits
The book explains circuits with a water analogy: charge is water, a wire is a pipe, voltage is the pressure, and resistance is how narrow the pipe is.
| Term | Measured in | Water analogy |
| Electric charge | Coulombs | Water |
| Electric current | Amps | Flow of water through a pipe |
| Voltage | Volts | Water pressure |
| Resistance | Ohms | The width of a pipe |
Ohm's law ties them together:
I = V / R
Amps = Volts / Ohms
AC periodically changes direction and is what comes out of the wall. DC flows one way and is what batteries and phones use. A diode lets current through in only one direction, and an LED is a diode that lights up.
Chapter 4: Digital circuits
Low voltage: Low, LO, off, ground, GND, false, zero, 0
High voltage: High, HI, on, V+, true, one, 1
Mechanical switches can't drive a computer, so transistors act as electronically controlled switches. Logic gates are built from transistors and sold as integrated circuits (chips).
NOTE: FIGURE OUT HOW TRANSISTORS WORK
Chapter 5: Math with digital circuits
Binary addition works like decimal addition with carries. A half adder adds two bits and produces a sum and a carry. Chaining full adders gives a ripple carry adder, which gets slower as the carry ripples through more bits.
To add 0001 + 0010
The least significant bit (ones)
0 + 1 = 1
0 + 1 = 1
0 + 0 = 0
The most significant bit
0 + 0 = 0
1 + 2 = 3
0111
+ 0011
1 + 1 = 0 (carry 1)
1 + 1 = 0 (carry 1)
1 + 1 = 0 (carry 1)
1 + 0 = 1 (carry 1)
Negative numbers are stored in two's complement: flip every bit and add 1. The same adder then works for both positive and negative values. Unsigned numbers skip negatives entirely, doubling the positive range.
5 -> 0101 (Binary) -> 1010 (Flip) -> 1011 -> -5 (in computing)
3 -> 0011 -> 1100 -> 1101 -> -3
0101 + 1101 -> 1 0010 = 3
Chapter 6: Memory and clock signals
Sequential logic depends on past inputs, not just present ones, which is what memory is. An SR latch remembers one bit and can be built from two cross-coupled NOR gates. A clock is a square wave that keeps components changing state together, measured in hertz, and components trigger on either its rising or falling edge.
Chapter 7: Computer hardware
Main memory (RAM) is volatile and byte-addressable. SRAM uses flip-flops and is fast but expensive, so it is used for caches. DRAM uses a transistor and a capacitor, needs refreshing, and is cheap enough for main memory. CPUs that share an instruction set architecture run the same software, and today that mostly means x86 or ARM. Inside the CPU, registers hold data, the ALU does the arithmetic and logic, and the control unit directs everything. Pipelining overlaps instructions within a core, multiple cores run separate tasks, and L1, L2 and L3 caches sit between the CPU and main memory.
NOTE: Learn about multi-threading and parallelism
Chapter 8: Machine code and low-level code
CPUs execute machine code, while developers write source code in higher-level languages. An instruction in ARM cpu looks something like so
11100011101000000111000000000100
1110 – Condition, tells the CPU if the instruction is conditional, in this case it isn't, and it will always run. The opcode here is mov, and the destination register 0111 is r7.
PAUSE – Learn assembly