Register Set
The register set is divided into three categories:
- General Purpose Registers
- Special Purpose Registers
- Control Registers
There are total eight (8) general purpose registers and two (2) special purpose registers in x86 (32-bit). Apart from this there are five (5) control registers. The prupose of each of these registers is tabulated below:
General Purpose Registers
| Register Name | Purpose |
|---|---|
| EAX | Accumulator |
| EBX | It has no specific uses, but is often set to a commonly used value (such as 0) throughout a function to speed up calculations |
| ECX | Counter in loops |
| EDX | Occasionally used as a function parameter or generally used for storing short-term variables within a function |
| ESI | Source in string/memory operations |
| EDI | Destination in string/memory operations |
| EBP | Base frame pointer |
| ESP | Stack pointer |
Special Purpose Registers
| Register Name | Purpose |
|---|---|
| EIP | Instruction Pointer |
| EFLAGS | Flags to store the status of arithmetic operations and other execution states (e.g., trap flag). |
Control Registers
The important registers that are used to control low-level system mechanisms such as virtual memory, interrupts, and debugging are listed below:
| Register Name | Purpose |
|---|---|
| CR0 | Controls whether paging is on or off |
| CR1 | Reserved, the CPU will throw an exception when trying to access it. |
| CR2 | Linear address that caused a page fault aka Page Fault Linear Address (PFLA) |
| CR3 | Base address of a paging data structure |
| CR4 | Controls the hardware virtualization settings |
| DR0 – DR7 | Used to set memory breakpoints |
| CR5-7 | Reserved |
Data Types
Following four types of data would be most commonly used in programming the x86 processor.
- Bytes - 8 bits. Examples: AL , BL , CL
- Word - 16 bits. Examples: AX , BX , CX
- Double word - 32 bits. Examples: EAX , EBX , ECX
- Quad word - 64 bits