de1 toplevel entity and mem-address/regfile fix for add, and, ...
[calu.git] / 3c_disasm / instr / add.cpp
index 7cdf820def5d026441eb02ca3a19d29d3fd7780b..a6967e490999e48a3a44366f337472a3c1c55454 100644 (file)
@@ -6,6 +6,7 @@ class Cadd : public Iinstr {
                void evalInstr();
                void execInstr();
                std::string toString();
+               Iinstr* getNew();
 };
 
 /**
@@ -19,6 +20,10 @@ extern "C" Iinstr* create_instruction() {
     return new Cadd();
 }
 
+Iinstr* Cadd::getNew() {
+       return new Cadd();
+}
+
 /**
  * Name:      destroy_instruction
  * Purpose:   if compiled as shared library, this functions destoys the 
@@ -53,7 +58,14 @@ void Cadd::evalInstr()
 
 void Cadd::execInstr()
 {
-       cout << "should exec" << this->toString() << endl;
+       //cout << "should exec " << this->toString() << endl;
+       CDat ra = this->m_cpu->getRegister(m_ra);
+       CDat rb = this->m_cpu->getRegister(m_rb);
+       CDatd val = ra + rb;
+       this->m_cpu->setRegister(m_rd, val);
+       if(!this->m_d) {
+               this->m_cpu->updateFlags(val, ra, rb);
+       }
 }
 
 std::string Cadd::toString()
@@ -64,6 +76,6 @@ std::string Cadd::toString()
        if(m_d) op << 'D';
        if(m_c) op << 'C';
 
-       op << " r" << m_rd << ", r" << m_ra << ", r" << m_rb;
+       op << this->getConditionFlag() << " r" << m_rd << ", r" << m_ra << ", r" << m_rb;
        return op.str();
 }