Thank you for the info - I will certainly look at the
I will try to port the C compiler to amd64 - while preserving as much of
the original code as I can. But not sure if this is even feasible.
Thanks and Regards
If that is your goal, you might want to start with the version included with 2.11BSD. It
is essentially the same as the version from V7, but with 15 more years of bug fixes. I
used that source to port V6 Unix to the TI990 architecture back in 2014/2015 and the good
thing about it is that it still compiles with a modern gcc.
For your project, I think you would be able to use the first pass ‘c0’ almost unchanged.
The second pass ‘c1’ would need major restructuring. It mainly builds a tree for each
expression and then performs various transformations, many of which are PDP11 specific
(but also portable ones, like handling of constant expressions). It then covers the tree
with code fragments selected from a library. This library (‘optable') would need a
full rewrite as well. The last pass ‘c2’ is the optimiser and is also highly PDP11
specific. It reads the assembler output of ‘c1’ function by function, building an
instruction list. It then performs some portable optimisations (eliminating unnecessary
jumps, etc.) and also more PDP11 specific optimisations (the most complex being removing
redundant register loads - the concept of which would be reusable).
There are about 12,000 lines of code and as a rough guess I would say that some 40% needs
rewriting. A new code fragment library would probably be some 2 to 3 thousand lines.
I recall reading about a project to revive the Ritchie C compiler one or two years ago,
but a quick web search came up dry. Anybody else remember reading that?