Exemplo n.º 1
0
        protected void DumpInfo()
        {
            writer.WriteLine();
            writer.WriteLine("D0: {0}   D4: {1}   A0: {2}   A4: {3}     PC: {4}",
                             cpu.GetDataRegisterLong(0).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetDataRegisterLong(4).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetAddrRegisterLong(0).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetAddrRegisterLong(4).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetPC().ToString("x8", CultureInfo.InvariantCulture));
            writer.WriteLine("D1: {0}   D5: {1}   A1: {2}   A5: {3}     SR:  {4} {5}",
                             cpu.GetDataRegisterLong(1).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetDataRegisterLong(5).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetAddrRegisterLong(1).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetAddrRegisterLong(5).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetSR().ToString("x4", CultureInfo.InvariantCulture),
                             MakeFlagView());
            writer.WriteLine("D2: {0}   D6: {1}   A2: {2}   A6: {3}     USP: {4}",
                             cpu.GetDataRegisterLong(2).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetDataRegisterLong(6).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetAddrRegisterLong(2).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetAddrRegisterLong(6).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetUSP());
            writer.WriteLine("D3: {0}   D7: {1}   A3: {2}   A7: {3}     SSP: {4}",
                             cpu.GetDataRegisterLong(3).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetDataRegisterLong(7).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetAddrRegisterLong(3).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetAddrRegisterLong(7).ToString("x8", CultureInfo.InvariantCulture),
                             cpu.GetSSP().ToString("x8", CultureInfo.InvariantCulture));
            buffer.Clear();
            int addr = cpu.GetPC();

            if (addr < 0 || addr >= memory.Size())
            {
                buffer.Append($"{addr.ToString("x8", CultureInfo.InvariantCulture)}   ????");
            }
            else
            {
                int                     opcode = cpu.ReadMemoryWord(addr);
                IInstruction            i      = cpu.GetInstructionFor(opcode);
                DisassembledInstruction di     = i.Disassemble(addr, opcode);
                if (showBytes)
                {
                    di.FormatInstruction(buffer);
                }
                else
                {
                    di.ShortFormat(buffer);
                }
            }

            writer.WriteLine($"==> {buffer}{Environment.NewLine}");
        }