1 #include <boost/lexical_cast.hpp>
2 #include <boost/dynamic_bitset.hpp>
7 Iinstr* disasm::decode(std::string str)
9 /* we need 0x prefix */
13 CDat val = lexical_cast<uint32_from_hex>(hex);
14 return this->decodeNum(val);
18 Iinstr* disasm::decodeNum(CDat val)
20 dynamic_bitset<> bits(32,val), opcode(32,val), condition(9), args(32);
32 //cout << "<" << hex << "> is in int " << val << "\t is binary " << bits << " opcode?" << opcode << " condition " << condition << endl;
34 Iinstr* instr = decodeOpcode(opcode.to_ulong());
35 instr->decodeCondition(condition.to_ulong());
36 instr->loadBits(args);
40 catch(std::string &e) {
41 cerr << " Error: " << e << endl;
46 std::string disasm::decodeToString(std::string str)
48 return this->decode(str)->toString();
51 Iinstr* disasm::decodeOpcode(short opcode)
53 auto iter = instrs.find(opcode);
54 if(iter != instrs.end()) {
55 Iinstr* p = (iter->second)->getNew();
60 err << "opcode not found. in was " << opcode << endl;