29

For example, the accumulator is named EAX and, while the instruction pointer is called IP. I also know that there are bytes called CL and DH. I know there must be a convention to all of the names, but what is it?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
eleven81
  • 6,301
  • 11
  • 37
  • 48
  • See also [Why are first four x86 GPRs named in such unintuitive order?](//retrocomputing.stackexchange.com/q/5121) on retrocomputing - more detail about how 8086 registers are designed to enable easy asm source compatibility with 8080. (Then 386 extended them to 32-bit, AMD64 extended them to 64-bit and added 8 new registers: [What are the names of the new X86\_64 processors registers?](//stackoverflow.com/q/1753602)) – Peter Cordes Nov 29 '19 at 23:23

5 Answers5

30

Something I found:

* EAX - Accumulator Register
* EBX - Base Register
* ECX - Counter Register
* EDX - Data Register
* ESI - Source Index
* EDI - Destination Index
* EBP - Base Pointer
* ESP - Stack Pointer
Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
Ólafur Waage
  • 68,817
  • 22
  • 142
  • 198
  • 1
    Note that these are just names, not the only thing you can use each register for. They're all general-purpose registers. Calling conventions matter more in what you actually choose. See also [Does it matter which registers you use when writing assembly?](https://stackoverflow.com/a/59870938) . This is a good answer to the question asked, about what the names historically stand for, but don't read too much into it. See also [Why are first four x86 General Purpose Registers named in such unintuitive order?](https://retrocomputing.stackexchange.com/q/5121) re: 8086 origins. – Peter Cordes Aug 05 '22 at 19:59
  • @PeterCordes Yes, all 8 registers are general-purpose. But each one has shorter machine code bytes for certain opcodes. – Nayuki Jan 07 '23 at 19:29
  • 2
    @Nayuki: Each register has some implicit uses, but [shorter encodings](https://codegolf.stackexchange.com/a/160739/30206) are usually just for AL/AX/EAX/RAX. The other implicit uses, like `shl r/m32, cl` or `div` (implicit use of rDX) mostly don't have alternative encodings that would allow a different register. (Except BMI2 `shlx r, r/m, r` instead of CL, or `movsx`.) [Why are rbp and rsp called general purpose registers?](https://stackoverflow.com/q/36529449) lists at least one implicit use for each legacy register. – Peter Cordes Jan 07 '23 at 23:37
28

The C and the D are numbers/types and H for high and L for low parts of the higher register. http://en.wikipedia.org/wiki/X86

Wikipedia explains it very well.

More from the Wikipedia:

  1. AX/EAX/RAX: accumulator
  2. BX/EBX/RBX: base
  3. CX/ECX/RCX: counter
  4. DX/EDX/RDX: data/general
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
18

It's history. The x86 came from the 8086, which came from the 8080, which came from the 8008, which came from the 4004. There were 16-bit registers AX, BX, etc. and for the 80386 they got "extended" to 32 bits.

Added: BTW the Motorola 68K had 32-bit registers from the start, so it was much easier to program for the first couple decades. I worked on projects where Intel was chosen for business reasons, not technical.

Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135
  • 1
    The history isn't continuous - the 8080 has different register names, and those names came in with the 8086. Worth noting the CISC architecture here, with special purpose registers, in both the 8086 and 8080 variants, though - RISC came along later, with its 'all registers are much the same' approach (helped along by having 32 bits per instruction instead of trying to encode most instructions into 8 bits). – ijw Sep 16 '12 at 00:28
  • 4
    @ijw - but there are/were 8080 to 8086 translators, and there is a mapping. 8080's A register became AL, 8080's register pair B,C became CH, CL. 8080's register pair D,E became DH, DL. 8080's register pair H,L became BH, BL. 8086 includes LAHF and SAHF instructions which helps with 8080 to 8086 translation. 8086 added registers like SI (source index), DI (destination index), and BP (base pointer that defaults to SS segment register). – rcgldr Nov 25 '16 at 16:23
  • This does not actually answer the question. – fuz Feb 17 '23 at 15:40
6

Older processors have accumulators named A, B, etc (alphabetically ordered). When 16-bit and later 32-bit accumulators got developed, engineers added an X (extended) and an E (extended) respectively.
So it's all about history, just like the language C is called the way it is, because it was developed from the B language (Bell labs).

The convention is only internal, to keep up with the names they were already familiar with.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
RMAAlmeida
  • 304
  • 3
  • 13
0

The following is a brief explanation of what each of the x86 general-purpose registers stands for:

  • EAX: "Extended Accumulator" - used for arithmetic and logical operations, as well as for storing return values from functions.
  • EBX: "Extended Base" - often used as a pointer to data in the data segment of memory.
  • ECX: "Extended Counter" - often used for loop and string operations, as well as for storing function arguments.
  • EDX: "Extended Data" - often used for I/O operations and for storing function arguments.
  • ESI: "Extended Source Index" - often used as a pointer to a source operand in string operations.
  • EDI: "Extended Destination Index" - often used as a pointer to a destination operand in string operations.
  • EBP: "Extended Base Pointer" - often used as a pointer to the base of the current stack frame.
  • ESP: "Extended Stack Pointer" - often used as a pointer to the top of the current stack frame.
Shehan Hasintha
  • 947
  • 10
  • 10