Computer Architecture & Low Level Programming
In this page we'll be discussing basic computer architecture terms and concepts and their importance to binary exploitation along with and into to basic assembly
Before we start hacking and writing exploits and finding zerodays, it's essential to fully grasp how computers work if you want to dive deep into binary exploitation, at the end of the day, binary exploitation is low level hacking, if we want to hack in this low level environment, we want to understand it properly, enough about me justifying why we need to learn computer architecture basics, let's go!
We'll segment our mind map into 2 main parts
Understanding Computer Architecture
Introduction to Assembly Language.
Understanding Computer Architecture
What is a Computer Architecture?
Computer architecture is basically how a computer is built and how it actually works, like the blueprint of a high-tech brain with an attitude. It decides how fast your memes load, how smooth your games run, and why your laptop sounds like a jet engine when you open 100 Chrome tabs...
I like to think that computer architecture has 3 main components:
CPU (The Boss)
The CEO of the computer, making all the big decisions.
Executes instructions, does math, and tells other parts what to do.
Has a Control Unit (the manager) and an ALU (the number cruncher).
More cores = more power = more tabs before your computer cries.
Registers – The Brain’s Sticky Notes
The fastest memory inside the CPU, used to store data that needs to be accessed instantly.
Examples:
Accumulator (ACC) – Stores immediate calculations.
Program Counter (PC) – Keeps track of which instruction is next.
Instruction Register (IR) – Holds the current instruction.
Memory (The Forgetful Assistant)
RAM (Random Access Memory) holds data temporarily, like sticky notes that get erased when you turn off your PC.
Cache is like a VIP section for frequently used data, super fast, super small.
If RAM is full, your PC starts using storage as "fake RAM" (paging) and that's when things get painfully slow.
I/O (The Social Butterfly)
Everything that lets you talk to the computer...keyboard, mouse, screen, USB drives, even your angry keyboard smashes.
Without this, your computer would be a lonely genius with no way to communicate.
The main function of a computer processor is to execute instructions and generate an output. The CPU follows a fundamental cycle consisting of Fetch, Decode, Execute, and Store, orchestrated by the Control Unit (CU) and Arithmetic Logic Unit (ALU).
Fetch: The Control Unit (CU) retrieves an instruction from RAM, which is represented in binary, and transfers it to the CPU.
Decode: The CU interprets the instruction and prepares the necessary components for execution. If the instruction involves calculations or logical operations, the Arithmetic Logic Unit (ALU) takes charge.
Execute: The instruction is carried out, this may involve performing a calculation, moving data, or interacting with hardware components.
Store: Once execution is complete, the result is stored back in memory for future use.
This cycle repeats continuously, allowing the CPU to process multiple instructions efficiently, ensuring smooth system operation.
Introduction To Assembly Language
Now that we’ve explored computer architecture and how memory is structured in x86-64, let’s talk about how we actually interact with the CPU at a low level.
Everything a computer does boils down to instructions, tiny operations like adding numbers, moving data, or jumping to a different part of a program. These instructions are executed by the CPU, but writing them directly in binary (machine code) is painful. That’s where Assembly language comes in.
Assembly is a human-readable version of machine code.
It uses mnemonics (short, easy-to-remember words) instead of raw binary.
Each instruction corresponds directly to an operation the CPU can execute.
For example, instead of writing a binary instruction like:
…you can write something more understandable in Assembly:
Both do the same thing, but Assembly is far easier for humans to read.
Why Learn Assembly? 🤯
✅ Gives you direct control over the CPU – You see exactly how instructions are executed. ✅ Essential for reverse engineering & security – Hackers and security researchers use Assembly to analyze malware, exploits, and vulnerabilities. ✅ Helps in debugging & optimization – Knowing Assembly helps you understand how compiled programs run at the lowest level. ✅ Used in embedded systems & OS development – Low-level programming is crucial for writing firmware, kernels, and drivers.
Assembly works closely with registers (tiny storage units inside the CPU).
It follows the Fetch-Decode-Execute cycle we talked about earlier.
Different architectures (like ARM or RISC-V) have their own Assembly languages, but the concepts remain similar.
What's Next?
Now that you understand why Assembly is important, let's dive into: 🔹 Registers and their role in x86-64 Assembly 🔹 Basic instructions (mov, add, sub, cmp, etc.) 🔹 How Assembly interacts with memory (stack, heap, data segment, etc.)
Ready to start writing your first Assembly program?
The Stack Frame
Before we go further, let’s talk about stack frames, they define how functions work and how memory is allocated for each one.
Why does this matter? Because most of the attacks we’ll learn involve manipulating the stack frame and its registers. If you understand how it works, you’ll know exactly where to poke holes and break things.
Stack Frames, What Are They Exactly?
Every time a function is called, the CPU creates a stack frame to store everything the function needs, this includes local variables, function arguments, return addresses, and saved registers. When the function ends, the stack frame is removed, and execution returns to the caller.
How a Stack Frame is Set Up
When a function is called:
The return address is pushed onto the stack (this tells the CPU where to go after the function finishes).
The old base pointer (RBP) is saved, and RBP is updated to mark the start of the new stack frame.
Function arguments and local variables are allocated within the stack frame.
The function executes, using registers and stack memory as needed.
When the function ends, RBP is restored, the stack is cleaned up, and execution returns to the caller.
Stack Frame Layout
RBP (Base Pointer) stays fixed to track the stack frame.
RSP (Stack Pointer) moves as values are pushed/popped.
Epilogue
This isn't the last time we'll visit how computers work, the deeper we dive into pwn the more we dive into computer architecture...
References
Last updated