X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=3c_disasm%2FIinstr.hpp;fp=3c_disasm%2FIinstr.hpp;h=2cc17df5e1f4d5093e10a75d4eb5f3b03db25e41;hb=79a8ce96e5f987dfc89f3e8bdd262a9d78f50ed6;hp=d94c88f494e878a22c37f5e4a9aa67eb2baea438;hpb=fb88c4ad2ce96a8b49f4131b2fc88688a5f2982f;p=calu.git diff --git a/3c_disasm/Iinstr.hpp b/3c_disasm/Iinstr.hpp index d94c88f..2cc17df 100644 --- a/3c_disasm/Iinstr.hpp +++ b/3c_disasm/Iinstr.hpp @@ -10,6 +10,10 @@ class CCpu; #include "ccpu.hpp" +class disasm; + +#include "disasm.h" + /* concept from https://groups.google.com/group/comp.arch.embedded/msg/9d430b6d3da12c8f */ #define to_HEX__(x) 0x##x##LU @@ -54,7 +58,8 @@ class Iinstr { CDat m_imm; short m_cond; boost::dynamic_bitset<> argbits; - Iinstr() : opcode(0), name(""), m_ra(0), m_rb(0), m_rd(0), m_c(0), m_d(0), m_hl(0), m_f(0), m_s(0), m_imm(0), m_cond(ALWAYS), argbits(32) {} + CDat hexdump; + Iinstr() : opcode(0), name(""), m_ra(0), m_rb(0), m_rd(0), m_c(0), m_d(0), m_hl(0), m_f(0), m_s(0), m_imm(0), m_cond(ALWAYS), argbits(32), hexdump(0) {} CDat generate16ImmFill(const CDat value) const { CDat i = value; @@ -114,20 +119,24 @@ class Iinstr { } static CCpu* m_cpu; + static disasm* m_disasm; public: static void setCPU(CCpu* cpu) { m_cpu = cpu; } + static void setDisasm(disasm* dasm) { m_disasm = dasm; } virtual ~Iinstr() {} virtual short getOpcode() { return this->opcode; } virtual std::string getName() { return this->name; } - virtual void loadBits(boost::dynamic_bitset<> bits) { argbits = bits; } + virtual void loadBits(boost::dynamic_bitset<> bits) { argbits = bits; this->constructHex(); } virtual void evalInstr() = 0; virtual void execInstr() = 0; virtual std::string toString() = 0; virtual Iinstr* getNew() = 0; - + + unsigned long toNum() { return this->hexdump; } + short getCondition() { return m_cond; } @@ -143,6 +152,15 @@ class Iinstr { protected: + void constructHex() + { + hexdump = this->m_cond; + hexdump <<= 5; + hexdump += this->opcode; + hexdump <<= 23; + hexdump += this->argbits.to_ulong(); + } + std::string getConditionFlag() { stringstream cond;