1 #include "../Iinstr.hpp"
3 class Caddi : public Iinstr {
8 std::string toString();
13 * Name: create_instruction
14 * Purpose: if compiled as shared library, this functions creates the
17 * Returns: pointer to instruction object
19 extern "C" Iinstr* create_instruction() {
23 Iinstr* Caddi::getNew() {
29 * Name: destroy_instruction
30 * Purpose: if compiled as shared library, this functions destoys the
33 * Parameter: IInstruction - the instruction object to delete
35 extern "C" void destroy_instruction(Iinstr* p) {
45 void Caddi::evalInstr()
47 this->m_s = argbits[2];
48 this->m_c = argbits[1];
49 this->m_d = argbits[0];
52 dynamic_bitset<> immb = argbits;
54 this->m_imm = this->generate12ImmSign(immb.to_ulong());
57 m_ra = this->getRegister(argbits);
60 m_rd = this->getRegister(argbits);
63 void Caddi::execInstr()
65 //cout << "should exec " << this->toString() << endl;
66 CDat ra = this->m_cpu->getRegister(m_ra);
67 CDatd reg = ra + this->m_imm;
68 this->m_cpu->setRegister(m_rd, reg);
70 this->m_cpu->updateFlags(reg, ra, this->m_imm);
74 std::string Caddi::toString()
77 op << this->getName();
83 op << this->getConditionFlag() << " r" << m_rd << ", r" << m_ra << ", " << m_imm;