Live data from Hacker News

AT&T Syntax versus Intel Syntax (2001)

cs.mcgill.ca

41–50 of 112 posts

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

#41
post #27

I initially learned the Intel syntax, and preferred it for awhile. But the more I work with non-x86 CPUs, the more I prefer AT&T just because it feels less different than everything else.

Much agreed. Intel syntax just seems somewhat alien.

Intel syntax is more similar to ARM, MIPS, and even RISC-V's official syntax than AT&T.

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

#42

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.

Be that as it may, the AT&T indirect memory reference `section:disp(base, index,scale)` is an abomination unto God.

At least the Intel one makes actual mathematical sense: `section:[base + index*scale + disp]`

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

#44

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.

That is extremely confusing for comparisons, which are effectively a subtraction.

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

#45
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…

It's funny how many things come down to 'UNIX hackers did it this way when they had to work with a PC'

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

#46
post #38

Earlier quoted context omitted.

X86 addressing modes are an atrocity: https://stackoverflow.com/questions/63571979/clarifying-thre...

They are an atrocity in AT&T syntax . They are perfectly readable in Intel format. For example: https://blog.yossarian.net/2020/06/13/How-x86_64-addresses-m...

That is an excellent write up, thanks.

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

#47
post #29

Earlier quoted context omitted.

> 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

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.

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

#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.

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

#49
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.

Good luck convincing anyone that value = variable makes sense.

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

#50
post #23

AT&T syntax is the most elite syntax. I've used it to write some famous hacks, like Actually Portable Executable, which is a 16-bit BIOS bootloader shell script ELF / Mach-O / PE executable. People dislike it because writing assembly Bell Labs style requires great responsibility. What makes AT&T syntax so powerful is its tight cooperation with the linker. I don't think it would have been possible for me to invent APE…

Isn't this a function of the tools you were using, not the syntax? Couldn't any of these tools support any syntax and do the same thing?

The line between syntax and functionality is pretty thin for an assembler.

I've definitely had code that some assemblers accepted and others didn't on the same arch, so even if they could be equally expressive in practice they aren't. Fairly sure that's also true of inline assembly on clang x64, had to change between intel and at&t for something a while ago.

Post reply on HN