Devilution: Suggestion to add the /FAs compiler flag to the VC workspace

Created on 7 Jan 2019  路  10Comments  路  Source: diasurgical/devilution

Trying to achieve binary exactness for a given function is usually rather iterative as you have to play around a litte until the code the compiler emits is the same as the original Diablo binary. The compiler /FAs flag is quite helpful for this because you can find out exactly what the compiler emits for every statement in C.

I personally find it quite useful and shouldn't affect the resulting binary. Is this something that is worth adding to the compiler flags for VC 6?

Most helpful comment

So this is what it looks like with VC6 SP5/PP, it produces an asm file for every compilation unit:
image

You basically see the C code as comments around the actual assembler stuff. I will run a couple of tests compiling the code with the /FAs flag and once without it and report back my findings as soon as a I can.

All 10 comments

From what I take it /FA simply outputs the assembly listing, and within this listing is also details (with comments?) what line of code was responsible for what set of instructions? If so, then that sounds great :)

We can do a quick test with and without to see if it changes the binary (besides updating e.g. the time stamp).

So this is what it looks like with VC6 SP5/PP, it produces an asm file for every compilation unit:
image

You basically see the C code as comments around the actual assembler stuff. I will run a couple of tests compiling the code with the /FAs flag and once without it and report back my findings as soon as a I can.

You basically see the C code as comments around the actual assembler stuff.

That's perfect, and should be really helpful to gain a better understanding!

I will run a couple of tests compiling the code with the /FAs flag and once without it and report back my findings as soon as a I can.

Sounds good :) Essentially what we want to make sure is that the assembly with and without are the same. Timestamps (and perhaps some other data?) may differ in the output. Looking forward to hearing what you figure out!

Nice find, I can also add this to the make script so that you can specify a single file to do it for (i think a single file makes sense as you wouldn't be working on more than one at a time)

Ok so I ran some tests with the /FAs to see if anything unexpected happened.

1) Adding the flag does not result in any changes in the binary size, it is exactly the same with the flag.
2) I compared a series of binary identical functions, once with the /FAs flag and once without it. The output seems to be exactly the same in terms of the asm code. So for example this is the original Diablo executable and a Devilution-compiled binary without /FAs for the NetSendCmdGItem2 function:

withoutfas

Adding /FAs results in exactly the same asm code:
withfas

@JustAnotherGuid Perfect!

559 updates the Makefiles, but after this PR is merged. Perhaps you could add the /FAs flag?

@JustAnotherGuid, another heads up. We've discussed in the chat to merge nightly into master and start doing releases more often.

P.S. feel free to ping me if you want an invite to the Discord chat channel. If not, that's fine too.

@mewmew Thanks for the heads up sounds good. I joined the Devilution-pub based on the link in the main description, feel free to message me any time. My username is the same as it is here.

Any progress on this? :) I think the open would help me troubleshoot the drlg_l1 functions.

this has now been added, for now its enabled for all files and not just the onebeing worked on

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nomdenom picture nomdenom  路  9Comments

utilForever picture utilForever  路  4Comments

Ogodei picture Ogodei  路  6Comments

AJenbo picture AJenbo  路  7Comments

AJenbo picture AJenbo  路  7Comments