mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-25 15:39:28 +00:00
Adding indexed direct and absolute addressing modes
This commit is contained in:
@@ -202,4 +202,59 @@ Test(AddrMode, ProgramCounterRelativeLongNegative)
|
||||
auto addr = pair.second.cpu->_getProgramCounterRelativeLongAddr();
|
||||
cr_assert_eq(addr, 0x806B00, "Returned address was %x but was expecting 0x806B00.", addr);
|
||||
cr_assert_eq(pair.second.cpu->_registers.pac, 0x808012);
|
||||
}
|
||||
|
||||
Test(AddrMode, AbsoluteIndirect)
|
||||
{
|
||||
auto pair = Init();
|
||||
pair.second.cpu->_registers.pac = 0x808000;
|
||||
pair.second.cartridge->_data[0] = 0xAB;
|
||||
pair.second.cartridge->_data[1] = 0x01;
|
||||
pair.second.wram->_data[0x01AB] = 0xEF;
|
||||
pair.second.wram->_data[0x01AC] = 0x01;
|
||||
auto addr = pair.second.cpu->_getAbsoluteIndirectAddr();
|
||||
cr_assert_eq(addr, 0x01EF, "Returned address was %x but was expecting 0x01EF.", addr);
|
||||
cr_assert_eq(pair.second.cpu->_registers.pac, 0x808002);
|
||||
}
|
||||
|
||||
Test(AddrMode, AbsoluteIndexedIndirect)
|
||||
{
|
||||
auto pair = Init();
|
||||
pair.second.cpu->_registers.pac = 0x808000;
|
||||
pair.second.cartridge->_data[0] = 0xAB;
|
||||
pair.second.cartridge->_data[1] = 0x01;
|
||||
pair.second.cpu->_registers.x = 2;
|
||||
pair.second.wram->_data[0x01AD] = 0xEF;
|
||||
pair.second.wram->_data[0x01AE] = 0x01;
|
||||
auto addr = pair.second.cpu->_getAbsoluteIndexedIndirectAddr();
|
||||
cr_assert_eq(addr, 0x01EF, "Returned address was %x but was expecting 0x01EF.", addr);
|
||||
cr_assert_eq(pair.second.cpu->_registers.pac, 0x808002);
|
||||
}
|
||||
|
||||
Test(AddrMode, DirectIndirect)
|
||||
{
|
||||
auto pair = Init();
|
||||
pair.second.cpu->_registers.pac = 0x808000;
|
||||
pair.second.cartridge->_data[0] = 0x01;
|
||||
pair.second.cpu->_registers.d = 0x1010;
|
||||
pair.second.wram->_data[0x1011] = 0xEF;
|
||||
pair.second.wram->_data[0x1012] = 0x01;
|
||||
pair.second.cpu->_registers.dbr = 0x88;
|
||||
auto addr = pair.second.cpu->_getDirectIndirectAddr();
|
||||
cr_assert_eq(addr, 0x8801EF, "Returned address was %x but was expecting 0x8801EF.", addr);
|
||||
cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
|
||||
}
|
||||
|
||||
Test(AddrMode, DirectIndirectLong)
|
||||
{
|
||||
auto pair = Init();
|
||||
pair.second.cpu->_registers.pac = 0x808000;
|
||||
pair.second.cartridge->_data[0] = 0x06;
|
||||
pair.second.cpu->_registers.d = 0x1010;
|
||||
pair.second.wram->_data[0x1016] = 0xEF;
|
||||
pair.second.wram->_data[0x1017] = 0x01;
|
||||
pair.second.wram->_data[0x1018] = 0x88;
|
||||
auto addr = pair.second.cpu->_getDirectIndirectLongAddr();
|
||||
cr_assert_eq(addr, 0x8801EF, "Returned address was %x but was expecting 0x8801EF.", addr);
|
||||
cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
|
||||
}
|
||||
Reference in New Issue
Block a user