Simplify 6809 boolean flag handling

This commit is contained in:
Adrian Conlon committed 2026-05-11 19:18:11 +01:00
1 parent f01762b9de
commit e1470a13fa
25 files changed
+303 -287

No files matched your search

+2 -2
View File
@@ -17,8 +17,8 @@ namespace MC6809
public bool Ignore => this.CPU.HALT.Lowered()
|| this.CPU.RESET.Lowered()
|| this.CPU.NMI.Lowered()
|| this.CPU.FIRQ.Lowered() && this.CPU.FastInterruptMasked == 0
|| this.CPU.INT.Lowered() && this.CPU.InterruptMasked == 0;
|| this.CPU.FIRQ.Lowered() && this.CPU.FastInterruptMasked
|| this.CPU.INT.Lowered() && this.CPU.InterruptMasked;
private Bus BUS { get; } = bus;
+10 -10
View File
@@ -52,11 +52,11 @@ namespace MC6809.UnitTest
Assert.AreEqual(0x80d4, this.cpu.X.Word);
Assert.AreEqual(0, this.cpu.Y.Word);
Assert.AreEqual(0, this.cpu.U.Word);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.HalfCarry);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.HalfCarry);
Assert.AreEqual(3, this.cpu.Cycles);
}
@@ -75,11 +75,11 @@ namespace MC6809.UnitTest
Assert.AreEqual(0x80d4, this.cpu.X.Word);
Assert.AreEqual(0, this.cpu.Y.Word);
Assert.AreEqual(0, this.cpu.U.Word);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.HalfCarry);
Assert.IsTrue(this.cpu.Carry);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.HalfCarry);
Assert.AreEqual(3, this.cpu.Cycles);
}
}
+22 -22
View File
@@ -33,11 +33,11 @@ namespace MC6809.UnitTest
this.cpu.A = 0x3a;
this.cpu.Step();
Assert.AreEqual(0xb7, this.cpu.A);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.HalfCarry);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.HalfCarry);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -50,11 +50,11 @@ namespace MC6809.UnitTest
this.board.Poke(1, 0x02);
this.cpu.Step();
Assert.AreEqual(7, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.HalfCarry);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.HalfCarry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -68,11 +68,11 @@ namespace MC6809.UnitTest
this.board.Poke(1, 0x02);
this.cpu.Step();
Assert.AreEqual(0x10, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreNotEqual(0, this.cpu.HalfCarry);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.IsTrue(this.cpu.HalfCarry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -86,11 +86,11 @@ namespace MC6809.UnitTest
this.board.Poke(1, 0x22);
this.cpu.Step();
Assert.AreEqual(0x37, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.HalfCarry);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.HalfCarry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -104,8 +104,8 @@ namespace MC6809.UnitTest
this.board.Poke(1, 0x2B);
this.cpu.Step();
Assert.AreEqual(0x40, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreNotEqual(0, this.cpu.HalfCarry);
Assert.IsFalse(this.cpu.Carry);
Assert.IsTrue(this.cpu.HalfCarry);
Assert.AreEqual(2, this.cpu.Cycles);
}
}
+46 -46
View File
@@ -31,11 +31,11 @@ namespace MC6809.UnitTest
this.cpu.A = 0x24;
this.cpu.Step();
Assert.AreEqual(0xaf, this.cpu.A);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.HalfCarry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.HalfCarry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -51,11 +51,11 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(6, this.cpu.A);
Assert.AreEqual(5, this.cpu.B);
Assert.AreEqual(0, this.cpu.HalfCarry);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.HalfCarry);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -71,9 +71,9 @@ namespace MC6809.UnitTest
this.cpu.A = 3;
this.cpu.Step();
Assert.AreEqual(2, this.cpu.A);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -88,11 +88,11 @@ namespace MC6809.UnitTest
this.cpu.CC = 0;
this.cpu.Step();
Assert.AreEqual(0x81, this.cpu.B);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.HalfCarry);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.HalfCarry);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -107,10 +107,10 @@ namespace MC6809.UnitTest
this.cpu.CC = 0;
this.cpu.Step();
Assert.AreEqual(0xfe, this.cpu.B);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -125,10 +125,10 @@ namespace MC6809.UnitTest
this.cpu.CC = 0;
this.cpu.Step();
Assert.AreEqual(0x7f, this.cpu.B);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -143,10 +143,10 @@ namespace MC6809.UnitTest
this.cpu.CC = 0;
this.cpu.Step();
Assert.AreEqual(0xfe, this.cpu.B);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -164,10 +164,10 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0x06, this.cpu.A);
Assert.AreEqual(0xb5, this.cpu.B);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(4, this.cpu.Cycles);
}
@@ -185,10 +185,10 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0x66, this.cpu.A);
Assert.AreEqual(0xb5, this.cpu.B);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(4, this.cpu.Cycles);
}
@@ -206,10 +206,10 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0xb0, this.cpu.A);
Assert.AreEqual(0x00, this.cpu.B);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(4, this.cpu.Cycles);
}
@@ -227,10 +227,10 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0xe0, this.cpu.A);
Assert.AreEqual(0x00, this.cpu.B);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(4, this.cpu.Cycles);
}
}
+3 -3
View File
@@ -33,9 +33,9 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0x10, this.cpu.A);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
+3 -3
View File
@@ -34,9 +34,9 @@ namespace MC6809.UnitTest
this.cpu.A = 0x7a;
this.cpu.Step();
Assert.AreEqual(0xf4, this.cpu.A);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
}
+9 -9
View File
@@ -34,9 +34,9 @@ namespace MC6809.UnitTest
this.cpu.A = 0xcb;
this.cpu.Step();
Assert.AreEqual(0xe5, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -47,9 +47,9 @@ namespace MC6809.UnitTest
this.cpu.A = 0x40;
this.cpu.Step();
Assert.AreEqual(0x20, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -60,9 +60,9 @@ namespace MC6809.UnitTest
this.cpu.A = 0x01;
this.cpu.Step();
Assert.AreEqual(0x00, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.IsTrue(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
}
+2 -2
View File
@@ -36,8 +36,8 @@ namespace MC6809.UnitTest
this.cpu.CC = (byte)StatusBits.ZF;
this.cpu.Step();
Assert.AreEqual(0xa6, this.cpu.A);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
}
+4 -4
View File
@@ -34,10 +34,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0x43;
this.cpu.Step();
Assert.AreEqual(0, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.IsFalse(this.cpu.Carry);
Assert.IsTrue(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.Overflow);
Assert.AreEqual(2, this.cpu.Cycles);
}
}
+24 -24
View File
@@ -31,10 +31,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0xf6;
this.cpu.Step();
Assert.AreEqual(0xf6, this.cpu.A);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -57,7 +57,7 @@ namespace MC6809.UnitTest
Assert.AreEqual(0, this.cpu.X.Word);
Assert.AreEqual(0x206, this.cpu.Y.Word);
Assert.AreEqual(0, this.cpu.U.Word);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.IsTrue(this.cpu.Zero);
Assert.AreEqual(6, this.cpu.Cycles);
}
@@ -80,7 +80,7 @@ namespace MC6809.UnitTest
Assert.AreEqual(0, this.cpu.X.Word);
Assert.AreEqual(0x207, this.cpu.Y.Word);
Assert.AreEqual(0, this.cpu.U.Word);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.IsTrue(this.cpu.Zero);
Assert.AreEqual(7, this.cpu.Cycles);
}
@@ -103,7 +103,7 @@ namespace MC6809.UnitTest
Assert.AreEqual(0, this.cpu.X.Word);
Assert.AreEqual(0x204, this.cpu.Y.Word);
Assert.AreEqual(0, this.cpu.U.Word);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.IsTrue(this.cpu.Zero);
Assert.AreEqual(6, this.cpu.Cycles);
}
@@ -126,7 +126,7 @@ namespace MC6809.UnitTest
Assert.AreEqual(0, this.cpu.X.Word);
Assert.AreEqual(0x203, this.cpu.Y.Word);
Assert.AreEqual(0, this.cpu.U.Word);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.IsTrue(this.cpu.Zero);
Assert.AreEqual(7, this.cpu.Cycles);
}
@@ -139,10 +139,10 @@ namespace MC6809.UnitTest
this.cpu.CC = (byte)StatusBits.NF;
this.cpu.B = 0xa0;
this.cpu.Step();
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Negative);
Assert.IsTrue(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -155,10 +155,10 @@ namespace MC6809.UnitTest
this.cpu.CC = (byte)StatusBits.NF;
this.cpu.B = 0x70;
this.cpu.Step();
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -173,10 +173,10 @@ namespace MC6809.UnitTest
this.cpu.PokeWord(1, 0x33);
this.cpu.Step();
Assert.AreEqual(0x5410, this.cpu.X.Word);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(7, this.cpu.Cycles);
}
@@ -188,10 +188,10 @@ namespace MC6809.UnitTest
this.cpu.X.Word = 0x1ab0;
this.cpu.Step();
Assert.AreEqual(0x1ab0, this.cpu.X.Word);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(4, this.cpu.Cycles);
}
}
+4 -4
View File
@@ -36,10 +36,10 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0xf8, this.board.Peek(0x0200));
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Carry);
}
[TestMethod]
+4 -4
View File
@@ -40,10 +40,10 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0x85, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Carry);
}
}
}
+12 -12
View File
@@ -31,10 +31,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0x32;
this.cpu.Step();
Assert.AreEqual(0x31, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -47,10 +47,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0x80;
this.cpu.Step();
Assert.AreEqual(0x7f, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -63,10 +63,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0;
this.cpu.Step();
Assert.AreEqual(0xff, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
}
+12 -12
View File
@@ -31,10 +31,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0x32;
this.cpu.Step();
Assert.AreEqual(0x33, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -46,10 +46,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0x7f;
this.cpu.Step();
Assert.AreEqual(0x80, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -61,10 +61,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0xff;
this.cpu.Step();
Assert.AreEqual(0, this.cpu.A);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Negative);
Assert.IsTrue(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
}
+2 -2
View File
@@ -73,7 +73,7 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0x50, this.cpu.X.Word);
Assert.AreEqual(0, this.cpu.Zero);
Assert.IsFalse(this.cpu.Zero);
}
[TestMethod]
@@ -90,7 +90,7 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0xe7a, this.cpu.X.Word);
Assert.AreEqual(0, this.cpu.Zero);
Assert.IsFalse(this.cpu.Zero);
}
}
}
+7 -7
View File
@@ -37,8 +37,8 @@ namespace MC6809.UnitTest
Assert.AreEqual(0x1F, this.cpu.A);
Assert.AreEqual(2, this.cpu.CC);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Negative);
}
// Logical Shift Right of 1
@@ -55,9 +55,9 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsTrue(this.cpu.Zero);
Assert.IsTrue(this.cpu.Carry);
Assert.IsFalse(this.cpu.Negative);
}
// Logical Shift Right of 0xB8
@@ -73,8 +73,8 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0x5c, this.cpu.A);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Carry);
}
// Shift a byte at 0x0402, because DP = 0x04.
+4 -4
View File
@@ -42,8 +42,8 @@ namespace MC6809.UnitTest
Assert.AreEqual(0x4b0, this.cpu.D.Word);
Assert.AreEqual(0x4, this.cpu.A);
Assert.AreEqual(0xb0, this.cpu.B);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Carry);
}
// Multiply 0x0C with 0x00. Result is 0x0000.
@@ -65,8 +65,8 @@ namespace MC6809.UnitTest
Assert.AreEqual(0, this.cpu.D.Word);
Assert.AreEqual(0, this.cpu.A);
Assert.AreEqual(0, this.cpu.B);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Zero);
Assert.IsFalse(this.cpu.Carry);
}
}
}
+8 -8
View File
@@ -33,7 +33,7 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Carry);
}
[TestMethod]
@@ -46,7 +46,7 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0xff, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Carry);
}
[TestMethod]
@@ -59,8 +59,8 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0xfe, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.IsTrue(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
}
[TestMethod]
@@ -73,10 +73,10 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0x80, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Negative);
}
}
}
+5 -5
View File
@@ -38,7 +38,7 @@ namespace MC6809.UnitTest
Assert.AreEqual(0xb01, this.cpu.PC.Word);
Assert.AreEqual(0x13, this.cpu.B);
Assert.AreEqual(0x3, this.cpu.CC);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Carry);
}
[TestMethod]
@@ -69,10 +69,10 @@ namespace MC6809.UnitTest
Assert.AreEqual(0xb0, this.cpu.B);
Assert.AreEqual(9, this.cpu.CC);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Negative);
}
}
}
+4 -4
View File
@@ -37,8 +37,8 @@ namespace MC6809.UnitTest
Assert.AreEqual(0xc4, this.cpu.B);
Assert.AreEqual(9, this.cpu.CC);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.IsTrue(this.cpu.Negative);
}
[TestMethod]
@@ -54,8 +54,8 @@ namespace MC6809.UnitTest
Assert.AreEqual(0x44, this.cpu.B);
Assert.AreEqual(1, this.cpu.CC);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.IsFalse(this.cpu.Negative);
}
}
}
+19 -19
View File
@@ -32,10 +32,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0x14;
this.cpu.Step();
Assert.AreEqual(0xdf, this.cpu.A);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -53,10 +53,10 @@ namespace MC6809.UnitTest
this.cpu.B = 0x35;
this.cpu.Step();
Assert.AreEqual(0x31, this.cpu.B);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(4, this.cpu.Cycles);
}
@@ -71,10 +71,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0xff;
this.cpu.Step();
Assert.AreEqual(0, this.cpu.A);
Assert.AreEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -89,10 +89,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0;
this.cpu.Step();
Assert.AreEqual(1, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -107,9 +107,9 @@ namespace MC6809.UnitTest
this.cpu.A = 0;
this.cpu.Step();
Assert.AreEqual(0xff, this.cpu.A);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
}
+20 -20
View File
@@ -38,10 +38,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0;
this.cpu.Step();
Assert.AreEqual(1, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Negative);
Assert.IsTrue(this.cpu.Carry);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Negative);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -60,10 +60,10 @@ namespace MC6809.UnitTest
this.cpu.A = 0;
this.cpu.Step();
Assert.AreEqual(0xff, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -79,10 +79,10 @@ namespace MC6809.UnitTest
this.cpu.B = 2;
this.cpu.Step();
Assert.AreEqual(0x4f, this.cpu.B);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -98,10 +98,10 @@ namespace MC6809.UnitTest
this.cpu.B = 2;
this.cpu.Step();
Assert.AreEqual(0x81, this.cpu.B);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(2, this.cpu.Cycles);
}
@@ -119,10 +119,10 @@ namespace MC6809.UnitTest
this.cpu.Y.Word = 0x21;
this.cpu.Step();
Assert.AreEqual(0xe2, this.cpu.B);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Carry);
Assert.AreEqual(4, this.cpu.Cycles);
}
}
+12 -12
View File
@@ -38,9 +38,9 @@ namespace MC6809.UnitTest
Assert.AreEqual(0xb02, this.cpu.PC.Word);
Assert.AreEqual(0xabba, this.cpu.D.Word);
Assert.AreEqual(0xabba, this.cpu.Y.Word);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
}
[TestMethod]
@@ -57,9 +57,9 @@ namespace MC6809.UnitTest
Assert.AreEqual(0x1bb1, this.cpu.PC.Word);
Assert.AreEqual(0x1bb1, this.cpu.S.Word);
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.IsFalse(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
}
[TestMethod]
@@ -76,12 +76,12 @@ namespace MC6809.UnitTest
Assert.AreEqual(0x1b, this.cpu.DP);
Assert.AreEqual(0x1b, this.cpu.CC);
Assert.AreEqual(0, this.cpu.HalfCarry);
Assert.AreNotEqual(0, this.cpu.InterruptMasked);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreNotEqual(0, this.cpu.Overflow);
Assert.AreNotEqual(0, this.cpu.Carry);
Assert.IsFalse(this.cpu.HalfCarry);
Assert.IsTrue(this.cpu.InterruptMasked);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsTrue(this.cpu.Overflow);
Assert.IsTrue(this.cpu.Carry);
}
[TestMethod]
+9 -9
View File
@@ -34,9 +34,9 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0xff, this.cpu.A);
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
}
[TestMethod]
@@ -64,9 +64,9 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0, this.cpu.Negative);
Assert.AreNotEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.IsFalse(this.cpu.Negative);
Assert.IsTrue(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
}
[TestMethod]
@@ -81,9 +81,9 @@ namespace MC6809.UnitTest
this.cpu.Step();
Assert.AreEqual(0xff, this.board.Peek(0x205));
Assert.AreNotEqual(0, this.cpu.Negative);
Assert.AreEqual(0, this.cpu.Zero);
Assert.AreEqual(0, this.cpu.Overflow);
Assert.IsTrue(this.cpu.Negative);
Assert.IsFalse(this.cpu.Zero);
Assert.IsFalse(this.cpu.Overflow);
}
}
}
+56 -40
View File
@@ -361,35 +361,51 @@ namespace MC6809
#region Status (etc.) bit twiddling
public int EntireRegisterSet => this.CC & (byte)StatusBits.EF;
public int EntireRegisterSetFlag => this.CC & (byte)StatusBits.EF;
public bool E => this.EntireRegisterSet != 0;
public bool EntireRegisterSet => this.EntireRegisterSetFlag != 0;
public int FastInterruptMasked => this.CC & (byte)StatusBits.FF;
public bool E => this.EntireRegisterSet;
public int HalfCarry => this.CC & (byte)StatusBits.HF;
public int FastInterruptMaskedFlag => this.CC & (byte)StatusBits.FF;
public int InterruptMasked => this.CC & (byte)StatusBits.IF;
public bool FastInterruptMasked => this.FastInterruptMaskedFlag != 0;
public int Negative => this.CC & (byte)StatusBits.NF;
public int HalfCarryFlag => this.CC & (byte)StatusBits.HF;
public int Zero => this.CC & (byte)StatusBits.ZF;
public bool HalfCarry => this.HalfCarryFlag != 0;
public int Overflow => this.CC & (byte)StatusBits.VF;
public int InterruptMaskedFlag => this.CC & (byte)StatusBits.IF;
public int Carry => this.CC & (byte)StatusBits.CF;
public bool InterruptMasked => this.InterruptMaskedFlag != 0;
private bool LS => this.Carry != 0 || this.Zero != 0; // (C OR Z)
public int NegativeFlag => this.CC & (byte)StatusBits.NF;
private bool HI => !this.LS; // !(C OR Z)
public bool Negative => this.NegativeFlag != 0;
private bool LT => (this.Negative >> 3 ^ this.Overflow >> 1) != 0; // (N XOR V)
public int ZeroFlag => this.CC & (byte)StatusBits.ZF;
private bool GE => !this.LT; // !(N XOR V)
public bool Zero => this.ZeroFlag != 0;
private bool LE => this.Zero != 0 || this.LT; // (Z OR (N XOR V))
public int OverflowFlag => this.CC & (byte)StatusBits.VF;
private bool GT => !this.LE; // !(Z OR (N XOR V))
public bool Overflow => this.OverflowFlag != 0;
public int CarryFlag => this.CC & (byte)StatusBits.CF;
public bool Carry => this.CarryFlag != 0;
private bool LS => this.Carry || this.Zero; // (C OR Z)
private bool HI => !this.LS; // !(C OR Z)
private bool LT => (this.NegativeFlag >> 3 ^ this.OverflowFlag >> 1) != 0; // (N XOR V)
private bool GE => !this.LT; // !(N XOR V)
private bool LE => this.Zero || this.LT; // (Z OR (N XOR V))
private bool GT => !this.LE; // !(Z OR (N XOR V))
private static byte SetBit(byte f, StatusBits flag) => SetBit(f, (byte)flag);
@@ -855,14 +871,14 @@ namespace MC6809
private void BRN() => this.BranchShort(false);
private void BHI() => this.BranchShort(this.HI);
private void BLS() => this.BranchShort(this.LS);
private void BCC() => this.BranchShort(this.Carry == 0);
private void BCS() => this.BranchShort(this.Carry != 0);
private void BNE() => this.BranchShort(this.Zero == 0);
private void BEQ() => this.BranchShort(this.Zero != 0);
private void BVC() => this.BranchShort(this.Overflow == 0);
private void BVS() => this.BranchShort(this.Overflow != 0);
private void BPL() => this.BranchShort(this.Negative == 0);
private void BMI() => this.BranchShort(this.Negative != 0);
private void BCC() => this.BranchShort(!this.Carry);
private void BCS() => this.BranchShort(this.Carry);
private void BNE() => this.BranchShort(!this.Zero);
private void BEQ() => this.BranchShort(this.Zero);
private void BVC() => this.BranchShort(!this.Overflow);
private void BVS() => this.BranchShort(this.Overflow);
private void BPL() => this.BranchShort(!this.Negative);
private void BMI() => this.BranchShort(this.Negative);
private void BGE() => this.BranchShort(this.GE);
private void BLT() => this.BranchShort(this.LT);
private void BGT() => this.BranchShort(this.GT);
@@ -872,14 +888,14 @@ namespace MC6809
private void LBRN() => this.BranchLong(false);
private void LBHI() => this.BranchLong(this.HI);
private void LBLS() => this.BranchLong(this.LS);
private void LBCC() => this.BranchLong(this.Carry == 0);
private void LBCS() => this.BranchLong(this.Carry != 0);
private void LBNE() => this.BranchLong(this.Zero == 0);
private void LBEQ() => this.BranchLong(this.Zero != 0);
private void LBVC() => this.BranchLong(this.Overflow == 0);
private void LBVS() => this.BranchLong(this.Overflow != 0);
private void LBPL() => this.BranchLong(this.Negative == 0);
private void LBMI() => this.BranchLong(this.Negative != 0);
private void LBCC() => this.BranchLong(!this.Carry);
private void LBCS() => this.BranchLong(this.Carry);
private void LBNE() => this.BranchLong(!this.Zero);
private void LBEQ() => this.BranchLong(this.Zero);
private void LBVC() => this.BranchLong(!this.Overflow);
private void LBVS() => this.BranchLong(this.Overflow);
private void LBPL() => this.BranchLong(!this.Negative);
private void LBMI() => this.BranchLong(this.Negative);
private void LBGE() => this.BranchLong(this.GE);
private void LBLT() => this.BranchLong(this.LT);
private void LBGT() => this.BranchLong(this.GT);
@@ -1208,11 +1224,11 @@ namespace MC6809
{
this.HandleNMI();
}
else if (this.FIRQ.Lowered() && this.FastInterruptMasked == 0)
else if (this.FIRQ.Lowered() && !this.FastInterruptMasked)
{
this.HandleFIRQ();
}
else if (this.INT.Lowered() && this.InterruptMasked == 0)
else if (this.INT.Lowered() && !this.InterruptMasked)
{
this.HandleINT();
}
@@ -1715,7 +1731,7 @@ namespace MC6809
private void ADCA() => this.A = this.AddWithCarry(this.A);
private void ADCB() => this.B = this.AddWithCarry(this.B);
private byte AddWithCarry(byte operand) => this.Add(operand, this.Bus.Data, (byte)this.Carry);
private byte AddWithCarry(byte operand) => this.Add(operand, this.Bus.Data, (byte)this.CarryFlag);
private void ADDA() => this.A = this.Add(this.A);
private void ADDB() => this.B = this.Add(this.B);
@@ -1765,7 +1781,7 @@ namespace MC6809
{
this.CC = SetBit(this.CC, StatusBits.CF, operand & (byte)Bits.Bit7);
this.CC = this.AdjustNZ(operand <<= 1);
var overflow = this.Carry ^ this.Negative >> 3;
var overflow = this.CarryFlag ^ this.NegativeFlag >> 3;
this.CC = SetBit(this.CC, StatusBits.VF, overflow);
return operand;
}
@@ -1855,10 +1871,10 @@ namespace MC6809
var original = this.A;
var lowNibble = LowNibble(original);
var lowAdjust = this.HalfCarry != 0 || lowNibble > 9;
var lowAdjust = this.HalfCarry || lowNibble > 9;
var highNibble = HighNibble(original);
var highAdjust = this.Carry != 0 || highNibble > 9 || (highNibble == 9 && lowNibble > 9);
var highAdjust = this.Carry || highNibble > 9 || (highNibble == 9 && lowNibble > 9);
byte correction = 0;
@@ -2004,7 +2020,7 @@ namespace MC6809
private byte RotateLeft(byte operand)
{
var carryIn = this.Carry;
var carryIn = this.CarryFlag;
this.CC = SetBit(this.CC, StatusBits.CF, operand & (byte)Bits.Bit7);
this.CC = SetBit(this.CC, StatusBits.VF, (operand & (byte)Bits.Bit7) >> 7 ^ (operand & (byte)Bits.Bit6) >> 6);
var result = (byte)(operand << 1 | carryIn);
@@ -2025,7 +2041,7 @@ namespace MC6809
private byte RotateRight(byte operand)
{
var carryIn = this.Carry;
var carryIn = this.CarryFlag;
this.CC = SetBit(this.CC, StatusBits.CF, operand & (byte)Bits.Bit0);
var result = (byte)(operand >> 1 | carryIn << 7);
this.CC = this.AdjustNZ(result);
@@ -2047,7 +2063,7 @@ namespace MC6809
private void SBCA() => this.A = this.SubtractWithCarry(this.A);
private void SBCB() => this.B = this.SubtractWithCarry(this.B);
private byte SubtractWithCarry(byte operand) => this.Subtract(operand, this.Bus.Data, (byte)this.Carry);
private byte SubtractWithCarry(byte operand) => this.Subtract(operand, this.Bus.Data, (byte)this.CarryFlag);
private void SUBA() => this.A = this.Subtract(this.A);
private void SUBB() => this.B = this.Subtract(this.B);