I'm disassembling an old (1996) game, that has been compiled with the Watcom 386 compiler. This compiler seems to aggressively reorder instructions to make better use of the processor pipeline, as seen in this chunk of assembly:
The instructions marked with a red dot set up the parameters for the next call; the instructions with a blue dot finish the initialization of the object returned from the previous call. Rearranging them makes the assembly much easier to read:
... call ClassAlloc13680_0FAh mov edx, [eax] mov [edx+Class180F4.WidgetInputHandler], offset gblHandleTransportDestinationAndCheckForPassengersSpace mov edx, [eax] mov [edx+Class13680.Paint???], offset ClassVehicleManager__PaintForSomeWidget mov dword_A4D88, eax mov eax, [eax] mov [eax+Class10B8C.MouseInputHandler], offset ClassVehicleManager__MouseInputHandler push 0 push 2 push 0 push 4Eh push 5Bh mov ebx, 5Ch mov ecx, 21h mov edx, ebp mov eax, ebp call ClassAlloc13680_0FAh push 0 push 2 ...
(Note that i moved the
mov reg, xxh instructions even further down, because the compiler's calling convention is ax-dx-cx-bx-stack, so i can see the order of arguments here as well)
Is there a way to accomplish this in IDA? I'm not asking for an algorithm to automatically determine which instructions should be "red" and which should be "blue", and i don't want to patch the original binary file, i'd just like to manually re-arrange instructions in the ida database.
Or is there another way to improve readability of this kind of code in IDA?