CPU Registers x86: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
→General Purpose Registers: 8 bit sil, dil, bpl, spl |
Add x86-64 registers and use uppercase for acronyms |
||
Line 1: | Line 1: | ||
== General Purpose Registers == |
|||
[[Category:CPU_Registers]] |
|||
==General Purpose Registers== |
|||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! |
! 64-bit |
||
! |
! 32-bit |
||
! |
! 16-bit |
||
! 8 |
! 8 high bits |
||
! 8 low bits |
|||
! description |
|||
! Description |
|||
|- |
|- |
||
| |
| RAX |
||
| |
| EAX |
||
| |
| AX |
||
| |
| AH |
||
| AL |
|||
| accumulator |
|||
| Accumulator |
|||
|- |
|- |
||
| |
| RBX |
||
| |
| EBX |
||
| |
| BX |
||
| |
| BH |
||
| |
| BL |
||
| Base |
|||
|- |
|- |
||
| |
| RCX |
||
| |
| ECX |
||
| |
| CX |
||
| |
| CH |
||
| |
| CL |
||
| Counter |
|||
|- |
|- |
||
| |
| RDX |
||
| |
| EDX |
||
| |
| DX |
||
| |
| DH |
||
| |
| DL |
||
| Data |
|||
|- |
|- |
||
| |
| RSI |
||
| |
| ESI |
||
| SI |
|||
| N/A |
| N/A |
||
| |
| SIL |
||
| Source |
|||
| source index |
|||
|- |
|- |
||
| |
| RDI |
||
| |
| EDI |
||
| DI |
|||
| N/A |
| N/A |
||
| |
| DIL |
||
| Destination |
|||
| destination index |
|||
|- |
|- |
||
| |
| RSP |
||
| |
| ESP |
||
| SP |
|||
| N/A |
| N/A |
||
| |
| SPL |
||
| Stack Pointer |
|||
| base pointer |
|||
|- |
|- |
||
| |
| RBP |
||
| |
| EBP |
||
| BP |
|||
| N/A |
| N/A |
||
| |
| BPL |
||
| Stack Base Pointer |
|||
| stack pointer |
|||
|- |
|- |
||
|} |
|} |
||
==Pointer Registers== |
== Pointer Registers == |
||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! |
! 64-bit |
||
! |
! 32-bit |
||
! 16-bit |
|||
! description |
|||
! Description |
|||
|- |
|- |
||
| |
| RIP |
||
| |
| EIP |
||
| IP |
|||
| instruction pointer |
|||
| Instruction Pointer |
|||
|- |
|- |
||
|} |
|} |
||
==Segment Registers== |
== Segment Registers == |
||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! 16 |
! 16-bit |
||
! Description |
|||
! description |
|||
|- |
|- |
||
| |
| CS |
||
| |
| Code Segment |
||
|- |
|- |
||
| |
| DS |
||
| |
| Data Segment |
||
|- |
|- |
||
| |
| ES |
||
| Extra Segment |
|||
| extra segment |
|||
|- |
|- |
||
| |
| SS |
||
| Stack Segment |
|||
| stack segment |
|||
|- |
|- |
||
| |
| FS |
||
| General Purpose F Segment |
|||
| general purpose f segment |
|||
|- |
|- |
||
| |
| GS |
||
| General Purpose G Segment |
|||
| general purpose g segment |
|||
|- |
|- |
||
|} |
|} |
||
==EFLAGS Register== |
== EFLAGS Register == |
||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! |
! Bit |
||
! |
! Label |
||
! Description |
|||
! description |
|||
|- |
|- |
||
| 0 |
| 0 |
||
| |
| CF |
||
| |
| Carry flag |
||
|- |
|- |
||
| 2 |
| 2 |
||
| |
| PF |
||
| |
| Parity flag |
||
|- |
|- |
||
| 4 |
| 4 |
||
| |
| AF |
||
| |
| Auxiliary flag |
||
|- |
|- |
||
| 6 |
| 6 |
||
| |
| ZF |
||
| |
| Zero flag |
||
|- |
|- |
||
| 7 |
| 7 |
||
| |
| SF |
||
| |
| Sign flag |
||
|- |
|- |
||
| 8 |
| 8 |
||
| |
| TF |
||
| |
| Trap flag |
||
|- |
|- |
||
| 9 |
| 9 |
||
| |
| IF |
||
| |
| Interrupt enable flag |
||
|- |
|- |
||
| 10 |
| 10 |
||
| |
| DF |
||
| |
| Direction flag |
||
|- |
|- |
||
| 11 |
| 11 |
||
| |
| OF |
||
| |
| Overflow flag |
||
|- |
|- |
||
| 12-13 |
| 12-13 |
||
| |
| IOPL |
||
| |
| I/O privilege level |
||
|- |
|- |
||
| 14 |
| 14 |
||
| |
| NT |
||
| |
| Nested task flag |
||
|- |
|- |
||
| 16 |
| 16 |
||
| |
| RF |
||
| |
| Resume flag |
||
|- |
|- |
||
| 17 |
| 17 |
||
| |
| VM |
||
| |
| Virtual 8086 mode flag |
||
|- |
|- |
||
| 18 |
| 18 |
||
| |
| AC |
||
| |
| Alignment check |
||
|- |
|- |
||
| 19 |
| 19 |
||
| |
| VIF |
||
| |
| Virtual interrupt flag |
||
|- |
|- |
||
| 20 |
| 20 |
||
| |
| VIP |
||
| |
| Virtual interrupt pending |
||
|- |
|- |
||
| 21 |
| 21 |
||
| |
| ID |
||
| Able to use CPUID instruction |
|||
| id flag |
|||
|- |
|- |
||
|} |
|} |
||
Unlisted bits are reserved. |
|||
==Control Registers== |
==Control Registers== |
||
Line 188: | Line 197: | ||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! |
! Bit |
||
! |
! Label |
||
! Description |
|||
! description |
|||
|- |
|- |
||
| 0 |
| 0 |
||
| |
| PE |
||
| Protected Mode Enable |
|||
| protected mode enable |
|||
|- |
|- |
||
| 1 |
| 1 |
||
| |
| MP |
||
| |
| Monitor co-processor |
||
|- |
|- |
||
| 2 |
| 2 |
||
| |
| EM |
||
| x87 FPU Emulation |
|||
| emulation |
|||
|- |
|- |
||
| 3 |
| 3 |
||
| |
| TS |
||
| |
| Task switched |
||
|- |
|- |
||
| 4 |
| 4 |
||
| |
| ET |
||
| |
| Extension type |
||
|- |
|- |
||
| 5 |
| 5 |
||
| |
| NE |
||
| |
| Numeric error |
||
|- |
|- |
||
| 16 |
| 16 |
||
| |
| WP |
||
| |
| Write protect |
||
|- |
|- |
||
| 18 |
| 18 |
||
| |
| AM |
||
| |
| Alignment mask |
||
|- |
|- |
||
| 29 |
| 29 |
||
| |
| NW |
||
| |
| Not-write through |
||
|- |
|- |
||
| 30 |
| 30 |
||
| |
| CD |
||
| |
| Cache disable |
||
|- |
|- |
||
| 31 |
| 31 |
||
| |
| PG |
||
| |
| Paging |
||
|- |
|- |
||
|} |
|} |
||
NOTE |
NOTE: This register is the only control register that can be written and read via 2 ways unlike the other that can be accessed only via the MOV instruction |
||
<source lang="asm"> |
<source lang="asm"> |
||
; First way: |
|||
;way 1: |
|||
; |
; Write: |
||
mov cr0,reg |
mov cr0, reg |
||
;read: |
|||
; Read: |
|||
mov reg,cr0 |
|||
mov reg, cr0 |
|||
;---------------------- |
|||
; ---------------------- |
|||
;way 2: |
|||
; Second way: |
|||
;write: |
|||
; Write: |
|||
lmsw reg |
lmsw reg |
||
; |
; Read: |
||
smsw reg |
smsw reg |
||
</source> |
</source> |
||
Line 255: | Line 265: | ||
====CR1==== |
====CR1==== |
||
Reserved, the |
Reserved, the CPU will throw a #UD exception when trying to access it. |
||
====CR2==== |
====CR2==== |
||
Line 261: | Line 271: | ||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! |
! Bit |
||
! |
! Label |
||
! Description |
|||
! description |
|||
|- |
|- |
||
| 0-31 (63) |
| 0-31 (63) |
||
| |
| PFLA |
||
| Page Fault Linear Address |
|||
| page fault linear address |
|||
|- |
|- |
||
|} |
|} |
||
Line 275: | Line 285: | ||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! |
! Bit |
||
! Label |
|||
! description |
|||
! Description |
|||
! [[PAE]] mode |
|||
! [[ |
! [[PAE]] |
||
! [[Long Mode]] |
|||
|- |
|- |
||
| 3 |
| 3 |
||
| PWT |
|||
| page-level write-through (PWT) |
|||
| Page-level Write-Through |
|||
| (not used) |
|||
| ( |
| (Not used) |
||
| (Not used) |
|||
|- |
|- |
||
| 4 |
| 4 |
||
| PCD |
|||
| page-level cache disable (PCD) |
|||
| Page-level Cache Disable |
|||
| (not used) |
|||
| ( |
| (Not used) |
||
| (Not used) |
|||
|- |
|- |
||
| 12-31 (63) |
| 12-31 (63) |
||
| PDBR |
|||
| physical base address of page directory |
|||
| Page Directory Base Register |
|||
| base of PDPT |
|||
| |
| Base of PDPT |
||
| Base of PML4T |
|||
|- |
|- |
||
|} |
|} |
||
Line 302: | Line 316: | ||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! |
! Bit |
||
! |
! Label |
||
! Description |
|||
! description |
|||
|- |
|- |
||
| 0 |
| 0 |
||
| |
| VME |
||
| |
| Virtual 8086 Mode Extensions |
||
|- |
|- |
||
| 1 |
| 1 |
||
| |
| PVI |
||
| |
| Protected-mode Virtual Interrupts |
||
|- |
|- |
||
| 2 |
| 2 |
||
| |
| TSD |
||
| Time Stamp Disable |
|||
| time stamp disable |
|||
|- |
|- |
||
| 3 |
| 3 |
||
| |
| DE |
||
| Debugging Extensions |
|||
| debugging extensions |
|||
|- |
|- |
||
| 4 |
| 4 |
||
| |
| PSE |
||
| Page Size Extension |
|||
| page size extension |
|||
|- |
|- |
||
| 5 |
| 5 |
||
| |
| PAE |
||
| Physical Address Extension |
|||
| physical address extension |
|||
|- |
|- |
||
| 6 |
| 6 |
||
| |
| MCE |
||
| Machine Check Exception |
|||
| machine check exception |
|||
|- |
|- |
||
| 7 |
| 7 |
||
| |
| PGE |
||
| Page Global Enabled |
|||
| page global enable |
|||
|- |
|- |
||
| 8 |
| 8 |
||
| |
| PCE |
||
| Performance-Monitoring Counter enable |
|||
| performance monitoring counter enable |
|||
|- |
|- |
||
| 9 |
| 9 |
||
| |
| OSFXSR |
||
| |
| Operating system support for FXSAVE and FXRSTOR instructions |
||
|- |
|- |
||
| 10 |
| 10 |
||
| OSXMMEXCPT |
|||
| osxmmexcpt |
|||
| Operating System Support for Unmasked SIMD Floating-Point Exceptions |
|||
| os support for unmasked simd floating point exceptions |
|||
|- |
|- |
||
| 11 |
| 11 |
||
| |
| UMIP |
||
| |
| User-Mode Instruction Prevention (if set, #GP on SGDT, SIDT, SLDT, SMSW, and STR instructions when CPL > 0) |
||
|- |
|- |
||
| 13 |
| 13 |
||
| |
| VMXE |
||
| Virtual Machine Extensions Enable |
|||
| virtual machine extensions enable |
|||
|- |
|- |
||
| 14 |
| 14 |
||
| |
| SMXE |
||
| Safer Mode Extensions Enable |
|||
| safer mode extensions enable |
|||
|- |
|||
| 16 |
|||
| FSGSBASE |
|||
| Enables the instructions RDFSBASE, RDGSBASE, WRFSBASE, and WRGSBASE |
|||
|- |
|- |
||
| 17 |
| 17 |
||
| |
| PCIDE |
||
| |
| PCID Enable |
||
|- |
|- |
||
| 18 |
| 18 |
||
| |
| OSXSAVE |
||
| |
| XSAVE and Processor Extended States Enable |
||
|- |
|- |
||
| 20 |
| 20 |
||
| |
| SMEP |
||
| Supervisor Mode Execution Protection Enable |
|||
| supervisor mode executions protection enable |
|||
|- |
|- |
||
| 21 |
| 21 |
||
| |
| SMAP |
||
| Supervisor Mode Access Prevention Enable |
|||
| supervisor mode access protection enable |
|||
|- |
|- |
||
| 22 |
| 22 |
||
| |
| PKE |
||
| Protection Key Enable |
|||
| protection keys for user-mode pages enable |
|||
|- |
|- |
||
| 23 |
| 23 |
||
| |
| CET |
||
| Control-flow Enforcement Technology |
|||
| control-flow-enforcement enable |
|||
|- |
|- |
||
| 24 |
| 24 |
||
| |
| PKS |
||
| Enable Protection Keys for Supervisor-Mode Pages |
|||
| protection keys for supervisor-mode pages enable |
|||
|- |
|- |
||
|} |
|} |
||
Line 415: | Line 433: | ||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! |
! Bit |
||
! Description |
|||
! description |
|||
|- |
|- |
||
| 0 |
| 0 |
||
| |
| Local DR0 breakpoint |
||
|- |
|- |
||
| 1 |
| 1 |
||
| |
| Global DR0 breakpoint |
||
|- |
|- |
||
| 2 |
| 2 |
||
| |
| Local DR1 breakpoint |
||
|- |
|- |
||
| 3 |
| 3 |
||
| |
| Global DR1 breakpoint |
||
|- |
|- |
||
| 4 |
| 4 |
||
| |
| Local DR2 breakpoint |
||
|- |
|- |
||
| 5 |
| 5 |
||
| |
| Global DR2 breakpoint |
||
|- |
|- |
||
| 6 |
| 6 |
||
| |
| Local DR3 breakpoint |
||
|- |
|- |
||
| 7 |
| 7 |
||
| |
| Global DR3 breakpoint |
||
|- |
|- |
||
| 16-17 |
| 16-17 |
||
| |
| Conditions for DR0 |
||
|- |
|- |
||
| 18-19 |
| 18-19 |
||
| |
| Size of DR0 breakpoint |
||
|- |
|- |
||
| 20-21 |
| 20-21 |
||
| |
| Conditions for DR1 |
||
|- |
|- |
||
| 22-23 |
| 22-23 |
||
| |
| Size of DR1 breakpoint |
||
|- |
|- |
||
| 24-25 |
| 24-25 |
||
| |
| Conditions for DR2 |
||
|- |
|- |
||
| 26-27 |
| 26-27 |
||
| |
| Size of DR2 breakpoint |
||
|- |
|- |
||
| 28-29 |
| 28-29 |
||
| |
| Conditions for DR3 |
||
|- |
|- |
||
| 30-31 |
| 30-31 |
||
| |
| Size of DR3 breakpoint |
||
|- |
|- |
||
|} |
|} |
||
A local breakpoint bit deactivates on hardware task switches, while a global does not.<br> |
A local breakpoint bit deactivates on hardware task switches, while a global does not.<br> |
||
Condition 00b means execution break, 01b means a write watchpoint, and 11b means an R/W watchpoint. 10b is reserved for I/O R/W (unsupported). |
|||
==Test Registers== |
==Test Registers== |
||
Line 474: | Line 492: | ||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! |
! Name |
||
! Description |
|||
! description |
|||
|- |
|- |
||
| TR3 - TR5 |
| TR3 - TR5 |
||
| Undocumented |
|||
| undocumented |
|||
|- |
|- |
||
| TR6 |
| TR6 |
||
| |
| Test command register |
||
|- |
|- |
||
| TR7 |
| TR7 |
||
| |
| Test data register |
||
|- |
|- |
||
|} |
|} |
||
Line 494: | Line 512: | ||
{| {{wikitable}} |
{| {{wikitable}} |
||
|- |
|- |
||
! |
! Nits |
||
! |
! Label |
||
! Description |
|||
! description |
|||
|- |
|- |
||
| 0-15 |
| 0-15 |
||
| |
| Limit |
||
| ( |
| (Size of [[GDT]]) - 1 |
||
|- |
|- |
||
| 16-47 |
| 16-47 |
||
| |
| Base |
||
| |
| Starting address of [[GDT]] |
||
|- |
|- |
||
|} |
|} |
||
Line 513: | Line 531: | ||
{| {{wikitable}} |
{| {{wikitable}} |
||
! |
! Bits |
||
! |
! Label |
||
! Description |
|||
! description |
|||
|- |
|- |
||
| 0-15 |
| 0-15 |
||
| |
| Limit |
||
| ( |
| (Size of [[LDT]]) - 1 |
||
|- |
|- |
||
| 16-47 |
| 16-47 |
||
| |
| Base |
||
| |
| Starting address of [[LDT]] |
||
|- |
|- |
||
|} |
|} |
||
Line 532: | Line 550: | ||
{| {{wikitable}} |
{| {{wikitable}} |
||
! |
! Bits |
||
! |
! Label |
||
! Description |
|||
! description |
|||
|- |
|- |
||
| 0-15 |
| 0-15 |
||
| |
| Limit |
||
| ( |
| (Size of [[IDT]]) - 1 |
||
|- |
|- |
||
| 16-47 |
| 16-47 |
||
| |
| Base |
||
| |
| Starting address of [[IDT]] |
||
|- |
|- |
||
|} |
|} |
||
Stores the segment selector of the [[IDT]]. |
Stores the segment selector of the [[IDT]]. |
||
[[Category:CPU_Registers]] |