Fixed incorrect ordering of instructions

This commit is contained in:
KallDrexx
2025-10-11 15:49:10 -04:00
parent 8e811e2cbc
commit 826747aacb
@@ -37,8 +37,13 @@ public class DecompiledFunction
// We need to order the instructions so that the starting instruction is the first one encountered.
// We can't just rely on the CPU address, because a function may jump to a code point earlier than
// the first instruction.
var initialInstructions = instructions.Where(x => x.CPUAddress >= address);
var trailingInstructions = instructions.Where(x => x.CPUAddress < address);
var initialInstructions = instructions
.Where(x => x.CPUAddress >= address)
.OrderBy(x => x.CPUAddress);
var trailingInstructions = instructions
.Where(x => x.CPUAddress < address)
.OrderBy(x => x.CPUAddress);
OrderedInstructions = initialInstructions.Concat(trailingInstructions).ToArray();
}