BR 2062342: ndisasm: r12 *can* be an index register

R12 can be used as an index register.  Special encodings in the modr/m
byte are done *without* consideration for the REX prefix, but special
encodings in the SIB byte *do* take the REX prefix into consideration,
since it doesn't affect the overall instruction format.
This commit is contained in:
H. Peter Anvin 2008-08-20 09:42:47 -07:00
parent 2a09b3bf11
commit 83b2e4f82c

View File

@ -319,8 +319,8 @@ static uint8_t *do_ea(uint8_t *data, int modrm, int asize,
op->scale = 1 << scale;
if (index == 4)
op->indexreg = -1; /* ESP/RSP/R12 cannot be an index */
if (index == 4 && !(rex & REX_X))
op->indexreg = -1; /* ESP/RSP cannot be an index */
else if (a64)
op->indexreg = nasm_rd_reg64[index | ((rex & REX_X) ? 8 : 0)];
else