View Single Post
  #10  
Old 06-20-2018, 05:38
chants chants is offline
VIP
 
Join Date: Jul 2016
Posts: 738
Rept. Given: 37
Rept. Rcvd 48 Times in 30 Posts
Thanks Given: 671
Thanks Rcvd at 1,064 Times in 482 Posts
chants Reputation: 48
It matters because its very convenient to program like this. By having to call/return or jump/jump or what have you (also don't forget all the stack setup and cleanup), it forces calling conventions and requires the parameters to be dealt with and such. Yes the MS implementation is not as clever as in GCC/GAS where you can really customize details of the behavior. I agree for optimization its a lame point as you would better be off with pure asm or optimized C rather than a mix and match without sophisticated inline-ing support.

Further its easier to write portable 64/32 bit code without calling conventions and clever use of macros, as the calling conventions are so different you have to use different assembly instructions (registers vs stack).

A C function can modify itself in memory also using clever tricks with inline assembler which has its obfuscation or other uses.

But I suppose this discussion is easily already documented:
Quote:
https://msdn.microsoft.com/en-us/library/80ccffx3.aspx
Quote:
Advantages of Inline Assembly
Because the inline assembler doesn't require separate assembly and link steps, it is more convenient than a separate assembler. Inline assembly code can use any C variable or function name that is in scope, so it is easy to integrate it with your program's C code. Because the assembly code can be mixed inline with C or C++ statements, it can do tasks that are cumbersome or impossible in C or C++.
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.
Writing prolog and epilog code for "naked" calls.
So optimization is on the list after all
Reply With Quote
The Following User Says Thank You to chants For This Useful Post:
tonyweb (06-20-2018)