Re: AT&T C Compiler Source in Assembly Language

John R Levine <>
30 Jan 1998 00:32:07 -0500

          From comp.compilers

Related articles
AT&T C Compiler Source in Assembly Language (Matthew Webb) (1998-01-23)
Re: AT&T C Compiler Source in Assembly Language (John R Levine) (1998-01-30)
| List of all articles for this month |

From: John R Levine <>
Newsgroups: comp.compilers
Date: 30 Jan 1998 00:32:07 -0500
Organization: Compilers Central
References: 98-01-090
Keywords: C, history

> >[Do you have a GE 635 to run it on? -John]
> No! I want to see the structure of it and any way, I have found that
> there is not one from the creator of C. So why do you think there is?
> Do you know something he does not? Please explain.

The first implementation of C was on the GE 635. I have no idea whether
any of the source code survives.

The 5th edition Unix compiler was written in C but had a
straightforward two pass structure: the first pass parsed everything
and created the symbol table. It generated assembly code for the
flow-of-control operators and RPN token strings for expressions.

The second pass passed through the assembly code and turned the RPN
into assembler by making a tree of each expression, doing Sethi-Ullman
register estimates, and then walking the trees to generate code from
tables. There were three tables, one for generating code for the side
effect, one for the truth value, and one for numeric value. The
tables weren't complete and it would fall back from one to another if
it couldn't find a match.

There was an optional third pass that made a peephole optimizing pass
over the assembler. It was quite simple, just read the assembler for
each routine and did simple pattern matching to remove dead code, move
tests from one end of a loop to another and stuff like that. It
wasn't a general assembler optimizer, it only understood the assembly
code that the C compiler put out.

I remember all this because I wrote a replacement for the first pass called
INfort that compiled Fortran 77 rather than C.

John Levine, comp.compilers moderator,,

PS: The dsk files in the 5th edition archives are disk images in 5th
edition Unix file system format. Better get out those bit tweezers.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.