disasm/sim: changed interface, branch => br, features++
[calu.git] / 3c_disasm / Iinstr.hpp
index d590dc70720c2a52dbdb5b41a52580b6414731e9..416db47a869cb6041163165d5e96d968b6477e78 100644 (file)
@@ -1,10 +1,15 @@
+#ifndef __IINSTR_I_
+#define __IINSTR_I_
+
 #include <string>
 #include <boost/dynamic_bitset.hpp>
 #include <iostream>
 #include <sstream>
 
-#ifndef __IINSTR_I_
-#define __IINSTR_I_
+class CCpu;
+
+#include "ccpu.hpp"
+
 
 /* concept from https://groups.google.com/group/comp.arch.embedded/msg/9d430b6d3da12c8f */
 #define to_HEX__(x) 0x##x##LU
@@ -16,6 +21,7 @@
                   +((x & 0xF0000UL) ? 16 : 0) 
 
 #define B5(x) ((unsigned char)to_B5__(to_HEX__(x)))
+/* end concept */
 
 using namespace std;
 using namespace boost;
@@ -107,7 +113,12 @@ class Iinstr {
                        return bits.to_ulong();
                }
 
+               static CCpu* m_cpu;
+
        public:
+
+               static void setCPU(CCpu* cpu) { m_cpu = cpu; }
+
                virtual ~Iinstr() {}
                virtual short getOpcode() { return this->opcode; }
                virtual std::string getName() { return this->name; }
@@ -115,6 +126,11 @@ class Iinstr {
                virtual void evalInstr() = 0;
                virtual void execInstr() = 0;
                virtual std::string toString() = 0;
+               virtual Iinstr* getNew() = 0;
+                       
+               short getCondition() {
+                       return m_cond;
+               }
 
                void decodeCondition(short condition) {
                        if(condition >= 0 && condition <= 15) {
@@ -126,6 +142,7 @@ class Iinstr {
                }
 
        protected:
+
                std::string getConditionFlag()
                {
                        stringstream cond;
@@ -185,4 +202,5 @@ class Iinstr {
                        return cond.str();
                }
 };
+
 #endif