News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Running existing code in 64-bit mode?

Started by Eddy, March 27, 2006, 09:50:33 AM

Previous topic - Next topic

Eddy

Hi all,

The other day, when checking out the DAA (Decimal Adjust AL after Addition) cpu command, I noticed that the Intel Manual said that this instruction is 'not valid in 64-bit mode'.
For as far as I could tell, all of the 'not valid in 64-bit mode' instructions are :
- the decimal and ASCII adjust instructions,
- BOUND
- PUSHA / PUSHAD
- POPA / POPAD

I assume this means that if I want my existing code to still run in 64-bit mode, I have to browse all my code looking for these instructions and replace them?
Or otherwise run my code in compatibility mode?
This last option seems the easiest. How do I do this? Can I enforce this in my program or does the user that wants to run my code have to set this option manually somewhere?

JFYI. I don't have a 64-bit cpu system, so I can't test anything yet..

Kind regards
Eddy
Eddy
www.devotechs.com -- HIME : Huge Integer Math and Encryption library--

EduardoS

Your assembly 32bit code won't work in long mode anyway...

evlncrn8

depends on the processor.. amd chip can run 32 bit code fine inside a 64 bit executable, it just depends on how you use the registers and what your code actually does, pushad doesnt work, unsure about the other opcodes, but in 64 bit code you are meant to handle the stack etc inside your own code, and preserve what registers you mess with which does take a bit of getting used to

Tedd

Quote from: Eddy on March 27, 2006, 09:50:33 AM
I assume this means that if I want my existing code to still run in 64-bit mode, I have to browse all my code looking for these instructions and replace them?
Or otherwise run my code in compatibility mode?
Yes (as I understand it.) But obviously your code was written as 32-bit, so you can't expect it to work entirely correctly in 64-bit mode (same situation with 16-bit code in 32-bit mode.)

Quote
This last option seems the easiest. How do I do this? Can I enforce this in my program or does the user that wants to run my code have to set this option manually somewhere?
Put the processor in compatibility mode, and run the code. I presume this will be made a lot easier by running the code within an OS. When your exe is loaded, it will be automatically identified as a 32-bit PE and therefore run in compatibility mode. 64-bit programs will obviously need to be labelled as 64-bit in some way for exactly this reasaon.
So, short answer: I don't think you'll actually need to do anything different from creating a 'normal' 32-bit program.

Quote
JFYI. I don't have a 64-bit cpu system, so I can't test anything yet..
You're not the only one :lol
No snowflake in an avalanche feels responsible.

Eddy

Sounds reassuring ...
Thanks all for your replies !

Kind regards
Eddy
Eddy
www.devotechs.com -- HIME : Huge Integer Math and Encryption library--