I set VC++ to generate ASM for a method which calls sqrt, to see if it's generating FPU or SSE instructions. However when sq开发者_Go百科rt is called, I don't see the ASM. I only see a call to some function __CIsqrt, which I assume is some system sqrt function. I can't see any ASM for that to know what it is doing?
That's because the compiler isn't generating the code - the code already exists in the library. If you want to see it, the easiest method is often to trace into the library function call in the debugger in assembler mode.
The math functions are implemented in a library. The library contains the FPU/SSE2 instructions but additional code is needed to implement the /fp compile option. While most CRT code is available as source code in the vc\crt\src subdirectory of the VS install directory, that's not the case for the math functions. It is written by Intel, they probably didn't permit the source to be published. The library is located in vc\crt\src\intel\mt_lib\tran.lib. At a megabyte, far too much to ever consider disassembling.
If you want to see the assembly, you should build your project with /MT and step into the function with the debugger.
精彩评论