Open uxmal opened 8 years ago
Similarly, when a procedure returns a far pointer in the dx:ax
registers, Reko should be smart and realize that the regsters are being used as a pair, and deal with them as a unit. E.g. decompiling:
les ax,ds:[0x0124]
mov dx,es
ret
which today results in something like
es_ax_2 = Mem0[ds:0x0124:word32]
dx_3 = SLICE(es_ax_2, word16, 16);
axOut = (word16) es_ax
return dx_3
should instead result in:
es_ax_2 = Mem0[ds:0x0124:word32]
ds_ax_3 = es_ax_2
return ds_ax_3
which simplifies to
return Mem0[ds:0x0124:word32]
The x86 16-bit code fragment
is decompiled into
which, although correct, could be improved. MS-DOS / Win16 compilers traditionally compiled pointer arithmetic on
far
pointers (note: nothuge
pointers) as arithmetic only on the offset part of the pointer. It would be great if Reko could recognize that es_3 and bx_4 "belong together" since they were loaded from memory at the same time, and whenever both are used in the same expression, they can be replaced with the originales_bx_2
. After this analysis, the resulting code is:which is a lot more pleasant to the human reader.