From 10da41e328f24a6cc252d0c69f2f09c824341a2a Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 24 Feb 2012 20:57:04 -0800 Subject: [PATCH] HLE: Split the LOCK and REP prefix slots With HLE, the sequence REP LOCK actually makes sense, so support it. Signed-off-by: H. Peter Anvin --- assemble.c | 10 +++++----- disasm.c | 8 ++++---- nasm.h | 7 ++++--- parser.c | 3 ++- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/assemble.c b/assemble.c index f1583fd8..691e792b 100644 --- a/assemble.c +++ b/assemble.c @@ -1027,13 +1027,13 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, break; case 0336: - if (!ins->prefixes[PPS_LREP]) - ins->prefixes[PPS_LREP] = P_REP; + if (!ins->prefixes[PPS_REP]) + ins->prefixes[PPS_REP] = P_REP; break; case 0337: - if (!ins->prefixes[PPS_LREP]) - ins->prefixes[PPS_LREP] = P_REPNE; + if (!ins->prefixes[PPS_REP]) + ins->prefixes[PPS_REP] = P_REPNE; break; case 0340: @@ -1183,7 +1183,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits, !(ins->rex & (REX_P|REX_W|REX_X|REX_B)) && cpu >= IF_X86_64) { /* LOCK-as-REX.R */ - assert_no_prefix(ins, PPS_LREP); + assert_no_prefix(ins, PPS_LOCK); length++; } else { errfunc(ERR_NONFATAL, "invalid operands in non-64-bit mode"); diff --git a/disasm.c b/disasm.c index 66ea7b0c..9bedcc7b 100644 --- a/disasm.c +++ b/disasm.c @@ -918,14 +918,14 @@ static int matches(const struct itemplate *t, uint8_t *data, } if (lock) { - if (ins->prefixes[PPS_LREP]) + if (ins->prefixes[PPS_LOCK]) return false; - ins->prefixes[PPS_LREP] = P_LOCK; + ins->prefixes[PPS_LOCK] = P_LOCK; } if (drep) { - if (ins->prefixes[PPS_LREP]) + if (ins->prefixes[PPS_REP]) return false; - ins->prefixes[PPS_LREP] = drep; + ins->prefixes[PPS_REP] = drep; } ins->prefixes[PPS_WAIT] = dwait; if (!o_used) { diff --git a/nasm.h b/nasm.h index 01f9ffc4..23def297 100644 --- a/nasm.h +++ b/nasm.h @@ -544,12 +544,13 @@ enum ea_type { * preferences, you can change this. REX prefixes are handled * differently for the time being. * - * Note that LOCK and REP are in the same slot. This is - * an x86 architectural constraint. + * LOCK and REP used to be one slot; this is no longer the case since + * the introduction of HLE. */ enum prefix_pos { PPS_WAIT, /* WAIT (technically not a prefix!) */ - PPS_LREP, /* Lock or REP prefix */ + PPS_REP, /* REP/HLE prefix */ + PPS_LOCK, /* LOCK prefix */ PPS_SEG, /* Segment override prefix */ PPS_OSIZE, /* Operand size prefix */ PPS_ASIZE, /* Address size prefix */ diff --git a/parser.c b/parser.c index 37d71389..3a592fea 100644 --- a/parser.c +++ b/parser.c @@ -81,12 +81,13 @@ static int prefix_slot(int prefix) case R_GS: return PPS_SEG; case P_LOCK: + return PPS_LOCK; case P_REP: case P_REPE: case P_REPZ: case P_REPNE: case P_REPNZ: - return PPS_LREP; + return PPS_REP; case P_O16: case P_O32: case P_O64: -- 2.11.4.GIT