コード例 #1
0
        private void show_diss_post_registers()
        {
            ShowSrcDissStruct sms = show_diss_common();

            if (sms == null)
            {
                SetSourceView("Source not found for this address ");
                if (mIsAPUMode)
                {
                    sms = new ShowSrcDissStruct()
                    {
                        endNext = m_registerSet.GetPC() + 0x10
                        ,
                        startPrev = m_registerSet.GetPC()
                    };
                }
                else
                {
                    sms = new ShowSrcDissStruct()
                    {
                        endNext = m_registerSet.GetPC() + 0x20
                        ,
                        startPrev = m_registerSet.GetPC()
                    };
                }
            }
            sms.displayDissCallback = new CommandStruct.CS_TextDelegate(show_diss_get_post_dissasem);
            string         command = "d " + sms.startPrev.ToString("X") + " " + m_registerSet.GetPC().ToString("X");
            VICECOMManager vcom    = VICECOMManager.getVICEComManager();

            vcom.addTextCommand(command, CommandStruct.eMode.DoCommandReturnResults, new CommandStruct.CS_TextDelegate(show_src_diss_get_pre_dissasem), sms, this.Dispatcher);
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: hugovangalen/ACME
        private void show_src_diss_get_pre_dissasem(string reply, object userData)
        {
            ShowSrcDissStruct sms = userData as ShowSrcDissStruct;

            sms.disassemblyBefore = reply;
            string         command = "d " + m_registerSet.GetPC().ToString("X") + " " + sms.endNext.ToString("X");
            VICECOMManager vcom    = VICECOMManager.getVICEComManager();

            vcom.addTextCommand(command, CommandStruct.eMode.DoCommandReturnResults, sms.displayDissCallback, sms, this.Dispatcher);
        }
コード例 #3
0
ファイル: AcmePDBRandD.cs プロジェクト: martinpiper/ACME
        public ShowSrcDissStruct show_diss_common()
        {
            try
            {
                int startPrev = m_registerSet.GetPC();
                int endNext   = m_registerSet.GetPC();
                if (MainWindow.mIsAPUMode)
                {
                    startPrev -= 16;
                    endNext   += 16;
                }
                else
                {
                    // MPi: TODO: Tweak the 10 range based on the display height?
                    int range = 15;
                    // Step backwards trying to find a good starting point to disassemble
                    while (range-- > 0)
                    {
                        AddrInfo addrInfo2 = m_PDBData.getAddrInfoForAddr(startPrev); //mAddrInfoByAddr[startPrev];
                        if (addrInfo2.mPrevAddr < 0)
                        {
                            break;
                        }
                        startPrev = addrInfo2.mPrevAddr;
                    }

                    // MPi: TODO: Tweak the 10 range based on the display height?
                    range = 20;
                    // Step forwards trying to find a good ending point to disassemble
                    while (range-- > 0)
                    {
                        AddrInfo addrInfo2 = m_PDBData.getAddrInfoForAddr(endNext); //mAddrInfoByAddr[endNext];
                        if (addrInfo2.mNextAddr < 0)
                        {
                            break;
                        }
                        endNext = addrInfo2.mNextAddr;
                    }
                }

                ShowSrcDissStruct sms = new ShowSrcDissStruct()
                {
                    endNext = endNext
                    ,
                    startPrev = startPrev
                };
                return(sms);
            }
            catch (Exception)
            {
            }
            return(null);
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: hugovangalen/ACME
        private void show_diss_get_post_dissasem(string reply, object userData)
        {
            string displayText = String.Empty;

            try
            {
                ShowSrcDissStruct sms   = userData as ShowSrcDissStruct;
                string[]          split = sms.disassemblyBefore.Split('\r');
                bool doingBefore        = true;
                int  index = 0;
                while (index < split.Length)
                {
                    string line = split[index++];
                    if (line.Length < 7)
                    {
                        continue;
                    }
                    string tAddr = line.Substring(3);
                    tAddr = tAddr.Substring(0, 4);
                    int theAddr = int.Parse(tAddr, NumberStyles.HexNumber);
                    if (doingBefore && theAddr >= m_registerSet.GetPC())
                    {
                        split       = reply.Split('\r');
                        index       = 0;
                        doingBefore = false;
                        continue;
                    }

                    Brush brush = null;
                    if (theAddr == m_registerSet.GetPC())
                    {
                        line  = ">>>> " + line;
                        brush = Brushes.LightBlue;
                    }
                    else
                    {
                        line = "     " + line;
                    }
                    line += "\r";

                    displayText += line;
                }
            }
            catch (System.Exception)
            {
            }

            SetSourceView(displayText);
        }
コード例 #5
0
ファイル: FunctionJSONRAndD.cs プロジェクト: martinpiper/ACME
        public ShowSrcDissStruct show_diss_common()
        {
            ShowSrcDissStruct sms;
            FunctionData      func = getFuncForPC();

            if (func != null)
            {
                sms = new ShowSrcDissStruct()
                {
                    endNext   = func.EndAddr,
                    startPrev = func.StartAddr
                };
            }
            else
            {
                sms = new ShowSrcDissStruct()
                {
                    endNext   = m_registerSet.GetPC() + 0x40,
                    startPrev = m_registerSet.GetPC()
                };
            }
            return(sms);
        }
コード例 #6
0
ファイル: AcmePDBRandD.cs プロジェクト: martinpiper/ACME
        public string ShowSrcDissGetPostDissaem(string reply, object userData)
        {
            ShowSrcDissStruct sms = userData as ShowSrcDissStruct;

            sms.disassemblyAfter = reply;
            string displayText = String.Empty;

            try
            {
                string lastSourceDisplayed      = "";
                int    lastSourceIndexDisplayed = -1;
                int    lastSourceLineDisplayed  = -1;

                int[] lastDisplayedLine = new int[m_PDBData.getNumFiles()]; //mSourceFileNamesLength
                int   i;
                for (i = 0; i < m_PDBData.getNumFiles(); i++)               //mSourceFileNamesLength
                {
                    lastDisplayedLine[i] = 0;
                }

                //							gotText += disassemblyBefore;
                //							gotText += ">>>\n";
                //							gotText += disassemblyAfter;
                // Get something like:

                /*
                 *  .C:0427  AD 00 04    LDA $0400
                 *  .C:042a  AD 27 04    LDA $0427
                 *  ...
                 *  .C:0439  60          RTS
                 *  .C:043a  AD 3A 04    LDA $043A
                 */
                string[] split          = sms.disassemblyBefore.Split('\r');
                bool     doingBefore    = true;
                int      index          = 0;
                String   lastSourceLine = "";
                while (index < split.Length)
                {
                    string line = split[index++];
                    if (line.Length < 7)
                    {
                        continue;
                    }
                    if (!line.StartsWith(".C:"))
                    {
                        continue;
                    }
                    string tAddr = line.Substring(3);
                    tAddr = tAddr.Substring(0, 4);
                    int theAddr = int.Parse(tAddr, NumberStyles.HexNumber);
                    if (doingBefore && theAddr >= m_registerSet.GetPC())
                    {
                        split       = sms.disassemblyAfter.Split('\r');
                        index       = 0;
                        doingBefore = false;
                        continue;
                    }

                    try
                    {
                        AddrInfo addrInfo = m_PDBData.getAddrInfoForAddr(theAddr);              //mAddrInfoByAddr[theAddr];
                        if (lastSourceDisplayed != m_PDBData.getSourceFileName(addrInfo.mFile)) //mSourceFileNames[addrInfo.mFile])
                        {
                            lastSourceDisplayed = m_PDBData.getSourceFileName(addrInfo.mFile);  // mSourceFileNames[addrInfo.mFile];
                            displayText        += "--- " + lastSourceDisplayed + " ---\r";
                        }
                        if ((addrInfo.mLine - lastDisplayedLine[addrInfo.mFile]) > 5)
                        {
                            lastDisplayedLine[addrInfo.mFile] = addrInfo.mLine - 5;
                            if (lastDisplayedLine[addrInfo.mFile] < 0)
                            {
                                lastDisplayedLine[addrInfo.mFile] = 0;
                            }
                        }
                        if (lastDisplayedLine[addrInfo.mFile] > addrInfo.mLine)
                        {
                            lastDisplayedLine[addrInfo.mFile] = addrInfo.mLine;
                        }
                        for (i = lastDisplayedLine[addrInfo.mFile]; i <= addrInfo.mLine; i++)
                        {
                            if (lastSourceLine.Length > 0)
                            {
                                //gotText += "     " + "                                  " + lastSourceLine + "\n";
                                displayText   += "     " + lastSourceLine + "\r";
                                lastSourceLine = "";
                            }

                            if ((lastSourceIndexDisplayed == addrInfo.mFile) && (lastSourceLineDisplayed == i))
                            {
                                // Stop displaying the same source and line multiple times in a row
                                continue;
                            }
                            lastSourceLine           = string.Format("{0,5:###}", i) + ": " + m_PDBData.getLineFromSourceFile(addrInfo.mFile, i); // mSourceFiles[addrInfo.mFile][i];
                            lastSourceIndexDisplayed = addrInfo.mFile;
                            lastSourceLineDisplayed  = i;
                        }
                        lastDisplayedLine[addrInfo.mFile] = addrInfo.mLine + 1;
                    }
                    catch (System.Exception)
                    {
                    }

                    if (theAddr == m_registerSet.GetPC())
                    {
                        displayText += ">>>> ";
                    }
                    else
                    {
                        displayText += "     ";
                    }
                    if (lastSourceLine.Length > 0)
                    {
                        line           = line.PadRight(34, ' ');
                        displayText   += line + lastSourceLine + "\r";
                        lastSourceLine = "";
                    }
                    else
                    {
                        displayText += line + "\r";
                    }
                }
            }
            catch (System.Exception)
            {
            }

            return(displayText);
        }
コード例 #7
0
ファイル: FunctionJSONRAndD.cs プロジェクト: martinpiper/ACME
        public string ShowSrcDissGetPostDissaem(string reply, object userData)
        {
            int          PC       = m_registerSet.GetPC();
            FunctionData currFunc = getFuncForPC();

            if (currFunc != null)
            {
                ShowSrcDissStruct sms = userData as ShowSrcDissStruct;
                sms.disassemblyAfter = reply;
                string display = String.Empty;
                Dictionary <int, List <string> > dissAddrToLines;
                int pad = 16;
                try
                {
                    string   allDissasembly = sms.disassemblyBefore + "\r" + sms.disassemblyAfter;
                    string[] dissLines      = allDissasembly.Split('\r');
                    dissAddrToLines = new Dictionary <int, List <string> >(dissLines.Length);
                    int index = 0;
                    while (index < dissLines.Length)
                    {
                        string line = dissLines[index++];
                        //valid .C:XXXX line?
                        if (line.Length < 7)
                        {
                            continue;
                        }
                        if (!line.StartsWith(".C:"))
                        {
                            continue;
                        }
                        //yes
                        string tAddr = line.Substring(3);
                        tAddr = tAddr.Substring(0, 4);
                        int theAddr = int.Parse(tAddr, NumberStyles.HexNumber);
                        if (dissAddrToLines.ContainsKey(theAddr))
                        {
                            dissAddrToLines[theAddr].Add(line);
                        }
                        else
                        {
                            List <string> temp = new List <string>(4);
                            temp.Add(line);
                            dissAddrToLines[theAddr] = temp;
                        }
                        if (line.Length > pad)
                        {
                            pad = line.Length + 4;
                        }
                    }
                    //so now I have a dictionary of address to dissasembly lines
                    foreach (KeyValuePair <int, List <string> > item in currFunc.AddrsToCodeList)
                    {
                        if (item.Key == PC)
                        {
                            int count            = item.Value.Count;
                            int dissasemblyCount = 0;
                            if (dissAddrToLines.ContainsKey(item.Key))
                            {
                                dissasemblyCount = dissAddrToLines[item.Key].Count;
                            }
                            for (int i = 0; i < count; ++i)
                            {
                                string line = String.Empty;
                                if (i == count - 1)
                                {
                                    line += "=>";
                                }
                                else
                                {
                                    line += "  ";
                                }
                                if (i < dissasemblyCount)
                                {
                                    line += dissAddrToLines[item.Key][i];
                                }
                                line     = line.PadRight(pad, ' ');
                                line    += item.Value[i].Replace('\n', '\r');
                                display += line + "\r";
                            }
                        }
                        else
                        {
                            int dissasemblyCount = 0;
                            if (dissAddrToLines.ContainsKey(item.Key))
                            {
                                dissasemblyCount = dissAddrToLines[item.Key].Count;
                            }
                            int count = item.Value.Count;
                            for (int i = 0; i < count; ++i)
                            {
                                string line = "  ";
                                if (i < dissasemblyCount)
                                {
                                    line += dissAddrToLines[item.Key][i];
                                }
                                line     = line.PadRight(pad, ' ');
                                line    += item.Value[i].Replace('\n', '\r');
                                display += line + "\r";
                            }
                        }
                    }
                    return(display);
                }
                catch (Exception)
                {
                }
            }
            return("No source to show");
        }