![]() |
|
|
|
#1
|
|||
|
|||
|
Or as a fourth option since it has yet to be mentioned, write a tool which at compile time extracts all inline code from C modules intended for x64 compilation, put them in an .asm file with some type of label or function definition, compile them, replace the C code with an appropriate control flow transfer, and so forth.
Unfortunately, nothing will be exactly equivalent mentioned so far in MSVC as the control flow transfer is pretty hard to avoid. Best yet might be to keep requesting MS to make the long overdo change as a developer feedback or feature request. |
|
#2
|
|||
|
|||
|
Two ways:
- Intrinsics https://msdn.microsoft.com/en-us/library/26td21ds.aspx - As above suggested, .asm linking here a tutorial on how to setup VS + MASM http://lallouslab.net/2016/01/11/introduction-to-writing-x64-assembly-in-visual-studio/ Best Regards, Evilcry |
| The Following 2 Users Say Thank You to Evilcry For This Useful Post: | ||
Mahmoudnia (06-18-2018), tonyweb (06-18-2018) | ||
|
#3
|
|||
|
|||
|
But since you are not linking the .asm inline, there are excessive call or jump statements emitted. The best would be if MS were to add it.
|
|
#4
|
|||
|
|||
|
Does one call or jump really matter?
I mean, if you said you couldn't easily access local variables or structures, I'd agree... but "excessive call", it sounds like you are trying to optimize something. In that case inline assembler is hardly any good - it's a blackbox for the compiler (at least for the Microsoft's) so it has to dump the values from registers into local variables and after the inline assembly load them back. In other words, a piece of inline assembly heavily breaks the optimization of the surrounding C code - so it's usually not worth it, it does more damage than one call would (so it's better to write the whole CPU intensive piece of code in assembler as a separate function). |
| The Following User Says Thank You to gigaman For This Useful Post: | ||
tonyweb (06-20-2018) | ||
|
#5
|
|||
|
|||
|
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:
Quote:
|
| The Following User Says Thank You to chants For This Useful Post: | ||
tonyweb (06-20-2018) | ||
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| inline patche | hp3 | Source Code | 3 | 06-04-2021 14:48 |
| X64 inline asm | Fyyre | x64 OS | 48 | 08-10-2014 16:50 |
| Inline Patching | MaRKuS-DJM | General Discussion | 1 | 01-24-2004 23:03 |