mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 22:25:11 +00:00
Adding some Program Flow operations
This commit is contained in:
80
sources/APU/Instructions/ProgramFlow.cpp
Normal file
80
sources/APU/Instructions/ProgramFlow.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// Created by Melefo on 21/02/2020.
|
||||
//
|
||||
|
||||
#include "../APU.hpp"
|
||||
|
||||
namespace ComSquare::APU
|
||||
{
|
||||
int APU::BRA()
|
||||
{
|
||||
int8_t offset = this->_internalRead(this->_internalRegisters.pc++);
|
||||
|
||||
this->_internalRegisters.pc += offset;
|
||||
return 4;
|
||||
}
|
||||
|
||||
int APU::BEQ()
|
||||
{
|
||||
if (!this->_internalRegisters.z)
|
||||
return 2;
|
||||
this->BRA();
|
||||
return 4;
|
||||
}
|
||||
|
||||
int APU::BNE()
|
||||
{
|
||||
if (this->_internalRegisters.z)
|
||||
return 2;
|
||||
this->BRA();
|
||||
return 4;
|
||||
}
|
||||
|
||||
int APU::BCS()
|
||||
{
|
||||
if (!this->_internalRegisters.c)
|
||||
return 2;
|
||||
this->BRA();
|
||||
return 4;
|
||||
}
|
||||
|
||||
int APU::BCC()
|
||||
{
|
||||
if (this->_internalRegisters.c)
|
||||
return 2;
|
||||
this->BRA();
|
||||
return 4;
|
||||
}
|
||||
|
||||
int APU::BVS()
|
||||
{
|
||||
if (!this->_internalRegisters.v)
|
||||
return 2;
|
||||
this->BRA();
|
||||
return 4;
|
||||
}
|
||||
|
||||
int APU::BVC()
|
||||
{
|
||||
if (this->_internalRegisters.v)
|
||||
return 2;
|
||||
this->BRA();
|
||||
return 4;
|
||||
}
|
||||
|
||||
int APU::BMI()
|
||||
{
|
||||
if (!this->_internalRegisters.n)
|
||||
return 2;
|
||||
this->BRA();
|
||||
return 4;
|
||||
}
|
||||
|
||||
int APU::BPL()
|
||||
{
|
||||
if (this->_internalRegisters.n)
|
||||
return 2;
|
||||
this->BRA();
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user