X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=3c_disasm%2Finstr%2Fmovf.cpp;fp=3c_disasm%2Finstr%2Fmovf.cpp;h=d2c0a3558fd03a44566302fe7b438385bb9414f0;hb=69964280107c6139062349844f99ef80bc6f68be;hp=0000000000000000000000000000000000000000;hpb=bdac0a3a362e151f65cc32364f5120e28ce32314;p=calu.git diff --git a/3c_disasm/instr/movf.cpp b/3c_disasm/instr/movf.cpp new file mode 100644 index 0000000..d2c0a35 --- /dev/null +++ b/3c_disasm/instr/movf.cpp @@ -0,0 +1,79 @@ +#include "../Iinstr.hpp" + +class Cmovf : public Iinstr { + private: + bool m_type; + public: + Cmovf(); + 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 Cmovf(); +} + +Iinstr* Cmovf::getNew() { + return new Cmovf(); +} + +/** + * 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; +} + +Cmovf::Cmovf() : m_type(0) +{ + opcode = B5(01100); + name = "movf"; +} + +void Cmovf::evalInstr() +{ + this->m_type = argbits[18]; + if(this->m_type) { + name = "movpf"; + } + else { + name = "movsf"; + } + + argbits >>= 19; + m_rd = this->getRegister(argbits); +} + +void Cmovf::execInstr() +{ + //cout << "should exec " << this->toString() << endl; + CDat val; + if(this->m_type) { + val = this->m_cpu->getFlags(); + } + else { + val = this->m_cpu->getStack(); + } + this->m_cpu->setRegister(this->m_rd, val); +} + +std::string Cmovf::toString() +{ + stringstream op; + op << this->getName(); + op << " r" << m_rd; + return op.str(); +}