LOW LEVEL SYSTEM

Assembly Language.

The closest you can get to talking directly to a computer's brain. Fast, powerful, and deeply complex.

No Middleman

When you write code in Python or Java, you are talking to a translator. The translator changes your words into signals the computer can understand. This takes time.

Assembly is different. It has no middleman. You are giving orders directly to the computer's physical hardware. This makes it incredibly fast, but you must tell the computer exactly how to do every tiny step.

The Language Stack

High Level (Python) print("Hello")
Low Level (Assembly) MOV eax, 4
Machine Code (Hardware) 01001101 00000100

How the Machine Thinks

A computer's processor (CPU) is very fast, but very simple. It only does three things over and over again, billions of times a second. Assembly language is built perfectly for this three-step dance.

1

Fetch

The CPU goes to the memory and grabs the next instruction. In Assembly, every line you write is one exact instruction to fetch.

2

Decode

The CPU looks at the instruction and figures out what parts of the hardware it needs to turn on or off to make it happen.

3

Execute

The CPU actually does the math, moves the data, or jumps to a new part of the code. Then it goes back to step 1.

Registers: The CPU's Hands

Imagine you are doing mental math. You have to hold numbers in your head before you write them down.

Registers are the computer's way of holding things in its head. They are tiny, super-fast storage boxes built right inside the CPU. Assembly code spends most of its time moving data in and out of these boxes.

General Purpose Registers (x86)

EAX
00000000
EBX
00000000
ECX
00000000
EDX
00000000

In Assembly, you name these boxes directly. If you want to do math, you must load your numbers into these boxes first.

The Verbs (Instructions)

Assembly does not have fancy words. You build entire programs using very short commands called Instructions. Most instructions do only one tiny thing. Here are the most common ones you will see.

MOV
Move Data
Copies a number from memory into a register, or from one register to another.
ADD
Addition
Adds two numbers together and stores the answer.
SUB
Subtract
Takes one number away from another.
JMP
Jump
Tells the CPU to stop reading straight down, and skip to a different line of code.

The Memory Grid (RAM)

When you run out of registers, you must put data in main memory (RAM). Assembly sees memory as a giant list of numbered mailboxes. You must know the exact number (address) of the mailbox you want.

0x0001
10110011
0x0002
00001111
0x0003
DATA HERE
0x0004
11110000

Why is this hard?

In modern languages, you just say name = "John" and the computer finds an empty mailbox for you.

In Assembly, you are the manager. You must find an empty mailbox. You must remember the address 0x0003. If you make a mistake and overwrite a mailbox the computer needs to stay awake, the entire computer will crash.

Code Comparison: Doing Simple Math

Python (High Level)

# Just write the math

total = 5 + 3
print(total)

Friendly, easy to read. The computer does all the background work to figure out where to store the numbers.

Assembly (Low Level)

; Put 5 into the EAX register box
MOV EAX, 5

; Add 3 to the box
ADD EAX, 3

; Getting it to print requires 10+ more lines

You must move the number into a physical hardware box first, then do the math on that box.

The Assembler Tool

A CPU does not actually read the letters MOV or ADD. It only reads electricity (On or Off, 1 or 0).

To turn your words into 1s and 0s, you use a special tool called an Assembler. It acts like a very simple dictionary. It looks up the word MOV and changes it into the numbers 10110000.

MOV
ASSEMBLER
1011

The Ultimate Speed

  • No guessing: The computer does exactly what you tell it to do, immediately.
  • Tiny files: Assembly programs are incredibly small because there is no extra fluff.
  • Hardware power: You can control the fans, the power usage, and the exact timing of the CPU.

The High Cost

  • Very slow to write: What takes 1 line in Python can take 50 lines in Assembly.
  • Not portable: Assembly code written for an Intel CPU will completely fail on an Apple CPU.
  • Dangerous: If you make a mistake, there are no safety nets. The program will crash horribly.

The Stack (Temporary Storage)

When the CPU is doing complex math, it needs a place to drop numbers temporarily, like setting a heavy box down. It uses a special part of memory called The Stack.

It works like a stack of heavy plates. You can only put a new plate on the very top (called a PUSH). You can only take a plate off the very top (called a POP). You cannot grab the bottom plate without moving the top ones first.

PUSH
New Data
Old Data
Older Data

Pointers: The Treasure Maps

Sometimes, a box in memory doesn't hold a number or a letter. Instead, it holds the address of another box. This is called a Pointer.

Think of a pointer like a treasure map. The map itself is not the gold. But if you follow the directions on the map, you will find the gold. In Assembly, you constantly read maps to find where your data is hiding.

REGISTER EAX (The Map)
Address: 0x99
MEMORY 0x99 (The Gold)
Value: 5000
Your Assembly Code
Operating System (The Boss)
Hardware / Screen

System Calls

You might think Assembly lets you do absolutely anything. But modern computers have a safety guard: The Operating System (like Windows or Mac).

If your Assembly program wants to print something to the screen, or save a file, it is not allowed to touch the hardware directly. It must make a "System Call". This means stopping your code, raising your hand, and politely asking the Operating System to do the dangerous work for you.

Flags: The CPU's Memory Notes

When the CPU subtracts two numbers, it immediately forgets what the answer was unless you saved it. But what if you just wanted to know if the numbers were equal? The CPU uses tiny single-bit notes called Flags to remember what just happened.

Zero Flag (ZF)
Turns ON if the last math problem resulted in exactly zero.
Sign Flag (SF)
Turns ON if the last math problem resulted in a negative number.
Overflow (OF)
Turns ON if the answer was too big to fit inside the register box! Error!

The Compiler (The Robot Factory)

When you write C++ or Rust, a tool called a Compiler reads your code and automatically writes Assembly for you. Modern compilers are incredibly smart. They can reorganize your code to run faster than almost any human could write by hand.

The Assembler (The Hand-Crafter)

Writing Assembly by hand is like building a watch with tweezers. You only do it when the Robot Factory makes a mistake, or when you need to squeeze out 1% more speed in a very specific part of a video game.

Endianness: Reading Backwards

Here is a very confusing secret about most computers: they read big numbers backwards. If you want to store a large number that takes up multiple mailboxes, the computer stores the "smallest" part of the number first. This is called Little-Endian.

How Humans Read (Hexadecimal)
1A 2B 3C 4D
How Intel CPUs Store It in RAM
4D 3C 2B 1A
You must know this, or your data will look like gibberish!

Not All Assembly is the Same

Because Assembly talks directly to the physical metal, every type of CPU has its own unique language. They cannot understand each other. If you buy a new computer with a different chip, the old Assembly code is completely useless.

x86 / x64 Family

Used in older Windows PCs, Intel, and AMD chips.

  • Very complex language.
  • Thousands of different instructions.
  • Like a massive tool chest.

ARM Family

Used in iPhones, Androids, and Apple Macbooks (M1/M2 chips).

  • Simple, clean language.
  • Fewer instructions, but they run very fast.
  • Like a Swiss Army Knife.

"Hello World" is Exhausting

In Python, printing "Hello World" is 1 line. In Assembly, you must manually setup the text, tell the OS exactly how many letters are in the text, ask the OS to print it, and then explicitly ask the OS to shut down the program. Look at this work:

; 1. Define the text in memory
msg: db 'Hello, World!', 0xA
len: equ $ - msg

; 2. Prepare the System Call to write to screen
mov edx, len ; Pass the length of the string
mov ecx, msg ; Pass the address of the string
mov ebx, 1 ; Say we want the standard screen
mov eax, 4 ; Code for "Write"
int 0x80 ; Call the Operating System!

Debugging: One Step at a Time

When Assembly code breaks, there are no helpful error messages. To fix it, you use a Debugger.

A debugger lets you freeze time. You can press a button to step forward through your code exactly one line at a time. While frozen, you look at the register boxes and memory mailboxes to see exactly what numbers changed. It is tedious detective work.

--- DEBUGGER ATTACHED ---
> mov eax, 5
add ebx, eax
jmp end
EAX: 00000005
EBX: 00000000
ZF: 0

The Future: WebAssembly (WASM)

Normally, web browsers only run a slow language called JavaScript. But what if you want to run a heavy 3D video game inside Google Chrome?

We created WebAssembly (WASM). It is not real hardware assembly. It is a fake, safe assembly language that runs inside your browser. You can write complex code in C++, turn it into WebAssembly, and run it on a website at near-hardware speeds. It is changing the internet.

http://getbetterat.work/game
60 FPS RUNNING

Where is Real Assembly Used Today?

Car Engines & Brakes

When you hit the brakes, the computer cannot pause. It must work instantly. Assembly guarantees this speed.

Home Appliances

Washing machines and microwaves have very cheap, tiny computer chips. Assembly is small enough to fit inside them.

Video Game Engines

To draw millions of graphics on screen at 60 frames a second, game makers use Assembly for the heaviest math.

Security & Hacking

Security experts read Assembly to find secret bugs in software or to understand how computer viruses work.

Should You Learn It?

Most web developers and software builders never need to write Assembly. But learning how it works makes you a better programmer. It removes the magic. Once you understand Assembly, you understand exactly what the computer is doing behind the scenes.

Knowledge Verified