28 lines
416 B
C++
28 lines
416 B
C++
|
#include "doctest.h"
|
||
|
|
||
|
#include "cpu/cpu.h"
|
||
|
#include "memory/ram.h"
|
||
|
|
||
|
|
||
|
TEST_CASE("simple load and add")
|
||
|
{
|
||
|
u8 test_ram[] = {
|
||
|
0x3E, 0x10, // LD A, $0x10
|
||
|
0x87, // ADD A, A
|
||
|
};
|
||
|
RAM r(test_ram, 3, true);
|
||
|
Cpu cpu(&r);
|
||
|
|
||
|
CHECK(cpu.state.PC == 0x0);
|
||
|
|
||
|
cpu.step();
|
||
|
|
||
|
CHECK(cpu.state.PC == 0x2);
|
||
|
CHECK(cpu.state.A == 0x10);
|
||
|
|
||
|
cpu.step();
|
||
|
|
||
|
CHECK(cpu.state.PC == 0x3);
|
||
|
CHECK(cpu.state.A == 0x20);
|
||
|
}
|