1 #include "../Iinstr.hpp"
3 class Csubi : 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* Csubi::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 Csubi::evalInstr()
46 this->m_s = argbits[2];
47 this->m_c = argbits[1];
48 this->m_d = argbits[0];
51 dynamic_bitset<> immb = argbits;
53 this->m_imm = this->generate12ImmSign(immb.to_ulong());
56 m_ra = this->getRegister(argbits);
59 m_rd = this->getRegister(argbits);
62 void Csubi::execInstr()
64 //cout << "should exec " << this->toString() << endl;
65 CDat reg = this->m_cpu->getRegister(m_ra) - this->m_imm;
66 this->m_cpu->setRegister(m_rd, reg);
67 this->m_cpu->updateFlags(reg);
70 std::string Csubi::toString()
73 op << this->getName();
79 op << this->getConditionFlag() << " r" << m_rd << ", r" << m_ra << ", " << m_imm;