tags:

views:

3793

answers:

2

Why is %EAX = %AX and %AX = (%AH + %AL). Why isn't there a counterpart to %AX to equal %EAX?

+13  A: 

In the old 8-bit days, there was the A register.

In the 16-bit days, there was the 16 bit AX register, which was split into two 8 bit parts, AH and AL, for those times when you still wanted to work with 8 bit values.

In the 32-bit days, the 32 bit EAX register was introduced, but the AX, AH, and AL registers were all kept. The designers did not feel it necessary to introduce a new 16 bit register that addressed bits 16 through 31 of EAX.

Greg Hewgill
It continues to 64-bit registers today, the 64-bit RAX register includes EAX as the lower 32 bits.
Ferruccio
'E' and 'X' might both stand for "Extended", but what does the 'R' in RAX mean?
Hugh Allen
Revenge. Revenge of EAX.
Paul Nathan
"R"egister, presumably. There are additional new registers that are just named R+number.
Curt Hagenlocher
I've combed through the AMD64 manual and still have no idea what R stands for, except "register"---just to be in line with their R8--R15. (BTW, I have no idea why, with their fixation with numbers, they don't just rename all the existing general registers too. :-P)
Chris Jester-Young
i.e., R0 => RAX, R1 => RCX, R2 => RDX, R3 => RBX, R4 => RSP, R5 => RBP, R6 => RSI, R7 => RDI. :-) (BTW it's a pet peeve of mine when people get the register ordering wrong; the order is AX, CX, DX, BX, SP, BP, SI, DI. :-P)
Chris Jester-Young
Which register is :-P? :D
Jeff Yates
What were the names of the registers in the 8008, and why didn't the 8080 provide backward compatibility for them?
Windows programmer
@ffpf: :-P came after the list terminator, the full stop (or period, if you're American, or dot, if you're a mathematician); thus, it doesn't count. :-)
Chris Jester-Young
The 8008 had the same register set as the 8080 but the program counter (PC) was only 14 bits so it could only address 16K
Ferruccio
I want to program in the language where :-P is a register.
Erik Forbes
You can still easily get the big end of eax. Just subtract ax from eax, then divide the result by 16.
Austin Kelley Way
+25  A: 

Just for some clarification. In the early microprocessor days of the 1970's, CPUs had only a small number of registers and a very limited instruction set. Typically, the arithmetic unit could only operate on a single CPU register, often referred to as the "accumulator". The accumulator on the 8 bit 8080 & Z80 processors was called "A". There were 6 other general purpose 8 bit registers: B, C, D, E, H & L. These six registers could be paired up to form 3 16 bit registers: BC, DE & HL. Internally, the accumulator was combined with the Flags register to form the AF 16 bit register.

When Intel developed the 16 bit 8086 family they wanted to be able to port 8080 code, so they kept the same basic register structure:

Z80   8080/Z80
A     AX
BC    BX
DE    CX
HL    DX
IX    SI    
IY    DI

Because of the need to port 8 bit code they needed to be able to refer to the individual 8 bit parts of AX, BC, CX & DX. These are called AL, AH for the low & high bytes of AX and so on for BL/BH, CL/CH & DL/DH. IX & IY on the Z80 were only ever used as 16 bit pointer registers so there was no need to access the two halves of SI & DI.

When the 80386 was released in the mid 1980s they created "extended" versions of all the registers. So, AX became EAX, BX became EBX etc. There was no need to access to top 16 bits of these new extended registers, so they didn't create an EAXH pseudo register.

AMD applied the same trick when they produced the first 64 bit processors. The 64 bit version of the AX register is called RAX. So, now you have something that looks like this:

|63..32|31..16|15-8|7-0|
               |AH.|AL.|
               |AX.....|
       |EAX............|
|RAX...................|
Mike Thompson
There's generally no explanation as to why there isn't a pseudo-register for say 31..16 portion of EAX.I suppose it was not needed...
Calyth