Implementing the REP instruction

This commit is contained in:
AnonymusRaccoon
2020-02-14 11:22:38 +01:00
parent fbd10e8f48
commit 31aa3c843e
4 changed files with 61 additions and 4 deletions
+2
View File
@@ -279,6 +279,8 @@ namespace ComSquare::CPU
case Instructions::SEP: this->SEP(this->_getImmediateAddr()); return 3;
case Instructions::REP: this->REP(this->_getImmediateAddr()); return 3;
default:
throw InvalidOpcode("CPU", opcode);
}
+6 -2
View File
@@ -260,7 +260,9 @@ namespace ComSquare::CPU
LDY_ABSY = 0xBC,
LDY_DPY = 0xB4,
SEP = 0xE2
SEP = 0xE2,
REP = 0xC2
};
//! @brief The main CPU
@@ -360,7 +362,9 @@ namespace ComSquare::CPU
//! @brief Load the Y index register from memory.
void LDY(uint24_t addr);
//! @brief Set status bits.
void SEP(uint24_t addr);
void SEP(uint24_t valueAddr);
//! @brief Reset status bits.
void REP(uint24_t valueAddr);
public:
explicit CPU(std::shared_ptr<Memory::MemoryBus> bus, Cartridge::Header &cartridgeHeader);
CPU(const CPU &) = default;
@@ -6,8 +6,17 @@
namespace ComSquare::CPU
{
void CPU::SEP(uint24_t addr)
void CPU::SEP(uint24_t valueAddr)
{
this->_registers.p.flags |= this->_bus->read(addr);
this->_registers.p.flags |= this->_bus->read(valueAddr);
}
void CPU::REP(uint24_t valueAddr)
{
this->_registers.p.flags &= ~this->_bus->read(valueAddr);
if (this->_isEmulationMode) {
this->_registers.p.x_b = true;
this->_registers.p.m = true;
}
}
}