#include "../Iinstr.hpp" class Candx : public Iinstr { public: Candx(); void evalInstr(); void execInstr(); std::string toString(); Iinstr* getNew(); }; /** * Name: create_instruction * Purpose: if compiled as shared library, this functions creates the instruction object * Returns: pointer to instruction object */ extern "C" Iinstr* create_instruction() { return new Candx(); } Iinstr* Candx::getNew() { return new Candx(); } /** * Name: destroy_instruction * Purpose: if compiled as shared library, this functions destoys the instruction object * Parameter: IInstruction - the instruction object to delete */ extern "C" void destroy_instruction(Iinstr* p) { delete p; } Candx::Candx() { opcode = B5(00101); name = "andx"; } void Candx::evalInstr() { this->m_d = argbits[0]; this->m_f = argbits[1]; this->m_hl = argbits[2]; argbits >>= 3; dynamic_bitset<> immb = argbits; immb.resize(16); this->m_imm = this->generate16ImmSign(immb.to_ulong()); argbits >>= 16; m_rd = this->getRegister(argbits); } void Candx::execInstr() { CDat val = this->m_cpu->getRegister(this->m_rd); CDat imm = generate16ImmFill(this->m_imm); if(this->m_hl) { imm <<= 16; } val &= imm; this->m_cpu->setRegister(this->m_rd, val); if(!this->m_d) { this->m_cpu->updateFlags(val); } } std::string Candx::toString() { stringstream op; op << this->getName(); if(m_hl) op << 'H'; if(m_f) op << 'F'; if(m_d) op << 'D'; op << this->getConditionFlag() << " r" << m_rd << ", " << m_imm; return op.str(); }