0Day Forums
MS Visual Studio 2010 how to use the .asm generated file - Printable Version

+- 0Day Forums (https://zeroday.vip)
+-- Forum: Coding (https://zeroday.vip/Forum-Coding)
+--- Forum: Assembly (https://zeroday.vip/Forum-Assembly)
+--- Thread: MS Visual Studio 2010 how to use the .asm generated file (/Thread-MS-Visual-Studio-2010-how-to-use-the-asm-generated-file)



MS Visual Studio 2010 how to use the .asm generated file - trapezohedron253312 - 07-24-2023

I would like to ask about something I am thinking to try with Visual Studio 2010.

I am generating an .asm file from the.cpp file by setting the option to the "Assembler Output" in the project properties --> C/C++ --> Output Files (/FAs).

My question is, how can I on a next step use that .asm generated file to link again from that one without using anymore the .cpp file, in case I want to do some modifications inside the .asm file and then link again by keeping the modifications I did at assembly level.

It would be very helpful if you could provide the exact steps, including the correct configuration may needed in the project properties.





RE: MS Visual Studio 2010 how to use the .asm generated file - spiller253 - 07-24-2023

Here is a tutorial

[To see links please register here]




RE: MS Visual Studio 2010 how to use the .asm generated file - woodland532 - 07-24-2023

I did this recently. Here is a repeat of the answer I gave here [compile-assembly-output-generated-by-vc](

[To see links please register here]

). It turns out you can still do this in 32-bit mode in MSVC2012 but I think 64-bit mode is hopeless.

For 32-bit mode here is what you do.

Create an empty project and a source file *Source.cpp*

#include <stdio.h>
int main() {
printf("hello world\n");
return 0;
}

1. Right lick on your project and select "Build Customization" and
select masm as described here

[To see links please register here]

2. Under C++/OutputFiles select Assembly Output /FA
3. Comipile in 32-bit mode Release mode
4. Load the *Source.asm* file into MSVC so you can view it. It won't work yet. A few changes are still necessary.
5. Under C++/Optimization turn off Whole Program Optimization (removes `/GL`). This adds the line `INCLUDELIB MSVCRT`
6. In the Linker/Advanced set the last option "Image Has Safe Exception Handlers"to No (`/SAFESEH:NO`)
7. Now you should have a Source.asm file which will do the same thing that Source.cpp file did. Copy the Source.cpp from the Release directory to the same directory as Source.cpp (so it's not deleted when you build/clean).
8. Add *Source.asm* (as an existing file) to the Source Files and remove *Source.cpp* from the build.
9. **Rebuild and you should see "Hello World" without having to change any assembly lines by hand.**

I have used this for more complicated functions. I usually do it on a separate module and use `extern "C"` on the function name to remove the C++ name mangling.


RE: MS Visual Studio 2010 how to use the .asm generated file - intensifiers156996 - 07-24-2023

Simply drag the .obj files into the Project (Solution Explorer tree):

[To see links please register here]