I started a project to get a better understanding on how to compile a game for Windows 3.x. I tried to set up the build workflow so that it produce the byte-exact clone of a great open sourced Win16 game named Hyperoid. It took some time to get a working build for Windows 3.0 which I finally managed. However, no matter how I played with the compiler and linker options, I was not able to produce a similar EXE in some aspects.
One of them is related to stack handling. I see it in the disassembly that while the original EXE does push CONSTANT
instructions, the rebuilt one usually put the constant to the AX register and does a push ax
.
Original:
push 02FC
push 0000
push ds
New:
mov ax, 02FC
push ds
push ax
sub ax, ax
push ax
No matter how I played with the CL options, I was not able to change this behavior.
Is there a way to set up the Microsoft C 6.0 compiler to make it prefer constant push instructions over doing the same indirectly using registers?
(More details are in the project link above.)