32位窗口下的64位寄存器 [英] 64-bit registers under 32-bit windows

查看:39
本文介绍了32位窗口下的64位寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在我的 32 位 Vista 机器上安装了 mingw32 来试验 gcc 内联汇编.不幸的是,32 位 gcc 编译器无法识别 64 位寄存器,例如 %%rax.

I just installed mingw32 on my 32-bit Vista box to experiment with gcc inline assembly. Unfortunately the 32-bit gcc compiler does not recognize the 64-bit registers, such as %%rax.

在我花费大量时间尝试组装新工具链之前,我有几个问题:

Before i sink alot of time into trying to assemble a new toolchain, i have a few questions:

  1. x86(英特尔酷睿双核,T5800)上是否有一些处理器模式会阻止它在运行 Vista32 时使用 64 位寄存器(即这是一个失败的原因)?

  1. Is there some processor mode on the x86 (Intel Core Duo, T5800) that will prevent it from using the 64-bit registers while running Vista32 (i.e. is this a lost cause)?

假设 #1 的答案是当然您可以在 32 位 Windows 下使用 %rax 等",那么 gcc 可以配置为识别 64 位寄存器并构建一个可执行文件在 32 位 Windows 下运行?我知道 gcc 有一个 -m64 选项,但是我的 mingw32 附带的版本没有编译 64 位支持.如果 gcc 可以构建可以访问 64 位的 32 位应用程序,我当然愿意重建 gcc注册,但如果它无论如何都不起作用,我不想经历那种痛苦.

Assuming that the answer to #1 is "Of course you can use %rax, etc under 32-bit windows", can gcc be configured to both recognize the 64-bit registers AND build an executable that will run under 32-bit windows? I know that gcc has a -m64 option, but my version that came with mingw32 does not have 64-bit support compiled in. I'm certainly willing to rebuild gcc if it can build 32-bit applications that have access to 64-bit registers, but i don't want to go through that pain if it is not going to work anyway.

旁白:这实际上是学习 SSE2 指令的第一步(是的,我知道存在编译器内在函数,但我想从机器级别上理解它).

Aside: This is actually a first step towards learning the SSE2 instructions (yes, i know, compiler intrinsics exist, but i'd like to understand it from a machine level up).

推荐答案

  1. 是的,64 位处理器有 3 种大小模式,16 位、32 位和 64 位.操作系统不能以比操作系统本身更大的模式运行代码.因此,Vista 32 位只能运行为 16 位和 32 位构建的代码.您的处理器 确实支持 64 位,因此您应该尝试在其上安装 64 位操作系统.如果您的计算机带有实际的 Windows Vista CD,则可能有一张单独的 Vista 64 CD.如果您构建一个支持 x86-64 的新工具链,您将能够编译使用 64 位指令和寄存器的代码,但您将无法除非您安装 64 位操作系统,否则无法运行生成的可执行文件.

  1. Yes, a 64-bit processor has 3 size modes, 16-bit, 32-bit and 64-bit. An operating system cannot run code in a mode larger than the operating system itself. Thus Vista 32-bit can only run code built for 16-bits and 32-bits. Your processor does indeed support 64-bits, so you should try to install a 64-bit OS on it. If your computer came with actual windows Vista CDs, there may be a separate CD for Vista 64. If you build a new toolchain with x86-64 support you will be able to compile code that uses 64-bit instructions and registers, but you will not be able to run the resulting executables unless you install a 64-bit OS.

因为 rax 是一个 64 位寄存器(32 位等价物是 eax),所以它不能被 64 位程序访问.这样做的原因是对处理器如何解释程序发送的命令的相当复杂的解释.

Since rax is a 64-bit register (the 32-bit equivalent is eax) it cannot be accessed except from a 64-bit program. The reason for this is a rather convoluted explanation of how the processor interprets the commands your program sends.

但是,您实际上并不需要访问 64 位代码来使用 MMX、SSE、SSE2 和 SSE3.所有这些指令都在 32 位模式下可用,并且受您的处理器支持.

But, you don't actually need access to 64-bit code in order to use MMX, SSE, SSE2, and SSE3. All of those instructions are available in 32-bit mode and are supported by your processor.

您可能还想考虑运行虚拟机并将 Ubuntu 放入其中.这将允许您在 Windows 桌面上的窗口中运行 Linux.我认为与使用 mingw32 相比,使用 GNU 工具链(gcc 等)本机会更轻松.在这个时代,VM 易于安装和使用,几乎没有理由再使用 mingw32.您还可以查看 MS Visual C++ Express,它是一种基于 Windows 的编译器,Microsoft 免费提供,但它不支持 64 位(您必须为支持的版本付费).

You also might want to consider running a Virtual Machine and putting Ubuntu inside it. This will allow you to run Linux inside a window on your Windows desktop. I think you will have a easier time of things using the GNU tool chain (gcc, etc) natively than you will using mingw32. VMs are easy to install and use in this day and age, there's little reason to use mingw32 anymore. You could also look in to MS Visual C++ Express, which a windows-based compiler that is free from Microsoft, but it doesn't support 64-bit (you have to pay for a version that does).

这篇关于32位窗口下的64位寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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