Skip to content
Snippets Groups Projects
Commit f8e2d3f8 authored by clc5q's avatar clc5q
Browse files

Handle DEFs/USEs due to REP/REPNE prefixes.

parent a691a88e
No related branches found
No related tags found
No related merge requests found
......@@ -582,11 +582,34 @@ void SMPInstr::MDFixupDefUseLists(void) {
} // end if (o_phrase or o_displ operand)
} // end for (all operands)
// Next, handle repeat prefices in the instructions.
// Next, handle repeat prefices in the instructions. The Intel REPE/REPZ prefix
// is just the text printed for SCAS/CMPS instructions that have a REP prefix.
// Only two distinct prefix codes are actually defined: REP and REPNE/REPNZ, and
// REPNE/REPNZ only applies to SCAS and CMPS instructions.
bool HasRepPrefix = (0 != (this->SMPcmd.auxpref & aux_rep));
bool HasRepnePrefix = (0 != (this->SMPcmd.auxpref & aux_repne));
if (HasRepPrefix && HasRepnePrefix)
msg("REP and REPNE both present at %x %s\n", this->GetAddr(), this->GetDisasm());
if (HasRepPrefix || HasRepnePrefix) {
// All repeating instructions use ECX as the countdown register.
op_t BaseOpnd;
BaseOpnd.type = o_reg; // Change type and reg fields
BaseOpnd.reg = R_cx;
BaseOpnd.hasSIB = 0;
BaseOpnd.clr_showed();
this->Defs.SetRef(BaseOpnd);
this->Uses.SetRef(BaseOpnd);
}
if (!this->DefsFlags && ((this->SMPcmd.itype == NN_cmps) || (this->SMPcmd.itype == NN_scas))) {
// REPE and REPNE define the flags in addition to ECX.
op_t BaseOpnd;
BaseOpnd.type = o_reg; // Change type and reg fields
BaseOpnd.reg = X86_FLAGS_REG;
BaseOpnd.hasSIB = 0;
BaseOpnd.clr_showed();
this->Defs.SetRef(BaseOpnd);
this->DefsFlags = true;
}
// Now, handle special instruction categories that have implicit operands.
if (NN_cmpxchg == this->SMPcmd.itype) {
......@@ -640,11 +663,11 @@ void SMPInstr::MDFixupDefUseLists(void) {
if (this->type == COND_BRANCH) {
assert(SMPUsesFlags[this->SMPcmd.itype]);
}
if (SMPDefsFlags[this->SMPcmd.itype]) {
if (!this->DefsFlags && SMPDefsFlags[this->SMPcmd.itype]) {
this->MDAddRegDef(X86_FLAGS_REG, false);
this->DefsFlags = true;
}
if (SMPUsesFlags[this->SMPcmd.itype]) {
if (!this->UsesFlags && SMPUsesFlags[this->SMPcmd.itype]) {
this->MDAddRegUse(X86_FLAGS_REG, false);
this->UsesFlags = true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment