summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-08-20 09:42:47 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-08-20 09:42:47 -0700
commit83b2e4f82c78c2464e76dfd09a30f8286830c45e (patch)
tree77e2d087149d29c724f917c6cb18852e2df0485e
parent2a09b3bf1110776f60941cd2b036867d513828a1 (diff)
downloadnasm-83b2e4f82c78c2464e76dfd09a30f8286830c45e.tar.gz
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.
-rw-r--r--disasm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/disasm.c b/disasm.c
index f89b11b4..b8674931 100644
--- a/disasm.c
+++ b/disasm.c
@@ -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