When using Microsoft Visual C++ (not CLI, just standard native C++) does inline assembly cause optimisation to be disabled for the function?
When I checked using IDA, some of the function code outside the block does seem to change, but I'm not sure what the cause is. The function is (relatively) simple, containing bit manipulation and some math, but no external calls.
Other possible causes I could think of are:
Any ideas?
The uses of inline assembly include: Writing functions in assembly language. Spot-optimizing speed-critical sections of code. Making direct hardware access for device drivers.
GCC provides two forms of inline asm statements. A basic asm statement is one with no operands (see Basic Asm), while an extended asm statement (see Extended Asm) includes one or more operands.
Yes. See the MSDN articles: Optimizing Inline Assembly as well as Advantages of Inline Assembly
From the article:
The presence of an
__asm
block in a function affects optimization in several ways. First, the compiler doesn't try to optimize the__asm
block itself. What you write in assembly language is exactly what you get. Second, the presence of an __asm block affects register variable storage. The compiler avoids enregistering variables across an__asm
block if the register's contents would be changed by the__asm
block. Finally, some other function-wide optimizations will be affected by the inclusion of assembly language in a function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With