9

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.

  • 3
    The answer is likely unknowable unless you hunt down the person who added that functionality and asked 'why'. – user40980 Nov 21 '14 at 22:49
  • 1
    @MichaelT I'm aware of that possibility, but still I find that quite interesting topic... Maybe someone has seen some quote or so. – Vyktor Nov 21 '14 at 22:54
  • @Vyktor questions like this are sometimes unanswerable, but I still find computer science history to be interesting even if in the gray area of "on-topic" – user22815 Nov 22 '14 at 0:51
  • @Snowman agreed, but if it occurred to me to do what GlenH7 did (go trough gcc history instead of googling why gcc uses at&t) I wouldn't ask that question. – Vyktor Nov 22 '14 at 10:19
13

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.

  • I don't understand how I missed this "Intel syntax is dominant in the MS-DOS and Windows world, and AT&T syntax is dominant in the Unix world, since Unix was created at AT&T Bell Labs." Joined with your answer its just seem so straight forward. – Vyktor Nov 22 '14 at 10:21
  • What this answer doesn't touch upon, however, is why GAS uses the "native" syntax for so very many other CPU architectures. x86 CPUs seems to me to be among the few for which it actually uses AT&T syntax. – Dolda2000 Jul 29 '16 at 22:09
  • "...there was an underlying architectural difference between the CPUs powering Unix systems and PCs." Huh? The CPUs were the same. The instruction set architecture was the same. AT&T syntax has always been an alternative notation for the same underlying architecture. Right? – Maxpm Nov 13 '17 at 5:44
  • 1
    @Maxpm - The CPUs were not the same, and this is where big vs. little endian architectures matter. – GlenH7 Nov 13 '17 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.