mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-27 08:11:55 +00:00
Adding PEA
This commit is contained in:
+3
-1
@@ -437,6 +437,8 @@ namespace ComSquare::CPU
|
||||
int PER(uint24_t, AddressingMode);
|
||||
//! @brief Push Effective Indirect Address
|
||||
int PEI(uint24_t, AddressingMode);
|
||||
//! @brief Push Effective Absolute Address
|
||||
int PEA(uint24_t, AddressingMode);
|
||||
|
||||
//! @brief All the instructions of the CPU.
|
||||
//! @info Instructions are indexed by their opcode
|
||||
@@ -685,7 +687,7 @@ namespace ComSquare::CPU
|
||||
{&CPU::SBC, 5, "sbc", AddressingMode::DirectPageIndirectIndexedByY, 2}, // F1
|
||||
{&CPU::SBC, 5, "sbc", AddressingMode::DirectPageIndirect, 2}, // F2
|
||||
{&CPU::SBC, 7, "sbc", AddressingMode::StackRelativeIndirectIndexedByY, 2}, // F3
|
||||
{&CPU::BRK, 7, "pea #-#", AddressingMode::Implied, 2}, // F4
|
||||
{&CPU::PEA, 5, "pea", AddressingMode::Immediate16bits, 3}, // F4
|
||||
{&CPU::SBC, 4, "sbc", AddressingMode::DirectPageIndexedByX, 2}, // F5
|
||||
{&CPU::INC, 6, "inc", AddressingMode::DirectPageIndexedByX, 2}, // F6
|
||||
{&CPU::SBC, 6, "sbc", AddressingMode::DirectPageIndirectIndexedByYLong, 2}, // F7
|
||||
|
||||
@@ -193,6 +193,12 @@ namespace ComSquare::CPU
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CPU::PEA(uint24_t value, AddressingMode)
|
||||
{
|
||||
this->_push(static_cast<uint16_t>(value));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CPU::PEI(uint24_t value, AddressingMode)
|
||||
{
|
||||
this->_push(static_cast<uint16_t>(value));
|
||||
|
||||
@@ -930,12 +930,22 @@ Test(PER, simple)
|
||||
}
|
||||
|
||||
Test(PEI, simple)
|
||||
{
|
||||
Init()
|
||||
snes.cpu->_registers.s = 0x1FFF;
|
||||
snes.cpu->PEI(0xFFFF, ComSquare::CPU::AddressingMode::Implied);
|
||||
cr_assert_eq(snes.cpu->_registers.s, 0x1FFD, "The stack pointer should be equal to 0x1FFD but it was 0x%x.", snes.cpu->_registers.s);
|
||||
uint16_t value = snes.cpu->_pop16();
|
||||
cr_assert_eq(value, 0xFFFF, "The pushed value should be equal to 0xFFFF but it was 0x%x.", value);
|
||||
}
|
||||
|
||||
Test(PEA, simple)
|
||||
{
|
||||
Init()
|
||||
snes.cpu->_registers.s = 0x1FFF;
|
||||
snes.wram->_data[0x0] = 0xFF;
|
||||
snes.wram->_data[0x1] = 0xFF;
|
||||
snes.cpu->PER(0x0, ComSquare::CPU::AddressingMode::Implied);
|
||||
snes.cpu->PEA(0xFFFF, ComSquare::CPU::AddressingMode::Implied);
|
||||
cr_assert_eq(snes.cpu->_registers.s, 0x1FFD, "The stack pointer should be equal to 0x1FFD but it was 0x%x.", snes.cpu->_registers.s);
|
||||
uint16_t value = snes.cpu->_pop16();
|
||||
cr_assert_eq(value, 0xFFFF, "The pushed value should be equal to 0xFFFF but it was 0x%x.", value);
|
||||
|
||||
Reference in New Issue
Block a user