Dennis Ritchie's first C compiler on Github
11–20 of 88 posts
Re: Dennis Ritchie's first C compiler on Github
#12Is this written in C? If so, what compiled this? Sorry for the noob question, I'm just a little lost.
From the link on GitHub: http://cm.bell-labs.com/cm/cs/who/dmr/primevalC.html Which led me to here: http://cm.bell-labs.com/cm/cs/who/dmr/chist.html Where, if you take the time, you will find a wonderful story, upon completing, you will probably know more about the early embryonic history of C then 95% of your peers. (Spoiler - We start with BCPL, then Move to B - it's left as an exercise to determine how we original…
Oh how our minds play tricks on us!
Re: Dennis Ritchie's first C compiler on Github
#13Is this written in C? If so, what compiled this? Sorry for the noob question, I'm just a little lost.
Re: Dennis Ritchie's first C compiler on Github
#14Is this written in C? If so, what compiled this? Sorry for the noob question, I'm just a little lost.
To compile a C compiler, you don't need a full-blown C compiler. For instance, I bet floats and doubles are not used. Therefore, you can write a barebones proto-C compiler in whatever language you have available and use it to bootstrap your compiler. Rinse and repeat.
Re: Dennis Ritchie's first C compiler on Github
#15Is this written in C? If so, what compiled this? Sorry for the noob question, I'm just a little lost.
Re: Dennis Ritchie's first C compiler on Github
#16Earlier quoted context omitted.
Looks like a very early dialect. C assumes everything is an int unless specified otherwise. You can declare parameter types after the function name. So: init(s, t) char s[]; { would be equivalent to: int init(char s[], int t) { This still works with modern compilers. I'd be interested if anyone has any more info about this: waste() /* waste space */ { waste(waste(waste),waste(waste),waste(waste)); waste(waste(waste),…
From the linked description ( http://www.cs.bell-labs.com/who/dmr/primevalC.html ): A second, less noticeable, but astonishing peculiarity is the space allocation: temporary storage is allocated that deliberately overwrites the beginning of the program, smashing its initialization code to save space. The two compilers differ in the details in how they cope with this. In the earlier one, the start is found by naming a…
Cool to think that that waste function can still compile with todays compilers. A quick disassembly it seems to take up 751 bytes compiled on x64 using clang on O0.
Re: Dennis Ritchie's first C compiler on Github
#17Is this written in C? If so, what compiled this? Sorry for the noob question, I'm just a little lost.
Looks like a very early dialect. C assumes everything is an int unless specified otherwise. You can declare parameter types after the function name. So: init(s, t) char s[]; { would be equivalent to: int init(char s[], int t) { This still works with modern compilers. I'd be interested if anyone has any more info about this: waste() /* waste space */ { waste(waste(waste),waste(waste),waste(waste)); waste(waste(waste),…
Re: Dennis Ritchie's first C compiler on Github
#18Re: Dennis Ritchie's first C compiler on Github
#19Re: Dennis Ritchie's first C compiler on Github
#20Earlier quoted context omitted.
It compiles itself! http://en.wikipedia.org/wiki/Bootstrapping_(compilers)
I understand bootstrapping, but at some point there has to exist some outside compiler in another language or a hand-compiled version of this otherwise the chicken and egg chain never ends.