Page 1 of 1

Intrinsic functions

Posted: Mon Jan 12, 2009 8:41 am
by Gerrie
Since you are not allowed to use inline ASM in the VC++ compilers for x64 platforms, I was surfing on MSDN and came acros this:

http://msdn.microsoft.com/en-us/library/aa983406.aspx

Has anyone actually tried this in a CPU emulator ? I wasn't aware of this intrinsic function, but this could surely speed up my Z80 (and other) emulator.

Or, does anyone know of some profiling tools, so I can test this out myself ? I want to see the speed difference between my normal flag calculations, and flag calculations using the X86/X64 EFLAG register.

Posted: Mon Jan 12, 2009 9:09 pm
by Chilly Willy
Wow, MS compilers must really SUCK if you can't use inline assembly on them. :lol:

Posted: Mon Jan 12, 2009 9:43 pm
by AamirM
Ummm.....why not write completely in ASM? :P

For profiling, I use the __rdtsc intrinsic (inline asm actually, since I am working on 32-bit).

Posted: Tue Jan 13, 2009 3:35 am
by Chilly Willy
Actually, many of the opcodes are exactly the same between 32 and 64 bit mode, so using inline assembly should be okay if you're careful. It would just be tough to access the "extra" 64 bit regs as they require a prefix byte the compiler probably doesn't know... however, if YOU know it, you can use the old 32 bit opcode the prefix co-opted before the instruction. Not really recommended... you should just get a better compiler. :wink:

Posted: Tue Jan 13, 2009 7:25 am
by Gerrie
AamirM wrote:Ummm.....why not write completely in ASM? :P
Because I have to write a different version for each platform. You can't just simply re-compile your 32-bits ASM into a 64-bits object ;)

That's why I switched to C/C++ only. With some small #ifdefs and a simple recompile I can have a x86 and x64 binary :D
Chilly Willy wrote:Wow, MS compilers must really SUCK if you can't use inline assembly on them.
Chilly Willy wrote:Actually, many of the opcodes are exactly the same between 32 and 64 bit mode, so using inline assembly should be okay if you're careful. It would just be tough to access the "extra" 64 bit regs as they require a prefix byte the compiler probably doesn't know... however, if YOU know it, you can use the old 32 bit opcode the prefix co-opted before the instruction. Not really recommended... you should just get a better compiler.
The VC++ compiler really isn't that bad ;) Microsoft was just too lazy to add inline ASM when targetting x64, eg. it's just not possible to do. The compiler would complain. If I'm correct, the Intel compiler does support it.
AamirM wrote:For profiling, I use the __rdtsc intrinsic (inline asm actually, since I am working on 32-bit).
Thanks, I will look into that one.

Posted: Tue Jan 13, 2009 5:16 pm
by Near
Chilly Willy wrote:Wow, MS compilers must really SUCK if you can't use inline assembly on them. :lol:
At least its had link-time code generation for the last six or so years. What decade do you think GCC will catch up? Would sure be nice not having to inline every critical function inside header files ;)

Posted: Tue Jan 13, 2009 11:05 pm
by Chilly Willy
byuu wrote:
Chilly Willy wrote:Wow, MS compilers must really SUCK if you can't use inline assembly on them. :lol:
At least its had link-time code generation for the last six or so years. What decade do you think GCC will catch up? Would sure be nice not having to inline every critical function inside header files ;)
I think most developers will agree that inline assembly is FAR more important than LTO. :wink: