|
|
|
@ -12,7 +12,15 @@
|
|
|
|
|
struct CPUTest { |
|
|
|
|
CPU cpu { 0 }; |
|
|
|
|
|
|
|
|
|
bool isCarry(uint32_t lhs, uint32_t rhs, uint32_t limit_bit) { return cpu.isCarry(lhs, rhs, limit_bit); } |
|
|
|
|
bool isCarry(uint32_t limit_bit, uint32_t first, uint32_t second, uint32_t third = 0x0) |
|
|
|
|
{ |
|
|
|
|
return cpu.isCarry(limit_bit, first, second, third); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool isCarrySubtraction(uint32_t limit_bit, uint32_t lhs, uint32_t rhs, uint32_t rhs_extra = 0x0) |
|
|
|
|
{ |
|
|
|
|
return cpu.isCarrySubtraction(limit_bit, lhs, rhs, rhs_extra); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
@ -23,27 +31,27 @@ TEST_CASE(CPUIsCarry)
|
|
|
|
|
|
|
|
|
|
// 8-bit Half-carry false
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(test.isCarry(56, 17, 0x10), false); |
|
|
|
|
EXPECT(test.isCarry(0xf, 56, 17) == false); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(test.isCarry(16, -1, 0x10), false); |
|
|
|
|
EXPECT_EQ(test.isCarry(32, -1, 0x10), false); |
|
|
|
|
EXPECT_EQ(test.isCarry(144, -1, 0x10), false); |
|
|
|
|
EXPECT_EQ(test.isCarry(211, -20, 0x10), false); |
|
|
|
|
EXPECT(test.isCarrySubtraction(0xf, 136, 1) == false); |
|
|
|
|
EXPECT(test.isCarrySubtraction(0xf, 219, 20) == false); |
|
|
|
|
EXPECT(test.isCarrySubtraction(0xf, 250, 20) == false); |
|
|
|
|
|
|
|
|
|
// 8-bit Half-carry true
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(test.isCarry(46, 34, 0x10), true); |
|
|
|
|
EXPECT_EQ(test.isCarry(62, 34, 0x10), true); |
|
|
|
|
EXPECT(test.isCarry(0xf, 46, 34) == true); |
|
|
|
|
EXPECT(test.isCarry(0xf, 62, 34) == true); |
|
|
|
|
|
|
|
|
|
EXPECT_EQ(test.isCarry(136, -1, 0x10), true); |
|
|
|
|
EXPECT_EQ(test.isCarry(219, -20, 0x10), true); |
|
|
|
|
EXPECT_EQ(test.isCarry(250, -20, 0x10), true); |
|
|
|
|
EXPECT(test.isCarrySubtraction(0xf, 16, 1) == true); |
|
|
|
|
EXPECT(test.isCarrySubtraction(0xf, 32, 1) == true); |
|
|
|
|
EXPECT(test.isCarrySubtraction(0xf, 144, 1) == true); |
|
|
|
|
EXPECT(test.isCarrySubtraction(0xf, 211, 20) == true); |
|
|
|
|
|
|
|
|
|
// 8-bit Full carry false
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(test.isCarry(254, 1, 0x100), false); |
|
|
|
|
EXPECT(test.isCarry(0xff, 254, 1) == false); |
|
|
|
|
|
|
|
|
|
// 8-bit Full carry true
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(test.isCarry(254, 2, 0x100), true); |
|
|
|
|
EXPECT(test.isCarry(0xff, 254, 2) == true); |
|
|
|
|
} |
|
|
|
|