[Scummvm-git-logs] scummvm-tools master -> d82948865dbaa89590e18ee4322d9184414a6567

Die4Ever noreply at scummvm.org
Tue Dec 20 06:49:33 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-tools' repo located at https://github.com/scummvm/scummvm-tools .

Summary:
d82948865d DECOMPILER: reassembler improved debugging


Commit: d82948865dbaa89590e18ee4322d9184414a6567
    https://github.com/scummvm/scummvm-tools/commit/d82948865dbaa89590e18ee4322d9184414a6567
Author: Die4Ever (die4ever2005 at gmail.com)
Date: 2022-12-20T00:49:23-06:00

Commit Message:
DECOMPILER: reassembler improved debugging

Changed paths:
    decompiler/groovie/disassembler.cpp
    decompiler/reassembler.cpp


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<byte> &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) {
 	}




More information about the Scummvm-git-logs mailing list