I've been trying to learn 32-bit Intel x86 nasm syntax assembly on my Linux OS, and I've run into a question about the four general purpose 32-bit registers.
From what I've been thinking, eax was a 32-bit register that was supposed to be used with the 16-bit register ax, which was subdivided into ah (upper 8 bits), and al (lower 8 bits). And the same with ebx, ecx, and edx.
However after reading a quick article, I've become sort of confused.
Is the 32-bit register composed of the 16-bit register (which in turn is composed of the two 8-bit registers) with an additional 16-bits added on?
So far from what I've read on Google, all the results say is what they're used for, not their actual composition.
You are entirely correct. Four of the general purpose-registers EAX
, EBX
, ECX
and EDX
are composed as follows (I used the accumulator in the example) :
AX = AH || AL
AX
, which forms the dword. So, EAX = EAX(31:16) || AX
.RAX = RAX(63:32) || EAX
.The ||
operator is the concatenation operator. You should note that this rule does not apply to the other four general purpose registers, ESP
, EBP
, ESI
and EDI
.