knowledge

Overview

x86 architecture is a family of instruction set architectures (ISA) developed by Intel, defining how a CPU executes instructions, manages memory, and interacts with software. It is one of the most widely used architectures in modern computing and is foundational for understanding low-level programming and exploitation.


Terminology

TermDefinition
ISA (Instruction Set Architecture)Defines the set of instructions a CPU can execute
RegisterSmall, high-speed storage location inside the CPU
StackRegion of memory operating in Last-In, First-Out (LIFO) order
EFLAGSRegister storing status flags from ALU operations (Zero, Carry, Overflow)
EBP (Base Pointer)Points to the base of the current stack frame
ESP (Stack Pointer)Points to the top of the current stack

Core Concepts

General Purpose Registers (GPRs)

Used for arithmetic, logic, and data movement operations.

RegisterCommon Use
EAXAccumulator; stores return values
EBXBase register; general use
ECXCounter; used in loops
EDXData; used in I/O and multiplication
ESISource index; string/memory operations
EDIDestination index; string/memory operations
EBPBase pointer; marks base of stack frame
ESPStack pointer; tracks top of stack

Segment Registers

Used in segmented memory models to point to different memory segments.

RegisterSegment
CSCode Segment
DSData Segment
SSStack Segment
ES, FS, GSAdditional/extended segments

Control & Status Registers

  • EFLAGS – Stores status flags from ALU operations (Zero Flag, Carry Flag, Overflow Flag)
  • Control Registers (CR0–CR4) – Manage CPU modes and memory management (e.g., paging)

Instruction Types

Arithmetic & Logic

Perform mathematical and logical operations.

InstructionOperation
ADD / SUBAddition / Subtraction
INC / DECIncrement / Decrement
IMUL / IDIVSigned multiply / divide
AND / OR / XOR / NOTBitwise logical operations

Data Movement

Move data between registers, memory, and the stack.

InstructionOperation
MOVCopy data from source to destination
PUSH / POPAdd/remove data from the stack
LEALoad effective address into a register

Control Flow

Control the order of execution.

InstructionOperation
CMPCompare two values (sets EFLAGS)
JMPUnconditional jump
JE / JNEJump if equal / not equal
CALLJump to function and store return address
RETReturn execution to caller

The Stack

A region of memory (in RAM) used for temporary data storage during execution.

  • Operates in Last-In, First-Out (LIFO) order
  • Managed using ESP (stack pointer) and EBP (base/frame pointer)
  • PUSH – Adds data to the top of the stack
  • POP – Removes data from the top of the stack

Subroutines (Functions)

Reusable blocks of code called and returned using the stack.

  • CALL – Jumps to function and stores return address on the stack
  • RET – Pops return address from stack and resumes execution
  • Stack stores return addresses, function arguments, and local variables
⚠︎Security Note

The stack’s predictable structure makes it a primary target for exploitation techniques such as buffer overflows and return-oriented programming.


  • Buffer Overflow
  • Stack-Based Exploitation
  • Return-Oriented Programming (ROP)
  • Integer Overflow

References / Images

  • x86 register diagram
  • Stack frame visualization