1 #include <boost/lexical_cast.hpp>
2 #include <boost/dynamic_bitset.hpp>
7 std::string disasm::decode(std::string str)
9 /* we need 0x prefix */
13 unsigned int val = lexical_cast<uint32_from_hex>(hex);
15 dynamic_bitset<> bits(32,val), opcode(32,val), condition(9), args(32);
27 //cout << "<" << hex << "> is in int " << val << "\t is binary " << bits << " opcode?" << opcode << " condition " << condition << endl;
29 Iinstr* instr = decodeOpcode(opcode.to_ulong());
30 instr->decodeCondition(condition.to_ulong());
31 instr->loadBits(args);
33 return instr->toString();
35 catch(std::string &e) {
36 cerr << " Error: " << e << endl;
41 Iinstr* disasm::decodeOpcode(short opcode)
43 auto iter = instrs.find(opcode);
44 if(iter != instrs.end()) {
49 err << "opcode not found" << endl;