Exemplo n.º 1
0
        public static WordRegister AsWordRegister(this InstructionElement argument)
        {
            argument = argument switch
            {
                InstructionElement.AddressFromIXAndOffset => InstructionElement.IX,
                InstructionElement.AddressFromIYAndOffset => InstructionElement.IY,
                var a when(a >= InstructionElement.AddressFromHL && a <= InstructionElement.AddressFromSP) => (InstructionElement)(a - 6),
                _ => argument
            };

            // this looks clunky but it's *much* faster than using Enum.ToString()
            WordRegister register = argument switch
            {
                InstructionElement.AF => WordRegister.AF,
                InstructionElement.BC => WordRegister.BC,
                InstructionElement.DE => WordRegister.DE,
                InstructionElement.HL => WordRegister.HL,
                InstructionElement.IX => WordRegister.IX,
                InstructionElement.IY => WordRegister.IY,
                InstructionElement.SP => WordRegister.SP,
                _ => WordRegister.None
            };

            return(register);
        }
Exemplo n.º 2
0
        public override IElement Interpret(InstructionElement instruction, IndividualDecompilationContext context)
        {
            var constructor = (ConstructorInfo)((MethodReferenceInstruction)instruction.Instruction).Method;
            var arguments   = this.CaptureArguments(constructor.GetParameters(), constructor, context);

            return(new ExpressionElement(Expression.New(constructor, arguments)));
        }
Exemplo n.º 3
0
        public Instruction(string fullOpcode, string mnemonic, Condition condition, InstructionElement target, InstructionElement source, InstructionElement arg1, InstructionElement arg2,
                           byte sizeInBytes, IEnumerable <MachineCycle> machineCycles, ByteRegister?copyResultTo = ByteRegister.None, IMicrocode microcode = null)
        {
            FullOpcode   = fullOpcode;
            CopyResultTo = copyResultTo;

            if (int.TryParse(fullOpcode[..^ 2], NumberStyles.HexNumber, null, out int prefix))
Exemplo n.º 4
0
        private static MutableObject CreateInstructionMutable(InstructionElement element, int instructionCount)
        {
            var newInstruction = new MutableObject();

            newInstruction.Add("Eip", element.Eip);

            newInstruction.Add("Wall Time", (float)element.Header.WallTime);
            newInstruction.Add("Raw Type Index", (int)element.Header.RawTypeIndex);
            newInstruction.Add("Length", (int)element.Header.Length);
            newInstruction.Add("Original Index", (int)element.Header.InstructionCount);
            newInstruction.Add("Processed Index", instructionCount);

            newInstruction.Add("Annotated", false);

            newInstruction.Add("Trace Instruction", element);

            return(newInstruction);
        }
Exemplo n.º 5
0
        public static ByteRegister AsByteRegister(this InstructionElement argument)
        {
            ByteRegister register = argument switch
            {
                InstructionElement.A => ByteRegister.A,
                InstructionElement.B => ByteRegister.B,
                InstructionElement.C => ByteRegister.C,
                InstructionElement.D => ByteRegister.D,
                InstructionElement.E => ByteRegister.E,
                InstructionElement.F => ByteRegister.F,
                InstructionElement.H => ByteRegister.H,
                InstructionElement.L => ByteRegister.L,
                InstructionElement.IXh => ByteRegister.IXh,
                InstructionElement.IYh => ByteRegister.IYh,
                InstructionElement.IXl => ByteRegister.IXl,
                InstructionElement.IYl => ByteRegister.IYl,
                InstructionElement.I => ByteRegister.I,
                InstructionElement.R => ByteRegister.R,
                _ => ByteRegister.None
            };

            return(register);
        }
 protected override IElement VisitInstruction(InstructionElement instruction)
 {
     this.OpCodes.Add(instruction.OpCode);
     return(base.VisitInstruction(instruction));
 }
Exemplo n.º 7
0
 public static bool IsAddressFromIndexAndOffset(this InstructionElement argument)
 {
     return(argument == InstructionElement.AddressFromIXAndOffset || argument == InstructionElement.AddressFromIYAndOffset);
 }
Exemplo n.º 8
0
 public override bool CanInterpret(InstructionElement instruction)
 {
     return(instruction.OpCode == OpCodes.Newobj);
 }
Exemplo n.º 9
0
 private double GetCallTime(InstructionElement element)
 {
     return(element.Header.WallTime);
 }