64位应用程序和内联汇编 [英] 64bit Applications and Inline Assembly

查看:460
本文介绍了64位应用程序和内联汇编的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Visual C ++ 2010开发32位Windows应用程序。也有一些是我真的想用内联汇编。但我只是意识到,VISUAL C ++不支持内嵌汇编的64位应用程序。因此,移植在未来的64位是一个大问题。

我不知道如何64位应用程序从32位应用程序的不同。是否有机会,32位应用程序都将有升级的未来,以64位?听说64位CPU有更多的寄存器。因为性能不为我的应用的关注,使用这些额外寄存器不是一个问题我。是否还有其他原因,32位应用程序需要升级到64位?请问一个64位的应用程序不同的事情时,用32位的应用程序相比,除了从64位应用程序可以使用特有的64位CPU的寄存器或指令?

我的应用程序需要与其他的操作系统组件,例如互动司机,我知道必须在64位64位窗口。将与他们我的32位应用程序兼容?

解决方案

的Visual C ++不支持内联汇编的64位模式,因为一般都采用内嵌汇编是一个坏主意。

  1. 在通常的编译器产生更好的装配比人类。
  2. 即使你能产生更好的装配比编译器,使用内联汇编通常击败任何类型的code优化。当然,你的手工优化code位可能会更快,但事实上,它周围code不能优化通常会导致较慢的总体方案。
  3. 编译器内在可从pretty的多少每一个主要的让您访问的方式,是用C和C ++语言一致,并没有击败优化高级CPU功能(比如SSE)的编译器。
  

我不知道会不会有这32位应用程序都将有升级在未来64位的机会。

这取决于你的目标受众。如果你的目标服务器,那么是的,这是合理的,允许用户不安装WOW64子系统,因为它是一个服务器 - 你知道它可能会无法运行太多的32位code。我相信,在Windows Server 2008 R2已经让这个就好像你安装它作为一个服务器核心实例的选项。

  

由于性能不适合我APPLI所以使用额外的64位寄存器的一个担心是不是担心我。是否有其他原因,一个32位APPLI有升级在未来64?

64位无关,与寄存器。它必须与寻址虚拟内存的大小。

  

请问一个64位的应用程序进程正在使用的一些寄存器由一个32位的申请过程除了那64位APPLI不同/指令是唯一的64位CPU的?

最有可能的。 32位应用程序的限制,因为它们不能映射的东西超过〜2GB到内存中一次。 64位应用程序没有这个问题。即使他们不使用超过4GB的物理内存,能够比4GB的虚拟内存来解决更多的是有助于在磁盘上的文件映射到内存和类似。

  

我的应用程序需要与其他的操作系统组件,例如互动司机,我知道必须在64位64位窗口。将与他们我的32位应用程序兼容?

这完全取决于你如何使用这些驱动程序进行通信。如果是通过类似命名的文件界面,那么你的应用程序可以留为32位。如果你试图做类似的共享内存(哎呀!分享了一个用户驱动模式下可访问的内存?!?),那么你将不得不建立自己的应用程序为64位。

I am using Visual C++ 2010 developing 32bit windows applications. There is something I really want to use inline assembly. But I just realized that visual C++ does not support inline assembly in 64bit applications. So porting to 64bit in the future is a big issue.

I have no idea how 64bit applications are different from 32bit applications. Is there a chance that 32bit applications will ALL have to be upgraded to 64bit in the future? I heard that 64bit CPUs have more registers. Since performance is not a concern for my applications, using these extra registers is not a concern to me. Are there any other reasons that a 32bit application needs to be upgraded to 64bit? Would a 64 bit application process things differently when compared with a 32bit application, apart from that the 64bit applications may use registers or instructions that are unique to 64bit CPUs?

My application needs to interact with other OS components e.g. drivers, which i know must be 64bit in 64bit windows. Would my 32bit application compatible with them?

解决方案

Visual C++ does not support inline assembly for x64 mode, because generally using inline assembly is a bad idea.

  1. Usually compilers produce better assembly than humans.
  2. Even if you can produce better assembly than the compiler, using inline assembly generally defeats code optimizers of any type. Sure, your bit of hand optimized code might be faster, but the fact that code around it can't be optimized will generally lead to a slower overall program.
  3. Compiler intrinsics are available from pretty much every major compiler that let you access advanced CPU features (e.g. SSE) in a manner that's consistent with the C and C++ languages, and does not defeat the optimizer.

I am wondering would there be a chance that 32bit applications will ALL have to be upgraded to 64bit in the future.

That depends on your target audience. If you're targeting servers, then yes, it's reasonable to allow users to not install the WOW64 subsystem because it's a server -- you know it'll probably not be running too much 32 bit code. I believe Windows Server 2008 R2 already allows this as an option if you install it as a "server core" instance.

Since performance is not a concern for my appli so using the extra 64bit registers is not a concern to me. Is there any other reasons that a 32bit appli has to be upgraded to 64bit in the future?

64 bit has nothing to do with registers. It has to do with size of addressable virtual memory.

Would a 64 bit app process different from a 32bit appl process apart from that the 64bit appli is using some registers/instructions that is unique to 64bit CPUs?

Most likely. 32 bit applications are constrained in that they can't map things more than ~2GB into memory at once. 64 bit applications don't have that problem. Even if they're not using more than 4GB of physical memory, being able to address more than 4GB of virtual memory is helpful for mapping files on disk into memory and similar.

My application needs to interact with other OS components e.g. drivers, which i know must be 64bit in 64bit windows. Would my 32bit application compatible with them?

That depends entirely on how you're communicating with those drivers. If it's through something like a "named file interface" then your app could stay as 32 bit. If you try to do something like shared memory (Yikes! Shared memory accessible from user mode with a driver?!?) then you're going to have to build your app as 64 bit.

这篇关于64位应用程序和内联汇编的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆