示例#1
0
        private void ColorObject(uint objFrame, uint varFrame, TreeNode root)
        {
            uint i, addr, addrnext;

            root     = root.Nodes.Add(String.Format("Object {0:X}", objFrame));
            root.Tag = (int)objFrame;

            root.Nodes.Add(String.Format("Variable Space {0:X4}", varFrame)).Tag = (int)varFrame;
            Colorize[varFrame] = Brushes.LightBlue;

            ushort size    = Chip.DirectReadWord(objFrame);
            byte   longs   = Chip.DirectReadByte(objFrame + 2);
            byte   objects = Chip.DirectReadByte(objFrame + 3);

            for (i = 0; i < longs * 4; i++)
            {
                Colorize[i + objFrame] = Brushes.LightPink;
            }
            for (; i < (longs + objects) * 4; i++)
            {
                Colorize[i + objFrame] = Brushes.LavenderBlush;
            }
            for (; i < size; i++)
            {
                Colorize[i + objFrame] = Brushes.LightGreen;
            }

            addrnext = Chip.DirectReadWord(1 * 4 + objFrame) + objFrame;
            for (i = 1; i < longs; i++)
            {
                addr     = addrnext;
                addrnext = Chip.DirectReadWord((i + 1) * 4 + objFrame) + objFrame;
                if (i == longs - 1)
                {
                    addrnext = addr + 1;
                    while (Colorize[addrnext] == Brushes.LightGreen)
                    {
                        addrnext++;
                    }
                }
                ColorFunction(addr, addrnext, root);
            }

            for (i = 0; i < objects; i++)
            {
                ColorObject(Chip.DirectReadWord((longs + i) * 4 + objFrame) + objFrame,
                            Chip.DirectReadWord((longs + i) * 4 + 2 + objFrame) + varFrame, root);
            }
        }
示例#2
0
        private void ColorObject(uint objFrame, uint varFrame, TreeNode parent)
        {
            uint i, addr, addrnext;

            var objectNode = parent.Nodes.Add(String.Format("Object {0:X}", objFrame));

            objectNode.Nodes.Add(String.Format("Variable Space {0:X4}", varFrame)).Tag =
                Tuple.Create((int)varFrame, (int)varFrame);
            colorMap[varFrame] = 4;

            ushort size        = Chip.DirectReadWord(objFrame);
            uint   clippedSize = Math.Min(size, (uint)PropellerCPU.TOTAL_MEMORY - objFrame);

            objectNode.Tag = Tuple.Create((int)objFrame, (int)(objFrame + clippedSize));
            byte longs   = Chip.DirectReadByte(objFrame + 2);
            byte objects = Chip.DirectReadByte(objFrame + 3);

            for (i = 0; i < longs * 4 && i < clippedSize; i++)
            {
                colorMap[i + objFrame] = 5;
            }
            for (; i < (longs + objects) * 4 && i < clippedSize; i++)
            {
                colorMap[i + objFrame] = 6;
            }
            for (; i + 4 < clippedSize; i++)
            {
                colorMap[i + objFrame] = 7;
            }

            addr = Chip.DirectReadWord(objFrame + 4) + objFrame;
            for (i = 1; i < longs - 1; i++)
            {
                addrnext = Chip.DirectReadWord(objFrame + 4 + i * 4) + objFrame;
                ColorFunction(addr, addrnext, objectNode);
                addr = addrnext;
            }
            if (longs > 0)
            {
                ColorFunction(addr, objFrame + clippedSize, objectNode);
            }

            for (i = 0; i < objects; i++)
            {
                ColorObject(Chip.DirectReadWord((longs + i) * 4 + objFrame) + objFrame,
                            Chip.DirectReadWord((longs + i) * 4 + 2 + objFrame) + varFrame, objectNode);
            }
        }
示例#3
0
        private void ColorCode()
        {
            int i;

            objectView.Nodes.Clear();
            TreeNode root = objectView.Nodes.Add("Spin");
            TreeNode node;

            node     = root.Nodes.Add(String.Format("System Frequency: {0}mhz", Chip.DirectReadLong(0)));
            node.Tag = (int)0;
            node     = root.Nodes.Add(String.Format("Clock Mode: {0:X2}", Chip.DirectReadByte(4)));
            node.Tag = (int)4;
            node     = root.Nodes.Add(String.Format("Check Sum: {0:X2}", Chip.DirectReadByte(5)));
            node.Tag = (int)5;
            node     = root.Nodes.Add(String.Format("Root Object: {0:X4}", Chip.DirectReadWord(6)));
            node.Tag = (int)6;
            node     = root.Nodes.Add(String.Format("Variable Base: {0:X4}", Chip.DirectReadWord(8)));
            node.Tag = (int)8;
            node     = root.Nodes.Add(String.Format("Local Frame: {0:X4}", Chip.DirectReadWord(10)));
            node.Tag = (int)10;
            node     = root.Nodes.Add(String.Format("Entry PC: {0:X4}", Chip.DirectReadWord(12)));
            node.Tag = (int)12;
            node     = root.Nodes.Add(String.Format("Starting Stack: {0:X4}", Chip.DirectReadWord(14)));
            node.Tag = (int)14;

            for (i = 0; i < 16; i++)
            {
                Colorize[i] = Brushes.White;
            }

            for (i = Chip.DirectReadWord(0x8); i < Chip.DirectReadWord(0xA); i++)
            {
                Colorize[i] = Brushes.LightYellow;
            }

            for (; i < 0x8000; i++)
            {
                Colorize[i] = Brushes.LightGray;
            }

            ColorObject(Chip.DirectReadWord(0x6), Chip.DirectReadWord(0x8), root);
        }
示例#4
0
        private void ColorCode()
        {
            int i;

            objectView.Nodes.Clear();
            TreeNode root = objectView.Nodes.Add("Spin");
            TreeNode node;

            node     = root.Nodes.Add(String.Format("System Frequency: {0}mhz", Chip.DirectReadLong(0)));
            node.Tag = Tuple.Create(0, 4);
            node     = root.Nodes.Add(String.Format("Clock Mode: {0:X2}", Chip.DirectReadByte(4)));
            node.Tag = Tuple.Create(4, 5);
            node     = root.Nodes.Add(String.Format("Check Sum: {0:X2}", Chip.DirectReadByte(5)));
            node.Tag = Tuple.Create(5, 6);
            node     = root.Nodes.Add(String.Format("Root Object: {0:X4}", Chip.DirectReadWord(6)));
            node.Tag = Tuple.Create(6, 8);
            node     = root.Nodes.Add(String.Format("Variable Base: {0:X4}", Chip.DirectReadWord(8)));
            node.Tag = Tuple.Create(8, 10);
            node     = root.Nodes.Add(String.Format("Local Frame: {0:X4}", Chip.DirectReadWord(10)));
            node.Tag = Tuple.Create(10, 12);
            node     = root.Nodes.Add(String.Format("Entry PC: {0:X4}", Chip.DirectReadWord(12)));
            node.Tag = Tuple.Create(12, 14);
            node     = root.Nodes.Add(String.Format("Starting Stack: {0:X4}", Chip.DirectReadWord(14)));
            node.Tag = Tuple.Create(14, 16);

            for (i = 0; i < 16; i++)
            {
                colorMap[i] = 1;
            }

            for (i = Chip.DirectReadWord(0x8); i < Chip.DirectReadWord(0xA); i++)
            {
                colorMap[i] = 2;
            }

            for (; i < 0x8000; i++)
            {
                colorMap[i] = 3;
            }

            ColorObject(Chip.DirectReadWord(0x6), Chip.DirectReadWord(0x8), root);
        }
示例#5
0
        private void Repaint(bool tick, InterpretedCog host)
        {
            Graphics g = Graphics.FromImage((Image)BackBuffer);
            Brush    brush;

            g.Clear(SystemColors.Control);

            String display;
            uint   topLine, bottomLine;

            topLine    = 5;
            bottomLine = (uint)((ClientRectangle.Height / MonoFont.Height) - 5);

            zeroFlagLabel.Text   = "";
            carryFlagLabel.Text  = "";
            OpcodeSize.Visible   = true;
            DisplayUnits.Visible = true;

            if (memoryViewButton.Checked)
            {
                for (uint i = (uint)positionScroll.Value, y = 0;
                     y < ClientRectangle.Height;
                     y += (uint)MonoFont.Height, i++)
                {
                    if ((i > 0xFFFF) || (i < 0))
                    {
                        continue;
                    }

                    uint mem = host[(int)i];

                    string binary = Convert.ToString((long)mem, 2);

                    while (binary.Length < 32)
                    {
                        binary = "0" + binary;
                    }

                    display = String.Format("{0:X4}:  {1:X8}   {2}   ",
                                            i, mem, binary);
                    if (displayAsHexadecimal)
                    {
                        display = display + String.Format("{0:X8}", mem);
                    }
                    else
                    {
                        display = display + String.Format("{0}", mem);
                    }

                    g.FillRectangle(SystemBrushes.Control, 0, y, assemblyPanel.Width, y + MonoFont.Height);

                    g.DrawString(
                        display,
                        (host.ProgramCursor == i) ? MonoFontBold : MonoFont,
                        SystemBrushes.ControlText, 0, y);
                }
            }
            else
            {
                uint y = 0;

                for (uint i = (uint)positionScroll.Value, line = 1; y < ClientRectangle.Height; y += (uint)MonoFont.Height, line++)
                {
                    if (i > 0xFFFF)
                    {
                        continue;
                    }

                    uint start = i;

                    Propeller.MemoryManager mem = new Propeller.MemoryManager(Chip, i);
                    string inst = InstructionDisassembler.InterpreterText(mem, displayAsHexadecimal, useShortOpcodes);
                    i                   = mem.Address;
                    display             = String.Format("{0:X4}: ", start);
                    InterpAddress[line] = start;

                    for (uint q = start; q < start + 4; q++)
                    {
                        if (q < i)
                        {
                            byte b = Chip.DirectReadByte(q);
                            display += String.Format(" {0:X2}", b);
                        }
                        else
                        {
                            display += "   ";
                        }
                    }


                    display += "  " + inst;

                    if (InterpAddress[line] == host.BreakPoint)
                    {
                        brush = System.Drawing.Brushes.Pink;
                    }
                    else if ((!followPCButton.Checked) || (line <= topLine) || (line >= bottomLine))
                    {
                        brush = SystemBrushes.Control;
                    }
                    else
                    {
                        brush = SystemBrushes.Window;
                    }
                    g.FillRectangle(brush, 0, y, assemblyPanel.Width, y + MonoFont.Height);

                    g.DrawString(
                        display,
                        (host.ProgramCursor == start) ? MonoFontBold : MonoFont,
                        SystemBrushes.ControlText, 0, y);
                }

                StringBrush = SystemBrushes.ControlText;
                StringY     = 0;
                StringX     = (uint)(assemblyPanel.Width - StackMargin);

                DrawString(g, String.Format("@Stk[0] = ${0:X4} {0}", host.Stack));
                DrawString(g, String.Format("@Obj[0] = ${0:X4} {0}", host.Object));
                DrawString(g, String.Format("@Loc[0] = ${0:X4} {0}", host.Local));
                DrawString(g, String.Format("@Var[0] = ${0:X4} {0}", host.Variable));
                g.DrawLine(Pens.Black, assemblyPanel.Width - StackMargin, StringY, assemblyPanel.Width, StringY);
                DrawString(g, String.Format("Caller& = ${0:X4} {0}", Chip.DirectReadWord(host.Local - 8)));
                DrawString(g, String.Format("          ${0:X4} {0}", Chip.DirectReadWord(host.Local - 6)));
                DrawString(g, String.Format("          ${0:X4} {0}", Chip.DirectReadWord(host.Local - 4)));
                DrawString(g, String.Format("Return& = ${0:X4}", Chip.DirectReadWord(host.Local - 2)));
                g.DrawLine(Pens.Black, assemblyPanel.Width - StackMargin, StringY, assemblyPanel.Width, StringY);

                for (uint i = host.Local; i < host.Stack && StringY < ClientRectangle.Height; i += 4)
                {
                    DrawString(g, String.Format("${0:X8}  {0}", (int)Chip.DirectReadLong(i)));
                }
            }
        }