The Language Your CPU Actually Speaks
Every app you have ever opened runs as a river of tiny numbered commands. Assembly is the readable name for those commands, and this is your first look at one running.
Open any app on your machine right now. A browser, a game, a text editor. Whatever it is, your CPU is not reading it. It is not parsing Python, it is not walking a JavaScript syntax tree, and it is certainly not thinking about your for-loop.
It is doing something far dumber and far faster: pulling in one tiny numbered command at a time and obeying it. Billions per second. Commands like copy this number here, add these two, if that was zero, skip ahead.
That stream of tiny commands is machine code: literally numbers, stored in memory, that the processor's circuitry is wired to react to. Every language you have ever written eventually becomes this. There is nothing underneath it.
What is your CPU actually executing when you run a program?
- AMachine code: numbered commands it is physically wired to react to
- BThe source file you wrote, read line by line
- CA tree structure the compiler handed it
- DBytecode that it interprets one statement at a time
Here is a real machine instruction, exactly as it lives in memory:
48 C7 C0 2A 00 00 00Seven bytes. It means "put the number 42 into the register called RAX". You could, in principle, write an entire program this way. People genuinely did, in the 1950s, with switches.
Nobody wants to. So we invented a one-to-one readable name for each of those byte patterns:
mov rax, 42That line is those seven bytes. Not a summary of them, not a convenient shorthand that expands into several steps. One line, one instruction, one thing the CPU does.
The readable form is called assembly language (usually just assembly), and the program that converts it into those bytes is called an assembler.
What makes assembly different from a language like Python or JavaScript?
- AOne line of assembly is one machine instruction, so nothing is hidden underneath it
- BAssembly runs faster because it is compiled ahead of time
- CAssembly has no variables, so there is less to learn
- DAssembly is interpreted directly by the operating system
Enough description. Below is a working CPU with a three-instruction program loaded into it, and you are about to run it.
Press Step once. Watch the arrow in the left margin move, and watch the right panel change. Then press it again. Then again.
Do not worry about what mov and add mean yet. That is the next two modules. Right now the only thing to notice is the rhythm: one instruction, one change, one instruction, one change. That rhythm is the entire machine.
Your first three instructions
Press Step three times. Nothing here needs to make sense yet.
mov rax, 10
mov rbx, 32
add rax, rbxThe readable, one-line-per-instruction language we just stepped through is called ___ language.
One honest warning before we go further, because it changes how you should read this course.
Almost nobody writes whole programs in assembly any more, and this course will not try to convince you to. Compilers are better at it than humans for ordinary code, and they never get bored.
So why learn it? Because assembly is the only view where you can see what your computer is doing. After this course:
- A stack trace stops being magic. You will know what a stack actually is.
- "Segmentation fault" becomes a sentence you can read, not a curse.
- Performance advice stops being folklore, because you can see the work.
- Reverse engineering, security research, embedded work, compiler work and debugging tooling all open up.
The goal is not to make you write assembly for a living. The goal is to end the mystery.
- Your CPU executes machine code: numbered commands stored in memory that its circuitry reacts to directly.
- Assembly language is a readable name for those commands, with one line per machine instruction and nothing hidden underneath.
- An assembler turns assembly into machine-code bytes. Going backwards is called disassembly.
mov rax, 42and the bytes48 C7 C0 2A 00 00 00are the same instruction written two ways.- The point of learning this is not to write assembly daily. It is to be able to see what the machine is doing.
Next lesson: your Python and JavaScript already turn into this. Let's watch the trip.