mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-05 19:04:22 +00:00
Finishing Bit operations
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include "../APU.hpp"
|
||||
#include "../../Utility/Utility.hpp"
|
||||
|
||||
namespace ComSquare::APU
|
||||
{
|
||||
@@ -31,4 +32,61 @@ namespace ComSquare::APU
|
||||
this->_internalRegisters.z = !data;
|
||||
return 6;
|
||||
}
|
||||
|
||||
int APU::TCLR1(uint24_t abs)
|
||||
{
|
||||
uint8_t data = this->_internalRead(abs);
|
||||
|
||||
this->_internalWrite(abs, data & ~this->_internalRegisters.a);
|
||||
this->_internalRegisters.n = data & 0x80u;
|
||||
this->_internalRegisters.z = !data;
|
||||
return 6;
|
||||
}
|
||||
|
||||
int APU::AND1(std::pair<uint24_t, uint24_t> operand, bool invert)
|
||||
{
|
||||
if (invert)
|
||||
this->_internalRegisters.c &= ~this->_internalRead(operand.first) & (1u << operand.second);
|
||||
else
|
||||
this->_internalRegisters.c &= this->_internalRead(operand.first) & (1u << operand.second);
|
||||
return 4;
|
||||
}
|
||||
|
||||
int APU::OR1(std::pair<uint24_t, uint24_t> operand, bool invert)
|
||||
{
|
||||
if (invert)
|
||||
this->_internalRegisters.c |= ~this->_internalRead(operand.first) & (1u << operand.second);
|
||||
else
|
||||
this->_internalRegisters.c |= this->_internalRead(operand.first) & (1u << operand.second);
|
||||
return 5;
|
||||
}
|
||||
|
||||
int APU::EOR1(std::pair<uint24_t, uint24_t> operand)
|
||||
{
|
||||
this->_internalRegisters.c ^= this->_internalRead(operand.first) & (1u << operand.second);
|
||||
return 5;
|
||||
}
|
||||
|
||||
int APU::NOT1(std::pair<uint24_t, uint24_t> operand)
|
||||
{
|
||||
this->_internalWrite(operand.first, this->_internalRead(operand.first) ^ (1u << operand.second));
|
||||
return 5;
|
||||
}
|
||||
|
||||
int APU::MOV1(std::pair<uint24_t, uint24_t> operand, bool to_carry)
|
||||
{
|
||||
if (to_carry) {
|
||||
this->_internalRegisters.c = this->_internalRead(operand.first) & (1u << operand.second);
|
||||
return 4;
|
||||
}
|
||||
else {
|
||||
uint24_t mask = (1u << operand.second);
|
||||
|
||||
if (this->_internalRegisters.c)
|
||||
this->_internalWrite(operand.first, this->_internalRead(operand.first) | mask);
|
||||
else
|
||||
this->_internalWrite(operand.first, this->_internalRead(operand.first) & ~mask);
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user