Creating a 16 bits (real mode) OS

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
User avatar
Fergo
Member
Member
Posts: 27
Joined: Fri Oct 19, 2007 3:11 pm
Contact:

Creating a 16 bits (real mode) OS

Post by Fergo »

Hello everyone, its my first post in here.

For the past two weeks I've been reading a lot of guides/topics/tutorials about kernel programming. Almost 100% of the papers were about protected mode and 32 bit programming, and there was a lot of information and concepts that at the time I don't understand. Due to this fact, I decided that I need to really get into the real mode before getting in something bigger.

I have some experience on creating a basic kernel in real mode using assembly, and now I want to use C to program the mini-os. The problem is that GCC/DJGPP do not compile 16 bit code (as far as I know) and I have no idea on how to link my code with the kernel_start.asm (which calls the "main" function) using TurboC 2.01 (which seems to generate a lot of junk code with only a "void main() {}"). The bootloader I've already programmed (in asm).

Can you guys give some tips on how to correctly compile and link a 16bit C code with TurboC or point another compiler that is able to generate 16bit binaries?

Sorry for my english.

Thanks in advance,
Fergo
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

I think this question has been asked before.. but I'll reply anyway..

Bruce Evans's C compiler seems decent, generates 16bit code..

This site includes it as well has a few other related utilities..

http://homepage.ntlworld.com/robert.debath/
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
CopperMan
Posts: 5
Joined: Sat Jul 02, 2005 11:00 pm
Location: Ukraine

Post by CopperMan »

Open Watcom C, I think is the best choise for 16 bit modes.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

I use to use Turbo C..
User avatar
Fergo
Member
Member
Posts: 27
Joined: Fri Oct 19, 2007 3:11 pm
Contact:

Post by Fergo »

Thanks everyone.
CopperMan, can you give me some hints about compiling the code with watcom? (I've got a bit confused with the bunch of executables and command line arguments of Watcom).

Regards,
Fergo
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Most of the older DOS compilers generate 16-bits code. The question is which of those can be manipulated to the extent that it can compile kernels.

BCC has been used to compile the bios of bochs/qemu, which makes it look like a viable choice. JLoc is a linker that can generate flat binaries, and IIRC can read Turbo C generated object files, which is also a viable combination. I have seen the name openwatcom a few times before, but since I have no experience with it, I cannot vouch that it is suitable for os development, but to be honest, I can't say that for either of the other compilers until I've seen it work.

The big thing is that few of us actually write 16-bit oses - I know one, but he used to be doing it in Pascal. In essence that means that you'll have to figure mostly everything out yourself. Once you do get something working, be sure to let us know since this question does get asked relatively often while we don't have an answer ready. Of course this invitation is not limited to yourself - any 16-bit barebones is welcome :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

You should go for Turbo C 2.01, here is a simple example of using it to code a real mode C kernel. Its called "OS for Dummies Loader"
http://alexfru.chat.ru/epm.html#los4d
Post Reply