是否可以在intel/64位win7的32位应用程序中使用64位指令 [英] Is it possible to use 64-bit instruction in a 32-bit application on intel/64-bit win7

查看:96
本文介绍了是否可以在intel/64位win7的32位应用程序中使用64位指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的环境是64位win7 VC2010.

My environment is 64-bit win7, VC2010.

当然,内部的intel是64位CPU.

Of course, the intel inside is 64-bit CPU.

我可以在32位应用程序中使用64位指令/本机字(64位)吗?由于我的大多数代码是32位的,因此我不想将其移植到64位.

Can I use the 64-bit instruction/native machine word(64-bit) in a 32-bit application? Since most of my code is 32-bit, I do not want to port it to 64-bit.

对于某些对性能至关重要的热代码,我想通过编译器固有的或内联汇编(也可以是64位VC编译器不支持内联汇编)进行手动优化,是否可以运行64位代码,例如mov rax, rbx在32位模式的应用程序中?

For some performance critical hot code, I want to manually optimize it by compiler intrinsic or inline assembly(Also 64-bit VC compiler do NOT support inline assembly), is it possible to run 64-bit code fox example mov rax, rbx in a 32-bit mode application?

推荐答案

实际上,您可以.从32位模式切换到64位模式(显然必须存在于能够运行32位代码的64位OS上)的机制没有受到任何保护,可以从用户代码中使用.在Windows上,它称为天堂之门",它非常简单:只是一个远程调用,其分段选择器为33h.

Actually, you kind of can. The mechanism used to switch from 32 to 64 bit mode (which clearly must exist on a 64 bit OS capable of running 32 bit code) is not in any way protected, and can be used from user code. On Windows it is called Heaven's Gate, and it's pretty simple: just a far call with a segment selector of 33h.

那么,如何运行64位代码?

So, how to run 64bit code?

call 33h:your64bitcode
...
your64bitcode:
; do something
retf

以这种方式输入的64位代码可以做的事情当然会受到一些限制,因为您并非真正处于64位进程中.

There are, of course, some limitations to what you can do from 64bit code entered in that way, because you're not truly in a 64bit process.

这篇关于是否可以在intel/64位win7的32位应用程序中使用64位指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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