/// <summary> /// Implementation of IComparer.Compare. In reality, /// </summary> /// <param name="oInstrA"></param> /// <param name="oInstrB"></param> /// <returns></returns> public override bool CompareOperands(MachineInstruction a, MachineInstruction b) { var instrA = (PICInstruction)a; var instrB = (PICInstruction)b; if (instrA.Mnemonic != instrB.Mnemonic) { return(false); } if (instrA.NumberOfOperands != instrB.NumberOfOperands) { return(false); } bool retval = true; if (instrA.NumberOfOperands > 0) { retval = CompareOperands(instrA.Operands[0], instrB.Operands[0]); if (retval && instrA.NumberOfOperands > 1) { retval = CompareOperands(instrA.Operands[1], instrB.Operands[1]); if (retval && instrA.NumberOfOperands > 2) { retval = CompareOperands(instrA.Operands[2], instrB.Operands[2]); } } } return(retval); }
public void Mcdm_FindInstructionIndex() { var instrs = new MachineInstruction[] { new FakeInstruction(Operation.Add) { Address = Address.Ptr32(0x1000), Length = 2 }, new FakeInstruction(Operation.Add) { Address = Address.Ptr32(0x1002), Length = 2 }, }; Func <uint, int> Idx = u => MixedCodeDataModel.FindIndexOfInstructionAddress( instrs, Address.Ptr32(u)); Assert.AreEqual(-1, Idx(0x0FFF)); Assert.AreEqual(0, Idx(0x1000)); Assert.AreEqual(0, Idx(0x1001)); Assert.AreEqual(1, Idx(0x1002)); Assert.AreEqual(1, Idx(0x1003)); Assert.AreEqual(-1, Idx(0x1004)); }
public override int GetOperandsHash(MachineInstruction instr) { var a = (Msp430Instruction)instr; var h = GetOperandHash(a.Operands[0]) ^ GetOperandHash(a.Operands[1]) * 37; return(h); }
/// <summary> /// Returns true if this function might continue to the next instruction. /// </summary> /// <param name="i"></param> /// <returns></returns> private bool MayFallThrough(MachineInstruction i) { return((i.InstructionClass & (InstructionClass.Linear | InstructionClass.Conditional | InstructionClass.Call)) != 0); //$REVIEW: what if you call a terminating function? }
public bool DumpAssemblerLine( MemoryArea mem, IProcessorArchitecture arch, MachineInstruction instr, InstrWriter writer, MachineInstructionRendererOptions options) { var instrAddress = instr.Address; Address addrBegin = instrAddress; if (ShowAddresses) { writer.WriteFormat("{0} ", addrBegin); } if (ShowCodeBytes) { WriteOpcodes(mem, arch, instrAddress, instrAddress + instr.Length, writer); if (instr.Length * 3 < 16) { writer.WriteString(new string(' ', 16 - (instr.Length * 3))); } } writer.WriteString("\t"); instr.Render(writer, options); writer.WriteLine(); return(true); }
public override bool CompareOperands(MachineInstruction x, MachineInstruction y) { var a = (Msp430Instruction)x; var b = (Msp430Instruction)y; return(CompareOperands(a.op1, b.op1) && CompareOperands(a.op2, b.op2)); }
public override bool CompareOperands(MachineInstruction x, MachineInstruction y) { var a = (Msp430Instruction)x; var b = (Msp430Instruction)y; return(CompareOperands(a.Operands[0], b.Operands[0]) && CompareOperands(a.Operands[1], b.Operands[1])); }
/// <summary> /// Implementation of IComparer.Compare. In reality, /// </summary> /// <param name="oInstrA"></param> /// <param name="oInstrB"></param> /// <returns></returns> public override bool CompareOperands(MachineInstruction a, MachineInstruction b) { var instrA = (X86Instruction)a; var instrB = (X86Instruction)b; if (instrA.Mnemonic != instrB.Mnemonic) { return(false); } if (instrA.Operands.Length != instrB.Operands.Length) { return(false); } bool retval = true; if (instrA.Operands.Length > 0) { retval = CompareOperands(instrA.Operands[0], instrB.Operands[0]); if (retval && instrA.Operands.Length > 1) { retval = CompareOperands(instrA.Operands[1], instrB.Operands[1]); if (retval && instrA.Operands.Length > 2) { retval = CompareOperands(instrA.Operands[2], instrB.Operands[2]); } } } return(retval); }
public DisassemblyFormatter(Program program, MachineInstruction instr, List <TextSpan> line) { this.program = program; this.instr = instr; this.line = line; this.Platform = program.Platform; }
/// <summary> /// Implementation of IComparer.Compare. In reality, /// </summary> /// <param name="oInstrA"></param> /// <param name="oInstrB"></param> /// <returns></returns> public override bool CompareOperands(MachineInstruction a, MachineInstruction b) { var instrA = (X86Instruction)a; var instrB = (X86Instruction)b; if (instrA.code != instrB.code) { return(false); } if (instrA.Operands != instrB.Operands) { return(false); } bool retval = true; if (instrA.Operands > 0) { retval = CompareOperands(instrA.op1, instrB.op1); if (retval && instrA.Operands > 1) { retval = CompareOperands(instrA.op2, instrB.op2); if (retval && instrA.Operands > 2) { retval = CompareOperands(instrA.op3, instrB.op3); } } } return(retval); }
public override int GetOperandsHash(MachineInstruction instr) { var arm = ((Arm32Instruction)instr).instruction; if (arm == null) { return(0); } var ops = arm.ArchitectureDetail.Operands; int hash = 0; for (int i = 0; i < ops.Length; ++i) { var op = ops[i]; hash = hash * 23; switch (op.Type) { case ArmInstructionOperandType.Register: if (!NormalizeRegisters) { hash ^= op.RegisterValue.Value.GetHashCode(); } break; case ArmInstructionOperandType.Immediate: if (!NormalizeConstants) { hash ^= op.ImmediateValue.Value.GetHashCode(); } break; case ArmInstructionOperandType.Memory: if (!NormalizeRegisters) { hash ^= op.MemoryValue.BaseRegister.GetHashCode(); } hash *= 29; if (!NormalizeConstants) { hash ^= op.MemoryValue.Displacement.GetHashCode(); } break; case ArmInstructionOperandType.CImmediate: case ArmInstructionOperandType.PImmediate: if (!NormalizeConstants) { hash ^= op.ImmediateValue.Value; } break; default: throw new AddressCorrelatedException( instr.Address, "ARM32 instruction comparer doesn't handle {0} yet.", op.Type); } } return(hash); }
public override int GetOperandsHash(MachineInstruction instr) { var tinstr = (Tlcs90Instruction)instr; return (HashOp(tinstr.Operands[0]) ^ HashOp(tinstr.Operands[1]) * 17); }
public override int GetOperandsHash(MachineInstruction i) { var instr = (Pdp11Instruction)i; return (Hash(instr.op1) * 23 ^ Hash(instr.op2)); }
public override int GetOperandsHash(MachineInstruction i) { var instr = (Z80Instruction)i; return (HashOp(instr.Operands[0]) ^ HashOp(instr.Operands[1]) * 17); }
public override int GetOperandsHash(MachineInstruction sInstr) { var instr = (SparcInstruction)sInstr; return (17 * GetOperandHash(instr.Operands[0]) ^ 23 * GetOperandHash(instr.Operands[1]) ^ 59 * GetOperandHash(instr.Operands[2])); }
public DisassemblyFormatter(Program program, IProcessorArchitecture arch, MachineInstruction instr, List <TextSpan> line) { this.program = program; this.arch = arch; this.instr = instr; this.line = line; this.Platform = program.Platform; this.annotations = new List <string>(); }
public override bool CompareOperands(MachineInstruction x, MachineInstruction y) { var a = (SparcInstruction)x; var b = (SparcInstruction)y; return(CompareOperands(a.Op1, b.Op1) && CompareOperands(a.Op2, b.Op2) && CompareOperands(a.Op3, b.Op3)); }
public override bool CompareOperands(MachineInstruction x, MachineInstruction y) { var a = (Pdp11Instruction)x; var b = (Pdp11Instruction)y; return (Compare(Op(x, 0), Op(y, 0)) && Compare(Op(x, 1), Op(y, 1))); }
public DisassemblyFormatter(Program program, IProcessorArchitecture arch, MachineInstruction instr, List <TextSpan> line) { this.program = program; this.arch = arch; this.instr = instr; this.line = line; this.annotations = new List <string>(); this.mnemonicStyle = Gui.Services.UiStyles.DisassemblerOpcode; }
public void ReportMissingRewriter(string testPrefix, MachineInstruction instr, string mnemonic, EndianImageReader rdr, string message, string opcodeAsText) { if (IsMuted) { return; } lock (lockObject) svc.ReportMissingRewriter(testPrefix, instr, mnemonic, rdr, message, opcodeAsText); }
public void ReportMissingRewriter(string testPrefix, MachineInstruction instr, string mnemonic, EndianImageReader rdr, string message, Func <byte[], string>?hexize = null) { if (IsMuted) { return; } lock (lockObject) svc.ReportMissingRewriter(testPrefix, instr, mnemonic, rdr, message, hexize); }
public override int GetOperandsHash(MachineInstruction instr) { var i = (M68kInstruction)instr; return (OperandHash(i.Operands[0]) * 23 ^ OperandHash(i.Operands[1]) * 29 ^ OperandHash(i.Operands[2]) * 9); }
public override int GetOperandsHash(MachineInstruction instr) { var i = (M68kInstruction)instr; return (OperandHash(i.op1) * 23 ^ OperandHash(i.op2) * 29 ^ OperandHash(i.op3) * 9); }
public override int GetOperandsHash(MachineInstruction instr) { return(1); /* * var arm = ((Arm32InstructionOld)instr).instruction; * if (arm == null) * return 0; * var ops = arm.ArchitectureDetail.Operands; * int hash = 0; * for (int i = 0; i < ops.Length; ++i) * { * var op = ops[i]; * hash = hash * 23; * switch (op.Type) * { * case ArmInstructionOperandType.Register: * if (!NormalizeRegisters) * { * hash ^= op.RegisterValue.Value.GetHashCode(); * } * break; * case ArmInstructionOperandType.Immediate: * if (!NormalizeConstants) * { * hash ^= op.ImmediateValue.Value.GetHashCode(); * } * break; * case ArmInstructionOperandType.Memory: * if (!NormalizeRegisters) * { * hash ^= op.MemoryValue.BaseRegister.GetHashCode(); * } * hash *= 29; * if (!NormalizeConstants) * { * hash ^= op.MemoryValue.Displacement.GetHashCode(); * } * break; * case ArmInstructionOperandType.CImmediate: * case ArmInstructionOperandType.PImmediate: * if (!NormalizeConstants) * { * hash ^= op.ImmediateValue.Value; * } * break; * default: * throw new AddressCorrelatedException( * instr.Address, * "ARM32 instruction comparer doesn't handle {0} yet.", * op.Type); * } * } * return hash; */ }
public override bool CompareOperands(MachineInstruction x, MachineInstruction y) { var a = (M68kInstruction)x; var b = (M68kInstruction)y; return (Compare(a.op1, a.op1) && Compare(a.op2, a.op2) && Compare(a.op3, a.op3)); }
public override int GetOperandsHash(MachineInstruction oinstr) { int h = 0; var instr = (MipsInstruction)oinstr; h = h * 23 ^ GetHashCode(instr.op1); h = h * 23 ^ GetHashCode(instr.op2); h = h * 23 ^ GetHashCode(instr.op3); return(h); }
public override int GetOperandsHash(MachineInstruction instr) { var i = (RiscVInstruction)instr; int hash = GetOperandHash(i.Operands[0]) * 23 ^ GetOperandHash(i.Operands[1]) * 19 ^ GetOperandHash(i.Operands[2]); return(hash); }
private string BuildBytes(MachineInstruction instr) { var sb = new StringBuilder(); var rdr = program.CreateImageReader(instr.Address); for (int i = 0; i < instr.Length; ++i) { sb.AppendFormat("{0:X2} ", rdr.ReadByte()); } return sb.ToString(); }
private static string BuildBytes(Program program, MachineInstruction instr) { var sb = new StringBuilder(); var rdr = program.CreateImageReader(instr.Address); for (int i = 0; i < instr.Length; ++i) { sb.AppendFormat("{0:X2} ", rdr.ReadByte()); } return(sb.ToString()); }
public override string RenderAsObjdump(MachineInstruction i) { var instr = (AArch64Instruction)i; var sb = new StringBuilder(); if (instr.Mnemonic == Mnemonic.b && instr.Operands[0] is ConditionOperand cop) { sb.Append($"b.{cop.Condition.ToString().ToLower()}"); } else { sb.Append(instr.Mnemonic.ToString()); } var sep = "\t"; foreach (var op in instr.Operands) { sb.Append(sep); sep = ", "; switch (op) { case RegisterOperand reg: sb.Append(reg.Register.Name); break; case ImmediateOperand imm: sb.AppendFormat("0x{0:x}", imm.Value.ToUInt64()); break; case AddressOperand addr: sb.AppendFormat("0x{0:x}", addr.Address.ToLinear()); break; case MemoryOperand mem: sb.Append('['); sb.Append(mem.Base.Name); if (mem.Offset != null && !mem.Offset.IsZero) { sb.AppendFormat(", #{0}", mem.Offset.ToInt32()); } sb.Append(']'); if (mem.PreIndex) { sb.Append('!'); } break; default: sb.Append(op); break; } } return(sb.ToString()); }
public IJumpTableDialog CreateJumpTableDialog(Program program, MachineInstruction instrIndirectJmp, Address addrVector, int stride) { return(new JumpTableDialog() { Services = this.services, Program = program, Instruction = instrIndirectJmp, VectorAddress = addrVector, Stride = stride }); }
public Syscall(MachineInstruction machineInstruction) : base("syscall", machineInstruction, Flag.None, FunctionalUnit.Types.None) { }
public C_un_s(MachineInstruction machineInstruction) : base("c_un_s", machineInstruction) { }
public IntImmOp(string mnemonic, MachineInstruction machineInstruction, Flag flags, FunctionalUnit.Types fuType) : base(mnemonic, machineInstruction, flags, fuType) { this.Imm = (short)machineInstruction[BitField.INTIMM]; this.ZextImm = 0x0000FFFF & machineInstruction[BitField.INTIMM]; this.SextImm = BitHelper.Sext (machineInstruction[BitField.INTIMM], 16); }
public C_ult_d(MachineInstruction machineInstruction) : base("c_ult_d", machineInstruction) { }
public Mul_s(MachineInstruction machineInstruction) : base("mul_s", machineInstruction, Flag.FloatComputation, FunctionalUnit.Types.FloatMultiply) { }
public Xor(MachineInstruction machineInstruction) : base("xor", machineInstruction, Flag.IntegerComputation, FunctionalUnit.Types.IntALU) { }
public Mtc1(MachineInstruction machineInstruction) : base("mtc1", machineInstruction, Flag.None, FunctionalUnit.Types.None) { }
public Mult(MachineInstruction machineInstruction) : base("mult", machineInstruction, Flag.IntegerComputation, FunctionalUnit.Types.IntALU) { }
public Mov_s(MachineInstruction machineInstruction) : base("mov_s", machineInstruction, Flag.None, FunctionalUnit.Types.None) { }
public MemoryOp(string mnemonic, MachineInstruction machineInstruction, Flag flags, FunctionalUnit.Types fuType) : base(mnemonic, machineInstruction, flags, fuType) { this.Displacement = BitHelper.Sext (machineInstruction[BitField.OFFSET], 16); }
public Lwr(MachineInstruction machineInstruction) : base("lwr", machineInstruction, Flag.Memory | Flag.Load | Flag.DisplacedAddressing, FunctionalUnit.Types.ReadPort) { }
public Unimplemented(string mnemonic, MachineInstruction machineInstruction) : base(mnemonic, machineInstruction, Flag.None, FunctionalUnit.Types.None) { }
public Neg_s(MachineInstruction machineInstruction) : base("neg_s", machineInstruction, Flag.FloatComputation, FunctionalUnit.Types.FloatCompare) { }
public Unknown(MachineInstruction machineInstruction) : base("unknown", machineInstruction, Flag.None, FunctionalUnit.Types.None) { }
public Nop(MachineInstruction machineInstruction) : base("nop", machineInstruction, Flag.None, FunctionalUnit.Types.None) { }
public Xori(MachineInstruction machineInstruction) : base("xori", machineInstruction, Flag.IntegerComputation | Flag.Immediate, FunctionalUnit.Types.IntALU) { }
public Jalr(MachineInstruction machineInstruction) : base("jalr", machineInstruction, Flag.Control | Flag.UnconditionalBranch | Flag.FunctionCall | Flag.IndirectJump, FunctionalUnit.Types.IntALU) { }
public FloatConvertOp(string mnemonic, MachineInstruction machineInstruction) : base(mnemonic, machineInstruction, Flag.FloatComputation, FunctionalUnit.Types.FloatConvert) { }
public IntOp(string mnemonic, MachineInstruction machineInstruction, Flag flags, FunctionalUnit.Types fuType) : base(mnemonic, machineInstruction, flags, fuType) { }
public C_seq_d(MachineInstruction machineInstruction) : base("c_seq_d", machineInstruction) { }
public Div_s(MachineInstruction machineInstruction) : base("div_s", machineInstruction, Flag.FloatComputation, FunctionalUnit.Types.FloatDivide) { }
public FailUnimplemented(string mnemonic, MachineInstruction machineInstruction) : base(mnemonic, machineInstruction) { }
public Swr(MachineInstruction machineInstruction) : base("swr", machineInstruction, Flag.Memory | Flag.Store | Flag.DisplacedAddressing, FunctionalUnit.Types.WritePort) { }
public Sqrt_s(MachineInstruction machineInstruction) : base("sqrt_s", machineInstruction, Flag.FloatComputation, FunctionalUnit.Types.FloatSquareRoot) { }
public Jr(MachineInstruction machineInstruction) : base("jr", machineInstruction, Flag.Control | Flag.UnconditionalBranch | Flag.FunctionReturn | Flag.IndirectJump, FunctionalUnit.Types.None) { }
public Subu(MachineInstruction machineInstruction) : base("subu", machineInstruction, Flag.IntegerComputation, FunctionalUnit.Types.IntALU) { }
public Sub_s(MachineInstruction machineInstruction) : base("sub_s", machineInstruction, Flag.FloatComputation, FunctionalUnit.Types.FloatAdd) { }
public Jump(string mnemonic, MachineInstruction machineInstruction, Flag flags, FunctionalUnit.Types fuType) : base(mnemonic, machineInstruction, flags, fuType) { this.Target = this[BitField.JMPTARG] << 2; }
public Divu(MachineInstruction machineInstruction) : base("divu", machineInstruction, Flag.IntegerComputation, FunctionalUnit.Types.IntDivide) { }