Is it possible to use the 8-bit registers (al, ah, bl, bh, r8b
) in indexed addressing modes in x86-64? For example:
mov ecx, [rsi + bl]
mov edx, [rdx + dh * 2]
In particular, this would let you use the bottom 8-bits of a register as a 0-255 offset, which could be useful for some kernels.
I poured over the Intel manuals and they aren't explicit on the matter, but all the examples they give only have 32-bit or 64-bit base and index registers. In 32-bit code I only saw 16 or 32-bit registers. Looking at the details of mod-r/m and SIB byte encoding also seems to point towards "no" but that's complex enough with enough corner cases that I'm not sure I got it right.
I'm mostly interested in the x86-64 behavior, but of course if it's possible in 32-bit mode only I'd like to know.
As an add-on question too small and related to deserve another post - can 16-bit registers be used for base or index? E.g., mov rax, [rbx + cx]
. My investigation pointed towards basically the same answer as above: probably not.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…