Exetools

Exetools (https://forum.exetools.com/index.php)
-   x64 OS (https://forum.exetools.com/forumdisplay.php?f=44)
-   -   X64 inline asm (https://forum.exetools.com/showthread.php?t=12730)

_ruzmaz_ 08-09-2010 07:54

hiew 8.x has x64 assembler

pLayAr 03-08-2011 17:48

we can use .asm file with custom build in vc to support x64 asm

RaptorFactor 05-17-2011 21:32

Sorry to bump such an old thread, but another alternative to using a different compiler or linking in .asm files is to use a library such as AsmJit* (it's what I use to dynamically generate code stubs for things like robust DLL injection, remote export calling, etc etc).

Obviously there is more overhead as you need to 'JIT' the function, but this is a one-off cost, and if you're worried about using the code in performance critical areas of your code you can simply JIT all your functions at startup and cache them rather than on-demand.

* AsmJit project page: https://code.google.com/p/asmjit/

Pansemuckl 05-26-2011 08:52

Quote:

Originally Posted by pLayAr (Post 71874)
we can use .asm file with custom build in vc to support x64 asm


How can you explain?

ArC 06-13-2011 22:28

Quote:

Originally Posted by Pansemuckl
How can you explain?

In VS2010, compiling *.asm files is provided out of the box but I think you need to enable it explicitly for each project. To do so, load your project and choose Project->Build Customizations and enable the entry masm. Now, any *.asm file in your project is configured to to be compiled with MASM (except for those which have their item type explicitly set I suppose).

AFAIK this feature is not present in older versions of VS and you need to specify a custom build step to compile *.asm files. To do so add your *.asm files to your project, right click them and select Properties. The Item Type property should show Does not participate in build. Change this to Custom Build Tool and hit Apply. A new category should appear in the properties tree which allows you to specify the command line to run, message to print to build log, what files it outputs etc. For building *.asm files the Command Line and Outputs should look like that:
Code:

Command Line: ml /c /Fo"$(IntDir)%(Filename).obj" "%(FullPath)"
Outputs: "$(IntDir)%(Filename).obj"

You may want to adjust the command line a bit, e.g. to have debug info generated, but appart from that *.asm files should compile now.

infern0 10-30-2011 21:34

is anybody succeed with using intel compiler in VS2010 ?

rox 10-31-2011 23:44

Quote:

Originally Posted by infern0 (Post 75600)
is anybody succeed with using intel compiler in VS2010 ?

its plug&play type software, you can hardly fail.. just after installing compiler right click your project and select something like 'use intel compiler blah blah blah'

dbcch 11-14-2011 11:07

Does anyone have any empirical or measured benchmarks on how well the Intel C/C++ compiler does vs Microsoft's? Aside from the X64 inline assembly support, I'm just wondering if there is a compelling reason to switch. It would seem it is likely to generate optimal code, but is the code generated tuned for Intel processors? Hmm...

Quote:

Originally Posted by rox (Post 75612)
its plug&play type software, you can hardly fail.. just after installing compiler right click your project and select something like 'use intel compiler blah blah blah'

Agreed, WTF... how could you fail? ;p

Quote:

Originally Posted by gigaman (Post 67801)
For the inline assembler, keep in mind that it heavily "corrupts" the optimization of the surrounding C code (well, at least it always did for MSVC, donno about Intel, but would guess it's the same). When the compiler reaches the asm block, it's a "black box" for it... so it dumps all the register values into local variables, appends the assembler block... and then loads the register values back.
So, it's better to write the whole function in inline assembler - than just a part, in which case the result might be worse than keeping it all in C, because the rest of the function is optimized much worse than if it were all in C.

AMEN Brother! Besides incurring overhead when injected into the middle of a function, people need to remember it mucks with the compiler's optimization in general. As processors become more complex, it frankly takes a 'smart' compiler to generate optimal code. Therefore, you must be very careful about using inline asm. Use it only when you absolutely have to, basically. Any extraneous use and you risk doing more harm than good.

Quote:

Originally Posted by gigaman (Post 67801)
It would be interesting to know what led Microsoft to bad inline assembler in x64...

I believe it is because of your aforementioend issue, though who knows for sure. I believe they want to discourage any inline assembly, of any type, and took the chance to not add this feature.

JMI 11-14-2011 19:18

dbcch:

It appears you turned what should easily have been one post into three, which makes it appear like attempting to just increase your post count. I have combined them into one post, rather than just deleting them. ;)

Regards,

dbcch 11-15-2011 13:06

.... Ok, thanks. I see what you mean now, that 25 post to get to downloads stuff. I don't want downloads, so you can cancel me from downloads forever as opposed to treating my posts as part of any scheme.

deepzero 01-04-2012 19:06

Quote:

For the inline assembler, keep in mind that it heavily "corrupts" the optimization of the surrounding C code (well, at least it always did for MSVC, donno about Intel, but would guess it's the same). When the compiler reaches the asm block, it's a "black box" for it... so it dumps all the register values into local variables, appends the assembler block... and then loads the register values back.
I am using the 32 bit version VS2008 and it doesnt do that. It just blindly drops the __asm inlinded code into the middle of the function. You are responsible for saving and restoring registers/stack/... I also coudltn observe any difference as to the optimizing of surrounded code. It`s true, the inlinde asm code is NOT AT ALL optimized, but the surrounding code is.

Quote:

they did same with default values for methods in c# - no such thing there because 'it might confuse programmer'.
lol, really? Source? :)

Ghandi2006 01-04-2012 19:53

I was pleasantly surprised to see that MSVS2008 can support .asm files with little trouble. Inline asm is ok but linking external obj files is still better than no asm imho.

HR,
Ghandi

mrb! 02-23-2012 07:00

I apologise for the bump but I have a question.
I read some things about ICC neutering AMD performance when compiling. Since it seems ICC is the only option for inline x64 these days with MSVC, I am wondering if this is still the case.

Yeah, using NASM is no issue at all, but inline ASM would be nice.
Thanks in advance.

pp2 07-30-2012 00:10

Quote:

Originally Posted by mrb! (Post 77537)
I apologise for the bump but I have a question.
I read some things about ICC neutering AMD performance when compiling. Since it seems ICC is the only option for inline x64 these days with MSVC, I am wondering if this is still the case.

Yeah, using NASM is no issue at all, but inline ASM would be nice.
Thanks in advance.

As a developer, I can say, that ICC do not disable any optimizations, when compiling for AMD. Moreover, you can compile code on Intel machine, but execute it on AMD, so ICC cannot do anything bad, even if it wanted. But, of course, ICC supports more optimizations for features "unsupported" in AMD, and this can affect performance, but this is a rare case. If you write normal code (not system-specific, like SVM or smth else) - ICC is a good choice even for AMD platform.

chenm001 01-05-2013 10:07

I think the intrinstic assembly is more general.


All times are GMT +8. The time now is 07:18.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX