40 lines
670 B
C++
40 lines
670 B
C++
|
#include "doctest.h"
|
||
|
|
||
|
#include "cpu/cpu.h"
|
||
|
#include "memory/ram.h"
|
||
|
|
||
|
TEST_CASE("Bit set, clear and test")
|
||
|
{
|
||
|
u8 test_ram[] = {
|
||
|
0xCB, 0xD7, // SET 2, A
|
||
|
0xCB, 0x57, // BIT 2, A
|
||
|
0xCB, 0x97, // RES 2, A
|
||
|
0xCB, 0x57, // BIT 2, A
|
||
|
};
|
||
|
RAM r(test_ram, 0x8, true);
|
||
|
Cpu cpu(&r);
|
||
|
|
||
|
CHECK(cpu.state.PC == 0x00);
|
||
|
CHECK(cpu.state.A == 0b00000000);
|
||
|
|
||
|
cpu.step();
|
||
|
|
||
|
CHECK(cpu.state.PC == 0x02);
|
||
|
CHECK(cpu.state.A == 0b00000100);
|
||
|
|
||
|
cpu.step();
|
||
|
|
||
|
CHECK(cpu.state.PC == 0x04);
|
||
|
CHECK(!cpu.state.zero);
|
||
|
|
||
|
cpu.step();
|
||
|
|
||
|
CHECK(cpu.state.PC == 0x06);
|
||
|
CHECK(cpu.state.A == 0b00000000);
|
||
|
|
||
|
cpu.step();
|
||
|
|
||
|
CHECK(cpu.state.PC == 0x08);
|
||
|
CHECK(cpu.state.zero);
|
||
|
}
|