Author Topic: Moving from 32 to 64 bit processor  (Read 14402 times)

Offline sledge

  • Jr. Member
  • *
  • Posts: 19
Moving from 32 to 64 bit processor
« on: August 05, 2011, 04:59:06 AM »
I'm thinking of moving from a 32bit computer to a 64b (also XP to Seven). Can I still program for x86 using NASM , using the extended 32bits registers, or am I gonna have to learn something new?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Moving from 32 to 64 bit processor
« Reply #1 on: August 05, 2011, 01:06:13 PM »
I'm still running 32-bit hardware, so I'm not absolutely sure, but I think your 32-bit code will still run as expected. You will lose the ability to run 16-bit (dos) code - not MS's fault, it just isn't supported in "long mode". There's more to writing actual 64-bit code than just changing eax to rax, etc. and using "-f win64" - it's a totally different interface to the OS - but I don't think that's what you're asking(?).

In Linux, we run into an "issue"... gcc and ld usually "come with" Linux, and the "new" versions expect to make 64-bit code by default. We need to specify "-386" and "-melf_i386" to tell 'em we want 32-bit code (if we do). You might run into a similar issue with Windows, if you've got new "tools" to go with your new OS...

Try it, and see what happens!

Best,
Frank


Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Moving from 32 to 64 bit processor
« Reply #2 on: August 05, 2011, 02:46:55 PM »
Windows 7 handles most 32-bit applications just fine, including 32-bit programs created using Nasm.
You don't have to learn how to program in 64-bits to run your 32-bit applications.
MS did a rather superb job regarding backward compatibility.

Offline MJaoune

  • Jr. Member
  • *
  • Posts: 94
Re: Moving from 32 to 64 bit processor
« Reply #3 on: August 05, 2011, 06:00:14 PM »
If you have a good experience in Assembly and computers, then you can move from 32 to 64 easily, the only thing that you have to know is to make a register 64 bit. I wont recommend you to program 32 bit programs on 64 bit systems, especially if you are creating something to control the memory, like Emulators for example, so when you create an emulator or similar software, you have to create one for 32 bits and one for 64 bits, even though 64-bits systems can run 32 bits programs.

Best,
Mahmoud

Edit: Misinformation removed by forum moderation.
« Last Edit: August 21, 2011, 09:36:28 PM by Keith Kanios »

Offline Rob Neff

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 429
  • Country: us
Re: Moving from 32 to 64 bit processor
« Reply #4 on: August 05, 2011, 11:04:42 PM »
If you have a good experience in Assembly and computers, then you can move from 32 to 64 easily, the only thing that you have to know is to make a register 64 bit

No.  As Frank has stated there is more to 64-bit assembly besides extended registers.
The calling convention is different, alignment of stack is crucial, etc...
It's not difficult but you must do your research properly as there are rather significant differences.

"I have never heard of an 64 bit register?", the answer is that you have to combine 2 32-bit registers and make them one 64 bit register, like the following register "EDX:EAX", this register is a combination between two 32 bit registers.

Again, No.  This is a very misguided way of describing 64-bit registers that confuses, rather than helps, their understanding.

Read this Wikipedia entry for starters.

Read the  x86-64 ABI documentation for advanced treatment of this topic.

I wont recommend you to program 32 bit programs on 64 bit systems, especially if you are creating something to control the memory, like Emulators for example, so when you create an emulator or similar software, you have to create one for 32 bits and one for 64 bits, even though 64-bits systems can run 32 bits programs.

Again, your recommendations are confusing.  There are many 32-bit applications that have no 64-bit requirements and run just fine.

Offline MJaoune

  • Jr. Member
  • *
  • Posts: 94
Re: Moving from 32 to 64 bit processor
« Reply #5 on: August 05, 2011, 11:22:17 PM »
No.  As Frank has stated there is more to 64-bit assembly besides extended registers.
The calling convention is different, alignment of stack is crucial, etc...
It's not difficult but you must do your research properly as there are rather significant differences.

I know that, but the most important, is how to control the registers.

Again, No.  This is a very misguided way of describing 64-bit registers that confuses, rather than helps, their understanding.

Well, I have understood it that way and I can easily progam 64 bit softwares, that works.

Again, your recommendations are confusing.  There are many 32-bit applications that have no 64-bit requirements and run just fine.

I have created some emulators for different systems (So I have experience in emulation), they need to be specific for the system you are programming for, and actually you have said "There are many 32-bit application", and I have said that mostly programs that control the memory won't work, such as emulators, so I haven't meant to say that 32 bit programs doesn't work at all on 64 bit systems.

Also, if you want a good program that is fully compatible, then you have to know what system you are programming for.