1 #include "../Iinstr.hpp"
3 class Cadd : 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* Cadd::getNew() {
28 * Name: destroy_instruction
29 * Purpose: if compiled as shared library, this functions destoys the
32 * Parameter: IInstruction - the instruction object to delete
34 extern "C" void destroy_instruction(Iinstr* p) {
44 void Cadd::evalInstr()
46 this->m_d = argbits[0];
47 this->m_c = argbits[1];
50 m_rb = this->getRegister(argbits);
53 m_ra = this->getRegister(argbits);
56 m_rd = this->getRegister(argbits);
59 void Cadd::execInstr()
61 //cout << "should exec " << this->toString() << endl;
62 CDat ra = this->m_cpu->getRegister(m_ra);
63 CDat rb = this->m_cpu->getRegister(m_rb);
65 this->m_cpu->setRegister(m_rd, val);
67 this->m_cpu->updateFlags(val, ra, rb);
71 std::string Cadd::toString()
74 op << this->getName();
79 op << " r" << m_rd << ", r" << m_ra << ", r" << m_rb;