#include "../Iinstr.hpp" class Ccmp : public Iinstr { public: Ccmp(); 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 Ccmp(); } Iinstr* Ccmp::getNew() { return new Ccmp(); } /** * 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; } Ccmp::Ccmp() { opcode = B5(11000); name = "cmp"; } void Ccmp::evalInstr() { argbits >>= 15; m_rb = this->getRegister(argbits); argbits >>= 4; m_ra = this->getRegister(argbits); } void Ccmp::execInstr() { //cout << "should exec " << this->toString() << endl; CDat ra = this->m_cpu->getRegister(m_ra); CDat rb = this->m_cpu->getRegister(m_rb); CDatd val = ra - rb; this->m_cpu->updateFlags(val, ra, rb); } std::string Ccmp::toString() { stringstream op; op << this->getName(); op << " r" << m_ra << ", r" << m_rb; return op.str(); }