public virtual void TestFlags() { cpu.SetSR(0x27ff); Assert.True(cpu.IsFlagSet(cpu.CFlag)); Assert.True(cpu.IsFlagSet(cpu.VFlag)); Assert.True(cpu.IsFlagSet(cpu.ZFlag)); Assert.True(cpu.IsFlagSet(cpu.NFlag)); Assert.True(cpu.IsFlagSet(cpu.XFlag)); Assert.True(cpu.IsSupervisorMode()); Assert.Equal(7, cpu.GetInterruptLevel()); cpu.SetSR(0); Assert.False(cpu.IsFlagSet(cpu.CFlag)); Assert.False(cpu.IsFlagSet(cpu.VFlag)); Assert.False(cpu.IsFlagSet(cpu.ZFlag)); Assert.False(cpu.IsFlagSet(cpu.NFlag)); Assert.False(cpu.IsFlagSet(cpu.XFlag)); Assert.False(cpu.IsSupervisorMode()); Assert.Equal(0, cpu.GetInterruptLevel()); cpu.SetCCRegister(cpu.CFlag); Assert.True(cpu.IsFlagSet(cpu.CFlag)); Assert.False(cpu.IsFlagSet(cpu.VFlag)); Assert.False(cpu.IsFlagSet(cpu.ZFlag)); Assert.False(cpu.IsFlagSet(cpu.NFlag)); Assert.False(cpu.IsFlagSet(cpu.XFlag)); Assert.False(cpu.IsSupervisorMode()); Assert.Equal(0, cpu.GetInterruptLevel()); cpu.SetCCRegister(cpu.VFlag); Assert.False(cpu.IsFlagSet(cpu.CFlag)); Assert.True(cpu.IsFlagSet(cpu.VFlag)); Assert.False(cpu.IsFlagSet(cpu.ZFlag)); Assert.False(cpu.IsFlagSet(cpu.NFlag)); Assert.False(cpu.IsFlagSet(cpu.XFlag)); Assert.False(cpu.IsSupervisorMode()); Assert.Equal(0, cpu.GetInterruptLevel()); cpu.SetCCRegister(cpu.ZFlag); Assert.False(cpu.IsFlagSet(cpu.CFlag)); Assert.False(cpu.IsFlagSet(cpu.VFlag)); Assert.True(cpu.IsFlagSet(cpu.ZFlag)); Assert.False(cpu.IsFlagSet(cpu.NFlag)); Assert.False(cpu.IsFlagSet(cpu.XFlag)); Assert.False(cpu.IsSupervisorMode()); Assert.Equal(0, cpu.GetInterruptLevel()); cpu.SetCCRegister(cpu.NFlag); Assert.False(cpu.IsFlagSet(cpu.CFlag)); Assert.False(cpu.IsFlagSet(cpu.VFlag)); Assert.False(cpu.IsFlagSet(cpu.ZFlag)); Assert.True(cpu.IsFlagSet(cpu.NFlag)); Assert.False(cpu.IsFlagSet(cpu.XFlag)); Assert.False(cpu.IsSupervisorMode()); Assert.Equal(0, cpu.GetInterruptLevel()); cpu.SetCCRegister(cpu.XFlag); Assert.False(cpu.IsFlagSet(cpu.CFlag)); Assert.False(cpu.IsFlagSet(cpu.VFlag)); Assert.False(cpu.IsFlagSet(cpu.ZFlag)); Assert.False(cpu.IsFlagSet(cpu.NFlag)); Assert.True(cpu.IsFlagSet(cpu.XFlag)); Assert.False(cpu.IsSupervisorMode()); Assert.Equal(0, cpu.GetInterruptLevel()); }
protected void HandleCCR(string[] tokens) { if (tokens is null) { throw new ArgumentNullException(nameof(tokens)); } if (tokens.Length == 1) { writer.WriteLine($"CCR: {cpu.GetCCRegister().ToString("x", CultureInfo.InvariantCulture)} {MakeFlagView()}"); } else if (tokens.Length == 2) { int value; try { value = ParseInt(tokens[1]); } catch (FormatException) { writer.WriteLine($"Bad value [{tokens[1]}]"); return; } cpu.SetCCRegister(value); } else { writer.WriteLine($"usage: {tokens[0]} [value]"); } }