Page 1 of 1

OS kernel in C

Posted: Sat Feb 08, 2003 12:36 pm
by slacker
Im trying to write a kernel in c..im not using grub and i want my code to start at 0050:0000 in real mode. when i link should i use ld -Ttext 0x500 to specify 0050:0000?
thanks anyone....

Re:OS kernel in C

Posted: Sun Feb 09, 2003 5:29 am
by Pype.Clicker
LD is a 32 bits only linker, afaik. It will not let you assemble such programs.
What you need is rather something like exe2bin ...

Re:OS kernel in C

Posted: Tue Feb 11, 2003 1:20 pm
by Tim
ld is a 32-bit linker, gcc is a 32-bit compiler, as is a 32-bit assembler. To write 16-bit C code you will need a completely different set of tools.

Re:OS kernel in C

Posted: Tue Feb 11, 2003 5:54 pm
by mr. xsism
hello,
i suggest you use nasm. it is a great assembler. If u ever need any help with loading or jumping to your kernel, come to #osdev @ irc.wyldryde.net. My name is xsism :)

Regards,
Mr. xsism

Re:OS kernel in C

Posted: Mon Feb 24, 2003 9:06 am
by xkazuya
hello.
gcc compiler can generate 16 bit code.
you only add

asm(".code16gcc");

to your source file.

Re:OS kernel in C

Posted: Mon Feb 24, 2003 9:41 am
by Pype.Clicker
indeed, (and i'm surprised to learn it :)
but it will still generate 32 bits ELF/COFF object files that completely ignore the segmentation (thus only the TINY model is available for you) and it simply add "db 66 db 67" before instructions so that its 32bits code runs correctly. This definitely suxx and will produce *very* inefficient code.

do not use it ... really.

Re:OS kernel in C

Posted: Mon Feb 24, 2003 10:25 am
by xkazuya
Now I understand what you say.
It is inefficient.