How to generate intermediate build as .asm file

How to generate intermediate build as .asm file

Post by TahoeKi » Sun, 02 Dec 2007 05:28:14


I would like for my builds to generate an intermediate assembler file.
I've done this in years gone by on other microsoft compilers, but I've
not found this option in VS 2005.

I have a special parser that I want to run on the intermediate .asm
file to inject some special assembler
instructions that is not generated by the compiler, then let the build
continue generating the .exe file.

This is for Win32 / C++, not for .NET.
So where is the setting to generate .asm output?
 
 
 

How to generate intermediate build as .asm file

Post by TahoeKi » Sun, 02 Dec 2007 06:14:21

I found the /FA option.
Next question is how, after the assembler is modified, I tell the
build process to use it as input to then generate the final
binary .exe file?
Hopefully as some kind of custom build step....

 
 
 

How to generate intermediate build as .asm file

Post by David Lown » Sun, 02 Dec 2007 06:42:15

>I found the /FA option.

I don't think there is any such facility. I vaguely recall that the
/FA output couldn't even be asssembled using the stand-alone masm, but
I may have that wrong.

Could you not have your special code generated into the C/C++ source
as inline asm (see the __asm keyword if you're not familiar with it)?

Dave
 
 
 

How to generate intermediate build as .asm file

Post by TahoeKi » Sun, 02 Dec 2007 09:21:26


I'm automatically modifying the compiler generated assembler with some
special detection and signature code for security reasons, so although
I could do this
in C++ source, it would be painful to maintain. I thought I could just
auto insert it into the assembler step before it generates the .exe
file.

The compiler, at least in the olden days, used to internally convert C/
C++ into assembler, then the assmelber module would generate the
linkable object file.
It used to be you could invoke the assembler directly onto the output
listing file and generate the same object file.

Reviewing the assembler output it sure looks like a valid assembly
language file (snippet below).
I guess I need to see if I can assemble it with the IDE somehow.

; Listing generated by Microsoft (R) Optimizing Compiler Version
14.00.50727.42

TITLE c:\win32\win32.cpp
.686P
.XMM
include listing.inc
.model flat

INCLUDELIB MSVCRTD
INCLUDELIB OLDNAMES

PUBLIC ?hInst@@3PAUHINSTANCE__@@A ; hInst
PUBLIC ?szTitle@@3PA_WA ; szTitle
PUBLIC ?szWindowClass@@3PA_WA ; szWindowClass
_BSS SEGMENT
 
 
 

How to generate intermediate build as .asm file

Post by Gary G. Li » Sun, 02 Dec 2007 13:14:20

So write an ASM source module that wraps your code in the assembly for a
C/C++ function, call these functions from your C/C++ source. Maintain the
ASM files just like you maintain C/C++. This also allows you to float
different source files for different processors. Alternately, write a C/C++
source file, wrapping your _asm {} in class methodologies.

The way you want to do it would be a pain in the ass anyway, since there is
NO GUARANTEE that the /FA output would be the same from one version of the
compiler to the next.

The personal opinion of
Gary G. Little