mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 22:25:11 +00:00
Finishing Program Flow Operations
This commit is contained in:
@@ -8,7 +8,7 @@ namespace ComSquare::APU
|
||||
{
|
||||
int APU::BRA()
|
||||
{
|
||||
int8_t offset = this->_internalRead(this->_internalRegisters.pc++);
|
||||
int8_t offset = this->_getDirectValue();
|
||||
|
||||
this->_internalRegisters.pc += offset;
|
||||
return 4;
|
||||
@@ -77,4 +77,61 @@ namespace ComSquare::APU
|
||||
this->BRA();
|
||||
return 4;
|
||||
}
|
||||
|
||||
int APU::BBS(uint24_t addr, uint8_t bit)
|
||||
{
|
||||
uint8_t data = this->_internalRead(addr);
|
||||
|
||||
if (!(data & (1u << bit)))
|
||||
return 5;
|
||||
this->BRA();
|
||||
return 7;
|
||||
}
|
||||
|
||||
int APU::BBC(uint24_t addr, uint8_t bit)
|
||||
{
|
||||
uint8_t data = this->_internalRead(addr);
|
||||
|
||||
if (data & (1u << bit))
|
||||
return 5;
|
||||
this->BRA();
|
||||
return 7;
|
||||
}
|
||||
|
||||
int APU::CBNE(uint24_t addr, bool by_x)
|
||||
{
|
||||
uint8_t data = this->_internalRead(addr);
|
||||
|
||||
if (this->_internalRegisters.a == data)
|
||||
return 5 + by_x;
|
||||
this->BRA();
|
||||
return 7 + by_x;
|
||||
}
|
||||
|
||||
int APU::DBNZ(bool direct_addr)
|
||||
{
|
||||
uint8_t data;
|
||||
|
||||
if (direct_addr) {
|
||||
uint24_t addr = this->_getDirectAddr();
|
||||
|
||||
data = this->_internalRead(addr);
|
||||
this->_internalWrite(addr, --data);
|
||||
}
|
||||
else
|
||||
data = --this->_internalRegisters.y;
|
||||
if (!data)
|
||||
return 4 + direct_addr;
|
||||
this->BRA();
|
||||
return 6 + direct_addr;
|
||||
}
|
||||
|
||||
int APU::JMP(uint24_t addr, bool by_x)
|
||||
{
|
||||
this->_internalRegisters.pc = addr;
|
||||
if (by_x)
|
||||
return 6;
|
||||
else
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user