x64 Registers
Registers are the small memory unit which are placed inside the CPU. In x86-64 architecture , 64 bit registers are used(excluding extended registers). example ➼ rax, rcx, rdx etc.
Total number of registers in a cpu may vary, but in general perpose 16 registers are used.
- Table of contents
Introduction to x64 registers.
Registers are the small size memory units placed inside the cpu. Registers holds data such as variables , memory addresses and other informations. These are more faster than other types of memory. Many of the registers have its lower (32bit, 16bit,8bit) parts that makes it flexible. For example following is a general purpose RAX register >>
General-Purpose Registers (GPRs)
General purpose register are the most important registers. These registers are generally used for arithmetic operations, data storage, and as temporary storage during function calls. In x64 , 16 general purpose registers are there -
- RAX : This is the Accumulator Register. Results of arithmetic operations are often stored in this register. In 32-bit systems, a 32-bit EAX register is present. The last 16 bits of this register can be accessed by addressing AX. Similarly, it can also be addressed in 8 bits by using AL for the lower 8 bits and AH for the higher 8 bits.
- RBX : This register is also called Base register. It is generally used for storing the addresses refrence of a memory. Similar to the RAX/EAX, it can be addressed as 64-bit RBX, 32-bit EBX, 16-bit BX, and 8-bit BH and BL registers.
- RCX : This register is also called the Counter Register and is often used in counting operations such as loops, etc. It can be addressed as 64-bit RCX, 32-bit ECX, 16-bit CX, and 8-bit CH and CL registers. It can be addressed as 64-bit RDX, 32-bit EDX, 16-bit DX, and 8-bit DH and DL registers.
- RDX : RDX stands for the Data register. It often holds data for arithmetic operations, particularly multiplication and division. It can be addressed as 64-bit RDX, 32-bit EDX, 16-bit DX, and 8-bit DH and DL registers.
- RSI : The Source Index register. It is frequently used as the source operand for string operations. It is a 32-bit register called ESI in 32-bit systems
- RDI : The Destination Index register. Similar to RSI, it is used as the destination operand for string operations.
- RSP : The Stack pointer register. It points to the top of the stack and is used during function calls and memory allocation. It is a 32-bit register called ESP in 32-bit systems
- RBP : The Base pointer register. It is used to access parameters passed by the stack. It is a 32-bit register called EBP in 32-bit systems
- R8–R15 : These 64-bit general-purpose registers are not present in 32-bit systems. They were introduced in the 64-bit systems. They are also addressable in 32-bit, 16-bit, and 8-bit modes. For example, for the R8 register, we can use R8D for lower 32-bit addressing, R8W for lower 16-bit addressing, and R8B for lower 8-bit addressing. Here, the suffix D stands for Double-word, W stands for Word, and B stands for Byte.
Flags Register
In a x64 cpu core , there is a single RFLAGS register with the size of 64bits. It contains many flags in it's bytes.
Here is the breakdown of 64 bits -
bit | Flag name | Description |
---|---|---|
0 | CF (Carry) | Indicates a carry or borrow out of the most significant bit in arithmetic operations. |
1 | Reserved | Always set to 1 |
2 | PF (Parity) | Indicates whether the number of 1-bits in the least significant byte of the result is even. |
3 | Reserved | Undefined or unused |
4 | AF (Auxiliary Carry) | Used for binary-coded decimal (BCD) operations, indicating a carry from bit 3 to bit 4. |
5 | ZF (Zero) | Set if the result of an operation is zero |
6 | SF (Sign) | Reflects the sign of the result (0 = positive, 1 = negative) |
7 | TF (Trap) | Enables single-step debugging by generating an exception after each instruction |
8 | IF (Interrupt) | Controls whether maskable interrupts are enabled (1 = enabled) |
9 | DF (Direction) | Controls string operations: 0 = auto-increment, 1 = auto-decrement |
10 | OF (Overflow) | Indicates whether the signed result of an operation exceeds the range of the destination |
11-12 | IOPL (I/O Privilege Level) | Indicates the I/O privilege level for the current task |
13 | NT (Nested Task) | Indicates whether the current task is nested inside another |
14 | Reserved | Undefined or unused |
15 | RF (Resume) | Used to control debugging exceptions |
16 | VM (Virtual 8086 Mode) | Enables Virtual 8086 mode if set. |
17 | AC (Alignment Check) | Enables alignment checking of memory accesses. |
18 | VIF (Virtual Interrupt) | Virtual version of IF flag for virtualization. |
19 | VIP (Virtual Interrupt Pending) | Indicates that a virtual interrupt is pending. |
20 | ID (Identification) | Allows CPUID instruction to execute if set. |
21-63 | Reserved | Unused or reserved. |