11

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.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 2
    I prefer Intel syntax and *really* dislike AT&T syntax, even though you see AT&T syntax a lot more in Linux. This question is similar to yours: [AT&T vs Intel Syntax and Limitations?](http://stackoverflow.com/questions/972602/att-vs-intel-syntax-and-limitations) – AusCBloke Dec 18 '11 at 02:39
  • I seem to find Intel syntax better too. I've searched for similar questions, but didn't come across this, I'm sorry if it's considered an exact duplicate. –  Dec 18 '11 at 02:42
  • https://stackoverflow.com/questions/2397528/mov-src-dest-or-mov-dest-src/60596999#60596999 As I noted in this answer, Intel syntax matches the order of address and immediate encodings, as well as the sense of conditional branches when the condition name is read between the two operands to a `cmp` – ecm Jun 11 '22 at 20:12

3 Answers3

9
  • 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 .

Gunther Piez
  • 29,760
  • 6
  • 71
  • 103
  • Embedded x86 is rare compared to ARM. GNU assembler (GAS) syntax for ARM isn't AT&T, it's still GAS directives but the same instruction syntax ARM's own documentation uses. Same for most other non-x86 ISAs; x86 is the only ISA I know of where GAS syntax is majorly different from the vendor's manuals, thanks to some PDP-11 fans at Bell Labs. See https://stackoverflow.com/tags/att/info vs. https://stackoverflow.com/tags/intel-syntax/info – Peter Cordes Jun 11 '22 at 18:44
  • Note that there's multiple dialects of "Intel syntax". MASM (Microsoft's) uses `DWORD PTR` (and this is what GAS copies in its Intel mode) and NASM doesn't (it's a much cleaner "everything is a label" syntax that doesn't attempt to emulate variables or variable types). – Brendan Jun 11 '22 at 21:18
5

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.

LeleDumbo
  • 9,192
  • 4
  • 24
  • 38
  • How is AT&T syntax less readable? I find having size suffixes on operands more consise than having "dword". Is there something else I'm missing? – Hawken Mar 25 '12 at 14:09
  • 3
    Well... some people do have concise = readable in mind, but such readability only applies to those who have enough experience. Even the experienced could forget sometimes (ever code in APL?). While readable that I mean is literally readable. – LeleDumbo Mar 28 '12 at 07:16
  • 2
    I find the experience point bizarre as I began learning assembly not a month ago, and have almost no experience and I found AT&T syntax more intuitive from the start. One minor exception is the use of the `l` postfix for 32bit operands instead of the more logical `d` for shortening `dword`. – Hawken Mar 31 '12 at 00:36
  • 2
    I find it bizarre that you feel the need to post the same comments on two questions, instead pointing out that this is a duplicate of [another question](http://stackoverflow.com/questions/972602). :P As for your qualms, it's not that AT&T is less readable, it's that Intel is more familiar to C[-like] programmers, imitating assigment expressions, casting, infix operators, etc. – bug Sep 08 '12 at 00:40
2

Although the question is old, one - as I find - important argument has not been mentioned:

If you are interested in Assemblercode, you are perhaps also interested in Reverse Engineering, which makes no sense without an undestanding of Assemblercode.

For the serious reverser, there are - among others - two important products in use: IdaPro from Hex-Rays and Ghidra from the NSA. Both use the Intel syntax and (I hope I am right here) do not understand AT&T syntax.

This might give the Intel notation and advantage over AT&T.

Otherwise, it's only a matter of taste.

josh
  • 671
  • 5
  • 10