OS kernel in C

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
slacker

OS kernel in C

Post 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....
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:OS kernel in C

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

Re:OS kernel in C

Post 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.
mr. xsism

Re:OS kernel in C

Post 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
xkazuya

Re:OS kernel in C

Post by xkazuya »

hello.
gcc compiler can generate 16 bit code.
you only add

asm(".code16gcc");

to your source file.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:OS kernel in C

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

Re:OS kernel in C

Post by xkazuya »

Now I understand what you say.
It is inefficient.
Post Reply