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 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);
35 catch(std::string &e) {
36 cerr << " Error: " << e << endl;
41 std::string disasm::decodeToString(std::string str)
43 return this->decode(str)->toString();
46 Iinstr* disasm::decodeOpcode(short opcode)
48 auto iter = instrs.find(opcode);
49 if(iter != instrs.end()) {
50 Iinstr* p = (iter->second)->getNew();
55 err << "opcode not found" << endl;