What are the names of the new X86_64 processors registers?
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.
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
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:
- Why did they use numbers for register names in x86-64?
- What do the E and R prefixes stand for in the names of Intel 32-bit and 64-bit registers?
- What does X mean in EAX,EBX,ECX ... in assembly?
- Why are first four x86 GPRs named in such unintuitive order?
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.
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?
精彩评论