X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=3c_disasm%2Finstr%2Fandx.cpp;fp=3c_disasm%2Finstr%2Fandx.cpp;h=fed223707d6fd4b77978d7ba2c888cb6a249bd6f;hb=f7afa120e8de972b9afb88125fb7dc49fcfccbbe;hp=0000000000000000000000000000000000000000;hpb=815c827247bc211e4785016985666fbfd201f423;p=calu.git diff --git a/3c_disasm/instr/andx.cpp b/3c_disasm/instr/andx.cpp new file mode 100644 index 0000000..fed2237 --- /dev/null +++ b/3c_disasm/instr/andx.cpp @@ -0,0 +1,84 @@ +#include "../Iinstr.hpp" + + +class Candx : public Iinstr { + public: + Candx(); + 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 Candx(); +} + +Iinstr* Candx::getNew() +{ + return new Candx(); +} +/** + * 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; +} + +Candx::Candx() +{ + opcode = B5(00101); + name = "andx"; +} + +void Candx::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 Candx::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 Candx::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(); +}