Is it true registers are 32-bit in x86 and 64-bit in x86-64?
Short answer: yes.
All CPUs have multiple registers. On x86 CPUs the largest is 32bits long and on x64 the longest is 64bits long.
The smaller registers are provided for backwards compatibility with older applications.
For example, the
bx register is always 16bits long, and exists for 16bit compatibility on most CPUs,
ebx is 32bits long, and exists on 32bit and 64bit CPUs.
Its important to note that
bx points to the "right-half" of
If the value in ebx is
0f0f 0b0b then the value in bx is
Take as an example the accumulator register.
In the 8086/8088 this was the 16 bit AX register. The left and right 8 bit parts could be accessed separately as AH and AL:
1 5 0 |+++++++*+++++++| AX: | AH | AL | |+++++++*+++++++|
The 32 bit processors added the 32 bit registers, while the original 16 and 8 bit registers kept available:
3 1 0 |+++++++*+++++++|+++++++*+++++++| | AX | EAX: | | AH | AL | |+++++++*+++++++|+++++++*+++++++|
And with 64 bit they repeated the trick:
6 3 0 |+++++++*+++++++|+++++++*+++++++|+++++++*+++++++|+++++++*+++++++| | | EAX | RAX: | | | AX | | | | AH | AL | |+++++++*+++++++|+++++++*+++++++|+++++++*+++++++|+++++++*+++++++|
And there are also the floating point registers, each 80 bit long regardless of the main register size.
General-purpose registers and the instruction pointer are 16 bits on a 16-bit x86 CPU (i.e. 80x86 up to 286, or later in compatibility mode), 32 bits on a 32-bit x86 CPU (i.e. 386 onwards), and 64 bits on a 64-bit CPU (i.e. amd64 or compatible). That's because an N-bit CPU is more or less defined as a CPU where general purpose registers are N bits wide (or a CPU where the instruction pointer is N bits wide, but on x86 and most other architectures that's the same).
Some other registers have different sizes. For example, 32-bit x86 CPUs have 16-bit segment registers (rarely used), and 80-bit floating point registers. The wikipedia article on X86 has a more complete list.