Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

64-bit registers under 32-bit windows

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

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

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

like image 615
Jim Avatar asked Aug 13 '11 01:08

Jim


1 Answers

  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.

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

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.

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

like image 191
SoapBox Avatar answered Oct 14 '22 20:10

SoapBox