Jump to content

Does NASM work on AMD?

- - - - -

  • Please log in to reply
9 replies to this topic

#1
DarkLordofthePenguins

DarkLordofthePenguins

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 409 posts
I'm thinking of getting NASM to do x86 Assembly programming. I'm wondering, will an x86 assembler work on AMD64? Does AMD64 understand x86, or does NASM convert the x86 to AMD assembly? I've never heard of an AMD64 Assembly language, so I don't know what form of Assembly AMD CPUs use. I have both an AMD-based PC and an Intel-based Mac, and I want to try it out of both of them.
Programming is a journey, not a destination.

#2
Gunner

Gunner

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
Intel and amd are basically the same... I think the main difference is one has mmx and the other has 3d now... And a few others.
You can look into nasmx...NASMX - Projects - ASM Community

#3
Gunner

Gunner

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
No, nasm doesn't do x64.. Nasmx does NASMX - Projects - ASM Community intel and amd are basically the same

#4
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
I thought NASM assembles 64-bit assembly, doesn't it?

Such as this?:
BITS 64 

ORG 0 


start: 


mov rax, 65 


sub rax, rbx 

And it has options for output format such as elf64, win64, and macho64; is x64 different from 64-bit?

#5
Gunner

Gunner

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts

RhetoricalRuvim said:

I thought NASM assembles 64-bit assembly, doesn't it?

oops.. Had a long day

Edited by Roger, 31 March 2011 - 12:04 PM.


#6
DarkLordofthePenguins

DarkLordofthePenguins

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 409 posts
I'm kind of confused here, because I've seen 64-bit operating systems described as being written for x86. I thought x86 was just a term for the main line of Intel processors (as opposed to Itanium, which has its own instruction set), regardless of whether they are 32-bit or 64-bit.
Programming is a journey, not a destination.

#7
Gunner

Gunner

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
Itanium is known as IA-64. X86 is a general term for 32 bit cpus.. X64 is a general term for 64 bit cpus.. Intel calls it IA-32... Amd calls them x86 and x64 at least thats what their manuals call em.

#8
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
I think I will take a crack at the terminology at least.. Intel originally named their Intel 80386 instruction set IA-32e (ironically in '86), we consider this the term x86 only because the line of processors ended in that model number. Intel wished to move on to 64-bit capabilities, and decided to make a 64 bit only processor instruction set which is a bit silly (but had truth back then), and as such named the instruction set IA-64 with the inclusion of their Itanium line of processors.

AMD's figured this was a bit silly as well and wished to design an alternative to this, so they designed an architecture named AMD64 which is in fact an extension of the x86 instruction set, the vender neutral term for this is x86-64. Intel decided to provide similar support for their IA-32e processors later in the form of Intel EM64t technology which provided an implementation to the proclaimed "x86-64" instruction set extension, and is now named Intel 64.

So in other words you should be fine compiling for a 64 bit (or in other words as mentioned, x86-64) architecture as long as you stay away from IA-32e-only instructions or AMD64-only instructions (suchas 3DNow!)

Edited by Alexander, 04 April 2011 - 12:13 AM.
Was autobolded?

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#9
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,252 posts
  • Location:C:\Countries\US
So there are superannuated instructions that are not supported by 64-bit? And do 64-bit processors start up in real-address mode, also?

#10
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,705 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript

RhetoricalRuvim said:

So there are superannuated instructions that are not supported by 64-bit?
Yes. Take a look at the Intel Architectures Software Developer's Manual, volumes 2A and 2B for a complete description of the instruction set. For each instruction there's an indication of what architectures support it; because of a few changes to the encoding (namely the REX prefix) some instructions are no longer valid in x86-64 and must be encoded in an equivalent form. Assemblers will automatically use the different encoding in 64-bit mode if possible. Good ones, anyway.

Some examples of invalid instructions in x86-64 mode include:
AAA, AAD, AAM, AAS
BOUND
DAA, DAS
LAHF (in some versions)
Some but not all encodings of LDS and LES
...etc...

Quote

And do 64-bit processors start up in real-address mode, also?
Yes.

Edited by dargueta, 04 April 2011 - 12:07 AM.
Clarified some stuff

sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users