how come OS be written in C

R

raashid bhatt

how is it possible to create a OS in c as firstly it require compiler
and requires support external libraries
for example on windows printf function is statically linked with
MSVCRT.DLL export
 
A

Antoninus Twink

You use a cross compiler. The compiler runs on a VAX or Apple Mac or
something, and the first program for the target is created - the OS. The
second program is the C compiler.

Or historically, I guess people wrote a rudimentary C compiler in
assembly, which was good enough to compile version 0.1 of their C
compiler, which could then compile version 0.2 of the compiler, and so
on.
 
S

santosh

raashid said:
how is it possible to create a OS in c as firstly it require compiler
and requires support external libraries
for example on windows printf function is statically linked with
MSVCRT.DLL export

Almost all parts of an operating system can be written in C (or in many
other high-level languages for that matter). An OS isn't really as
magical as it may seem to beginners. It's simply a program with
intimate knowledge of the system's hardware and usually running under
a "privileged mode" which protects it from damage by ordinary programs.
A small amount of an OS's code is usually platform specific assembler,
but the vast majority can be written in C. In fact C was expressly
designed by it's author for writing OSes and is very suited to do so
till this day.

For more such queries please use the group <but
check their FAQ and make a quick search of past posts before asking
elementary questions.
 
H

Herbert Rosenau

how is it possible to create a OS in c as firstly it require compiler
and requires support external libraries
for example on windows printf function is statically linked with
MSVCRT.DLL export

This is the same as how to get a computer to boot because you needs a
program to load before it can loaded?

It is simply magie!

O.k., look up:

you writes a very small program in hex code that will be able to read
and translate assembler and translate that assember to hex and stor
that to disk. Then you writes a simple program in hex that can
translate a basic C language to assembler. Then yoou use that to write
a more comfortable C compiler in that basic C to get assembly
translated to mashine code. Then you will use that simple compiler to
write a more complx compiler. You'll in a recursion until you have
created a full compiler. Then you'll write a kernel, linker and some
tools to get an operating system up and running.

When you owns already a computer that runs an operationg system and a
full flagged compier you will only write a new backend for that
compier and use that to translate the existent operating system and
compiler with the new backend to translate that for the new computer.

Easy, eh?
--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2R Deutsch ist da!
 
B

Bartc

Herbert Rosenau said:
This is the same as how to get a computer to boot because you needs a
program to load before it can loaded?
you writes a very small program in hex code that will be able to read
and translate assembler and translate that assember to hex and stor
that to disk.

I've actually done something similar. In my case, I had to wire up the
hardware first. Then the first programs were written in binary, not hex
(using push-buttons). (Although, since at first there was no display, only
LEDs, and no keyboard, these were not very exciting programs.)

With a text display and keyboard added, the next programs allowed entry via
the keyboard, using hex. After that, using hex machine code, some sort of
primitive editor and assembler. Then, writing in assembler now, a very
primitive high-level language. And this was used to do stuff with 3d
graphics and video capture (this was a big deal in 1981).
Then you writes a simple program in hex that can
translate a basic C language to assembler.

Think you mean, in assembler.
Then you'll write a kernel, linker and some
tools to get an operating system up and running.

If you've managed to get this far without an OS then you might also realise
that you don't need one! That'll save a bit of time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top