CPU Registers x86
跳到导航
跳到搜索
通用寄存器
| 64-bit | 32-bit | 16-bit | 8 high bits | 8 low bits | 描述 |
|---|---|---|---|---|---|
| RAX | EAX | AX | AH | AL | Accumulator累加器 |
| RBX | EBX | BX | BH | BL | Base |
| RCX | ECX | CX | CH | CL | Counter计数器 |
| RDX | EDX | DX | DH | DL | Data数据 |
| RSI | ESI | SI | N/A | SIL | Source来源 |
| RDI | EDI | DI | N/A | DIL | Destination目标 |
| RSP | ESP | SP | N/A | SPL | Stack Pointer堆栈指针 |
| RBP | EBP | BP | N/A | BPL | Stack Base Pointer堆栈基指针 |
指针寄存器
| 64-bit | 32-bit | 16-bit | 描述 |
|---|---|---|---|
| RIP | EIP | IP | 指令指针 |
段寄存器
| 16-bit | 描述 |
|---|---|
| CS | 代码段 |
| DS | Code Segment数据段 |
| ES | Extra Segment额外段 |
| SS | Stack Segment堆栈段 |
| FS | General Purpose F Segment通用F段 |
| GS | General Purpose G Segment通用G段 |
EFLAGS寄存器
| Bit | Label | 描述 |
|---|---|---|
| 0 | CF | Carry flag携带标志 |
| 2 | PF | Parity flag奇偶标志 |
| 4 | AF | Auxiliary flag辅助标志 |
| 6 | ZF | Zero flag零标志 |
| 7 | SF | Sign flag标志标志 |
| 8 | TF | Trap flag陷阱标志 |
| 9 | IF | Interrupt enable flag中断启用标志 |
| 10 | DF | Direction flag方向标志 |
| 11 | OF | Overflow flag溢出标志 |
| 12-13 | IOPL | I/O privilege level I/O权限级别 |
| 14 | NT | Nested task flag 嵌套任务标志 |
| 16 | RF | Resume flag 回复标志 |
| 17 | VM | 虚拟8086模式标志 |
| 18 | AC | Alignment check 对齐检查 |
| 19 | VIF | Virtual interrupt flag 虚拟中断标志 |
| 20 | VIP | Virtual interrupt pending 虚拟中断待处理 |
| 21 | ID | Able to use CPUID instruction 能够使用CPUID指令 |
未列出的位被保留。
Control Registers 控制寄存器
CR0
| Bit | Label | 描述 |
|---|---|---|
| 0 | PE | Protected Mode Enable 保护模式启用 |
| 1 | MP | Monitor co-processor 监控协处理器 |
| 2 | EM | x87 FPU仿真 |
| 3 | TS | Task switched 任务切换 |
| 4 | ET | Extension type 扩展类型 |
| 5 | NE | Numeric error 数字错误 |
| 16 | WP | Write protect 写保护 |
| 18 | AM | Alignment mask 对齐掩码 |
| 29 | NW | Not-write through 未写入 |
| 30 | CD | Cache disable 缓存禁用 |
| 31 | PG | Paging 分页 |
注意: 该寄存器是唯一可以通过两种方式写入和读取的控制寄存器,而其他方式只能通过MOV指令访问
; First way:
; Write:
mov cr0, reg
; Read:
mov reg, cr0
; ----------------------
; Second way:
; Write:
lmsw reg
; Read:
smsw reg
CR1
保留,CPU在尝试访问时会抛出 # UD异常。
CR2
| Bit | Label | 描述 |
|---|---|---|
| 0-31 (63) | PFLA | Page Fault Linear Address 页面故障线性地址 |
CR3
| Bit | Label | 描述 | PAE | Long Mode |
|---|---|---|---|---|
| 3 | PWT | Page-level Write-Through | (Not used) | (Not used if bit 17 of CR4 is 1) |
| 4 | PCD | Page-level Cache Disable | (Not used) | (Not used if bit 17 of CR4 is 1) |
| 12-31 (63) | PDBR | Page Directory Base Register | Base of PDPT | Base of PML4T/PML5T |
假定物理基址的位0-11为0。 CR3的位3和4仅在没有PAE的情况下访问32位分页中的PDE时使用。
CR4
| Bit | Label | 描述 |
|---|---|---|
| 0 | VME | Virtual 8086 Mode Extensions 虚拟8086模式扩展 |
| 1 | PVI | Protected-mode Virtual Interrupts 保护模式虚拟中断 |
| 2 | TSD | Time Stamp Disable 时间戳禁用 |
| 3 | DE | Debugging Extensions 调试扩展 |
| 4 | PSE | Page Size Extension 页面大小扩展 |
| 5 | PAE | Physical Address Extension 物理地址扩展 |
| 6 | MCE | Machine Check Exception 机器检查异常 |
| 7 | PGE | Page Global Enabled 页面全局启用 |
| 8 | PCE | Performance-Monitoring Counter enable 性能-监控计数器启用 |
| 9 | OSFXSR | Operating system support for FXSAVE and FXRSTOR instructions 操作系统对FXSAVE和FXRSTOR指令的支持 |
| 10 | OSXMMEXCPT | Operating System Support for Unmasked SIMD Floating-Point Exceptions 操作系统对未屏蔽的SIMD浮点异常的支持 |
| 11 | UMIP | User-Mode Instruction Prevention (if set, #GP on SGDT, SIDT, SLDT, SMSW, and STR instructions when CPL > 0) |
| 13 | VMXE | Virtual Machine Extensions Enable 虚拟机扩展启用 |
| 14 | SMXE | Safer Mode Extensions Enable |
| 16 | FSGSBASE | Enables the instructions RDFSBASE, RDGSBASE, WRFSBASE, and WRGSBASE |
| 17 | PCIDE | PCID Enable |
| 18 | OSXSAVE | XSAVE and Processor Extended States Enable |
| 20 | SMEP | Supervisor Mode Execution Protection Enable |
| 21 | SMAP | Supervisor Mode Access Prevention Enable |
| 22 | PKE | Protection Key Enable |
| 23 | CET | Control-flow Enforcement Technology |
| 24 | PKS | Enable Protection Keys for Supervisor-Mode Pages |
CR5 - CR7
保留,与cr1相同的情况。
CR8
| Bit | Label | 描述 |
|---|---|---|
| 0-3 | TPL | Task Priority Level 任务优先级别 |
Extended Control Registers 扩展控制寄存器
XCR0
| Bit | Label | Description |
|---|---|---|
| 0 | X87 | x87 FPU/MMX support (must be 1) |
| 1 | SSE | XSAVE support for MXCSR and XMM registers |
| 2 | AVX | AVX enabled and XSAVE support for upper halves of YMM registers |
| 3 | BNDREG | MPX enabled and XSAVE support for BND0-BND3 registers |
| 4 | BNDCSR | MPX enabled and XSAVE support for BNDCFGU and BNDSTATUS registers |
| 5 | opmask | AVX-512 enabled and XSAVE support for opmask registers k0-k7 |
| 6 | ZMM_Hi256 | AVX-512 enabled and XSAVE support for upper halves of lower ZMM registers |
| 7 | Hi16_ZMM | AVX-512 enabled and XSAVE support for upper ZMM registers |
| 9 | PKRU | XSAVE support for PKRU register |
XCR0 can only be accessed if bit 18 of CR4 is set to 1. XGETBV and XSETBV instructions are used to access XCR0.
Debug Registers 调试寄存器
DR0 - DR3
包含最多4个断点的线性地址。 如果启用了分页,则将它们转换为物理地址。
DR6
它允许调试器确定发生了哪些调试条件。
位0到3表示,在设置时,当生成调试异常时,它的相关断点条件已满足。
位13指示指令流中的下一个指令访问调试寄存器之一。
位14指示 (设置时) 调试异常是由单步执行模式触发的 (在eglags中使用TF位启用)。
位15指示 (设置时) 调试指令是由任务切换产生的,其中设置了目标任务的TSS中的T标志。
位16指示 (清除时) 调试异常或断点异常发生在RTM区域内。
DR7
| Bit | Description |
|---|---|
| 0 | Local DR0 breakpoint |
| 1 | Global DR0 breakpoint |
| 2 | Local DR1 breakpoint |
| 3 | Global DR1 breakpoint |
| 4 | Local DR2 breakpoint |
| 5 | Global DR2 breakpoint |
| 6 | Local DR3 breakpoint |
| 7 | Global DR3 breakpoint |
| 16-17 | Conditions for DR0 |
| 18-19 | Size of DR0 breakpoint |
| 20-21 | Conditions for DR1 |
| 22-23 | Size of DR1 breakpoint |
| 24-25 | Conditions for DR2 |
| 26-27 | Size of DR2 breakpoint |
| 28-29 | Conditions for DR3 |
| 30-31 | Size of DR3 breakpoint |
在硬件任务交换机上,本地断点位会停用,而全局则不会。
条件00b表示执行中断,01b表示写观察点,11b表示R/W观察点。 10b保留用于I/O R/W (不支持)。
Test Registers 测试寄存器
| Name | 描述 |
|---|---|
| TR3 - TR5 | 无文档 |
| TR6 | Test command register 测试命令寄存器 |
| TR7 | Test data register 测试数据寄存器 |
Protected Mode Registers 保护模式寄存器
GDTR
| Nits | Label | 描述 |
|---|---|---|
| 0-15 | Limit | (Size of GDT) - 1 |
| 16-47 | Base | GDT 的起始地址 |
存储 GDT 的分段选择器。
LDTR
| Bits | Label | 描述 |
|---|---|---|
| 0-15 | Limit | (Size of LDT) - 1 |
| 16-47 | Base | LDT 的起始地址 |
存储 LDT 的分段选择器。
IDTR
| Bits | Label | 描述 |
|---|---|---|
| 0-15 | Limit | (Size of IDT) - 1 |
| 16-47 | Base | IDT 的起始地址 |
存储 IDT 的分段选择器。