Files
ComSquare/sources/APU/Instructions/DecimalCompensation.cpp
Melefo 2776be601e Adding 8-bit Increment & Decrement Operations
Creating a generic function to set Negative and Zero flags with a value
2020-02-26 13:12:42 +01:00

34 lines
824 B
C++

//
// Created by Melefo on 25/02/2020.
//
#include "../APU.hpp"
namespace ComSquare::APU
{
int APU::DAA()
{
if (this->_internalRegisters.c || this->_internalRegisters.a > 0x99) {
this->_internalRegisters.c = true;
this->_internalRegisters.a += 0x60;
}
if (this->_internalRegisters.h || (this->_internalRegisters.a & 0x0Fu) > 0x09) {
this->_internalRegisters.a += 0x06;
}
this->_setNZflags(this->_internalRegisters.a);
return 3;
}
int APU::DAS()
{
if (!this->_internalRegisters.c || this->_internalRegisters.a > 0x99) {
this->_internalRegisters.c = false;
this->_internalRegisters.a -= 0x60;
}
if (!this->_internalRegisters.h || (this->_internalRegisters.a & 0x0Fu) > 0x09) {
this->_internalRegisters.a -= 0x06;
}
this->_setNZflags(this->_internalRegisters.a);
return 3;
}
}