I would like to modify some assembly lines from C++ code generated by MSVC. The reason I want to do this can be found here Difference in performance between MSVC and GCC for highly optimized matrix multplication code
So I tried to rum masm with the assembly output but it get's a bunch of errors. Instead I just tried a "hello world" example.
include <stdio.h>
int main() {
printf("asdf\n");
}
Compile it in 64 bit mode with /FA /O2...see the output below
When I run ml64 /c Source.asm I get the following error
Source.asm(35) : error A2006:undefined symbol : FLAT
Source.asm(17) : error A2006:undefined symbol : $LN3
Source.asm(18) : error A2006:undefined symbol : $LN3
After spending too much time on this I found these two threads http://social.microsoft.com/Forums/en-US/e0e541d9-5421-4297-8018-7c6a0f12ae62/compile-assembly-generated-by-cl?forum=whatforum and http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/4aad9e70-6bb8-4622-a5d9-a3b07b51fc7f/c-compiler-creates-assembler-directives-that-ml64-doesnt-understand?forum=windowssdk where microsoft says
Before the work was undertaken to target x64 with the Microsoft C/C++ compiler we made the call to no longer support assembling C/C++ generated listing files. In other words, the listing files are for informational purposes only.
Can someone explain another method to generator the assembly code from C++ code in MSVC2012 so that I can modify a few lines and then recompile/assemble it?
Edit: Here are some more useful comments a problem with cl.exe and ml.exe and MS Visual Studio 2010 how to use the .asm generated file
Here is the assembly output
; Listing generated by Microsoft (R) Optimizing Compiler Version 17.00.50727.1
;include listing.inc
INCLUDELIB OLDNAMES
PUBLIC ??_C@_05DBBGCHPA@asdf?6?$AA@ ; `string'
EXTRN __imp_printf:PROC
EXTRN __security_check_cookie:PROC
; COMDAT ??_C@_05DBBGCHPA@asdf?6?$AA@
CONST SEGMENT
??_C@_05DBBGCHPA@asdf?6?$AA@ DB 'asdf', 0aH, 00H ; `string'
CONST ENDS
PUBLIC main
; COMDAT pdata
pdata SEGMENT
$pdata$main DD imagerel $LN4
DD imagerel $LN4+24
DD imagerel $unwind$main
pdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$main DD 010401H
DD 04204H
xdata ENDS
; Function compile flags: /Ogtpy
; COMDAT main
_TEXT SEGMENT
main PROC ; COMDAT
; Line 2
$LN4:
sub rsp, 40 ; 00000028H
; Line 3
lea rcx, OFFSET FLAT:??_C@_05DBBGCHPA@asdf?6?$AA@
call QWORD PTR __imp_printf
; Line 4
xor eax, eax
add rsp, 40 ; 00000028H
ret 0
main ENDP
_TEXT ENDS
END