mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-04 02:36:03 +00:00
Implementing the XBA
This commit is contained in:
+3
-1
@@ -417,6 +417,8 @@ namespace ComSquare::CPU
|
||||
int TYX(uint24_t, AddressingMode);
|
||||
//! @brief Test and Set Memory Bits Against Accumulator
|
||||
int TSB(uint24_t, AddressingMode);
|
||||
//! @brief Exchange the B and A Accumulators
|
||||
int XBA(uint24_t, AddressingMode);
|
||||
|
||||
//! @brief All the instructions of the CPU.
|
||||
//! @info Instructions are indexed by their opcode
|
||||
@@ -656,7 +658,7 @@ namespace ComSquare::CPU
|
||||
{&CPU::INX, 2, "inx", AddressingMode::Implied, 1}, // E8
|
||||
{&CPU::SBC, 2, "sbc", AddressingMode::ImmediateForA, 2}, // E9
|
||||
{&CPU::NOP, 2, "nop", AddressingMode::Implied, 1}, // EA
|
||||
{&CPU::BRK, 7, "xba #-#", AddressingMode::Implied, 2}, // EB
|
||||
{&CPU::XBA, 3, "xba", AddressingMode::Implied, 1}, // EB
|
||||
{&CPU::CPX, 4, "cpx", AddressingMode::Absolute, 3}, // EC
|
||||
{&CPU::SBC, 4, "sbc", AddressingMode::Absolute, 3}, // ED
|
||||
{&CPU::INC, 6, "inc", AddressingMode::Absolute, 3}, // EE
|
||||
|
||||
@@ -398,4 +398,14 @@ namespace ComSquare::CPU
|
||||
}
|
||||
return cycles;
|
||||
}
|
||||
|
||||
int CPU::XBA(uint24_t, AddressingMode)
|
||||
{
|
||||
int tmp = this->_registers.ah;
|
||||
this->_registers.ah = this->_registers.al;
|
||||
this->_registers.al = tmp;
|
||||
this->_registers.p.n = this->_registers.al & 0x80u;
|
||||
this->_registers.p.z = this->_registers.al == 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -321,3 +321,23 @@ Test(EOR, zero)
|
||||
cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flags should not be set.");
|
||||
cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flags should be set.");
|
||||
}
|
||||
|
||||
Test(XBA, zero)
|
||||
{
|
||||
Init()
|
||||
snes.cpu->_registers.a = 0x0001;
|
||||
snes.cpu->XBA(0x0, ComSquare::CPU::AddressingMode::Implied);
|
||||
cr_assert_eq(snes.cpu->_registers.a, 0x0100, "The accumulator's value should be 0x0100 but it was 0x%x.", snes.cpu->_registers.a);
|
||||
cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flags should not be set.");
|
||||
cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flags should be set.");
|
||||
}
|
||||
|
||||
Test(XBA, negative)
|
||||
{
|
||||
Init()
|
||||
snes.cpu->_registers.a = 0x8001;
|
||||
snes.cpu->XBA(0x0, ComSquare::CPU::AddressingMode::Implied);
|
||||
cr_assert_eq(snes.cpu->_registers.a, 0x0180, "The accumulator's value should be 0x0180 but it was 0x%x.", snes.cpu->_registers.a);
|
||||
cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flags should be set.");
|
||||
cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should be not set.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user