X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=3c_disasm%2Finstr%2Fldi.cpp;fp=3c_disasm%2Finstr%2Fldi.cpp;h=2c523a1f254afdfb77a35edd7d74ce5a0eb9b606;hb=b5f15e1e75a5027fc4eb3d27b0542cb3324ed3a9;hp=0000000000000000000000000000000000000000;hpb=d89f102f95f913e8ca5304d7c544592f5dcb9ec0;p=calu.git diff --git a/3c_disasm/instr/ldi.cpp b/3c_disasm/instr/ldi.cpp new file mode 100644 index 0000000..2c523a1 --- /dev/null +++ b/3c_disasm/instr/ldi.cpp @@ -0,0 +1,70 @@ +#include "../Iinstr.hpp" + + +class Cldi : public Iinstr { + public: + Cldi(); + void evalInstr(); + void execInstr(); + std::string toString(); +}; + +/** + * 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 Cldi(); +} + +/** + * 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; +} + +Cldi::Cldi() +{ + opcode = B5(11010); + name = "ldi"; +} + +void Cldi::evalInstr() +{ + this->m_s = argbits[2]; + this->m_hl = argbits[1]; + + 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 Cldi::execInstr() +{ + cout << "should exec " << this->toString() << endl; +} + +std::string Cldi::toString() +{ + stringstream op; + op << this->getName(); + + if(m_hl) op << 'H'; + if(m_s) op << 'S'; + + op << this->getConditionFlag() << " r" << m_rd << ", " << m_imm; + + return op.str(); +}