how to compile "hello world" as kernel use DJGPP

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
qflash

how to compile "hello world" as kernel use DJGPP

Post 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?
Tim

Re:how to compile "hello world" as kernel use DJGP

Post 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.
Post Reply