487 words
2 minutes
Inroduction to CPU Register

Introduction to CPU Registers (Simplified)#

alt text Registers are tiny storage spaces inside a computer’s CPU (Central Processing Unit). They’re super fast and are used to hold data the CPU needs right now, like numbers being added or memory addresses.

Let’s explore the main types of registers, how they’re structured, and what they’re used for.


Basic General Purpose Registers#

These are like temporary boxes for storing values while the CPU works on them. They’re commonly used in assembly programming.

The main 32-bit registers are:

  • EAX – Accumulator (used for arithmetic/logic operations)
  • EBX – Base register (often used to point to data)
  • ECX – Counter register (commonly used for loops)
  • EDX – Data register (used in I/O operations, division)

Each of these is 32 bits wide, meaning they can hold 4 bytes of data.


Register Breakdown: Internal Structure#

Registers aren’t just solid blocks—they can be broken down into smaller parts for more flexible use. alt text Let’s look at EAX as an example:

NameSizeDescription
EAX32 bitsEntire register (4 bytes)
AX16 bitsLower half of EAX
AH8 bitsHigher byte of AX
AL8 bitsLower byte of AX

Example:

If EAX = 0x12345678:

  • AX = 5678 (last 4 hex digits)
  • AH = 56 (first 2 hex digits of AX)
  • AL = 78 (last 2 hex digits of AX)

This breakdown applies to EBX, ECX, and EDX too.


64-bit Registers#

alt text Modern CPUs often use 64-bit registers, which can hold 8 bytes of data—twice as much as 32-bit registers.

Let’s take a look at RAX, the 64-bit version of EAX.

NameSizeDescription
RAX64 bitsFull register (8 bytes)
EAX32 bitsLower half of RAX
AX16 bitsLower half of EAX
AH8 bitsHigher byte of AX
AL8 bitsLower byte of AX

This structure lets you work with just part of the register when you don’t need the full 64 bits.


Other Important Registers#

Besides the general-purpose ones, there are special-purpose registers that help control the CPU’s operations.

String Index Registers#

Used during string or memory operations:

  • ESISource Index: Points to the source of data
  • EDIDestination Index: Points to where data will go

These are handy for tasks like copying arrays or strings in memory.


Instruction Pointer#

  • EIPInstruction Pointer: Holds the memory address of the next instruction the CPU will execute.

Think of this as the CPU’s “to-do list cursor.”


Stack Frame Pointers#

alt text The stack is a part of memory used for function calls, local variables, and temporary storage. These two registers help manage it:

  • ESPStack Pointer: Points to the top of the stack
  • EBPBase Pointer: Points to the bottom (or base) of the current function’s stack frame

Together, they help keep track of where things are stored during a program’s execution.


Summary#

RegisterPurposeSize (Common)
EAX, EBX, ECX, EDXGeneral operations32 bits
RAX, RBX, RCX, RDXGeneral operations (64-bit)64 bits
AH, AL, BH, BLByte-level access8 bits each
ESI, EDISource/Destination Index32 bits
EIPNext instruction address32 bits
ESP, EBPStack management32 bits

Why Registers Matter#

Registers are at the heart of all low-level programming. Whether you’re writing assembly code, analyzing malware, or doing binary exploitation in cybersecurity, understanding how registers work is essential.

They’re your frontline tools for controlling how the CPU processes data.


Let me know if you’d like a diagram version of these concepts or a flashcard-style cheat sheet!

Inroduction to CPU Register
https://frqblog.vercel.app/posts/intro-to-registers/
Author
frqblog
Published at
2025-07-26
License
CC BY-NC-SA 4.0