public static Myx86Instruction Create(x86OpCode opcode, Opnd operand1, Opnd operand2) { Myx86Instruction newInstruction = new Myx86Instruction(); newInstruction.OpCode = opcode; newInstruction.operand1 = operand1; newInstruction.operand2 = operand2; newInstruction.GenerateBytes(); return newInstruction; }
internal void ProcessOperandBytes(Myx86Instruction instruction) { uint nextOffset = (uint)(instruction.Offset.FileOffset + instruction.Size); Operand operandValue = null; switch (instruction.OpCode.GetNormalOperandType()) { case x86OperandType.Byte: operandValue = new Opnd(instruction.operandbytes[0]); break; case x86OperandType.Word: operandValue = new Opnd(BitConverter.ToInt16(instruction.operandbytes, 0)); break; case x86OperandType.WordAndByte: break; // TODO case x86OperandType.Dword: operandValue = new Opnd(BitConverter.ToUInt32(instruction.operandbytes, 0)); break; case x86OperandType.Fword: break; // TODO case x86OperandType.Qword: operandValue = new Opnd(BitConverter.ToUInt64(instruction.operandbytes, 0)); break; case x86OperandType.InstructionAddress: operandValue = CreateTargetOffset((uint)(nextOffset + BitConverter.ToInt32(instruction.operandbytes, 0))); break; case x86OperandType.ShortInstructionAddress: operandValue = CreateTargetOffset((uint)(nextOffset + ASMGlobals.ByteToSByte(instruction.operandbytes[0]))); break; case x86OperandType.Register32: DecodeSingleRegister(instruction, instruction.code._opcodeBytes[instruction.code._opcodeBytes.Length - 1]); break; case x86OperandType.Instruction: // opcode is prefix. x86Instruction nextInstruction = DisassembleNextInstruction(); operandValue = new Operand(nextInstruction); instruction.operandbytes = ASMGlobals.MergeBytes(nextInstruction.code.OpCodeBytes, nextInstruction.operandbytes); instruction.code._operandLength = nextInstruction.Size; break; case x86OperandType.None: if (instruction.code.IsBasedOn(x86OpCodes.Unknown)) operandValue = new Operand(instruction.code._opcodeBytes[0]); break; } if (operandValue != null) { if (instruction.operand1 != null) instruction.operand2 = operandValue; else instruction.operand1 = operandValue; } }