Live data from Hacker News

AT&T Syntax versus Intel Syntax (2001)

cs.mcgill.ca

51–60 of 112 posts

Re: AT&T Syntax versus Intel Syntax (2001)

#51
post #19

Here's the why for the curious. It's just a historical quirk. It's "AT&T syntax" because it dates to the 1978 AT&T Labs effort to port UNIX to the 8086. [1] While the 8086 did not have virtual memory or hardware protection, its memory segmentation model was still adequate to support UNIX. It was the first microprocessor practically capable of running UNIX, and this was realized before the chip was even released. The…

I think there's a bit more to the story. It was before my time, but as I understand it the most widely used Unix for the 8086 was XENIX (initially a Microsoft product, later sold to SCO), which used Intel-syntax MASM as its assembler.

XENIX for 386 was based on AT&T System V/386, which introduced the AT&T syntax to 32-bit x86. I've found some references to 32-bit XENIX still using an assembler called "masm" but I don't know if it was still based on Microsoft's MASM or just called that for compatibility, or whether it was AT&T or Intel syntax. Also by that point compilers and assemblers weren't included in the base OS anymore, but a "development kit" sold separately.

The Minix compiler and assembler also used Intel syntax.

Re: AT&T Syntax versus Intel Syntax (2001)

#52

AT&T vs. Intel syntax has caused many arguments in some of my circles. AT&T is an atrocity and if you disagree... you're wrong. :)

op src dest is the logical order, the rest of the syntax I don’t care about much.

Sketchy part is when operations read and write with the same argument. Op first is nice for that as it becomes op arg0 arg1.

I quite like the SSA style which tends to be dst0 dst1 opcode src0 src1 but that doesn't model assembly brilliantly. Perhaps that order with read-write arguments required to appear on both sides of opcode with the same symbol has some merit.

Re: AT&T Syntax versus Intel Syntax (2001)

#53
post #40

Earlier quoted context omitted.

That's interesting. My entire world revolves around x86 and ARM, so "Intel" syntax (which to me mostly means op dest, src) is what seems normal to me.

Order of dst and src i have no strong feelings about, it's all the rest that i find weird about intel syntax.

dest = src

That's how I think of it.

ALSO: I really do not like the MOV instruction; I much prefer LD. The Z-80 instruction names got everything mostly right.

Re: AT&T Syntax versus Intel Syntax (2001)

#54
post #12

Earlier quoted context omitted.

In mathematics variable = value , variable receives value, ergo op dest src . That is logic.

...math has no such order. Half the point of algebra is that the two sides of the equation are semantically equivalent and can be swapped at will.

And it has no state. Half the point of computation is maintaining state for the purpose of efficiency. So, computation gets an "assignment" operator where pure math lacks one, pure math being relegated to subscripts of time and indicator functions instead.

Re: AT&T Syntax versus Intel Syntax (2001)

#55
post #48

IMHO the most confusing part is that AT&T/GAS syntax inverts the comparisons, which are otherwise natural in Intel syntax: cmp eax, ebx ; eax ? ebx jg foo ; jump if eax > ebx Related: http://x86asm.net/articles/what-i-dislike-about-gas/

Also the % before register names is completely unnecessary, it just another extra character to type.

[deleted]

Re: AT&T Syntax versus Intel Syntax (2001)

#56
post #8

Earlier quoted context omitted.

They are using a classic dollar sign for assignment, so clearly at&t is better.

> They are using a classic dollar sign for assignment They're using a dollar sign for immediates . As if you can't notice that it's a number. addl $4, %eax that's 3 different completely unnecessary symbols for things which are not ambiguous in the first place: - the operation width is provided by the registry - a number is an immediate - a register is named Hence the much less noisy Intel syntax: add eax, 4

The comma is unnecessary too, so that’s 4 unneeded symbols.

Re: AT&T Syntax versus Intel Syntax (2001)

#57
post #49

Earlier quoted context omitted.

...math has no such order. Half the point of algebra is that the two sides of the equation are semantically equivalent and can be swapped at will.

Good luck convincing anyone that value = variable makes sense.

My math teachers had no problem with '42 = x' vs 'x = 42' as long as the steps made sense to get there. In fact they'd probably comment that there was no need to go with 'x = 42' if I obviously took a circuitous route simply to end up with x on the left side of the equation, as that would have demonstrated a lack of internalizing some of the base ideas of algebra and it's approach of equation symmetry.

Re: AT&T Syntax versus Intel Syntax (2001)

#58

AT&T vs. Intel syntax has caused many arguments in some of my circles. AT&T is an atrocity and if you disagree... you're wrong. :)

op src dest is the logical order, the rest of the syntax I don’t care about much.

I used to think this was more intuitive, but after using both for a while I came to the conclusion that putting the destination first is much more practical, because my eyes can scan the left column to quickly find where a register was last written to. If the destination is last, it doesn’t appear in a consistent location horizontally.

Re: AT&T Syntax versus Intel Syntax (2001)

#59
post #48

IMHO the most confusing part is that AT&T/GAS syntax inverts the comparisons, which are otherwise natural in Intel syntax: cmp eax, ebx ; eax ? ebx jg foo ; jump if eax > ebx Related: http://x86asm.net/articles/what-i-dislike-about-gas/

Also the % before register names is completely unnecessary, it just another extra character to type.

It disambiguates labels from registers, assuming of course you allow labels to have register names. eg this is valid:

        mov rax,%rax                                                            
  rax:  .ascii "hello\0"
Stupid perhaps, but valid.

Re: AT&T Syntax versus Intel Syntax (2001)

#60
post #47
post #29

Earlier quoted context omitted.

addl is not necessary if it is not ambiguous add $4, %eax - is fine Compare with add 4, %eax The "less noisy" Intel syntax becomes: add eax, DWORD PTR [4]

Most assemblers for Intel syntax will let you write: add eax, [4] if you desire. Indeed, many disassemblers will follow suit in unambiguous cases. IDA, for example, does this.

The only time “DWORD PTR” is required is when (1) you're working with old assemblers, or (2) you're using a memory operand with an immediate:

    add eax, [4]       ; inferred
    add [eax], 4       ; ambiguous
    add DWORD [eax], 4 ; explicit
A disassembler may output it when not necessary, however.
Post reply on HN