#include "../Iinstr.hpp" class Cxorx : public Iinstr { public: Cxorx(); 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 Cxorx(); } Iinstr* Cxorx::getNew() { return new Cxorx(); } /** * 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; } Cxorx::Cxorx() { opcode = B5(01001); name = "xorx"; } void Cxorx::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 Cxorx::execInstr() { CDat val = this->m_cpu->getRegister(this->m_rd); CDat imm = generate16ImmFill(this->m_imm); val ^= imm; this->m_cpu->setRegister(this->m_rd, val); if(!this->m_d) { this->m_cpu->updateFlags(val); } } std::string Cxorx::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(); }