问题
I'm going through the Intel processor documentation and writing some basic assembly code at the same time. I have both nasm
and as
(GAS) on my server and I understand the basic differences of both assemblers.
In the long run:
- Focusing on which of these syntax is a better idea?
- What are the advantages and disadvantages of these syntax?
- Which one is more widely used and understood?
I would also appreciate any preferences you could share with me.
回答1:
- Focusing on which of these syntax is a better idea?
Depends on your projects. Not every compiler does allow both kinds of syntax. If you need to have to code assembled on other platforms Intel is probably better, even after some years experience with both I personally like Intel more, but it`s a small difference, and it doesn't really matter to me.
- What are the advantages and disadvantages of these syntax?
In the AT&T syntax there are slightly to much %
, even more if you need to use macros. OTOH I prefer the source, destination ordering, but thats personal taste, others may prefer it the other way around because it resembles the writing order of an assignment operator in say C (and many more).
I INTEL syntax the are obscenities like DWORD PTR
, where in AT&T a small appended l
is sufficient. The exact spelling of the mnemonics differs in many cases, I find the AT&T more logical while of course Intels way is the standard. The addressing modes in Intel are somewhat more readable.
- Which one is more widely used and understood?
I believe AT&T is more used, because of the ubiquitousness of linux on embedded platforms, where assembler is much more often used that in other software projects. There are more assemblers which understand Intels syntax, that much is true, but I believe gcc/gas is more used in a field where assembler matters/is useful .
回答2:
Focusing on which of these syntax is a better idea?
Whichever you're comfortable to work with
What are the advantages and disadvantages of these syntax?
For me: Advantages: - Intel: readable - AT&T : more platforms (since 'as' is available on many platforms) Disadvantages: - Intel: many assemblers, but very few common similarities, many features are assembler specific - AT&T: it adds +/- to your eyes
Which one is more widely used and understood?
AFAIK Intel syntax is more widely used. You can check the number of assemblers supporting Intel vs AT&T.
来源:https://stackoverflow.com/questions/8549427/nasm-intel-versus-att-syntax-what-are-the-advantages