Page 1 of 1
how to compile "hello world" as kernel use DJGPP
Posted: Sun Jun 22, 2003 12:24 am
by qflash
ex: kernel.c
#include "stdio.h"
main()
{
printf("Hello World!");
}
I am use DJGPP under WIN2000.
How can i compile kernle.c as my os's Kernle?
Re:how to compile "hello world" as kernel use DJGP
Posted: Sun Jun 22, 2003 4:37 am
by Tim
1. Write your own printf function.
2. Insert an infinite loop at the end of main.
3. Write some assembly startup code which acts as a bridge between the loader and the C code. This should set up registers, stack, etc.
4. Compile the kernel.c file as normal.
5. Link in the way that your loader expects.
If you have a copy of GRUB (recommended), you'll find a simple hello world kernel there which does the stuff in the list.