1 #include "../Iinstr.hpp"
3 class Cstackop : public Iinstr {
9 std::string toString();
14 * Name: create_instruction
15 * Purpose: if compiled as shared library, this functions creates the
18 * Returns: pointer to instruction object
20 extern "C" Iinstr* create_instruction() {
21 return new Cstackop();
24 Iinstr* Cstackop::getNew()
26 return new Cstackop();
29 * Name: destroy_instruction
30 * Purpose: if compiled as shared library, this functions destoys the
33 * Parameter: IInstruction - the instruction object to delete
35 extern "C" void destroy_instruction(Iinstr* p) {
39 Cstackop::Cstackop() : m_typ(0)
45 void Cstackop::evalInstr()
49 dynamic_bitset<> type = argbits;
51 this->m_typ = type.to_ulong();
67 cerr << "What have you done? 2 bits that have more than 4 values?!" << endl;
71 m_rd = this->getRegister(argbits);
74 void Cstackop::execInstr()
76 CDat sp = this->m_cpu->getStack();
81 this->m_cpu->setRegister(m_rd, this->m_cpu->getRAM(sp));
87 this->m_cpu->setRegister(m_rd, this->m_cpu->getRAM(sp));
90 this->m_cpu->setRAM(sp, this->m_cpu->getRegister(m_rd));
94 cerr << "What have you done? 2 bits that have more than 4 values?!" << endl;
97 this->m_cpu->setStack(sp);
100 std::string Cstackop::toString()
103 op << this->getName();
105 op << this->getConditionFlag();