Is it possible to use a 64-bit instruction in a 32-bit application on Intel / 64-bit win7

My environment is the 64-bit version of win7, VC2010.

Of course, Intel inside is a 64-bit processor.

Is it possible to use a 64-bit instruction / native machine word (64-bit) in a 32-bit application? Since most of my code is 32-bit, I don’t want to port it to the 64-bit version.

For some critical “hot” performance code, I want to manually optimize it using the built-in or built-in compiler assembly (also the 64-bit VC compiler does NOT support the built-in assembly), is it possible to run the 64-bit fox code of the example mov rax, rbx in an application with 32 -discharge mode?

+4
source share
2 answers

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

So how to run 64 bit code?

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

There are, of course, some restrictions on what you can do from the 64-bit code entered in this way, because you really are not running the 64-bit process.

+9
source

32- , , 64- "" . :

+4

All Articles