1

It's a very low level question about modern CPU architecture. I learned that I can use more additional registers in 64bit mode. such as ARM architecture has r15-r31 general purpose registers , for Intel/AMD r8-r15 general purpose registers. also SIMD registers are going to double like xmm8-xmm15 (or ymm8-ymm15)

Does anybody know how does it possible in only the 64bit mode?

I don't expect simple answer like "They just built more registers" becuase in 32bit mode , I can't use that additional register. Even those additional registers are not quite used by modern compilers.

2
  • 5
    ...They aren't available for use in 32 bit mode. The coding for instructions is different in 64 bit mode, allowing for more registers to be encoded. Adding the registers into 32 bit mode would break machine code compatibility.
    – chbaker0
    Dec 29, 2013 at 2:08
  • For a "long" answer, see stackoverflow.com/a/5556505/2864740 and the resources linked/referenced. Dec 29, 2013 at 2:10

2 Answers 2

1

(I'm not familar with arm64, so I use X86-64 as example.) Register selecting is encoded in binary instructions. 32-bit instructions can only use registers in 80386, and cannot use registers beyond these. Moreover, IA-32(x86-32)use 3 bits to represent registers, but x86-64 need 4bits to represent all registers, you need another bit to access additional registers, and this bit is in the REX byte in 64-bit instructions. That means, for using additional registers, REX byte is needed, and REX is a part of 64-bit instructions; there's not a REX byte in 32-bit instructions, so you can't use additional regs in 32-bit.

In SIMD instructions you also need extention bit(s) to access more registers.


For ARM64, I know a little: its register file and instruction set are brand-new, not a extension of 32-bit ARM(X86-64 is a extension of X86-32). ARM64 processor can run 32-bit ARM legacy instructions for compatibility, but this is processor's work, not the architecture(ISA)'s work. Early ARM64 processor can run two instruction set architectures for supporting old software, but in future, 32-bit architecture support may be dropped, leaving only 64-bit(ARM64).

1

It is possible to add registers in 32-bit mode - for example, the SSE instructions and registers. It is even possible to add general-purpose registers. But existing code cannot take advantage of the new registers without recompiling. The CPU makers felt that adding more GPRs doesn't produce enough benefit to try to convince everyone to recompile their code. So nobody bothered to implement a REX-like prefix for x86-32.

For 64-bit mode, no existing binary code is compatible anyway, so all the source code needs to be recompiled. Because the CPU designers felt that more registers would improve performance (trading off against state size, instruction width, etc.), they chose to make this change which imposes no extra compilation cost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.