Live data from Hacker News

AT&T Syntax versus Intel Syntax (2001)

cs.mcgill.ca

71–80 of 112 posts

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

#71
post #69

On Linux, is there a way to convert an assembly language file from one syntax to the other? I know that there are ways to ask GCC to emit one syntax or the other, as well as ways to assemble code in either syntax. However I don't know any program that just translates one to the other.

Assemble and disassemble? While that will of course lose your labels etc. :-D

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

#72
post #2

Hmm. "AT&T"? I thought it at least came from DEC via the PDP-11,7 assembler. And I'm guessing Intel didn't invent doing it backwards in their own either.

It's the AT&T syntax because AT&T are the one who unleashed that on the world against the wishes of everyone. See the sibling comment: > The AT&T folks did not even wait for Intel's assembler [...] Nor did they closely model their assembler after it. They just took the assembler they already had for the PDP-11 and adapted it with minimal changes for the 8086.

Wow, is your bias showing. "Against the wishes of everyone"? How about the wishes of those who wanted an x86 assembler before Intel got around to releasing theirs? And who wanted to be able to not have to switch their brains into a backward syntax when working on an x86?

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

#73
post #59
post #48

Earlier quoted context omitted.

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.

Probably an artifact of the original use of the assembler being to process compiler output, and causing variable names to appear.

One of the x86 assemblers I remember trying out in the late 80s had a slight variant of Intel syntax in that everything that wasn't a reserved word/mnemonic was automatically assumed to be a label.

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

#74
post #12

Earlier quoted context omitted.

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

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

That's just a convention. The way we would order the sentence in English is also just a convention.

You know what the logical convention to use would have been? The order that every assembler on the planet already used.

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

#75
I'm in the Intel syntax camp, pretty thoroughly. I use other assemblers, too, and the Intel syntax is a lot more similar to ARM, RISC-V, and assemblies used by DSPs (which are surprisingly C-like). The order of operations, the order of comparisons, the addressing syntax, and the lack of spurious wingdings characters all make it easier to read and write.

The one thing AT&T syntax has going for it is the "strong typing" of operand widths: `addl` is slightly more readable than `add` + operand-inferred width.

If you want the C preprocessor, you can have it with Intel syntax too (gas can use either), but I think the preprocessing syntax designed for assembly is cleaner with assembly code, and some of those preprocessors are surprisingly powerful.

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

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

The amount of disagreement this individual testimony is generating is fascinating and frustrating to me.

I didn’t think it ever really makes sense to disagree with a comment like this, unless one is claiming that the content of your comment is intentionally untrue. Anyways, appreciate your perspective.

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

#77
post #4

In a dumb idea to depend only on GAS, before it had good support for Intel syntax, I ported some code from Intel syntax into AT&T many moons ago, quite dumb idea, if i was doing it today I would have listed nasm or yasm as a requirement and be done with it.

I'm pretty sure all this predates the existence of gas

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

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

The amount of disagreement this individual testimony is generating is fascinating and frustrating to me. I didn’t think it ever really makes sense to disagree with a comment like this, unless one is claiming that the content of your comment is intentionally untrue. Anyways, appreciate your perspective.

It's rare that I post unpopular opinions, but when I see an HN thread full of people talking about how terrible the tools are which helped me be successful, I just can't help but speak up. It's an important topic for me because I originally believed the consensus. Like all of you, I read the countless Internet comments which say things like GNU AS is meant only as a backend for GCC, that you must never write assembly, and if you do then AT&T syntax is the devil. As a result, I wasted half a year of my life trying to build APE using programs like nasm and fasm. It wasn't until I decided to use only GNU tools that I began making progress.

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

#79

Earlier quoted context omitted.

It's the AT&T syntax because AT&T are the one who unleashed that on the world against the wishes of everyone. See the sibling comment: > The AT&T folks did not even wait for Intel's assembler [...] Nor did they closely model their assembler after it. They just took the assembler they already had for the PDP-11 and adapted it with minimal changes for the 8086.

Wow, is your bias showing. "Against the wishes of everyone"? How about the wishes of those who wanted an x86 assembler before Intel got around to releasing theirs? And who wanted to be able to not have to switch their brains into a backward syntax when working on an x86?

Probably "against the wishes of assembly language programmers who were familiar with microprocessors like the 8080 and Z-80 - and those who would have preferred to standardize on the official intel syntax rather than deal with two different and incompatible assembly language syntaxes."

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

#80

Similar thing also happens on 68k: Motorola syntax v.s. "MIT" syntax which is probably only used by GNU toolchain

Practically, 68k is far more usable in AT&T syntax than x86. When I used to do PalmPilot development, you could basically write standard 68k asm with just some extra %s sprinkled before registers and as would be fine with it. The x86 AT&T syntax is far more alien compared to the syntax in the official manuals, with arguments backward and nonstandard instruction names like addl and movabsq.

I never understood the need for names for movabsq. The top comment on this HN discussion is about how this is all a historical quirk, people wanting to get a job done quick and dirty. But movabsq is a new instruction introduced only with x86-64 (then known as AMD64). With the 64-bit transition why didn't they take the opportunity to clean up and reorganize this mess?
Post reply on HN