简体   繁体   中英

Why does Apple use R8l for the byte registers instead of R8b?

I saw this in Making Code 64-Bit Clean topic

╔═════════════════════╤══════════════════════════════════════════════════════╗
║ Register name       │ Description                                          ║
╠═════════════════════╪══════════════════════════════════════════════════════╣
║ R8                  │ A 64-bit register.                                   ║
╟─────────────────────┼──────────────────────────────────────────────────────╢
║ R8d                 │ A 32-bit register containing the bottom half of R8.  ║
╟─────────────────────┼──────────────────────────────────────────────────────╢
║ R8w                 │ A 16-bit register containing the bottom half of R8d. ║
╟─────────────────────┼──────────────────────────────────────────────────────╢
║ R8l (Lowercase “l”) │ An 8-bit register containing the bottom half of R8w. ║
╚═════════════════════╧══════════════════════════════════════════════════════╝

With the l suffix I first thought that it's a long register like in GAS syntax.

Why is Apple using a different name from everybody else?

As from Ross Ridge's comment, that's because of the difference in AMD and Intel's register naming convention

From AMD64 Architecture Programmer's Manual, Volume 1: Application Programming

3.1.2 64-Bit-Mode Registers

In 64-bit mode, eight new GPRs are added to the eight legacy GPRs, all 16 GPRs are 64 bits wide, and the low bytes of all registers are accessible. Figure 3-3 on page 27 shows the GPRs, flags register, and instruction-pointer register available in 64-bit mode. The GPRs include:

  • Sixteen 8-bit low-byte registers (AL, BL, CL, DL, SIL, DIL, BPL, SPL, R8B, R9B, R10B, R11B, R12B, R13B, R14B, R15B ).
  • Four 8-bit high-byte registers (AH, BH, CH, DH), addressable only when no REX prefix is used.
  • Sixteen 16-bit registers (AX, BX, CX, DX, DI, SI, BP, SP, R8W, R9W, R10W, R11W, R12W, R13W, R14W, R15W).
  • Sixteen 32-bit registers (EAX, EBX, ECX, EDX, EDI, ESI, EBP, ESP, R8D, R9D, R10D, R11D, R12D, R13D, R14D, R15D).
  • Sixteen 64-bit registers (RAX, RBX, RCX, RDX, RDI, RSI, RBP, RSP, R8, R9, R10, R11, R12, R13, R14, R15).

Compared to Intel® 64 and IA-32 Architectures - Software Developer's Manual Volume 1: Basic Architecture

3.7.2.1 Register Operands in 64-Bit Mode

Register operands in 64-bit mode can be any of the following:

  • 64-bit general-purpose registers (RAX, RBX, RCX, RDX, RSI, RDI, RSP, RBP, or R8-R15)
  • 32-bit general-purpose registers (EAX, EBX, ECX, EDX, ESI, EDI, ESP, EBP, or R8D-R15D)
  • 16-bit general-purpose registers (AX, BX, CX, DX, SI, DI, SP, BP, or R8W-R15W)
  • 8-bit general-purpose registers: AL, BL, CL, DL, SIL, DIL, SPL, BPL, and R8L-R15L are available using REX prefixes; AL, BL, CL, DL, AH, BH, CH, DH are available without using REX prefixes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM