This question may be silly, but I'm confused.

If you compile a C program into an .exe, then you disassemble that .exe with a disassembler, then you assemble the generated asm code with your assembler of choise, would that make the second .exe smaller in size and/or faster in execution (more efficient)?

My guess would be that the asm code that the disassembler produces wouldn't get past the assembler because of the extra info (PE headers etc.).

But as I said, I'm confused about this.
Posted on 2006-10-07 09:13:04 by belhifet
it wouldn't be faster (only if theoritacally)

with using of "proper" disasm and asm, it will work
Posted on 2006-10-07 11:56:01 by vid

would that make the second .exe smaller in size and/or faster in execution (more efficient)?

My belief is that you would end up with an exe that was almost identical to the original.  This is because the disassembly would be an exact assembler version of the "C" original.
Of course you would need the symbols in order to establish the data section properly and in order to make all the correct calls.
Posted on 2006-10-07 16:47:41 by jorgon
Thats correct, in order to benefit from the (superior) binary compilation available from an Assembler, you need to rewrite the (lowlevel) disassembled sourcecode into (midlevel) asm source, suitable for the Assembler to generate (optimized) binary code.
If you were clever, you could write a (preprocessor) program to perform this chore, and then yes, you could EXPECT some gains.
Of course, all of this relies on the premise that C and other high level compilers do a really POOR job of producing optimal binary code in the first place, which is not necessarily (always) true.
Posted on 2006-10-08 06:45:49 by Homer
Back in the days of pascal programming, there was a peephole optimizer that worked on already-compiled code... say something about the *cough* quality *cough* of borland compilers :)
Posted on 2006-10-08 16:59:16 by f0dder