1 #include "../Iinstr.hpp"
3 class Cbranchreg : public Iinstr {
11 std::string toString();
16 * Name: create_instruction
17 * Purpose: if compiled as shared library, this functions creates the
20 * Returns: pointer to instruction object
22 extern "C" Iinstr* create_instruction() {
23 return new Cbranchreg();
26 Iinstr* Cbranchreg::getNew()
28 return new Cbranchreg();
31 * Name: destroy_instruction
32 * Purpose: if compiled as shared library, this functions destoys the
35 * Parameter: IInstruction - the instruction object to delete
37 extern "C" void destroy_instruction(Iinstr* p) {
41 Cbranchreg::Cbranchreg() : m_taken(1), m_typ(0)
47 void Cbranchreg::evalInstr()
51 dynamic_bitset<> type = argbits;
53 this->m_typ = type.to_ulong();
63 cerr << "What have you done? 1 bits that have more than 2 values?!" << endl;
67 m_rd = this->getRegister(argbits);
70 void Cbranchreg::execInstr()
72 //cout << "should exec " << this->toString() << endl;
73 CDat pc = this->m_cpu->getRegister(this->m_rd);
75 if(this->m_typ == 1) {
76 CDat sp = this->m_cpu->getStack();
78 this->m_cpu->setRAM(sp, this->m_cpu->getCurPC());
79 this->m_cpu->setStack(sp);
81 this->m_cpu->setNextPC(pc);
84 std::string Cbranchreg::toString()
87 op << this->getName();
89 op << this->getConditionFlag();