1 #include "../Iinstr.hpp"
3 class Cbranch : public Iinstr {
11 std::string toString();
15 * Name: create_instruction
16 * Purpose: if compiled as shared library, this functions creates the
19 * Returns: pointer to instruction object
21 extern "C" Iinstr* create_instruction() {
26 * Name: destroy_instruction
27 * Purpose: if compiled as shared library, this functions destoys the
30 * Parameter: IInstruction - the instruction object to delete
32 extern "C" void destroy_instruction(Iinstr* p) {
36 Cbranch::Cbranch() : m_taken(1), m_typ(0)
42 void Cbranch::evalInstr()
44 this->m_s = argbits[0];
45 this->m_taken = argbits[1];
49 dynamic_bitset<> type = argbits;
51 this->m_typ = type.to_ulong();
55 this->name = "branch";
67 cerr << "What have you done? 2 bits that have more than 4 values?!" << endl;
72 dynamic_bitset<> immb = argbits;
74 this->m_imm = this->generate16ImmSign(immb.to_ulong());
78 void Cbranch::execInstr()
80 cout << "should exec" << this->toString() << endl;
83 std::string Cbranch::toString()
86 op << this->getName();
90 op << this->getConditionFlag() << (m_taken ? '+' : '-');
92 op << " 0x" << std::hex << m_imm << "(" << std::dec << m_imm << ")";