disasm/sim: changed interface, branch => br, features++
[calu.git] / 3c_disasm / disasm.cpp
index b389d0361a501c5418b77ccbc7eefd5681876783..0c6c5f09119e6dde572aa5e20ec2cf3f831b3f73 100644 (file)
@@ -4,7 +4,7 @@
 
 using namespace boost;
 
-std::string disasm::decode(std::string str)
+Iinstr* disasm::decode(std::string str)
 {
        /* we need 0x prefix */
        string hex = "0x";
@@ -30,19 +30,25 @@ std::string disasm::decode(std::string str)
                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;