Пример #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}");
        }
Пример #2
0
        public virtual void TestException()
        {
            bus.WriteLong(0x08, 0x56789);
            bus.WriteLong(0x0c, 0x12345);
            bus.WriteLong(0x10, 0x23456);
            cpu.SetPC(0x32);
            cpu.SetSR(0x04);
            cpu.SetAddrRegisterLong(7, 0x0100);
            cpu.SetSSP(0x0200);
            cpu.RaiseException(2);
            Assert.Equal(0x56789, cpu.GetPC());
            Assert.Equal(0x01fa, cpu.GetAddrRegisterLong(7));
            Assert.Equal(0x0100, cpu.GetUSP());
            Assert.True(cpu.IsSupervisorMode());
            int sr = cpu.PopWord();
            int pc = cpu.PopLong();

            Assert.Equal(0x04, sr);
            Assert.Equal(0x32, pc);
            cpu.SetSR(sr);
            Assert.False(cpu.IsSupervisorMode());
            Assert.Equal(0x0100, cpu.GetUSP());
            Assert.Equal(0x0100, cpu.GetAddrRegisterLong(7));
            Assert.Equal(0x0200, cpu.GetSSP());
        }