private static IEnumerable<X86Instruction> CreateRegOrMemTestInstructions(X86OpCode opcode, X86Mnemonic mnemonic, bool flippedOperands)
{
for (int operandType = 0; operandType < 3; operandType++)
{
for (int register2Index = 0; register2Index < 8; register2Index++)
{
for (int register1Index = 0; register1Index < 8; register1Index++)
{
var operand1 = new X86Operand(X86OperandUsage.BytePointer,
(X86Register)register1Index | X86Register.Eax);
var operand2 = new X86Operand(X86OperandUsage.Normal, (X86Register)register2Index);
var instruction = new X86Instruction()
{
OpCode = opcode,
Mnemonic = mnemonic,
};
if (flippedOperands)
{
instruction.Operand2 = operand1;
instruction.Operand1 = operand2;
}
else
{
instruction.Operand1 = operand1;
instruction.Operand2 = operand2;
}
switch (register1Index)
{
case 4: // esp
continue;
case 5: // ebp
if (operandType != 0)
continue;
operand1.Value = 0x1337u;
break;
}
switch (operandType)
{
case 1:
operand1.Offset = 1;
operand1.OffsetType = X86OffsetType.Short;
break;
case 2:
operand1.Offset = 0x1337;
operand1.OffsetType = X86OffsetType.Long;
break;
}
yield return instruction;
}
}
}
}