Why don't have a specific register to access this other part of register ( 16-32 )?
Like ah or al to access a 8-bits part of ax register.
Why don't have a specific register to access this other part of register ( 16-32 )?
Like ah or al to access a 8-bits part of ax register.
The idea was to extend the registers to 32 bit, not to create a machine with twice as many 16 or 8 bit registers because you already had enough of those. To keep the encoding and the hardware simpler, they decided not to give direct access to the top 16 bits. Everything comes at a cost. Fun fact: the 64 bit extension did bring r8
-r15
with it, but you can't access the top 32 bit of those directly either.
Because it is unnecessary. Most of the time you work with the full register. Even small low registers like AL and AX are not commonly used, let alone some arbitrary values in the middle of a register like AH or the high bytes of EAX which are hardly found in practice. Byte registers are mainly used with SETcc and MOVcc instructions. Word registers are even rarer and almost never used because the instructions are longer (need a prefix byte) and likely slower. Narrow values are usually sign or zero extended to the full register immediately
Allowing access to those high parts require the introduction of new opcodes which is difficult to find in the current tight free space, and that will pollute the x86 opcode space. Moreover, separate access to different parts of the registers will introduce more complex dependencies due to partial register update which may cause a stall
That's one of the reasons why all instructions with a 32-bit destination in x86-64 zero the upper part of the result instead of preserving it. Same to the high bytes of XMM in AVX. INC is also not preferred compared to ADD 1 nowadays because it introduces a partial flag update
See also