private void InstructionWidget_Paint(object sender, PaintEventArgs e)
        {
            if (m_Op == null)
            {
                return;
            }

            if (Selected)
            {
                e.Graphics.FillRectangle(SystemBrushes.HighlightText, new Rectangle(0, 0, this.Width, this.Height));
            }

            Brush br = SystemBrushes.ControlText;

            if (!Executed)
            {
                br = SystemBrushes.InactiveCaption;
            }

            Font f = this.Font;

            if (!Executed)
            {
                f = m_ItalicFont;
            }

            e.Graphics.DrawString(m_Op.Disassemble(), f, br, new PointF(80 + 96, 0));

            if (!String.IsNullOrEmpty(m_Op.SimNotes))
            {
                e.Graphics.DrawString(m_Op.SimNotes, this.Font, SystemBrushes.ControlText, new PointF(this.Width - 200, 0));
            }
        }
Exemple #2
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}");
        }
Exemple #3
0
 private void LogInstruction(IInstruction instruction, byte opCode)
 {
     var instructionSize = instruction.Variants[opCode].InstructionSize();
     var instructionBytes = mem.SequenceFrom(state.Pc).Take(instructionSize).ToArray();
     Console.WriteLine("{0:X2}  {1,-10}{2,-32}A:{3:X2} X:{4:X2} Y:{5:X2} P:{6:X2} SP:{7:X2}", // TODO: Cycle and scanline goes at the end
         state.Pc,
         string.Join(" ", instructionBytes.Select(x => x.ToString("X2"))),
         instruction.Disassemble(instructionBytes),
         state.A,
         state.X,
         state.Y,
         state.StatusRegister,
         state.Sp);
 }
Exemple #4
0
        protected void HandleDisassemble(string[] tokens)
        {
            if (tokens is null)
            {
                throw new ArgumentNullException(nameof(tokens));
            }

            int start;
            int num_instructions = 8;

            if (tokens.Length > 2)
            {
                try
                {
                    num_instructions = ParseInt(tokens[2]);
                }
                catch (FormatException)
                {
                    writer.WriteLine($"Invalid instruction count: {tokens[2]}");
                    return;
                }
            }

            if (tokens.Length > 1)
            {
                string address = tokens[1];
                try
                {
                    start = ParseInt(address);
                }
                catch (FormatException)
                {
                    writer.WriteLine($"Unknown address [{address}]");
                    return;
                }
            }
            else
            {
                start = cpu.GetPC();
            }

            int count = 0;

            buffer = new StringBuilder(80);
            while (start < memory.Size() && count < num_instructions)
            {
                buffer.Clear();
                int                     opcode = cpu.ReadMemoryWord(start);
                IInstruction            i      = cpu.GetInstructionFor(opcode);
                DisassembledInstruction di     = i.Disassemble(start, opcode);
                if (showBytes)
                {
                    di.FormatInstruction(buffer);
                }
                else
                {
                    di.ShortFormat(buffer);
                }

                writer.WriteLine(buffer.ToString());
                start += di.Size();
                count++;
            }
        }
Exemple #5
0
 private void LogInstruction(IInstruction instruction, byte opCode)
 {
     var instructionSize = instruction.Variants[opCode].InstructionSize();
     var instructionBytes = mem.SequenceFrom(state.Pc).Take(instructionSize).ToArray();
     //if (false)
     {
         var contents = String.Format("{0:X4}  {1,-10}{2,-32}A:{3:X2} X:{4:X2} Y:{5:X2} P:{6:X2} SP:{7:X2} CYC:{8,3} SL:{9}\n", // TODO: Cycle and scanline goes at the end
             state.Pc,
             string.Join(" ", instructionBytes.Select(x => x.ToString("X2"))),
             instruction.Disassemble(instructionBytes, mem, state),
             state.A,
             state.X,
             state.Y,
             state.StatusRegister,
             state.Sp,
             cycle,
             scanline);
         instructionLog.Add(contents);
     //                File.AppendAllText("log.txt",
       //                  contents);
     }
 }