The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Eddy on March 27, 2006, 09:50:33 AM

Title: Running existing code in 64-bit mode?
Post by: Eddy on March 27, 2006, 09:50:33 AM
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
Title: Re: Running existing code in 64-bit mode?
Post by: EduardoS on March 27, 2006, 10:35:43 AM
Your assembly 32bit code won't work in long mode anyway...
Title: Re: Running existing code in 64-bit mode?
Post by: evlncrn8 on March 27, 2006, 02:03:41 PM
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
Title: Re: Running existing code in 64-bit mode?
Post by: Tedd on March 27, 2006, 06:24:24 PM
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
Title: Re: Running existing code in 64-bit mode?
Post by: Eddy on March 28, 2006, 08:51:55 AM
Sounds reassuring ...
Thanks all for your replies !

Kind regards
Eddy