GCC – Why Default to AT&T Syntax in Assembly

assemblygcchistory

I think title says it all 🙂

Is there any particular practical reason (I guess it's mostly historic, but I'm unable to find it on my own) why GCC uses AT&T/GAS syntax?

Note: I know this is just default and you can switch it

Note 2: I personally find "Intel syntax" much more readable, so that's why it surpises me.

Best Answer

GCC uses AT&T syntax by default because it was originally written on a system that either used AT&T System V (now known as UNIX) or had syntax that closely resembled System V.

From Wikipedia on GCC

In an effort to bootstrap the GNU operating system, Richard Stallman asked Andrew S. Tanenbaum, the author of the Amsterdam Compiler Kit (also known as the Free University Compiler Kit) if he could use that software for GNU. When Tanenbaum told him that while the Free University was free, the compiler was not, Stallman decided to write his own. Stallman's initial plan was to rewrite an existing compiler from Lawrence Livermore Laboratory from Pastel to C with some help from Len Tower and others. Stallman wrote a new C front end for the Livermore compiler, but then realized that it required megabytes of stack space, an impossibility on a 68000 Unix system with only 64K, and concluded he would have to write a new compiler from scratch. None of the Pastel compiler code ended up in GCC, though Stallman did use the C front end he had written.

Note the following part:

Stallman wrote a new C front end for the Livermore compiler, but then realized that it required megabytes of stack space, an impossibility on a 68000 Unix system with only 64K...

Given that GCC was first released March 22, 1987* and that System V Release 3 was released in 1986**, it's highly likely that GCC was written on either SVR2 or SVR3.


The Wikipedia quote makes it clear that Stallman was working on the Lawrence Livermore Labs' equipment, which was Unix based and therefore System V. So we could stop there and just say "that's what he had to work on." But it's also interesting to look at the available MS-DOS / PC-DOS systems at that point in time. According to this timeline, the likely candidate for PC-DOS1 would have been version 3.2.

PCs (personal computers) weren't as widely used in academic or research settings at that point in time because their networking facilities were not as good as what Unix based systems could provide. There was also a historical preference for server / terminal type environments. Server / terminal systems had been available prior to the existence of PCs and generally provided much greater processing power and other resources than what a PC could affordably provide.

So while Stallman could have developed GCC on a PC, he likely would not have wanted to since his primary work would have been on Unix systems.

And as noted in a comment, there was an underlying architectural difference between the CPUs powering Unix systems and PCs.

Put all those pieces together and it's pretty clear why Stallman chose the AT&T syntax over Intel when developing GCC.

1 Note that it's easiest to say that MS-DOS was called PC-DOS prior to version 3.31. That being said, there's a lot to the history of DOS development that's outside the scope of this question.