新的 X86_64 处理器寄存器的名称是什么?
在哪里可以找到用于在此架构上进行组装的新寄存器的名称?
我指的是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
MSDN 文档 包含有关 x64 寄存器的信息。
The MSDN documentation includes information about the x64 registers.
旧的 32 位寄存器已扩展到 64 位,即
r
寄存器(rax
、rbx
、rsp
等等)。此外,还有一些额外的通用寄存器
r8
到r15
,它们也可以作为(例如)r8d
、r8w< /code> 和
r8b
(分别是低 32 位双字、16 位字和 8 位字节)。b
后缀是原始的 AMD 命名法,但有时您会看到它写为l
(小写L
),表示“低字节”。我自己倾向于使用
b
后缀(即使当前的低字节寄存器是al
、bl
等),因为它匹配d/w = double/word
名称和l
可能会被误认为long
。或者,更糟糕的是,数字1
,让您质疑寄存器编号81
到底是什么:-)旧的16位寄存器的高字节仍然可以访问,在许多情况下,如
ah
、bh
等(尽管对于新的r8
到来说情况似乎并非如此) r15 寄存器)。有一些新的指令编码,特别是那些使用 REX 前缀的指令编码,无法访问那些原始的高字节,但其他指令编码仍然可以自由使用它们。
此外,还有一些新的 SSE 寄存器,
xmm8
到xmm15
。eip
和eflags
寄存器也已扩展到rip
和rflags
(尽管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
throughr15
which can also be accessed as (for example)r8d
,r8w
andr8b
(the lower 32-bit double-word, 16-bit word and 8-bit byte respectively). Theb
suffix is the original AMD nomenclature but you'll sometimes see it written asl
(lower caseL
) for "low byte".I tend to prefer the
b
suffix myself (even though the current low-byte registers areal
,bl
, and so on) since it matches thed/w = double/word
names andl
could potentially be mistaken forlong
. Or, worse, the digit1
, leading you to question what the heck register number81
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 newr8
throughr15
registers). There are some new instruction encodings, specifically those using theREX
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
thoughxmm15
.The
eip
andeflags
registers have also been extended torip
andrflags
(though the high 32 bits ofrflags
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:
X64 扩展了 32 位通用寄存器,如下:
X64 还添加了以下 64 位通用寄存器:
另外,SSE 是 X64 规范的一部分,因此 xmm0-xmm15 向量寄存器也是可用的,
您可以找到一些基本的有关架构的信息,请访问 Wikipedia/X86-64 或访问英特尔网站。
X64 extends the 32-bit general purpose registers as follows:
X64 also adds the following 64-bit general purpose registers:
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.
让我们阅读英特尔手册
在处理器手册《Intel 64 and IA-32 Architectures Software Developer's Manual Volume 1: Basic Architecture》中,例如版本 253665-053US< /a>:
在该部分:
提醒:64 位模式是 x86-64 中的“正常”模式。另一种主要模式是模拟 IA32 的“兼容模式”。
如果您继续在目录中搜索“寄存器”,您还会发现手册中散布着有关浮点和 SIMD 的“数字粉碎”寄存器的部分:
还有更多控制寄存器,它们具有各种副作用,通常不能写入,除非您想要这些效果(通常 需要环 0)。这些在“第 3 卷系统编程指南”中进行了总结
- 2.1.6 系统寄存器”,这对于操作系统开发人员来说更重要。
一个好的经验方法是在 GDB 中运行
info all-registers
:如何在 GDB 中打印寄存器值?Let's read the Intel manual
In the processor's manual "Intel 64 and IA-32 Architectures Software Developer’s Manual Volume 1: Basic Architecture", e.g. version 253665-053US:
On that section:
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:
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?