Page 1 of 1

Trying to Build an operating system

Posted: Sun Feb 25, 2001 12:00 am
by Arif Habib Shadan
Hi PPl
I am really new to this .... i have made a bootloader
now i have to make a kernall... can anybody tell me
how can i make a very easy kernal on c++ which will
only do some calculations or something ... so that
i can place this project of mine on the exhibition.


take care all of you.
Bye

RE:Trying to Build an operating system

Posted: Sun Feb 25, 2001 12:00 am
by Chase
>On 2001-02-25 05:59:03, Arif Habib Shadan wrote:
>
>can anybody tell me how can i make a very easy kernal
>on c++ which will only do some calculations or
something

You bootloader does setup pmode correct? Checkout DF's
faq at http://www.mega-tokyo.com/os/os-faq-cpp.html#start
for info relating to making a c++ kernel.

Also the guide located on this site about Mixing C and
Assembly contains some related information.

RE:Trying to Build an operating system

Posted: Mon Feb 26, 2001 12:00 am
by Guest
>On 2001-02-25 05:59:03, Arif Habib Shadan wrote:
>Hi PPl
>I am really new to this .... i have made a bootloader
>now i have to make a kernall... can anybody tell me
>how can i make a very easy kernal on c++ which will
>only do some calculations or something ... so that
>i can place this project of mine on the exhibition.

you can not use c++. just c. the reason is that
if you want to create an object, you have to
allocate some memory for it. constructors and
destructors call malloc() and free(). if you
don't have malloc() and free() implemented, it
will not even compile.

You may try to create some simple stuff with use
of TurboC++1.01 compiler available from Borland
for free. Make sure you don't use standard
functions like printf() 'coz you don't have any
kind of DOS available at the boot time.
Also, don't create COM and EXE programs in a way
you would do a regular DOS program. If you do so,
compiler adds some DOS specific code which will
not work w/o DOS. Just compile .C files to .OBJ
and link them together with some stuff written
in assembly and also compiled to .OBJ. Then link
those .OBJs together (asm part goes first and calls
_main) in let's say a COM program -
this would be easy.
Then load and this COM program. Don't forget to
make all preparations for a COM program:
CS=DS=ES=SS, IP=100h, SP=0FFFEh (or even 0). Also
make sure you have "ORG 100h" in that ASM part and
you run the code using correct CS:IP.

Good Luck

RE:Trying to Build an operating system

Posted: Wed Feb 28, 2001 12:00 am
by Nick
>On 2001-02-26 17:08:17, Anonymous wrote:
>you can not use c++. just c.

Of course you can!

>the reason is that
>if you want to create an object, you have to
>allocate some memory for it. constructors and
>destructors call malloc() and free(). if you
>don't have malloc() and free() implemented, it
>will not even compile.

There are many free/public-domain/GPLed implementations of
malloc() and free(), and of the new() and delete() operator functions.
Nearly all of them are made to be platform independent, eg, you
can put them in your OS.

If you are writing an OS, then you should be able to write up your own
versions of malloc() and free(), since they are just basic memory management.

Anyway, you don't even need to have them implemented. You can
allocate your objects statically at compile time, or as local
variables on the stack.

I know you are going to say that this is useless since you need to
allocate objects dynamically to represent certain data structures, eg,
page tables/directories, process information, etc. If you were
writting the OS in C, you would still need to dynamically allocate
struct's to represent those data structures, meaning that you would
need implementations of malloc() and free().


--Nick