#include "../Iinstr.hpp" class Cldw : public Iinstr { public: Cldw(); 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 Cldw(); } Iinstr* Cldw::getNew() { return new Cldw(); } /** * 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; } Cldw::Cldw() { opcode = B5(01110); name = "ldw"; } void Cldw::evalInstr() { this->m_s = true; dynamic_bitset<> immb = argbits; immb.resize(15); this->m_imm = this->generate15ImmSign(immb.to_ulong()); argbits >>= 15; m_ra = this->getRegister(argbits); argbits >>= 4; m_rd = this->getRegister(argbits); } void Cldw::execInstr() { cout << "should exec " << this->toString() << endl; CDat val = this->m_cpu->getRegister(this->m_ra); val += m_imm; val = this->m_cpu->getRAM(val); this->m_cpu->setRegister(this->m_rd,val); } std::string Cldw::toString() { stringstream op; op << this->getName(); op << this->getConditionFlag() << " r" << m_rd << ", " << m_imm << "(r" << m_ra << ")"; return op.str(); }