using namespace boost;
-std::string disasm::decode(std::string str)
+Iinstr* disasm::decode(std::string str)
{
/* we need 0x prefix */
string hex = "0x";
hex.append(str);
- unsigned int val = lexical_cast<uint32_from_hex>(hex);
+ CDat val = lexical_cast<uint32_from_hex>(hex);
+ return this->decodeNum(val);
+}
+
+Iinstr* disasm::decodeNum(CDat val)
+{
dynamic_bitset<> bits(32,val), opcode(32,val), condition(9), args(32);
args = opcode;
instr->decodeCondition(condition.to_ulong());
instr->loadBits(args);
instr->evalInstr();
- return instr->toString();
+ return instr;
}
catch(std::string &e) {
cerr << " Error: " << e << endl;
}
- return "";
+ return NULL;
+}
+
+std::string disasm::decodeToString(std::string str)
+{
+ return this->decode(str)->toString();
}
Iinstr* disasm::decodeOpcode(short opcode)
{
auto iter = instrs.find(opcode);
if(iter != instrs.end()) {
- return iter->second;
+ Iinstr* p = (iter->second)->getNew();
+ return p;
}
else {
stringstream err;