Example #1
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());
        }
Example #2
0
        protected void HandlePC(string[] tokens)
        {
            if (tokens is null)
            {
                throw new ArgumentNullException(nameof(tokens));
            }

            if (tokens.Length == 1)
            {
                writer.Write($"PC: {cpu.GetPC().ToString("x8", CultureInfo.InvariantCulture)}");
            }
            else if (tokens.Length == 2)
            {
                int value;
                try
                {
                    value = ParseInt(tokens[1]);
                }
                catch (FormatException)
                {
                    writer.WriteLine($"Bad value [{tokens[1]}]");
                    return;
                }

                cpu.SetPC(value);
            }
            else
            {
                writer.WriteLine($"usage: {tokens[0]} [value]");
            }
        }