Implementing the XCE instruction

This commit is contained in:
Anonymus Raccoon
2020-02-25 23:05:15 +01:00
parent 8dbaea89ed
commit 4da96894ae
5 changed files with 56 additions and 1 deletions
+33
View File
@@ -461,4 +461,37 @@ Test(SED, set)
pair.second.cpu->_registers.p.flags = 0x00;
pair.second.cpu->SED();
cr_assert_eq(pair.second.cpu->_registers.p.d, true, "The decimal flag should be set");
}
Test(XCE, enableEmulation)
{
auto pair = Init();
pair.second.cpu->_isEmulationMode = false;
pair.second.cpu->_registers.p.flags = 0;
pair.second.cpu->_registers.p.c = true;
pair.second.cpu->_registers.xh = 0xFF;
pair.second.cpu->_registers.yh = 0xFF;
pair.second.cpu->XCE();
cr_assert_eq(pair.second.cpu->_isEmulationMode, true, "The e flag should be set");
cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flag should not be set");
cr_assert_eq(pair.second.cpu->_registers.p.m, false, "The memory width flag should be untouched (unset)");
cr_assert_eq(pair.second.cpu->_registers.p.x_b, false, "The index width flag should be untouched (unset)");
cr_assert_eq(pair.second.cpu->_registers.xh, 0xFF, "The high byte of the x index flag should be untouched (0xFF)");
cr_assert_eq(pair.second.cpu->_registers.yh, 0xFF, "The high byte of the y index flag should be untouched (0xFF)");
}
Test(XCE, enableNative)
{
auto pair = Init();
pair.second.cpu->_isEmulationMode = true;
pair.second.cpu->_registers.p.flags = 0;
pair.second.cpu->_registers.xh = 0xFF;
pair.second.cpu->_registers.yh = 0xFF;
pair.second.cpu->XCE();
cr_assert_eq(pair.second.cpu->_isEmulationMode, false, "The e flag should be not set");
cr_assert_eq(pair.second.cpu->_registers.p.c, true, "The carry flag should be set");
cr_assert_eq(pair.second.cpu->_registers.p.m, true, "The memory width flag should be set");
cr_assert_eq(pair.second.cpu->_registers.p.x_b, true, "The index width flag should be set");
cr_assert_eq(pair.second.cpu->_registers.xh, 0, "The high byte of the x index flag should be set to 0");
cr_assert_eq(pair.second.cpu->_registers.yh, 0, "The high byte of the y index flag should be set to 0");
}