diff --git a/decompiler/groovie/disassembler.cpp b/decompiler/groovie/disassembler.cpp index d429dd41..db046e57 100644 --- a/decompiler/groovie/disassembler.cpp +++ b/decompiler/groovie/disassembler.cpp @@ -435,8 +435,11 @@ void GroovieDisassembler::writeParameter(char type, std::vector &bytes, co case '@': // Address jumpAddrStart = bytes.size(); // if arg is in 0xF3DE format, convert to 0000f3de - if(arg.find("0x") == 0) - jumpToLabel = (boost::format("%08x") % std::stoul(arg, 0, 16)).str(); + if(arg.find("0x") == 0) { + u32 = std::stoul(arg, 0, 16); + assert((boost::format("0x%X") % u32).str() == arg); + jumpToLabel = (boost::format("%08x") % u32).str(); + } else jumpToLabel = arg; bytes.push_back(0); diff --git a/decompiler/reassembler.cpp b/decompiler/reassembler.cpp index 06d0e051..1a8c9b54 100644 --- a/decompiler/reassembler.cpp +++ b/decompiler/reassembler.cpp @@ -55,7 +55,7 @@ void Reassembler::assemble() { args.push_back(line.substr(s, len)); std::cout << args.back(); } - std::cout << "; " << comment << "\n"; + std::cout << "; " << comment << " (" << (boost::format("0x%X") % _binary.size()) << ")\n"; // TODO: maybe parse the arguments into a ValueList of the Value subclasses doAssembly(label, instruction, args, comment); @@ -66,7 +66,13 @@ void Reassembler::assemble() { if(j._label.empty()) continue; - size_t addr = _labels.at(j._label); + size_t addr = 0; + try { + addr = _labels.at(j._label); + } catch(...) { + std::cout << "\nfailed rewriting jump to " << j._label << ", from (" << j.start << ", " << j.len << ")\n"; + throw; + } uint16 u16; uint32 u32; @@ -103,11 +109,10 @@ std::string Reassembler::readLine() { std::string line; try { while(!_f.eos()) { - - char c = _f.readByte(); - if(c == '\n') - break; - line += c; + char c = _f.readByte(); + if(c == '\n') + break; + line += c; } } catch(Common::FileException &e) { }