Exemplo n.º 1
0
        private void MainBoxDoubleClick(object sender, EventArgs e)
        {
            int index = mainBox.SelectedIndex;

            if (index == -1)
            {
                return;
            }

            string assembly = mainBox.Items[index].ToString();

            assembly = assembly.Substring(20, assembly.Length - 20);
            string[] sep = assembly.Split(new char[1] {
                '\t'
            }, StringSplitOptions.RemoveEmptyEntries);

            sep[0] = sep[0].ToLower();
            if (sep[0].StartsWith("b") && sep.Length > 1)
            {
                sep[1] = sep[1].Substring(sep[1].IndexOf("0x"));

                uint bAddress;
                if (GlobalFunctions.tryToHex(sep[1], out bAddress) && ValidMemory.validAddress(bAddress))
                {
                    DissToBox(bAddress);
                }
            }
        }
Exemplo n.º 2
0
        private bool ValidUserAddress(out uint address)
        {
            if (!GlobalFunctions.tryToHex(textBoxAddress.Text, out address) ||
                !ValidMemory.validAddress(address))
            {
                MessageBox.Show("Invalid address");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }

            if (radioButton16Bit.Checked && ((address & 1) != 0))
            {
                MessageBox.Show("address must be multiple of 2");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }
            else if (radioButton32Bit.Checked && ((address & 3) != 0))
            {
                MessageBox.Show("address must be multiple of 4");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        private bool ValidUserAddress(out UInt32 address)
        {
            // Is it a valid 32-bit hexadecimal address?
            if (!GlobalFunctions.tryToHex(textBoxAddress.Text, out address) ||
                !ValidMemory.validAddress(address))
            {
                MessageBox.Show("Invalid address");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }

            // Check alignment
            if (radioButton16Bit.Checked && ((address & 1) != 0))
            {
                MessageBox.Show("address must be multiple of 2");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }
            else if (radioButton32Bit.Checked && ((address & 3) != 0))
            {
                MessageBox.Show("address must be multiple of 4");
                textBoxAddress.Focus();
                textBoxAddress.SelectAll();
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        private void ChangeBy(int offset)
        {
            uint oAddress = cAddress;

            cAddress = (uint)((long)cAddress + offset);
            if (!ValidMemory.validAddress(cAddress))
            {
                cAddress = oAddress;
                return;
            }
            DissToBox();

            mainBox.Update();
        }
Exemplo n.º 5
0
        private void ChangeBy(int offset)
        {
            UInt32 oAddress = cAddress;

            cAddress = (UInt32)((long)cAddress + offset);
            if (!ValidMemory.validAddress(cAddress))
            {
                cAddress = oAddress;
                return;
            }
            DissToBox();

            // Force control to re-paint with the new disassembly
            mainBox.Update();
        }
Exemplo n.º 6
0
        public void SetSRR0(UInt32 address)
        {
            if (gecko.status() != WiiStatus.Breakpoint)
            {
                return;
            }
            if (ValidMemory.rangeCheck(address) != AddressType.UncachedMem1)
            {
                return;
            }


            changableRegs[BPList.regTextToID("SRR0")] = address;
            SendRegisters();
        }
Exemplo n.º 7
0
        public void SetSRR0(uint address)
        {
            if (contextAddress == 0)
            {
                return;
            }
            if (ValidMemory.rangeCheck(address) != AddressType.Ex)
            {
                return;
            }


            changableRegs[BPList.regTextToID("SRR0")] = address;
            SendRegisters();
        }
Exemplo n.º 8
0
        private void MainBoxDoubleClick(object sender, EventArgs e)
        {
            int index = mainBox.SelectedIndex;

            // If index is negative, bail out
            if (index == -1)
            {
                return;
            }

            // Grab the instruction that they selected
            String assembly = mainBox.Items[index].ToString();

            assembly = assembly.Substring(20, assembly.Length - 20);
            String[] sep = assembly.Split(new char[1] {
                '\t'
            }, StringSplitOptions.RemoveEmptyEntries);

            // Is it some sort of branch?  Does it have an address parameter?
            sep[0] = sep[0].ToLower();
            if (sep[0].StartsWith("b") && sep.Length > 1)
            {
                // Most of the time, this won't matter
                // However, some branches specify the cr (e.g. bge- cr6,0x802e583c)
                // So parse out anything before the 0x
                sep[1] = sep[1].Substring(sep[1].IndexOf("0x"));

                // Does it have a valid address after it?
                UInt32 bAddress;
                if (GlobalFunctions.tryToHex(sep[1], out bAddress) && ValidMemory.validAddress(bAddress))
                {
                    // tell the disassembly window to jump there
                    DissToBox(bAddress);
                }
            }
        }
Exemplo n.º 9
0
        public void Update(bool fast)
        {
            MemoryStream miniDump = new MemoryStream();
            int          oldColumnIndex, oldRowIndex;

            if (gView.SelectedCells.Count > 0)
            {
                oldColumnIndex = gView.SelectedCells[0].ColumnIndex;
                oldRowIndex    = gView.SelectedCells[0].RowIndex;
            }
            else
            {
                oldColumnIndex = 1;
                oldRowIndex    = 1;
            }

            UInt32 sAddress = cAddress & 0xFFFFFFF0;
            UInt32 offset   = cAddress - sAddress;

            try
            {
                gecko.Dump(sAddress, sAddress + 0x100, miniDump);

                //gView.Rows.Add(16);
                // Only clear and re-load gView.Rows when it's != 16
                // This was one thing slowing us down...
                if (gView.Rows.Count != 16)
                {
                    gView.Rows.Clear();
                    gView.Rows.Add(16);
                }

                miniDump.Seek(0, SeekOrigin.Begin);
                UInt32 value, bValue;
                Byte[] buffer = new Byte[4];
                UInt16 hwInput;
                UInt32 pValue = 0;
                for (int i = 0; i < 16; i++)
                {
                    gView.Rows[i].Cells[0].Value = GlobalFunctions.toHex(sAddress + i * 16);
                    for (int j = 1; j < 5; j++)
                    {
                        miniDump.Read(buffer, 0, 4);
                        bValue = BitConverter.ToUInt32(buffer, 0);
                        value  = ByteSwap.Swap(bValue);
                        if (sAddress + i * 0x10 + (j - 1) * 4 == selAddress)
                        {
                            pValue = value;
                        }
                        DataGridViewCell cell = gView.Rows[i].Cells[j];
                        if (PViewMode == MemoryViewMode.Hex)
                        {
                            cell.Value = GlobalFunctions.toHex(value);
                        }
                        else if (PViewMode == MemoryViewMode.ASCII)
                        {
                            cell.Value = DecodeASCII(buffer);
                        }
                        else if (PViewMode == MemoryViewMode.ANSI)
                        {
                            cell.Value = DecodeANSI(buffer);
                        }
                        else if (PViewMode == MemoryViewMode.Unicode)
                        {
                            cell.Value = DecodeUnicode(buffer);
                        }
                        else if (PViewMode == MemoryViewMode.Single)
                        {
                            cell.Value = PrettyFloat(GlobalFunctions.UIntToSingle(value));
                        }
                        else if (PViewMode == MemoryViewMode.AutoZero || PViewMode == MemoryViewMode.AutoDot)
                        {
                            // if it might be a pointer, cast it as hex
                            if (ValidMemory.validAddress(value))
                            {
                                cell.Value = GlobalFunctions.toHex(value);
                            }
                            else
                            {
                                // If it's a float, and it's not too big or small, cast it as a Single
                                Single singleCast = GlobalFunctions.UIntToSingle(value);
                                if (!Single.IsNaN(singleCast) && Math.Abs(singleCast) > 1e-7 && Math.Abs(singleCast) < 1e10)
                                {
                                    cell.Value = PrettyFloat(GlobalFunctions.UIntToSingle(value));
                                }
                                else
                                {
                                    if (IsASCII(buffer))
                                    {
                                        if (PViewMode == MemoryViewMode.AutoZero && value == 0)
                                        {
                                            // Cast 0 as hex in auto zero mode
                                            cell.Value = GlobalFunctions.toHex(value);
                                        }
                                        else
                                        {
                                            // If all characters are valid printable ASCII, cast it as char
                                            cell.Value = DecodeASCII(buffer);
                                        }
                                    }
                                    else
                                    {
                                        // When all else fails, cast as hex
                                        cell.Value = GlobalFunctions.toHex(value);
                                    }
                                }
                            }
                        }
                    }
                }
                oldRow = (int)offset / 0x10;
                oldCol = (int)(offset & 0xC) / 4 + 1;
                if (!fast)
                {
                    gView.Rows[oldRowIndex].Cells[oldColumnIndex].Selected = true;
                    // Don't update the poke value during auto-updates
                    // This way the user can still poke things

                    // TODO: Ignore this if the poke operation isn't write?
                    //pokeValue.Text = GlobalFunctions.toHex(pValue);
                }

                pokeAddress.Text = GlobalFunctions.toHex(selAddress);
                fpValue.Text     = GlobalFunctions.UIntToSingle(pValue).ToString("G6");
            }
            catch (ETCPGeckoException e)
            {
                exceptionHandling.HandleException(e);
            }
        }
Exemplo n.º 10
0
        public void Update(bool fast)
        {
            MemoryStream miniDump = new MemoryStream();
            int          oldColumnIndex, oldRowIndex;

            if (gView.SelectedCells.Count > 0)
            {
                oldColumnIndex = gView.SelectedCells[0].ColumnIndex;
                oldRowIndex    = gView.SelectedCells[0].RowIndex;
            }
            else
            {
                oldColumnIndex = 1;
                oldRowIndex    = 1;
            }

            uint sAddress = cAddress & 0xFFFFFFF0;
            uint offset   = cAddress - sAddress;

            try
            {
                gecko.Dump(sAddress, sAddress + 0x100, miniDump);

                if (gView.Rows.Count != 16)
                {
                    gView.Rows.Clear();
                    gView.Rows.Add(16);
                }

                miniDump.Seek(0, SeekOrigin.Begin);
                uint   value, bValue;
                byte[] buffer = new byte[4];
                uint   pValue = 0;
                for (int i = 0; i < 16; i++)
                {
                    gView.Rows[i].Cells[0].Value = GlobalFunctions.toHex(sAddress + i * 16);
                    for (int j = 1; j < 5; j++)
                    {
                        miniDump.Read(buffer, 0, 4);
                        bValue = BitConverter.ToUInt32(buffer, 0);
                        value  = ByteSwap.Swap(bValue);
                        if (sAddress + i * 0x10 + (j - 1) * 4 == selectedAddress)
                        {
                            pValue = value;
                        }
                        DataGridViewCell cell = gView.Rows[i].Cells[j];
                        if (viewMode == MemoryViewMode.Hex)
                        {
                            cell.Value = GlobalFunctions.toHex(value);
                        }
                        else if (viewMode == MemoryViewMode.ASCII)
                        {
                            cell.Value = DecodeASCII(buffer);
                        }
                        else if (viewMode == MemoryViewMode.ANSI)
                        {
                            cell.Value = DecodeANSI(buffer);
                        }
                        else if (viewMode == MemoryViewMode.Unicode)
                        {
                            cell.Value = DecodeUnicode(buffer);
                        }
                        else if (viewMode == MemoryViewMode.Single)
                        {
                            cell.Value = PrettyFloat(GlobalFunctions.UIntToSingle(value));
                        }
                        else if (viewMode == MemoryViewMode.AutoZero || viewMode == MemoryViewMode.AutoDot)
                        {
                            if (ValidMemory.validAddress(value))
                            {
                                cell.Value = GlobalFunctions.toHex(value);
                            }
                            else
                            {
                                float singleCast = GlobalFunctions.UIntToSingle(value);
                                if (!float.IsNaN(singleCast) && Math.Abs(singleCast) > 1e-7 && Math.Abs(singleCast) < 1e10)
                                {
                                    cell.Value = PrettyFloat(GlobalFunctions.UIntToSingle(value));
                                }
                                else
                                {
                                    if (IsASCII(buffer))
                                    {
                                        if (viewMode == MemoryViewMode.AutoZero && value == 0)
                                        {
                                            cell.Value = GlobalFunctions.toHex(value);
                                        }
                                        else
                                        {
                                            cell.Value = DecodeASCII(buffer);
                                        }
                                    }
                                    else
                                    {
                                        cell.Value = GlobalFunctions.toHex(value);
                                    }
                                }
                            }
                        }
                    }
                }
                oldRow = (int)offset / 0x10;
                oldCol = (int)(offset & 0xC) / 4 + 1;
                if (!fast)
                {
                    gView.Rows[oldRowIndex].Cells[oldColumnIndex].Selected = true;
                }

                pokeAddress.Text = GlobalFunctions.toHex(selectedAddress);
                fpValue.Text     = GlobalFunctions.UIntToSingle(pValue).ToString("G6");
            }
            catch (ETCPGeckoException e)
            {
                exceptionHandling.HandleException(e);
            }
        }
Exemplo n.º 11
0
        private void UpdateList()
        {
            try
            {
                int            i, j;
                UInt32[]       address;
                UInt32         peekAddress, actAddress, peekValue;
                WatchDataSize  dataSize;
                UInt32         dumpAnd;
                String         aOutput, vOutput;
                UInt32         add;
                bool           pointer, vPointer, vAddress;
                int            maxCount = Math.Min(addressWatchList.Count, watchOut.RowCount);
                DoubleString[] oUp      =
                    new DoubleString[maxCount];
                for (i = 0; i < maxCount; i++)
                {
                    // Skip over any rows that aren't displayed
                    if (!isRowDisplayed(watchOut, i))
                    {
                        continue;
                    }
                    address  = addressWatchList[i].address;
                    pointer  = address.Length > 1;
                    dataSize = addressWatchList[i].dataSize;
                    switch (dataSize)
                    {
                    case WatchDataSize.Bit8:
                        dumpAnd = 0xFFFFFFFF;
                        break;

                    case WatchDataSize.Bit16:
                        dumpAnd = 0xFFFFFFFE;
                        break;

                    default:
                        dumpAnd = 0xFFFFFFFC;
                        break;
                    }
                    vPointer    = true;
                    peekAddress = address[0];

                    for (j = 1; j < address.Length; j++)
                    {
                        if (ValidMemory.validAddress(peekAddress, enableDebug))
                        {
                            peekAddress &= 0xFFFFFFFC;
                            peekAddress  = gecko.peek(peekAddress);
                            peekAddress += address[j];
                        }
                        else
                        {
                            vPointer = false;
                            break;
                        }
                    }

                    vAddress = vPointer && ValidMemory.validAddress(peekAddress, enableDebug);
                    if (pointer)
                    {
                        aOutput = "P->";
                        if (vPointer)
                        {
                            aOutput += GlobalFunctions.toHex(peekAddress);
                        }
                        else
                        {
                            aOutput += "????????";
                        }
                    }
                    else
                    {
                        aOutput = GlobalFunctions.toHex(peekAddress);
                    }

                    if (vAddress)
                    {
                        actAddress   = peekAddress;
                        peekAddress &= 0xFFFFFFFC;
                        add          = actAddress - peekAddress;
                        add         &= dumpAnd;
                        peekValue    = gecko.peek(peekAddress);
                        vOutput      = ParseValue(peekValue, dataSize, add, addressWatchList[i]);

                        addressWatchList[i].addressAvail   = true;
                        addressWatchList[i].updatedAddress = peekAddress + add;
                    }
                    else
                    {
                        vOutput = "????????";
                        addressWatchList[i].addressAvail = false;
                    }
                    oUp[i].address = aOutput;
                    oUp[i].value   = vOutput;
                    watchOut.Invoke((MethodInvoker) delegate
                    {
                        watchOut.Rows[i].Cells[1].Value = oUp[i].address;
                        watchOut.Rows[i].Cells[3].Value = oUp[i].value;
                    });
                }

                //watchOut.Invoke((MethodInvoker)delegate
                // {
                //     for (i = 0; i < maxCount; i++)
                //     {
                //         watchOut.Rows[i].Cells[1].Value = oUp[i].address;
                //         watchOut.Rows[i].Cells[3].Value = oUp[i].value;
                //     }
                // });
            }
            catch (EUSBGeckoException e)
            {
                listEnabled = false;
                exceptionHandling.HandleException(e);
            }
            catch
            {
            }
        }
Exemplo n.º 12
0
        private void GetRegisters(Stream regStream)
        {
            regStream.Seek(0, SeekOrigin.Begin);
            String regValue;
            UInt32 rStream;

            UInt32[] allReg = new UInt32[72];
            for (int i = 0; i < 72; i++)
            {
                rStream = GlobalFunctions.ReadStream(regStream);

                if (i < 40)
                {
                    changableRegs[i] = rStream;
                }
                allReg[i] = rStream;

                if (i < 40 || ShowFloatsInHex)
                {
                    regValue = GlobalFunctions.toHex(rStream);
                }
                else
                {
                    regValue = GlobalFunctions.UIntToSingle(rStream).ToString("G8");
                }
                bpOutput.longRegTextBox[i].Text = regValue; // TODO: invoke required?
            }
            listSet = true;
            regStream.Close();

            String output = "";

            for (int i = 0; i < 72; i++)
            {
                output += BPList.longRegNames[bpOutput.longRegIDs[i]] + ":" +
                          GlobalFunctions.toHex(allReg[bpOutput.longRegIDs[i]]);
                if (i % 4 == 3 && i != 71)
                {
                    output += "\r\n";
                }
                else if (i % 4 != 3)
                {
                    output += " ";
                }

                if (i == 39)
                {
                    output += "\r\n";
                }
            }

            InvokeClassicTextBoxUpdate(output);

            // Make sure that (SRR0?) contains a valid address
            // Otherwise we might not be pointing at any valid memory to pass to disassemble
            if (ValidMemory.validAddress(changableRegs[5]))
            {
                UInt32 assAdd = changableRegs[5];
                PHitAddress = assAdd;   // cache this for later

                // Fill an array of strings with instructions
                // TODO: subtract back some so we can see what comes BEFORE the assembly address...
                String[] assembly = disassembler.DissToBox(assAdd);

                // Grab the first (i.e. current) instruction
                if (assembly.Length > 0)
                {
                    String fCommand = assembly[0];
                    currentInstructionAndAddress = fCommand;
                    fCommand = fCommand.Substring(20, fCommand.Length - 20);

                    // Split it along tabs so we can extract the operation
                    String[] sep = fCommand.Split(new char[1] {
                        '\t'
                    }, StringSplitOptions.RemoveEmptyEntries);
                    currentInstruction = sep;
                    fCommand           = sep[0].ToLower();

                    // If we're doing a branch-and-link, make a note that we can step over it
                    stepOverPossible = (fCommand == "bl" || fCommand == "bctrl");

                    GetMemoryAddress(sep);

                    UpdateBranchState(sep);
                }

                InvokeDissBoxUpdate(assembly);
            }
        }
Exemplo n.º 13
0
        public String GetStepLog()
        {
            String          DetailedInstruction = currentInstructionAndAddress;
            String          regDetails;
            MatchCollection getRegDetails;

            if (currentInstructionAndAddress == null)
            {
                return(String.Empty);
            }

            String[] Padding = DetailedInstruction.Split('\t');

            // this will help align things
            if (Padding.Length < 3)
            {
                DetailedInstruction += "        ";
            }
            else if (Padding[2].Length < 8)
            {
                for (int i = 8 - Padding[2].Length; i > 0; i--)
                {
                    DetailedInstruction += " ";
                }
            }

            // Get all the places where there's an LR
            getRegDetails = Regex.Matches(DetailedInstruction, "lr");

            for (int i = 0; i < getRegDetails.Count; i++)
            {
                regDetails = "LR = " + GlobalFunctions.toHex(GetRegisterValue(39));
                //DetailedInstruction = DetailedInstruction.Insert(getRegDetails[i].Index + getRegDetails[i].Length, regDetails);
                DetailedInstruction += "\t" + regDetails;
            }

            // Get all the places where there's an f0-f31
            // TODO: not 0-9 or a-f!
            // TODO: over matching?  switch to trying to find the 0x to determine when not a float reg?
            //getRegDetails = Regex.Matches(DetailedInstruction, "([^0-9]f[0-9][^0-9])|" +
            //                                                  "([^0-9]f1[0-9][^0-9])|" +
            //                                                  "([^0-9]f2[0-9][^0-9])|" +
            //                                                  "([^0-9]f3[01][^0-9])");

            if (!Regex.Match(DetailedInstruction, "0x").Success)
            {
                getRegDetails = Regex.Matches(DetailedInstruction, "f[0-9]+");

                for (int i = 0; i < getRegDetails.Count; i++)
                {
                    string floatReg = getRegDetails[i].Value;
                    int    index    = Int32.Parse(floatReg.Substring(1)) + 40;
                    Single floatVal = GetFloatRegisterValue(index);
                    regDetails = floatReg + " = " + floatVal.ToString("G6");
                    //DetailedInstruction = DetailedInstruction.Insert(getRegDetails[i].Index + getRegDetails[i].Length, regDetails);
                    DetailedInstruction += "\t" + regDetails;
                }
            }

            // Get all the places where there's an r0-r31
            getRegDetails = Regex.Matches(DetailedInstruction, "r[0-9]+");

            for (int i = 0; i < getRegDetails.Count; i++)
            {
                regDetails = getRegDetails[i].Value + " = " + GlobalFunctions.toHex(GetRegisterValue(Int32.Parse(getRegDetails[i].Value.Substring(1)) + 7));
                //DetailedInstruction = DetailedInstruction.Insert(getRegDetails[i].Index + getRegDetails[i].Length, regDetails);
                DetailedInstruction += "\t" + regDetails;
            }

            getRegDetails = Regex.Matches(DetailedInstruction, "\\(r[0-9]+\\)");

            for (int i = 0; i < getRegDetails.Count; i++)
            {
                if (ValidMemory.validAddress(MemoryAddress))
                {
                    regDetails = "[" + GlobalFunctions.toHex(MemoryAddress) + "] = " + GlobalFunctions.toHex(gecko.peek(MemoryAddress));
                    //DetailedInstruction = DetailedInstruction.Insert(getRegDetails[i].Index + getRegDetails[i].Length, regDetails);
                    if (Regex.Match(DetailedInstruction, "lfd|stfd").Success)
                    {
                        regDetails += GlobalFunctions.toHex(gecko.peek(MemoryAddress + 4));
                    }
                    DetailedInstruction += "\t" + regDetails;
                }
            }

            //if (IsTakenBranch())
            if ((isConditionalBranch(currentInstruction) && BranchTaken(currentInstruction)) || currentInstruction[0] == "b")
            {
                DetailedInstruction += "\r\n";
                for (int i = 0; i < logIndent; i++)
                {
                    DetailedInstruction += "|  ";
                }
                DetailedInstruction += "\t...\t...\t...\t...";
            }

            if (logIndent > 0)
            {
                for (int i = 0; i < logIndent; i++)
                {
                    DetailedInstruction = DetailedInstruction.Insert(0, "|  ");
                }
            }

            if (IsBL())
            {
                logIndent++;
            }

            if (logIndent > 0 && IsBLR())
            {
                logIndent--;
            }

            return(DetailedInstruction);
        }
Exemplo n.º 14
0
        private void GetRegisters(Stream regStream)
        {
            regStream.Seek(0, SeekOrigin.Begin);
            string regValue;
            uint   rStream;

            uint[] allReg = new uint[72];
            for (int i = 0; i < 72; i++)
            {
                rStream = GlobalFunctions.ReadStream(regStream);

                if (i < 40)
                {
                    changableRegs[i] = rStream;
                }
                allReg[i] = rStream;

                if (i < 40 || ShowFloatsInHex)
                {
                    regValue = GlobalFunctions.toHex(rStream);
                }
                else
                {
                    regValue = GlobalFunctions.UIntToSingle(rStream).ToString("G8");
                }
                if (i > 40)
                {
                    GlobalFunctions.ReadStream(regStream);
                }
                bpOutput.longRegTextBox[i].Text = regValue;
            }
            listSet = true;
            regStream.Close();

            string output = string.Empty;

            for (int i = 0; i < 72; i++)
            {
                output += BPList.longRegNames[bpOutput.longRegIDs[i]] + ":" +
                          GlobalFunctions.toHex(allReg[bpOutput.longRegIDs[i]]);
                if (i % 4 == 3 && i != 71)
                {
                    output += "\r\n";
                }
                else if (i % 4 != 3)
                {
                    output += " ";
                }

                if (i == 39)
                {
                    output += "\r\n";
                }
            }

            InvokeClassicTextBoxUpdate(output);

            if (ValidMemory.validAddress(changableRegs[5]))
            {
                uint assAdd = changableRegs[5];
                hitAddress = assAdd;

                string[] assembly = disassembler.DissToBox(assAdd);

                if (assembly.Length > 0)
                {
                    string fCommand = assembly[0];
                    currentInstructionAndAddress = fCommand;
                    fCommand = fCommand.Substring(20, fCommand.Length - 20);

                    string[] sep = fCommand.Split(new char[1] {
                        '\t'
                    }, StringSplitOptions.RemoveEmptyEntries);
                    currentInstruction = sep;
                    fCommand           = sep[0].ToLower();

                    stepOver = (fCommand == "bl" || fCommand == "bctrl");

                    GetMemoryAddress(sep);

                    UpdateBranchState(sep);
                }

                InvokeDissBoxUpdate(assembly);
            }
        }
Exemplo n.º 15
0
        public string GetStepLog()
        {
            string          DetailedInstruction = currentInstructionAndAddress;
            string          regDetails;
            MatchCollection getRegDetails;

            if (currentInstructionAndAddress == null)
            {
                return(string.Empty);
            }

            string[] Padding = DetailedInstruction.Split('\t');

            if (Padding.Length < 3)
            {
                DetailedInstruction += "        ";
            }
            else if (Padding[2].Length < 8)
            {
                for (int i = 8 - Padding[2].Length; i > 0; i--)
                {
                    DetailedInstruction += " ";
                }
            }

            getRegDetails = Regex.Matches(DetailedInstruction, "lr");

            for (int i = 0; i < getRegDetails.Count; i++)
            {
                regDetails           = "LR = " + GlobalFunctions.toHex(GetRegisterValue(39));
                DetailedInstruction += "\t" + regDetails;
            }

            if (!Regex.Match(DetailedInstruction, "0x").Success)
            {
                getRegDetails = Regex.Matches(DetailedInstruction, "f[0-9]+");

                for (int i = 0; i < getRegDetails.Count; i++)
                {
                    string floatReg = getRegDetails[i].Value;
                    int    index    = int.Parse(floatReg.Substring(1)) + 40;
                    float  floatVal = GetFloatRegisterValue(index);
                    regDetails           = floatReg + " = " + floatVal.ToString("G6");
                    DetailedInstruction += "\t" + regDetails;
                }
            }

            getRegDetails = Regex.Matches(DetailedInstruction, "r[0-9]+");

            for (int i = 0; i < getRegDetails.Count; i++)
            {
                regDetails           = getRegDetails[i].Value + " = " + GlobalFunctions.toHex(GetRegisterValue(int.Parse(getRegDetails[i].Value.Substring(1)) + 7));
                DetailedInstruction += "\t" + regDetails;
            }

            getRegDetails = Regex.Matches(DetailedInstruction, "\\(r[0-9]+\\)");

            for (int i = 0; i < getRegDetails.Count; i++)
            {
                if (ValidMemory.validAddress(MemoryAddress))
                {
                    regDetails = "[" + GlobalFunctions.toHex(MemoryAddress) + "] = " + GlobalFunctions.toHex(gecko.peek(MemoryAddress));
                    if (Regex.Match(DetailedInstruction, "lfd|stfd").Success)
                    {
                        regDetails += GlobalFunctions.toHex(gecko.peek(MemoryAddress + 4));
                    }
                    DetailedInstruction += "\t" + regDetails;
                }
            }

            if ((isConditionalBranch(currentInstruction) && BranchTaken(currentInstruction)) || currentInstruction[0] == "b")
            {
                DetailedInstruction += "\r\n";
                for (int i = 0; i < logIndent; i++)
                {
                    DetailedInstruction += "|  ";
                }
                DetailedInstruction += "\t...\t...\t...\t...";
            }

            if (logIndent > 0)
            {
                for (int i = 0; i < logIndent; i++)
                {
                    DetailedInstruction = DetailedInstruction.Insert(0, "|  ");
                }
            }

            if (IsBL())
            {
                logIndent++;
            }

            if (logIndent > 0 && IsBLR())
            {
                logIndent--;
            }

            return(DetailedInstruction);
        }