public override bool ShowExecutionInfo(enumMessageLevel level)
        {
            //Stack
            MessageManager.ShowLine("*Stack\r\nUsage of stack:" + (SetupData.MemoryContents[0].WordCapacity * 4 - StackPointerMin) + " bytes", level);

            return(true);
        }
예제 #2
0
 public static bool TestLevel(enumMessageLevel level)
 {
     if ((MessageLevel & level) != level)
     {
         return(false);
     }
     return(true);
 }
예제 #3
0
 public static void ShowLine(string text, enumMessageLevel level = enumMessageLevel.ProgressLog)
 {
     if ((MessageLevel & level) != level)
     {
         return;
     }
     ShowText(text);
     NeedToAppendLine = true;
 }
예제 #4
0
        public static void Show(string text, enumMessageLevel level = enumMessageLevel.ProgressLog)
        {
            if ((MessageLevel & level) != level)
            {
                return;
            }

            if (text.EndsWith("\r\n"))
            {
                ShowLine(text.Substring(0, text.Length - 2));
            }
            else
            {
                ShowText(text);
            }
        }
예제 #5
0
        public static void SetLevel(string mode)
        {
            enumMessageLevel level = enumMessageLevel.None;

            for (int i = 0; i < mode.Length; i++)
            {
                char c = mode[i];
                switch (c)
                {
                case 'e':
                    level |= enumMessageLevel.ExecutionLog;
                    break;

                case 'E':
                    level |= enumMessageLevel.ExecutionDetailLog;
                    break;

                case 'i':
                    level |= enumMessageLevel.InfomationLog;
                    break;

                case 'I':
                    level |= enumMessageLevel.InfomationDetailLog;
                    break;

                case 'p':
                    level |= enumMessageLevel.ProgressLog;
                    break;

                case 'P':
                    level |= enumMessageLevel.DetailProgressLog;
                    break;
                }
            }

            MessageLevel = level;
        }
        public void ShowAnalyzeResult(enumMessageLevel level)
        {
            {
                MessageManager.ShowLine("", level);
                MessageManager.ShowLine("Constants Mapping:", level);

                {
                    for (int i = 0; i < Readonlys.Count; i++)
                    {
                        var e       = Readonlys[i];
                        int tailIdx = i;
                        for (int cursor = i + 1; cursor < Readonlys.Count; cursor++)
                        {
                            var tail = Readonlys[cursor];
                            if (e.GroupedVariables.Count > 1 ||
                                tail.GroupedVariables.Count > 1 ||
                                e.GroupedVariables[0] != tail.GroupedVariables[0])
                            {
                                break;
                            }

                            tailIdx = cursor;
                        }

                        if (i == tailIdx)
                        {
                            MessageManager.ShowLine($"{ e.Index.ToString() }:\t{ e.Content.ToString() } (0x{ e.Content.GetValue().ToString("X8") })", level);
                            foreach (var v in e.GroupedVariables)
                            {
                                MessageManager.ShowLine($"   \t   *{ Assemble.AssemblyCode.GetBlockPathPrefix(v.DefinedBlock) + v.Name } (defined at { v.AssemblePosition.GenerateLocationText() })", level);
                            }
                        }
                        else
                        {
                            var tail = Readonlys[tailIdx];
                            MessageManager.Show($"{ e.Index.ToString() }-{tail.Index.ToString()}:\t{{ { e.Content.ToString() }", level);
                            for (int cursor = i + 1; cursor <= tailIdx; cursor++)
                            {
                                var cur = Readonlys[cursor];
                                MessageManager.Show($",{ cur.Content.ToString() }", level);
                            }
                            MessageManager.ShowLine(" }", level);
                            foreach (var v in e.GroupedVariables)
                            {
                                MessageManager.ShowLine($"   \t   *{ Assemble.AssemblyCode.GetBlockPathPrefix(v.DefinedBlock) + v.Name } (defined at { v.AssemblePosition.GenerateLocationText() })", level);
                            }
                        }

                        i = tailIdx;
                    }
                }

                {
                    MessageManager.ShowLine("", level);
                    MessageManager.ShowLine("Variables Mapping:", level);
                    for (int i = 0; i < Readwrites.Count; i++)
                    {
                        var e       = Readwrites[i];
                        int tailIdx = i;
                        for (int cursor = i + 1; cursor < Readwrites.Count; cursor++)
                        {
                            var tail = Readwrites[cursor];
                            if (e.GroupedVariables.Count > 1 ||
                                tail.GroupedVariables.Count > 1 ||
                                e.GroupedVariables[0] != tail.GroupedVariables[0])
                            {
                                break;
                            }

                            tailIdx = cursor;
                        }

                        if (i == tailIdx)
                        {
                            MessageManager.Show($"{ e.Index.ToString() }:\t", level);
                            if (e.NeedInitialization)
                            {
                                MessageManager.ShowLine($"{ e.InitialValue.ToString() } (0x{ e.InitialValue.GetValue().ToString("X8") })", level);
                            }
                            else
                            {
                                MessageManager.ShowLine("Any", level);
                            }
                            foreach (var v in e.GroupedVariables)
                            {
                                MessageManager.ShowLine($"   \t   *{ Assemble.AssemblyCode.GetBlockPathPrefix(v.DefinedBlock) + v.Name } (defined at { v.AssemblePosition.GenerateLocationText() })", level);
                            }
                        }
                        else
                        {
                            var tail = Readwrites[tailIdx];
                            MessageManager.Show($"{ e.Index.ToString() }-{tail.Index.ToString()}:\t{{ { e.InitialValue.ToString() }", level);
                            for (int cursor = i + 1; cursor <= tailIdx; cursor++)
                            {
                                var cur = Readwrites[cursor];
                                MessageManager.Show($",{ cur.InitialValue.ToString() }", level);
                            }
                            MessageManager.ShowLine(" }", level);
                            foreach (var v in e.GroupedVariables)
                            {
                                MessageManager.ShowLine($"   \t   *{ Assemble.AssemblyCode.GetBlockPathPrefix(v.DefinedBlock) + v.Name } (defined at { v.AssemblePosition.GenerateLocationText() })", level);
                            }
                        }

                        i = tailIdx;
                    }
                }
            }
            MessageManager.ShowLine("", level);
        }
예제 #7
0
        protected bool ShowMemoryDumpByMessage(ExecuteSetupData.MemoryContent setupMemoryContent, CommonModule.RAM memory, bool codeInstr, bool codeVar, bool stack, enumMessageLevel level)
        {
            if (!codeInstr && !codeVar && !stack)
            {
                return(false);
            }
            {
                var       mem = setupMemoryContent;
                const int contentTextWidth = 40;
                MessageManager.ShowLine($"ByteAddress     { "Raw".PadRight(contentTextWidth,' ') } Mean", level);
                if (codeInstr || codeVar)
                {
                    for (int memByteAddrHead = 0; memByteAddrHead < mem.CodeSize * 4; memByteAddrHead++)
                    {
                        int memByteAddrTail = memByteAddrHead;
                        for (int cursor = memByteAddrHead + 1; cursor < mem.CodeSize * 4; cursor++)
                        {
                            if (mem.GetDebugInfo(cursor / 4, 4, cursor % 4).Usage != MemoryContent.WordElement.enumUsage.FollowHead)
                            {
                                break;
                            }

                            memByteAddrTail = cursor;
                        }

                        //Statistics
                        string statisticsText = "";

                        //Content
                        string contentText = "";
                        var    usageType   = mem.GetDebugInfo(memByteAddrHead / 4, 4, memByteAddrHead % 4).Usage;
                        switch (usageType)
                        {
                        case MemoryContent.WordElement.enumUsage.Variable:
                        case MemoryContent.WordElement.enumUsage.VariableArray:
                        case MemoryContent.WordElement.enumUsage.FollowHead:
                            if (!codeVar)
                            {
                                memByteAddrHead = memByteAddrTail;
                                continue;
                            }

                            memByteAddrTail = memByteAddrHead + 3;     //Disabling group display
                            contentText     = $"0x{ memory[memByteAddrHead / 4].ToString("X8") } ({ (int)memory[memByteAddrHead / 4]})";

                            {
                                int   wordReadTimes, wordWriteTimes, execTimes;
                                int[] wordReadTimesPerType;
                                memory.GetWordAccessStatistics((uint)memByteAddrHead / 4, 4, memByteAddrHead % 4, out execTimes, out wordReadTimes, out wordWriteTimes, out wordReadTimesPerType);
                                statisticsText  = $"\r\n        #Access: RI={wordReadTimesPerType[(int)CommonModule.EnumMemorymAccessType.Instruction]}, RD={wordReadTimesPerType[(int)CommonModule.EnumMemorymAccessType.Data]}; W={wordWriteTimes}";
                                statisticsText += "\r\n";
                            }
                            break;

                        case MemoryContent.WordElement.enumUsage.Unknown:
                        default:
                            if (memByteAddrHead >= setupMemoryContent.CodeSize)
                            {
                                contentText = $"0x{ memory[memByteAddrHead / 4].ToString("X8") } ({ (int)memory[memByteAddrHead / 4]})";
                            }
                            else
                            {
                                contentText = "(Alignment)";
                            }
                            statisticsText += "\r\n";
                            break;

                        case MemoryContent.WordElement.enumUsage.Instruction:
                            if (!codeInstr)
                            {
                                memByteAddrHead = memByteAddrTail;
                                continue;
                            }

                            contentText = "";
                            for (int i = 0; i < memByteAddrTail - memByteAddrHead + 1; i++)
                            {
                                if ((memByteAddrHead + i) % 4 == 0 || (mem[(memByteAddrHead + i) / 4].DebugInfoCount >= 2 && (memByteAddrHead + i) % 2 == 0))
                                {
                                    contentText += " ";
                                }
                                contentText += "" + ApplyByteMask(memory[(memByteAddrHead + i) / 4], (memByteAddrHead + i) % 4).ToString("X2");
                            }

                            contentText = contentText.TrimStart(' ');
                            {
                                int   wordReadTimes, wordWriteTimes, execTimes;
                                int[] wordReadTimesPerType;
                                memory.GetWordAccessStatistics((uint)memByteAddrHead / 4, 4, memByteAddrHead % 4, out execTimes, out wordReadTimes, out wordWriteTimes, out wordReadTimesPerType);
                                statisticsText  = $"\r\n        #Access: EX={execTimes}, RI={wordReadTimesPerType[(int)CommonModule.EnumMemorymAccessType.Instruction]}, RD={wordReadTimesPerType[(int)CommonModule.EnumMemorymAccessType.Data]}; W={wordWriteTimes}";
                                statisticsText += "\r\n";
                            }
                            break;
                        }

                        //Start address
                        if (memByteAddrHead == memByteAddrTail)
                        {
                            MessageManager.Show($"{ memByteAddrHead.ToString("X8") }:       ", level);
                        }
                        else
                        {
                            MessageManager.Show($"{ memByteAddrHead.ToString("X8") }~[+{((memByteAddrTail - memByteAddrHead).ToString() + "]:").PadRight(5,' ') }", level);
                        }

                        //Contents
                        contentText = contentText.PadRight(contentTextWidth, ' ');
                        MessageManager.Show(
                            $"{ contentText } { mem.GetDebugInfo(memByteAddrHead / 4,4,memByteAddrHead % 4).DebugInfo?.PadRight(usageType == MemoryContent.WordElement.enumUsage.Instruction ? 70 : 0) }", level);

                        MessageManager.Show(statisticsText, level);


                        memByteAddrHead = memByteAddrTail;
                    }
                }
                if (stack)
                {
                    for (int memByteAddrHead = mem.CodeSize * 4; memByteAddrHead < mem.WordCapacity * 4; memByteAddrHead++)
                    {
                        int memByteAddrTail = memByteAddrHead;
                        for (int cursor = memByteAddrHead + 1; cursor < mem.WordCapacity * 4; cursor++)
                        {
                            if (mem.GetDebugInfo(cursor / 4, 4, cursor % 4).Usage != MemoryContent.WordElement.enumUsage.FollowHead)
                            {
                                break;
                            }

                            memByteAddrTail = cursor;
                        }

                        //Content
                        string contentText;
                        switch (mem.GetDebugInfo(memByteAddrHead / 4, 4, memByteAddrHead % 4).Usage)
                        {
                        case MemoryContent.WordElement.enumUsage.Variable:
                        case MemoryContent.WordElement.enumUsage.VariableArray:
                        case MemoryContent.WordElement.enumUsage.FollowHead:
                            memByteAddrTail = memByteAddrHead + 3;     //Disabling group display
                            contentText     = $"0x{ memory[memByteAddrHead / 4].ToString("X8") } ({ (int)memory[memByteAddrHead / 4]})";
                            break;

                        case MemoryContent.WordElement.enumUsage.Unknown:
                        default:
                            if (memByteAddrHead >= setupMemoryContent.CodeSize)
                            {
                                contentText = $"0x{ memory[memByteAddrHead / 4].ToString("X8") } ({ (int)memory[memByteAddrHead / 4]})";
                            }
                            else
                            {
                                contentText = "(Alignment)";
                            }
                            break;

                        case MemoryContent.WordElement.enumUsage.Instruction:
                            contentText = "";
                            for (int i = 0; i < memByteAddrTail - memByteAddrHead + 1; i++)
                            {
                                if ((memByteAddrHead + i) % 4 == 0 || (mem[(memByteAddrHead + i) / 4].DebugInfoCount >= 2 && (memByteAddrHead + i) % 2 == 0))
                                {
                                    contentText += " ";
                                }
                                contentText += "" + ApplyByteMask(memory[(memByteAddrHead + i) / 4], (memByteAddrHead + i) % 4).ToString("X2");
                            }
                            contentText = contentText.TrimStart(' ');
                            break;
                        }

                        //Start address
                        if (memByteAddrHead == memByteAddrTail)
                        {
                            MessageManager.Show($"{ memByteAddrHead.ToString("X8") }:       ", level);
                        }
                        else
                        {
                            MessageManager.Show($"{ memByteAddrHead.ToString("X8") }~[+{((memByteAddrTail - memByteAddrHead).ToString() + "]:").PadRight(5,' ') }", level);
                        }

                        //Contents
                        contentText = contentText.PadRight(contentTextWidth, ' ');
                        MessageManager.ShowLine(
                            $"{ contentText } { mem.GetDebugInfo(memByteAddrHead / 4,4,memByteAddrHead % 4).DebugInfo }", level);

                        memByteAddrHead = memByteAddrTail;
                    }
                }
                MessageManager.ShowLine($"-----------------------------------------------------------------------", level);
                MessageManager.ShowLine("", level);
            }
            return(true);
        }
예제 #8
0
 public abstract bool ShowExecutionInfo(enumMessageLevel level);
예제 #9
0
 public abstract bool ShowMemoryDumpByMessage(bool codeInstr, bool codeVar, bool stack, enumMessageLevel level);
예제 #10
0
 public override bool ShowExecutionInfo(enumMessageLevel level)
 {
     //Memory
     MessageManager.ShowLine("*Memory\n" + CircuitGroup.SyncMemory.GetStatisticsInfo(), level);
     return(true);
 }
예제 #11
0
        public void ShowByMessage(enumMessageLevel level)
        {
            if (!MessageManager.TestLevel(level))
            {
                return;
            }

            MessageManager.ShowLine($"Entry point: 0x{ StartupAddress.ToString("X8") }", level);

            MessageManager.ShowLine($"Memory slots: Uses { MemoryContents.Length } memory slots", level);
            MessageManager.ShowLine("", level);

            MessageManager.ShowLine($"Memory initial contents:", level);
            MessageManager.GoInnerTab();
            foreach (var mem in MemoryContents)
            {
                const int contentTextWidth = 40;
                MessageManager.ShowLine($"[Slot.{ mem.Slot }]:", level);
                MessageManager.ShowLine($"Capacity = { mem.WordCapacity } words", level);
                MessageManager.ShowLine($"ByteAddress     { "Initial-value".PadRight(contentTextWidth,' ') } Mean", level);
                for (int memByteAddrHead = 0; memByteAddrHead < mem.CodeSize * 4; memByteAddrHead++)
                {
                    int memByteAddrTail = memByteAddrHead;
                    for (int cursor = memByteAddrHead + 1; cursor < mem.CodeSize * 4; cursor++)
                    {
                        if (mem.GetDebugInfo(cursor / 4, 4, cursor % 4).Usage != MemoryContent.WordElement.enumUsage.FollowHead)
                        {
                            break;
                        }

                        memByteAddrTail = cursor;
                    }

                    //Content
                    string contentText;
                    switch (mem.GetDebugInfo(memByteAddrHead / 4, 4, memByteAddrHead % 4).Usage)
                    {
                    case MemoryContent.WordElement.enumUsage.Variable:
                    case MemoryContent.WordElement.enumUsage.VariableArray:
                    case MemoryContent.WordElement.enumUsage.FollowHead:
                        memByteAddrTail = memByteAddrHead + 3;     //Disabling group display
                        contentText     = $"0x{ mem[memByteAddrHead / 4].InitialValue.ToString("X8") } ({ (int)mem[memByteAddrHead / 4].InitialValue})";
                        break;

                    case MemoryContent.WordElement.enumUsage.Unknown:
                    default:
                        contentText = "(Alignment)";
                        break;

                    case MemoryContent.WordElement.enumUsage.Instruction:
                        contentText = "";
                        for (int i = 0; i < memByteAddrTail - memByteAddrHead + 1; i++)
                        {
                            if ((memByteAddrHead + i) % 4 == 0 || (mem[(memByteAddrHead + i) / 4].DebugInfoCount >= 2 && (memByteAddrHead + i) % 2 == 0))
                            {
                                contentText += " ";
                            }
                            contentText += "" + ApplyByteMask(mem[(memByteAddrHead + i) / 4].InitialValue, (memByteAddrHead + i) % 4).ToString("X2");
                        }
                        contentText = contentText.TrimStart(' ');
                        break;
                    }

                    //Start address
                    if (memByteAddrHead == memByteAddrTail)
                    {
                        MessageManager.Show($"{ memByteAddrHead.ToString("X8") }:       ", level);
                    }
                    else
                    {
                        MessageManager.Show($"{ memByteAddrHead.ToString("X8") }~[+{((memByteAddrTail - memByteAddrHead).ToString() + "]:").PadRight(5,' ') }", level);
                    }

                    //Contents
                    contentText = contentText.PadRight(contentTextWidth, ' ');
                    MessageManager.ShowLine(
                        $"{ contentText } { mem.GetDebugInfo(memByteAddrHead / 4,4,memByteAddrHead % 4).DebugInfo }", level);

                    memByteAddrHead = memByteAddrTail;
                }
                MessageManager.ShowLine($"-----------------------------------------------------------------------", level);
                MessageManager.ShowLine("", level);
            }
            MessageManager.GoOuterTab();
            MessageManager.ShowLine("", level);
        }