What are registers in the x86 processor
By Daniel McCarthy on in
Registers are memory storage locations built right into the CPU. Processor operations mostly involve processing data. To speed up the processor operations, registers store data elements for processing. That means no control buses involved, and all the complicated processes when accessing data from conventional RAM memory. The CPU uses internal memory storage locations.
There is a limited number of registers built into the CPU. There are 10 32-bit and 6 16-bit registers in IA-32 architecture. There are 3 categories of processor registers, namely, general, control, and segment registers, and each serve a specific purpose.
These are the registers we use more often than not. In most cases, these are the ones you are going to be using the most. Registers under this category are the ones most instructions use. The title says it all, they are generally used. And most can be broken down into 16 or even 8 bit registers:
General Purpose Registers
32 bits : EAX EBX ECX EDX
16 bits : AX BX CX DX
8 bits : AH AL BH BL CH CL DH DL
The suffixes 'L' and 'H' on 8 bit registers stand for low and high byte.
AX - The primary accumulator, used in input/output access, arithmetic, and interrupt calls.
BX - The base register, could be used in indexed addressing, or base pointer for memory access.
CX - The counter register, stores the loop count in iterative operations, and for shifts.
DX - The data register, also used in input/output operations, arithmetic, and some interrupt calls.
Control Registers
Instruction pointer registers, and flags registers combined are considered control registers. These registers change or control the general behaviour of a CPU.
Pointer registers indicate where a computer is in it's program sequence. There are three categories of pointer registers:
Instruction Pointer (IP) - Holds the offset of the next instruction to be executed.
Stack Pointer (SP) - Holds the top address of the stack
Base Pointer (BP) - Holds the base address of the stack
Flag Registers
Flags registers hold the state of the processor. Each bit holds the state of specific parameter of the last instruction. There is a ton of flags registers, the listing is as follows, not exhaustive:
CF Carry flag
PF Parity flag
AF Auxiliary carry flag
ZF Zero flag
SF Sign flag
TF Trap flag
IF Interrupt enable flag
DF Direction flag
OF Overflow flag
Segment Registers
There are 3 main segments, code, data, and stack segments. These are specific areas defined in a program for containing code, data and stack.
Code Segment (CS) - register stores the starting address of the code segment.
Data Segment (DS) - register stores the starting address of the data segment.
Stack Segment (SS) - register stores the starting address of the stack segment.
That was a brief overview of what registers are, the types of registers there is, and what each register does. For more on processor registers you can learn here: https://www.dragonzap.com/course/x86-assembly-language. In his course, Daniel McCarthy explains more about the subject