tests - Add test_cpu_prefix
This commit is contained in:
parent
50cac936b9
commit
a9b0b37a2e
1 changed files with 39 additions and 0 deletions
39
tests/test_cpu_prefix.cpp
Normal file
39
tests/test_cpu_prefix.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#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);
|
||||
}
|
Loading…
Reference in a new issue