mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 22:25:11 +00:00
Adding the RTI
This commit is contained in:
@@ -203,6 +203,8 @@ namespace ComSquare::CPU
|
||||
switch (opcode) {
|
||||
case Instructions::BRK: return 7 + this->BRK();
|
||||
|
||||
case Instructions::RTI: return 6 + this->RTI();
|
||||
|
||||
case Instructions::ADC_IM: return 2 + this->ADC(this->_getImmediateAddr());
|
||||
case Instructions::ADC_ABS: return 4 + this->ADC(this->_getAbsoluteAddr());
|
||||
case Instructions::ADC_ABSl: return 5 + this->ADC(this->_getAbsoluteLongAddr());
|
||||
|
||||
@@ -187,6 +187,7 @@ namespace ComSquare::CPU
|
||||
enum Instructions
|
||||
{
|
||||
BRK = 0x00,
|
||||
RTI = 0x40,
|
||||
|
||||
ADC_DPXi = 0x61,
|
||||
ADC_SR = 0x63,
|
||||
@@ -282,6 +283,8 @@ namespace ComSquare::CPU
|
||||
unsigned RESB();
|
||||
//! @brief Break instruction - Causes a software break. The PC is loaded from a vector table.
|
||||
unsigned BRK();
|
||||
//! @brief Return from Interrupt - Used to return from a interrupt handler.
|
||||
unsigned RTI();
|
||||
//! @brief Add with carry - Adds operand to the Accumulator; adds an additional 1 if carry is set.
|
||||
//! @return The number of extra cycles that this operation took.
|
||||
unsigned ADC(uint24_t valueAddr);
|
||||
|
||||
@@ -35,4 +35,16 @@ namespace ComSquare::CPU
|
||||
this->_registers.p.d = false;
|
||||
return !this->_isEmulationMode;
|
||||
}
|
||||
|
||||
unsigned CPU::RTI()
|
||||
{
|
||||
this->_registers.p.flags = this->pop();
|
||||
this->_registers.pc = this->pop16();
|
||||
|
||||
if (!this->_isEmulationMode) {
|
||||
this->_registers.pbr = this->pop16();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user