Unix and C
Siva Chelliah
siva at bally.Bally.COM
Fri Nov 9 11:38:43 AEST 1990
In article <fraser.658038441 at bilby> fraser at bilby.cs.uwa.oz.au (Fraser Wilson) writes:
>In <4458 at mint39.UUCP> gunda at motcid.UUCP (Indira Gunda) writes:
>
>>richb at railnet.UUCP (Richard Banks) writes:
>
>>>How can Unix be written in C ? I thought all OS`s had to be written
>>>in assembly language, else they'd have the same interrupts as the
>>>OS you booted your complier language under to write the program ?
>
>>Yes ... Why and how can UNIX be written in C? I'd also like to know.
>
>Why? Because it makes it very portable. Any machine that has a C
>compiler and a few kernal routines (actually a fair number) can run Unix
>fairly easily. If Unix were written in assembly, it would have to be
>completely rewritten for every new computer it runs on.
This discussion reminds me of something.
Q: How is the first compiler is written ?
A: In assembly language.
Q: How is the first assembler is written ?
A: In machine language.
Q: If you have just the hardware, how would you feed the machine language
into the computer ?
A: I thing you should burn the machine language into a chip, that would
accept a machine language from the user, and execute it.
>
>How? Well, you have a few system calls to assembly routines, and then
>write lots of C to use them. The C compiler itself is written in C.
>
Assume you have a C compiler ( write it any way you want - assembly, or Pascal
or anything ). It can be as sloppy as you want.
Let's call it sloppy_comp_sloppy.exe
sloppy_comm_sloppy.exe ===> a C compiler which is sloppy(doesn't do any
optimization)
Now write a optimizing C compiler in C call it opti_comp.c
opti_comp.c ===> a C compiler that will optimize other C programs.
compile this with sloppy_comm_sloppy.exe , and you will get
opti_comp_sloppy.exe ==> it is a sloppy exe file (will run slow,
but will compile other C programs and produce
good exe programs)
Now, compile opti_comp.c using opti_comp_sloppy.exe, and you will get
opti_comp_opti.exe ===> an optimized exe file which will produce other good
exe programs.
So we started with a sloppy C compiler and using that we produced a
optimizing C compiler ( which itself is optimized).
Siva
siva at bally.bally.com
More information about the Comp.lang.c
mailing list