public InstructionDef(EnumValue code, string opCodeString, string instructionString, EnumValue mnemonic, EnumValue mem, EnumValue bcst, EnumValue decoderOption, InstructionDefFlags1 flags1, InstructionDefFlags2 flags2, InstructionDefFlags3 flags3, InstrStrFmtOption instrStrFmtOption, InstructionStringFlags instrStrFlags, InstrStrImpliedOp[] instrStrImpliedOps, MandatoryPrefix mandatoryPrefix, OpCodeTableKind table, OpCodeL lBit, OpCodeW wBit, uint opCode, int opCodeLength, int groupIndex, int rmGroupIndex, CodeSize operandSize, CodeSize addressSize, TupleType tupleType, OpCodeOperandKind[] opKinds, PseudoOpsKind?pseudoOp, EnumValue encoding, EnumValue flowControl, ConditionCode conditionCode, BranchKind branchKind, RflagsBits read, RflagsBits undefined, RflagsBits written, RflagsBits cleared, RflagsBits set, EnumValue[] cpuid, OpInfo[] opInfo, FastFmtInstructionDef fast, FmtInstructionDef gas, FmtInstructionDef intel, FmtInstructionDef masm, FmtInstructionDef nasm) { Code = code; OpCodeString = opCodeString; InstructionString = instructionString; Mnemonic = mnemonic; Memory = mem; MemoryBroadcast = bcst; DecoderOption = decoderOption; EncodingValue = encoding; Flags1 = flags1; Flags2 = flags2; Flags3 = flags3; InstrStrFmtOption = instrStrFmtOption; InstrStrFlags = instrStrFlags; InstrStrImpliedOps = instrStrImpliedOps; MandatoryPrefix = mandatoryPrefix; Table = table; LBit = lBit; WBit = wBit; OpCode = opCode; OpCodeLength = opCodeLength; GroupIndex = groupIndex; RmGroupIndex = rmGroupIndex; TupleType = tupleType; OperandSize = operandSize; AddressSize = addressSize; OpKinds = opKinds; PseudoOp = pseudoOp; ControlFlow = flowControl; ConditionCode = conditionCode; BranchKind = branchKind; RflagsRead = read; RflagsUndefined = undefined; RflagsWritten = written; RflagsCleared = cleared; RflagsSet = set; RflagsInfo = null; Cpuid = cpuid; CpuidInternal = null; OpInfo = opInfo; OpInfoEnum = new EnumValue[opInfo.Length]; Fast = fast; Gas = gas; Intel = intel; Masm = masm; Nasm = nasm; }
public void GetBytes_BranchInstruction(BranchKind branchKind) { var instruction = new BranchInstruction(branchKind, 42); var expectedBytes = InstructionByteBuilder.Create() .Opcode(Opcode.Branch, branchKind, 42) .AsSpan(); Assert.True(expectedBytes.SequenceEqual(instruction.GetBytes())); }
public void Decode_BranchInstruction_FromByteArray(BranchKind branchKind) { var bytes = InstructionByteBuilder.Create() .Opcode(Opcode.Branch, branchKind, 42) .ToArray(); var branchInstruction = AssertBytesDecodedAs <BranchInstruction>(bytes); Assert.Equal(branchKind, branchInstruction.BranchKind); }
public Branch(bool condition, short offset, int endAddress) { this.Condition = condition; this.Offset = offset; this.endAddress = endAddress; if (offset == 0) { this.Kind = BranchKind.RFalse; } else if (offset == 1) { this.Kind = BranchKind.RTrue; } else { this.Kind = BranchKind.Address; } }
static void ReportBranchHierarchy(IProject project, BranchKind kind) { var roots = project.Branches.GetRoots(kind).ToArray(); var branchCount = 0; var hiddenBranchCount = 0; var maxDepth = 0; var minBranchNameLength = int.MaxValue; var maxBranchNameLength = int.MinValue; var haveNonAsciiNames = false; var seenBranchNames = new HashSet <string>(); var haveDuplicatedNames = false; foreach (var b in roots.Concat(roots.SelectMany(root => root.Descendants))) { ++branchCount; if (!b.IsViewable) { ++hiddenBranchCount; } maxDepth = Math.Max(maxDepth, b.DepthLevel); minBranchNameLength = Math.Min(minBranchNameLength, b.Name.Length); maxBranchNameLength = Math.Max(maxBranchNameLength, b.Name.Length); haveNonAsciiNames |= b.Name.Any(c => c < 0 || c > 127); haveDuplicatedNames |= !seenBranchNames.Add(b.Name); } Console.WriteLine(" Branches: {0}", branchCount); if (branchCount == 0) { return; } Console.WriteLine( " Hidden branches: {0} ({1}%)", hiddenBranchCount, hiddenBranchCount * 100 / branchCount); Console.WriteLine(" Deepest branch level: {0}", maxDepth + 1); Console.WriteLine( " Branch name length: {0}-{1} characters", minBranchNameLength, maxBranchNameLength); Console.WriteLine(" Non-ASCII branch names: {0}", FormatBool(haveNonAsciiNames)); Console.WriteLine(" Duplicated branch names: {0}", FormatBool(haveDuplicatedNames)); }
public void ToString_BranchInstruction(BranchKind branchKind, string expectedString) { var branchInstruction = new BranchInstruction(branchKind, 42); Assert.Equal(expectedString, branchInstruction.ToString()); }
private string ToString(BranchKind branchKind) => branchKind switch {
public BranchInstruction(BranchKind branchKind, int target) { BranchKind = branchKind; Target = target; }