新的 X86_64 处理器寄存器的名称是什么?

发布于 2024-08-11 07:41:53 字数 131 浏览 3 评论 0原文

在哪里可以找到用于在此架构上进行组装的新寄存器的名称?

我指的是 X86 中的寄存器,如 EAX、ESP、EBX 等。但我希望它们是 64 位的。

我不认为它们与我反汇编 C 代码时相同,我得到的是 r 而不是 e。

Where can I find the names of the new registers for assembly on this architecture?

I am referring to registers in X86 like EAX, ESP, EBX, etc. But I'd like them in 64bit.

I don't think they are the same as when I disassemble my C code, I get r's instead of e's.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

狼性发作 2024-08-18 07:41:53

MSDN 文档 包含有关 x64 寄存器的信息。

x64 扩展了 x64 的 8 个通用功能
寄存器为64位,并新增8个
64 位寄存器。 64 位寄存器
名称以“r”开头,所以对于
例如 eax 的 64 位扩展是
称为拉克斯。新的寄存器是
命名为 r8 到 r15。

低32位、16位、8位
每个寄存器的直接
可在操作数中寻址。这包括
寄存器,如esi,其低8位
位以前是不可寻址的。
下表指定
低层的汇编语言名称
64 位寄存器的部分。

64-bit register | Lower 32 bits | Lower 16 bits | Lower 8 bits
==============================================================
rax             | eax           | ax            | al
rbx             | ebx           | bx            | bl
rcx             | ecx           | cx            | cl
rdx             | edx           | dx            | dl
rsi             | esi           | si            | sil
rdi             | edi           | di            | dil
rbp             | ebp           | bp            | bpl
rsp             | esp           | sp            | spl
r8              | r8d           | r8w           | r8b
r9              | r9d           | r9w           | r9b
r10             | r10d          | r10w          | r10b
r11             | r11d          | r11w          | r11b
r12             | r12d          | r12w          | r12b
r13             | r13d          | r13w          | r13b
r14             | r14d          | r14w          | r14b
r15             | r15d          | r15w          | r15b

The MSDN documentation includes information about the x64 registers.

x64 extends x64's 8 general-purpose
registers to be 64-bit, and adds 8 new
64-bit registers. The 64-bit registers
have names beginning with "r", so for
example the 64-bit extension of eax is
called rax. The new registers are
named r8 through r15.

The lower 32 bits, 16 bits, and 8 bits
of each register are directly
addressable in operands. This includes
registers, like esi, whose lower 8
bits were not previously addressable.
The following table specifies the
assembly-language names for the lower
portions of 64-bit registers.

64-bit register | Lower 32 bits | Lower 16 bits | Lower 8 bits
==============================================================
rax             | eax           | ax            | al
rbx             | ebx           | bx            | bl
rcx             | ecx           | cx            | cl
rdx             | edx           | dx            | dl
rsi             | esi           | si            | sil
rdi             | edi           | di            | dil
rbp             | ebp           | bp            | bpl
rsp             | esp           | sp            | spl
r8              | r8d           | r8w           | r8b
r9              | r9d           | r9w           | r9b
r10             | r10d          | r10w          | r10b
r11             | r11d          | r11w          | r11b
r12             | r12d          | r12w          | r12b
r13             | r13d          | r13w          | r13b
r14             | r14d          | r14w          | r14b
r15             | r15d          | r15w          | r15b
蓝眸 2024-08-18 07:41:53

旧的 32 位寄存器已扩展到 64 位,即 r 寄存器(raxrbxrsp等等)。

此外,还有一些额外的通用寄存器 r8r15,它们也可以作为(例如)r8dr8w< /code> 和 r8b (分别是低 32 位双字、16 位字和 8 位字节)。 b 后缀是原始的 AMD 命名法,但有时您会看到它写为 l(小写 L),表示“低字节”。

我自己倾向于使用 b 后缀(即使当前的低字节寄存器是 albl 等),因为它匹配d/w = double/word 名称和 l 可能会被误认为long。或者,更糟糕的是,数字1,让您质疑寄存器编号81到底是什么:-)

旧的16位寄存器的高字节仍然可以访问,在许多情况下,如 ahbh 等(尽管对于新的 r8来说情况似乎并非如此) r15 寄存器)。有一些新的指令编码,特别是那些使用 REX 前缀的指令编码,无法访问那些原始的高字节,但其他指令编码仍然可以自由使用它们。

此外,还有一些新的 SSE 寄存器,xmm8xmm15

eipeflags 寄存器也已扩展到 riprflags(尽管 rep 的高 32 位>rflags 目前尚未使用)。

请参阅维基百科页面MSDN 了解更多详细信息。

我无法确定特定 C 编译器的 asm 关键字是否支持这些。我所做的一点汇编(并且每年大约有一天)都是在汇编中完成的,而不是在 C 中完成的。


相关:

The old 32-bit registers have been extended to 64 bits, the r registers (rax, rbx, rsp and so on).

In addition, there's some extra general purpose registers r8 through r15 which can also be accessed as (for example) r8d, r8w and r8b (the lower 32-bit double-word, 16-bit word and 8-bit byte respectively). The b suffix is the original AMD nomenclature but you'll sometimes see it written as l (lower case L) for "low byte".

I tend to prefer the b suffix myself (even though the current low-byte registers are al, bl, and so on) since it matches the d/w = double/word names and l could potentially be mistaken for long. Or, worse, the digit 1, leading you to question what the heck register number 81 is :-)

The high bytes of the old 16-bit registers are still accessible, under many circumstances, as ah, bh, and so on (though this appears to not be the case for the new r8 through r15 registers). There are some new instruction encodings, specifically those using the REX prefix, that can not access those original high bytes, but others are still free to use them.

In addition, there's some new SSE registers, xmm8 though xmm15.

The eip and eflags registers have also been extended to rip and rflags(though the high 32 bits of rflags are, for now, still unused).

See the wikipedia page and MSDN for more details.

Whether these are supported in the asm keyword for a particular C compiler, I couldn't say. What little assembly I do (and it's becoming about one day a year) is done in assembly rather than C.


Related:

浅笑轻吟梦一曲 2024-08-18 07:41:53

X64 扩展了 32 位通用寄存器,如下:

EAX -> RAX
EBX -> RBX
ECX -> RCX
EDX -> RDX
ESI -> RSI
EDI -> RDI
ESP -> RSP
EBP -> RBP

X64 还添加了以下 64 位通用寄存器:

R8, R9, R10, R11, R12, R13, R14, R15

另外,SSE 是 X64 规范的一部分,因此 xmm0-xmm15 向量寄存器也是可用的,

您可以找到一些基本的有关架构的信息,请访问 Wikipedia/X86-64 或访问英特尔网站。

X64 extends the 32-bit general purpose registers as follows:

EAX -> RAX
EBX -> RBX
ECX -> RCX
EDX -> RDX
ESI -> RSI
EDI -> RDI
ESP -> RSP
EBP -> RBP

X64 also adds the following 64-bit general purpose registers:

R8, R9, R10, R11, R12, R13, R14, R15

Additionally, SSE is part of the X64 specification, so the xmm0-xmm15 vector registers are available as well

You can find some basic info on the architecture at Wikipedia/X86-64 or go to Intel's website.

_蜘蛛 2024-08-18 07:41:53

让我们阅读英特尔手册

在哪里可以找到用于在此架构上进行组装的新寄存器的名称。

在处理器手册《Intel 64 and IA-32 Architectures Software Developer's Manual Volume 1: Basic Architecture》中,例如版本 253665-053US< /a>:

  • 搜索“寄存器”,
  • 第一个匹配项是索引“3.4 BASIC PROGRAM EXECUTION REGISTER”
  • 下面的两项“3.4.1.1 64位模式下的通用寄存器”

在该部分:

如果指定了 64 位操作数大小:RAX、RBX、RCX、
RDX、RDI、RSI、RBP、RSP、R8-R15 可供选择。 R8D-R
15D/R8-R15代表八个新的通用寄存器。

提醒:64 位模式是 x86-64 中的“正常”模式。另一种主要模式是模拟 IA32 的“兼容模式”。

如果您继续在目录中搜索“寄存器”,您还会发现手册中散布着有关浮点和 SIMD 的“数字粉碎”寄存器的部分:

  • 8.1.2 - x87 FPU 数据寄存器 (STx)
  • 9.9.2 - MMX 寄存器
  • 10.2.2 - XMM 寄存器
  • 14.1.1 - 256 位宽 SIMD 寄存器支持 (YMM)

还有更多控制寄存器,它们具有各种副作用,通常不能写入,除非您想要这些效果(通常 需要环 0)。这些在“第 3 卷系统编程指南”中进行了总结
- 2.1.6 系统寄存器”,这对于操作系统开发人员来说更重要。

一个好的经验方法是在 GDB 中运行 info all-registers如何在 GDB 中打印寄存器值?

Let's read the Intel manual

Where can I find the names of the new registers for assembly on this architecture.

In the processor's manual "Intel 64 and IA-32 Architectures Software Developer’s Manual Volume 1: Basic Architecture", e.g. version 253665-053US:

  • search for "registers"
  • the first match is the index "3.4 BASIC PROGRAM EXECUTION REGISTER"
  • two items below "3.4.1.1 General-Purpose Registers in 64-Bit Mode"

On that section:

if a 64-bit operand size is specified: RAX, RBX, RCX,
RDX, RDI, RSI, RBP, RSP, R8-R15 are available. R8D-R
15D/R8-R15 represent eight new general-purpose registers.

Reminder: 64 bit mode is the "normal" mode in x86-64. The other main mode is "compatibility mode" which emulates IA32.

If you keep searching for "register" on the TOC, you will also find sections on "number crushing" registers for floating point and SIMD scattered in the manual:

  • 8.1.2 - x87 FPU Data Registers (STx)
  • 9.9.2 - MMX Registers
  • 10.2.2 - XMM Registers
  • 14.1.1 - 256-Bit Wide SIMD Register Support (YMM)

There are many more control registers which have various side effects and can generally not be written to unless you want those effects (and often require ring 0). These are summarized in "Volume 3 System Programming Guide
- 2.1.6 System Registers", which is more for OS developers.

A good empirical approach is to run info all-registers in GDB: How to print register values in GDB?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文