Intrinsic functions

Talk about anything else you want

Moderator: BigEvilCorporation

Post Reply
Gerrie
Interested
Posts: 16
Joined: Tue Dec 12, 2006 9:33 pm
Contact:

Intrinsic functions

Post by Gerrie » Mon Jan 12, 2009 8:41 am

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.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Mon Jan 12, 2009 9:09 pm

Wow, MS compilers must really SUCK if you can't use inline assembly on them. :lol:

AamirM
Very interested
Posts: 472
Joined: Mon Feb 18, 2008 8:23 am
Contact:

Post by AamirM » Mon Jan 12, 2009 9:43 pm

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).

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Jan 13, 2009 3:35 am

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:

Gerrie
Interested
Posts: 16
Joined: Tue Dec 12, 2006 9:33 pm
Contact:

Post by Gerrie » Tue Jan 13, 2009 7:25 am

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.

Near
Very interested
Posts: 109
Joined: Thu Feb 28, 2008 4:45 pm

Post by Near » Tue Jan 13, 2009 5:16 pm

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 ;)

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Tue Jan 13, 2009 11:05 pm

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:

Post Reply