private SimInstruction(BaseOpcode opcode, byte size, int operandCount, byte opcodeSize) { Opcode = opcode; Size = size; OperandCount = operandCount; OpcodeSize = opcodeSize; }
private static void AdjustInstructionOperands(BaseOpcode opcode, List <SimOperand> operands) { if (IsSecondOperandDuplicate(opcode)) { operands.RemoveAt(1); } if (opcode == Opcode.Mul) { operands.RemoveAt(0); } else if (opcode == Opcode.Div) { operands.RemoveAt(0); operands.RemoveAt(0); } else if (opcode == Opcode.Idiv) { operands.RemoveAt(0); operands.RemoveAt(0); } else if (opcode == Opcode.Cdq) { operands.Clear(); } else if (opcode == Opcode.Xchg) { operands.RemoveAt(2); } else if (opcode == Opcode.Imul) { if (operands[0] == operands[1]) { operands.RemoveAt(0); } } }
public SimInstruction(BaseOpcode opcode, byte size, SimOperand operand1, SimOperand operand2, SimOperand operand3, byte opcodeSize) : this(opcode, size, 3, opcodeSize) { this.Operand1 = operand1; this.Operand2 = operand2; this.Operand3 = operand3; }
public SimInstruction(BaseOpcode opcode, byte size, SimOperand operand1, SimOperand operand2, SimOperand operand3, SimOperand operand4, byte opcodeSize) : this(opcode, size, 4, opcodeSize) { Operand1 = operand1; Operand2 = operand2; Operand3 = operand3; Operand4 = operand4; }
public SimInstruction(BaseOpcode opcode, byte opcodeSize, SimOperand operand1, SimOperand operand2, SimOperand operand3, SimOperand operand4) : this(opcode, opcodeSize, 4) { this.Operand1 = operand1; this.Operand2 = operand2; this.Operand3 = operand3; this.Operand4 = operand4; }
private static bool IsSecondOperandDuplicate(BaseOpcode opcode) { if (opcode == Opcode.Adc) { return(true); } if (opcode == Opcode.Add) { return(true); } if (opcode == Opcode.Addsd) { return(true); } if (opcode == Opcode.Addss) { return(true); } if (opcode == Opcode.And) { return(true); } //if (opcode == Opcode.Cld) return true; if (opcode == Opcode.CmpXchg) { return(true); } if (opcode == Opcode.Comisd) { return(true); } if (opcode == Opcode.Comiss) { return(true); } //if (opcode == Opcode.Cvtsd2ss) return true; //if (opcode == Opcode.Cvtsi2sd) return true; //if (opcode == Opcode.Cvtsi2ss) return true; //if (opcode == Opcode.Cvtss2sd) return true; //if (opcode == Opcode.Cvttsd2si) return true; //if (opcode == Opcode.Cvttss2si) return true; if (opcode == Opcode.Dec) { return(true); } if (opcode == Opcode.Div) { return(true); } if (opcode == Opcode.Divsd) { return(true); } if (opcode == Opcode.Divss) { return(true); } //if (opcode == Opcode.FarJmp) return true; //if (opcode == Opcode.Fld) return true; if (opcode == Opcode.Idiv) { return(true); } //if (opcode == Opcode.Imul) return false; if (opcode == Opcode.Inc) { return(true); } //if (opcode == Opcode.Lea) return true; if (opcode == Opcode.Mul) { return(true); } if (opcode == Opcode.Mulsd) { return(true); } if (opcode == Opcode.Mulss) { return(true); } if (opcode == Opcode.Not) { return(true); } if (opcode == Opcode.Or) { return(true); } if (opcode == Opcode.Rcr) { return(true); } //if (opcode == Opcode.Rdmsr) return true; //if (opcode == Opcode.Rdpmc) return true; //if (opcode == Opcode.Rdtsc) return true; //if (opcode == Opcode.Rep) return true; if (opcode == Opcode.Roundsd) { return(true); } if (opcode == Opcode.Roundss) { return(true); } if (opcode == Opcode.Sar) { return(true); } if (opcode == Opcode.Sbb) { return(true); } if (opcode == Opcode.Shl) { return(true); } if (opcode == Opcode.Shld) { return(true); } if (opcode == Opcode.Shr) { return(true); } if (opcode == Opcode.Shrd) { return(true); } //if (opcode == Opcode.Stos) return true; if (opcode == Opcode.Sub) { return(true); } if (opcode == Opcode.Subsd) { return(true); } if (opcode == Opcode.Subss) { return(true); } //if (opcode == Opcode.Ucomisd) return true; //if (opcode == Opcode.Ucomiss) return true; //if (opcode == Opcode.Xchg) return true; if (opcode == Opcode.Xor) { return(true); } if (opcode == Opcode.Pxor) { return(true); } //if (opcode == Opcode.Ucomisd) return true; //if (opcode == Opcode.Ucomiss) return true; if (opcode == Opcode.Neg) { return(true); } if (opcode == Opcode.Bts) { return(true); } if (opcode == Opcode.Btr) { return(true); } return(false); }
SimInstruction ISimAdapter.Convert(InstructionNode node, MosaMethod method, BasicBlocks basicBlocks, byte opcodeSize) { X86Instruction x86Instruction = node.Instruction as X86Instruction; if (x86Instruction == null) { return(null); } BaseOpcode opcode = ConvertToOpcode(x86Instruction, node.ConditionCode); if (opcode == null) { return(null); } var operands = GetOperands(node, method, basicBlocks); AdjustInstructionOperands(opcode, operands); byte size = 0; if (node.Size == InstructionSize.Size128) { size = 128; } else if (node.Size == InstructionSize.Size64) { size = 64; } else if (node.Size == InstructionSize.Size32) { size = 32; } else if (node.Size == InstructionSize.Size16) { size = 16; } else if (node.Size == InstructionSize.Size8) { size = 8; } SimInstruction instruction = null; switch (operands.Count) { case 0: instruction = new SimInstruction(opcode, size, opcodeSize); break; case 1: instruction = new SimInstruction(opcode, size, operands[0], opcodeSize); break; case 2: instruction = new SimInstruction(opcode, size, operands[0], operands[1], opcodeSize); break; case 3: instruction = new SimInstruction(opcode, size, operands[0], operands[1], operands[2], opcodeSize); break; case 4: instruction = new SimInstruction(opcode, size, operands[0], operands[1], operands[2], operands[3], opcodeSize); break; default: break; } return(instruction); }
public SimInstruction(BaseOpcode opcode, byte size, SimOperand operand1, byte opcodeSize) : this(opcode, size, 1, opcodeSize) { this.Operand1 = operand1; }
public SimInstruction(BaseOpcode opcode, byte size, byte opcodeSize) : this(opcode, size, 0, opcodeSize) { }
public SimInstruction(BaseOpcode opcode, byte size, SimOperand operand1, SimOperand operand2, byte opcodeSize) : this(opcode, size, 2, opcodeSize) { Operand1 = operand1; Operand2 = operand2; }
WasmNodeResult IWasmOpcodeVisitor <WasmNodeArg, WasmNodeResult> .Visit(BaseOpcode opcode, WasmNodeArg arg) => throw new System.NotImplementedException();
public SimInstruction(BaseOpcode opcode, byte opcodeSize, SimOperand operand1, SimOperand operand2) : this(opcode, opcodeSize, 2) { this.Operand1 = operand1; this.Operand2 = operand2; }
WasmMSILResult IWasmOpcodeVisitor <WasmMSILArg, WasmMSILResult> .Visit(BaseOpcode opcode, WasmMSILArg arg) => throw new NotImplementedException();
public static void Execute(this BaseOpcode opcode, WasmFunctionState state) { opcode.AcceptVistor(_executor, state); }
public WasmOpcodeExecutor Visit(BaseOpcode opcode, WasmFunctionState state) => throw new System.NotImplementedException();