Adding the AND instruction

This commit is contained in:
AnonymusRaccoon
2020-02-20 18:32:21 +01:00
parent 52b5a6ba23
commit 91150dfbc1
5 changed files with 108 additions and 3 deletions
@@ -0,0 +1,21 @@
//
// Created by anonymus-raccoon on 2/20/20.
//
#include "../../Models/Int24.hpp"
#include "../CPU.hpp"
namespace ComSquare::CPU
{
void CPU::AND(uint24_t valueAddr)
{
unsigned negativeMask = this->_isEmulationMode ? 0x80u : 0x8000u;
unsigned value = this->_bus->read(valueAddr);
if (this->_registers.p.m)
value += this->_bus->read(valueAddr + 1) << 8u;
this->_registers.a &= value;
this->_registers.p.n = this->_registers.a & negativeMask;
this->_registers.p.z = this->_registers.a == 0;
}
}