I'm trying to keep it simple here. So I'm making an OS on a FAT12 formatted floppy (antique, I know). I have written a bootloader that can load a single flat binary file into RAM and jump to it.
Here's the question: How could I compile a C program to be in a flat binary format? Also, how would I get many of the functions to work, such as printf, etc.
Thanks,
fuzzyhair2
ASM bootloader, C kernel
Re: ASM bootloader, C kernel
There you go. Read the links on the top first http://wiki.osdev.org/Bare_Bones
I assume you are still in real addressing mode? http://wiki.osdev.org/Babystep2
I realize this is not a direct answer but it's not intented as one.
I assume you are still in real addressing mode? http://wiki.osdev.org/Babystep2
I realize this is not a direct answer but it's not intented as one.
I'm Eino Tuominen from Finland, a web software dev learning low level stuff and reading / trying out kernel dev
Re: ASM bootloader, C kernel
There are many things that must be taken into account. Do you switch to 32-bit protected mode? It is harder to find a C compiler that can compile 16-bit code. Do you use gcc?
Study linker scripts so you can output flat binary files. You have to realize that basically all the "C functions" available are the ones you have written by yourself. Basically it is like writing assembly.
Of course you can port some C library to your OS but that is an advanced topic and it is not what you want now.
Study linker scripts so you can output flat binary files. You have to realize that basically all the "C functions" available are the ones you have written by yourself. Basically it is like writing assembly.
Of course you can port some C library to your OS but that is an advanced topic and it is not what you want now.
Re: ASM bootloader, C kernel
"Also, how would I get many of the functions to work, such as printf, etc."
A lot of C functions, including the ones which send output to the screen, rely upon operating system calls. Since the thing you are writing is an operating system, you can't use them until you have implemented the relevant functionality in your operating system, and then written the beginnings of a C library.
A lot of C functions, including the ones which send output to the screen, rely upon operating system calls. Since the thing you are writing is an operating system, you can't use them until you have implemented the relevant functionality in your operating system, and then written the beginnings of a C library.
-
- Member
- Posts: 510
- Joined: Wed Mar 09, 2011 3:55 am
Re: ASM bootloader, C kernel
As others have said: write them yourself. It's the entire point of writing an OS.fuzzyhair2 wrote: Also, how would I get many of the functions to work, such as printf, etc.
-
- Posts: 2
- Joined: Fri Apr 20, 2012 4:25 pm
Re: ASM bootloader, C kernel
Thanks for the help guys, really appreciate it!
I realized that my problem was that I didn't read Bare Bones carefully enough. I guess I learned my lesson...read carefully. Anyway, it worked flawlessly and I will continue to learn more!
Thanks,
fuzzyhair2
I realized that my problem was that I didn't read Bare Bones carefully enough. I guess I learned my lesson...read carefully. Anyway, it worked flawlessly and I will continue to learn more!
Thanks,
fuzzyhair2