Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions bdshemu/bdshemu_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -2640,8 +2640,9 @@ ShemuX86Emulate(
case ND_INS_LODS:
case ND_INS_STOS:
case ND_INS_MOVS:
// Fetch the rCX register, which is the third operand in case of repeated instructions.
while (Context->InstructionsCount < Context->MaxInstructionsCount)
// do/while: outer loop already gated this dispatch on a budget slot,
// so iteration #1 must run even at MaxInstructionsCount == 1.
do
{
// Get the RCX value.
GET_OP(Context, 2, &dst);
Expand All @@ -2667,12 +2668,13 @@ ShemuX86Emulate(
}

Context->InstructionsCount++;
}
} while (Context->InstructionsCount < Context->MaxInstructionsCount);
break;

case ND_INS_SCAS:
case ND_INS_CMPS:
while (Context->InstructionsCount < Context->MaxInstructionsCount)
// Same budget contract as MOVS above.
do
{
// Get the RCX value.
GET_OP(Context, 2, &dst);
Expand Down Expand Up @@ -2717,7 +2719,7 @@ ShemuX86Emulate(
}

Context->InstructionsCount++;
}
} while (Context->InstructionsCount < Context->MaxInstructionsCount);
break;

case ND_INS_MUL:
Expand Down
Loading