Пример #1
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary> Updates the memory. </summary>
        ///
        /// <remarks> 09/09/2018. </remarks>
        /// -------------------------------------------------------------------------------------------------
        public void UpdateMemory()
        {
            if (!this.Visible)
            {
                return;
            }
            if (sending)
            {
                return;
            }
            sending = true;


            int v;

            for (int i = 0; i < regs.Length; i++)
            {
                v = MainForm.myNewRegisters.GetRegisterValueint(regs[i]);
                ByteProvider bp = ByteProviders[i];
                bp.offset = v;

                int bank = NextAddress.GetBankFromAddress(ref MainForm.banks, v);


                Program.serialport.GetMemory(
                    delegate(byte[] response, int tag)
                {
                    Invoke((MethodInvoker) delegate { UIUpdate(response, tag); });
                }
                    , v, 32, bank, i);
            }
        }
Пример #2
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary> Updates the memory. </summary>
        ///
        /// <remarks> 09/09/2018. </remarks>
        /// -------------------------------------------------------------------------------------------------
        public void UpdateMemory()
        {
            if (!this.Visible)
            {
                return;
            }

            int          v  = memaddress;
            ByteProvider bp = byteProvider;

            bp.offset = v;

            int bank = bankNum;

            if (bankNum < 0)
            {
                bank = NextAddress.GetBankFromAddress(ref MainForm.banks, v);
            }



            Program.serialport.GetMemory(
                delegate(byte[] response, int tag)
            {
                Invoke((MethodInvoker) delegate { UIUpdate(response, tag); });
            }
                , v, 512, bank, 0);
        }
Пример #3
0
            public Label(string l, NextAddress na, bool f, bool d)
            {
                nextAddress = na;

                label    = l;
                function = f;
                define   = d;
            }
Пример #4
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary> Adds a label. </summary>
        ///
        /// <remarks> 07/09/2018. </remarks>
        ///
        /// <param name="label"> The label. </param>
        /// <param name="addr">  The address. </param>
        /// <param name="bank">  The bank. </param>
        /// -------------------------------------------------------------------------------------------------
        public static void AddLabel(string label, int addr, int bank, bool isfunction, bool isdefine)
        {
            NextAddress na = new NextAddress(addr, bank);

            if (isdefine)
            {
                na.SetAddressLong(addr);
            }

            labels.Add(new Label(label, na, isfunction, isdefine));
        }
Пример #5
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary> Request update. </summary>
        ///
        /// <remarks> 12/09/2018. </remarks>
        ///
        /// <param name="address"> The address. </param>
        /// -------------------------------------------------------------------------------------------------
        public void RequestUpdate(int pc)
        {
            int addr = Math.Max(0, pc - 64);

            int bank = NextAddress.GetBankFromAddress(ref MainForm.banks, addr);


            Program.serialport.GetMemory(
                delegate(byte[] response, int tag) { Invoke((MethodInvoker) delegate { UIUpdate(tag, response); }); }
                , addr, 128, bank, addr);
        }
Пример #6
0
        // -------------------------------------------------------------------------------------------------
        // Event handler. Called by stepoverbutton for click events
        //
        // \param   sender  Source of the event.
        // \param   e       Event information.
        // -------------------------------------------------------------------------------------------------
        private void stepoverbutton_Click(object sender, EventArgs e)
        {
            int breakpointAddress = MainForm.myDisassembly.GetStepOverAddress();
            int bank = NextAddress.GetBankFromAddress(ref MainForm.banks, breakpointAddress);


            Program.serialport.SetBreakpoint(
                delegate(byte[] response, int tag)
            {
                Invoke((MethodInvoker) delegate { ContinueExecution(); });
            }
                , breakpointAddress, bank);
        }
Пример #7
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary> Gets a label. </summary>
        ///
        /// <remarks> 07/09/2018. </remarks>
        ///
        /// <param name="addr"> The address. </param>
        ///
        /// <returns> The label. </returns>
        /// -------------------------------------------------------------------------------------------------
        public static Label GetLabel(ref int[] bankmap, int addr)
        {
            int bank     = NextAddress.GetBankFromAddress(ref bankmap, addr);
            int longaddr = NextAddress.MakeLongAddress(bank, addr);


            foreach (Label l in labels)
            {
                if (longaddr == l.nextAddress.GetLongAddress())
                {
                    return(l);
                }
            }

            return(null);
        }
Пример #8
0
 public MicroInstruction(int address, NextAddress nextAddress, bool enableValue,
     int value, JumpCriterion jumpCriterion, bool clearInterrupt,
     bool affected, AluCmd aluCommand, Source source,
     Destination destination, DataInput dataInput, ReadWrite readWrite)
 {
     this.Address = address;
     this.NextAddress = nextAddress;
     this.EnableValue = enableValue;
     this.Value = value;
     this.JumpCriterion = jumpCriterion;
     this.ClearInterrupt = clearInterrupt;
     this.AffectFlags = affected;
     this.AluCommand = aluCommand;
     this.Source = source;
     this.Destination = destination;
     this.DataInput = dataInput;
     this.ReadWrite = readWrite;
 }
Пример #9
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary> Updates the call stack. </summary>
        ///
        /// <remarks> 11/09/2018. </remarks>
        /// -------------------------------------------------------------------------------------------------
        public void UpdateCallStack()
        {
            if (!this.Visible)
            {
                return;
            }

            int sp   = MainForm.myNewRegisters.GetRegisterValueint(Registers.Z80Register.sp);
            int bank = NextAddress.GetBankFromAddress(ref MainForm.banks, sp);


            Program.serialport.GetMemory(
                delegate(byte[] response, int tag)
            {
                Invoke((MethodInvoker) delegate { UIUpdate(response, tag); });
            }
                , sp, 32, bank, sp);
        }
Пример #10
0
        // -------------------------------------------------------------------------------------------------
        // Patch dism memory with breakpoints
        //
        // \param [in,out]  mem
        // The memory.
        // \param           addr
        // The address.
        // \param           length
        // The length.
        // -------------------------------------------------------------------------------------------------
        private void PatchDismMemoryWithBreakpoints(ref byte[] mem, int addr, int length)
        {
            for (int i = 0; i < length; i++)
            {
                //looking for breakpoint instruction
                if (mem[i] == 0xc7)
                {
                    int a    = addr + i;
                    int bank = NextAddress.GetBankFromAddress(ref MainForm.banks, a);

                    int brk = Breakpoint.FindFreeBreakpointAddr(NextAddress.MakeLongAddress(bank, a));
                    if (brk >= 0)
                    {
                        //found a breakpoint so lets replace the memory bytes with the origional value.
                        mem[i] = Breakpoint.breakpointData[brk].replaceopcode;
                    }
                }
            }
        }
Пример #11
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary> Gets function with offset. </summary>
        ///
        /// <remarks> 18/09/2018. </remarks>
        ///
        /// <param name="addr">   The address. </param>
        /// <param name="lab">    [out] The lab. </param>
        /// <param name="offset"> [out] The offset. </param>
        ///
        /// <returns> True if it succeeds, false if it fails. </returns>
        /// -------------------------------------------------------------------------------------------------
        public static bool GetFunctionWithOffset(ref int[] bankmap, int addr, out Label lab, out int offset)
        {
            int bank     = NextAddress.GetBankFromAddress(ref bankmap, addr);
            int longaddr = NextAddress.MakeLongAddress(bank, addr);



            lab    = null;
            offset = 0;

            int best      = int.MaxValue;
            int bestindex = -1;
            int index     = 0;

            foreach (Label l in labels)
            {
                if (longaddr >= l.nextAddress.GetLongAddress() && l.function)
                {
                    int off = longaddr - l.nextAddress.GetLongAddress();
                    if (off < best)
                    {
                        best      = off;
                        bestindex = index;
                    }
                }

                index++;
            }


            if (bestindex < 0)
            {
                return(false);
            }

            lab    = labels[bestindex];
            offset = best;

            return(true);
        }
Пример #12
0
        // -------------------------------------------------------------------------------------------------
        // Gets dissasembly source
        //
        // \param [in,out]  tf
        // The tf.
        // \param           maxlines
        // The maxlines.
        //
        // \return  The dissasembly source.
        // -------------------------------------------------------------------------------------------------
        public string GetDissasemblySource(ref TraceFile tf, int maxlines, int currentline)
        {
            string textfile = "";

            tf.lines.Clear();
            int lineNumber = 0;


            for (int i = 0; i < maxlines - 1; i++)
            {
                textfile = textfile + DissasemblyLines[currentline].line + "\n";


                if (DissasemblyLines[currentline].addr >= 0)
                {
                    LineData ld = new LineData();
                    ld.lineNumber  = lineNumber;
                    ld.nextAddress = new NextAddress(DissasemblyLines[currentline].addr, NextAddress.GetBankFromAddress(ref MainForm.banks, DissasemblyLines[currentline].addr));
                    ld.tf          = tf;
                    tf.lines.Add(ld);
                }

                lineNumber++;
                currentline++;
            }



            return(textfile);
        }
Пример #13
0
 // -------------------------------------------------------------------------------------------------
 // Default constructor
 // -------------------------------------------------------------------------------------------------
 public BreakpointData()
 {
     nextAddress = new NextAddress(0, 0);
 }