Implementing the STX

This commit is contained in:
AnonymusRaccoon
2020-02-13 14:05:47 +01:00
parent 4d30a35620
commit 997bb4fa7c
4 changed files with 41 additions and 1 deletions
+4
View File
@@ -236,6 +236,10 @@ namespace ComSquare::CPU
case Instructions::STA_SR: this->STA(this->_getStackRelativeAddr()); return 4 + !this->_registers.p.m;
case Instructions::STA_SRYi: this->STA(this->_getStackRelativeIndirectIndexedYAddr()); return 7 + !this->_registers.p.m;
case Instructions::STX_ABS: this->STX(this->_getAbsoluteAddr()); return 4 + !this->_registers.p.m;
case Instructions::STX_DP: this->STX(this->_getAbsoluteAddr()); return 3 + !this->_registers.p.m + this->_registers.dl != 0;
case Instructions::STX_DPY: this->STX(this->_getAbsoluteAddr()); return 4 + !this->_registers.p.m + this->_registers.dl != 0;
default:
throw InvalidOpcode("CPU", opcode);
}
+7 -1
View File
@@ -218,7 +218,11 @@ namespace ComSquare::CPU
STA_DPYi = 0x91,
STA_DPYil = 0x97,
STA_SR = 0x83,
STA_SRYi = 0x93
STA_SRYi = 0x93,
STX_ABS = 0x8E,
STX_DP = 0x86,
STX_DPY = 0x96
};
//! @brief The main CPU
@@ -305,6 +309,8 @@ namespace ComSquare::CPU
void ADC(uint24_t valueAddr);
//! @brief Store the accumulator to memory.
void STA(uint24_t addr);
//! @brief Store the index register X to memory.
void STX(uint24_t addr);
public:
explicit CPU(std::shared_ptr<Memory::MemoryBus> bus, Cartridge::Header &cartridgeHeader);
//! @brief This function continue to execute the Cartridge code.
@@ -15,4 +15,14 @@ namespace ComSquare::CPU
this->_bus->write(addr + 1, this->_registers.ah);
}
}
void CPU::STX(uint24_t addr)
{
if (this->_registers.p.x_b)
this->_bus->write(addr, this->_registers.xl);
else {
this->_bus->write(addr, this->_registers.xl);
this->_bus->write(addr + 1, this->_registers.xh);
}
}
}